diff --git a/core/authorize.php b/core/authorize.php index 073770a..a72e0ac 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -116,10 +116,10 @@ function authorize_access_allowed(Request $request) { drupal_set_message($results['page_message']['message'], $results['page_message']['type']); } - $content['authorize_report'] = array( + $content['authorize_report'] = [ '#theme' => 'authorize_report', '#messages' => $results['messages'], - ); + ]; if (is_array($results['tasks'])) { $links = $results['tasks']; @@ -148,11 +148,11 @@ function authorize_access_allowed(Request $request) { ]; } - $content['next_steps'] = array( + $content['next_steps'] = [ '#theme' => 'item_list', '#items' => $links, '#title' => t('Next steps'), - ); + ]; } // If a batch is running, let it run. elseif ($request->query->has('batch')) { @@ -189,9 +189,9 @@ function authorize_access_allowed(Request $request) { } $bare_html_page_renderer = \Drupal::service('bare_html_page_renderer'); -$response = $bare_html_page_renderer->renderBarePage($content, $page_title, 'maintenance_page', array( +$response = $bare_html_page_renderer->renderBarePage($content, $page_title, 'maintenance_page', [ '#show_messages' => $show_messages, -)); +]); if (!$is_allowed) { $response->setStatusCode(403); } diff --git a/core/core.api.php b/core/core.api.php index 6a34823..a2ae9df 100644 --- a/core/core.api.php +++ b/core/core.api.php @@ -2052,39 +2052,39 @@ function hook_mail_alter(&$message) { function hook_mail($key, &$message, $params) { $account = $params['account']; $context = $params['context']; - $variables = array( + $variables = [ '%site_name' => \Drupal::config('system.site')->get('name'), '%username' => $account->getDisplayName(), - ); + ]; if ($context['hook'] == 'taxonomy') { $entity = $params['entity']; $vocabulary = Vocabulary::load($entity->id()); - $variables += array( + $variables += [ '%term_name' => $entity->name, '%term_description' => $entity->description, '%term_id' => $entity->id(), '%vocabulary_name' => $vocabulary->label(), '%vocabulary_description' => $vocabulary->getDescription(), '%vocabulary_id' => $vocabulary->id(), - ); + ]; } // Node-based variable translation is only available if we have a node. if (isset($params['node'])) { /** @var \Drupal\node\NodeInterface $node */ $node = $params['node']; - $variables += array( + $variables += [ '%uid' => $node->getOwnerId(), - '%url' => $node->url('canonical', array('absolute' => TRUE)), + '%url' => $node->url('canonical', ['absolute' => TRUE]), '%node_type' => node_get_type_label($node), '%title' => $node->getTitle(), '%teaser' => $node->teaser, '%body' => $node->body, - ); + ]; } $subject = strtr($context['subject'], $variables); $body = strtr($context['message'], $variables); - $message['subject'] .= str_replace(array("\r", "\n"), '', $subject); + $message['subject'] .= str_replace(["\r", "\n"], '', $subject); $message['body'][] = MailFormatHelper::htmlToText($body); } diff --git a/core/includes/batch.inc b/core/includes/batch.inc index f84c01b..fa5f864 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -50,7 +50,7 @@ function _batch_page(Request $request) { // Register database update for the end of processing. drupal_register_shutdown_function('_batch_shutdown'); - $build = array(); + $build = []; // Add batch-specific libraries. foreach ($batch['sets'] as $batch_set) { @@ -94,7 +94,7 @@ function _batch_do() { // Perform actual processing. list($percentage, $message, $label) = _batch_process(); - return new JsonResponse(array('status' => TRUE, 'percentage' => $percentage, 'message' => $message, 'label' => $label)); + return new JsonResponse(['status' => TRUE, 'percentage' => $percentage, 'message' => $message, 'label' => $label]); } /** @@ -130,9 +130,9 @@ function _batch_progress_page() { // it. While this causes invalid HTML, the same would be true if we didn't, // as content is not allowed to appear after anyway. $bare_html_page_renderer = \Drupal::service('bare_html_page_renderer'); - $response = $bare_html_page_renderer->renderBarePage(['#markup' => $fallback], $current_set['title'], 'maintenance_page', array( + $response = $bare_html_page_renderer->renderBarePage(['#markup' => $fallback], $current_set['title'], 'maintenance_page', [ '#show_messages' => FALSE, - )); + ]); // Just use the content of the response. $fallback = $response->getContent(); @@ -159,26 +159,26 @@ function _batch_progress_page() { $url = $batch['url']->toString(TRUE)->getGeneratedUrl(); - $build = array( + $build = [ '#theme' => 'progress_bar', '#percent' => $percentage, - '#message' => array('#markup' => $message), + '#message' => ['#markup' => $message], '#label' => $label, - '#attached' => array( - 'html_head' => array( - array( - array( + '#attached' => [ + 'html_head' => [ + [ + [ // Redirect through a 'Refresh' meta tag if JavaScript is disabled. '#tag' => 'meta', '#noscript' => TRUE, - '#attributes' => array( + '#attributes' => [ 'http-equiv' => 'Refresh', 'content' => '0; URL=' . $url, - ), - ), + ], + ], 'batch_progress_meta_refresh', - ), - ), + ], + ], // Adds JavaScript code and settings for clients where JavaScript is enabled. 'drupalSettings' => [ 'batch' => [ @@ -187,11 +187,11 @@ function _batch_progress_page() { 'uri' => $url, ], ], - 'library' => array( + 'library' => [ 'core/drupal.batch', - ), - ), - ); + ], + ], + ]; return $build; } @@ -243,13 +243,13 @@ function _batch_process() { list($callback, $args) = $item->data; // Build the 'context' array and execute the function call. - $batch_context = array( + $batch_context = [ 'sandbox' => &$current_set['sandbox'], 'results' => &$current_set['results'], 'finished' => &$finished, 'message' => &$task_message, - ); - call_user_func_array($callback, array_merge($args, array(&$batch_context))); + ]; + call_user_func_array($callback, array_merge($args, [&$batch_context])); if ($finished >= 1) { // Make sure this step is not counted twice when computing $current. @@ -257,7 +257,7 @@ function _batch_process() { // Remove the processed operation and clear the sandbox. $queue->deleteItem($item); $current_set['count']--; - $current_set['sandbox'] = array(); + $current_set['sandbox'] = []; } } @@ -312,7 +312,7 @@ function _batch_process() { $current = $total - $remaining + $finished; $percentage = _batch_api_percentage($total, $current); $elapsed = isset($current_set['elapsed']) ? $current_set['elapsed'] : 0; - $values = array( + $values = [ '@remaining' => $remaining, '@total' => $total, '@current' => floor($current), @@ -320,13 +320,13 @@ function _batch_process() { '@elapsed' => \Drupal::service('date.formatter')->formatInterval($elapsed / 1000), // If possible, estimate remaining processing time. '@estimate' => ($current > 0) ? \Drupal::service('date.formatter')->formatInterval(($elapsed * ($total - $current) / $current) / 1000) : '-', - ); + ]; $message = strtr($progress_message, $values); if (!empty($task_message)) { $label = $task_message; } - return array($percentage, $message, $label); + return [$percentage, $message, $label]; } else { // If we are not in progressive mode, the entire batch has been processed. @@ -385,7 +385,7 @@ function _batch_next_set() { // We use our stored copies of $form and $form_state to account for // possible alterations by previous form submit handlers. $complete_form = &$batch['form_state']->getCompleteForm(); - call_user_func_array($callback, array(&$complete_form, &$batch['form_state'])); + call_user_func_array($callback, [&$complete_form, &$batch['form_state']]); } return TRUE; } @@ -411,7 +411,7 @@ function _batch_finished() { if (is_callable($batch_set['finished'])) { $queue = _batch_queue($batch_set); $operations = $queue->getAllItems(); - $batch_set_result = call_user_func_array($batch_set['finished'], array($batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date.formatter')->formatInterval($batch_set['elapsed'] / 1000))); + $batch_set_result = call_user_func_array($batch_set['finished'], [$batch_set['success'], $batch_set['results'], $operations, \Drupal::service('date.formatter')->formatInterval($batch_set['elapsed'] / 1000)]); // If a batch 'finished' callback requested a redirect after the batch // is complete, save that for later use. If more than one batch set // returned a redirect, the last one is used. @@ -494,7 +494,7 @@ function _batch_finished() { /** @var \Drupal\Core\Url $source_url */ $source_url = $_batch['source_url']; if (is_callable($callback)) { - $callback($_batch['source_url'], array('query' => array('op' => 'finish', 'id' => $_batch['id']))); + $callback($_batch['source_url'], ['query' => ['op' => 'finish', 'id' => $_batch['id']]]); } elseif ($callback === NULL) { // Default to RedirectResponse objects when nothing specified. diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index ec12097..99ac00a 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -191,7 +191,7 @@ function config_get_config_directory($type) { function drupal_get_filename($type, $name, $filename = NULL) { // The location of files will not change during the request, so do not use // drupal_static(). - static $files = array(); + static $files = []; // Type 'core' only exists to simplify application-level logic; it always maps // to the /core directory, whereas $name is ignored. It is only requested via @@ -207,7 +207,7 @@ function drupal_get_filename($type, $name, $filename = NULL) { $type = 'module'; } if (!isset($files[$type])) { - $files[$type] = array(); + $files[$type] = []; } if (isset($filename)) { @@ -227,11 +227,11 @@ function drupal_get_filename($type, $name, $filename = NULL) { // system_rebuild_module_data() and // \Drupal\Core\Extension\ThemeHandlerInterface::rebuildThemeData(). if (!isset($files[$type][$name]) && \Drupal::hasService('state')) { - $files[$type] += \Drupal::state()->get('system.' . $type . '.files', array()); + $files[$type] += \Drupal::state()->get('system.' . $type . '.files', []); } // If still unknown, create a user-level error message. if (!isset($files[$type][$name])) { - trigger_error(SafeMarkup::format('The following @type is missing from the file system: @name', array('@type' => $type, '@name' => $name)), E_USER_WARNING); + trigger_error(SafeMarkup::format('The following @type is missing from the file system: @name', ['@type' => $type, '@name' => $name]), E_USER_WARNING); } } @@ -295,7 +295,7 @@ function drupal_get_path($type, $name) { * * @ingroup sanitization */ -function t($string, array $args = array(), array $options = array()) { +function t($string, array $args = [], array $options = []) { return new TranslatableMarkup($string, $args, $options); } @@ -370,7 +370,7 @@ function drupal_validate_utf8($text) { * * @see \Drupal\Core\Utility\Error::decodeException() */ -function watchdog_exception($type, Exception $exception, $message = NULL, $variables = array(), $severity = RfcLogLevel::ERROR, $link = NULL) { +function watchdog_exception($type, Exception $exception, $message = NULL, $variables = [], $severity = RfcLogLevel::ERROR, $link = NULL) { // Use a default value if $message is not set. if (empty($message)) { @@ -441,7 +441,7 @@ function watchdog_exception($type, Exception $exception, $message = NULL, $varia function drupal_set_message($message = NULL, $type = 'status', $repeat = FALSE) { if (isset($message)) { if (!isset($_SESSION['messages'][$type])) { - $_SESSION['messages'][$type] = array(); + $_SESSION['messages'][$type] = []; } // Convert strings which are safe to the simplest Markup objects. @@ -495,7 +495,7 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) { unset($_SESSION['messages'][$type]); } if (isset($messages[$type])) { - return array($type => $messages[$type]); + return [$type => $messages[$type]]; } } else { @@ -505,7 +505,7 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) { return $messages; } } - return array(); + return []; } /** @@ -869,7 +869,7 @@ function drupal_classloader_register($name, $path) { * @see drupal_static_reset() */ function &drupal_static($name, $default_value = NULL, $reset = FALSE) { - static $data = array(), $default = array(); + static $data = [], $default = []; // First check if dealing with a previously defined static variable. if (isset($data[$name]) || array_key_exists($name, $data)) { // Non-NULL $name and both $data[$name] and $default[$name] statics exist. @@ -948,7 +948,7 @@ function drupal_placeholder($text) { function &drupal_register_shutdown_function($callback = NULL) { // We cannot use drupal_static() here because the static cache is reset during // batch processing, which breaks batch handling. - static $callbacks = array(); + static $callbacks = []; if (isset($callback)) { // Only register the internal shutdown function once. @@ -959,7 +959,7 @@ function &drupal_register_shutdown_function($callback = NULL) { // Remove $callback from the arguments. unset($args[0]); // Save callback and arguments - $callbacks[] = array('callback' => $callback, 'arguments' => $args); + $callbacks[] = ['callback' => $callback, 'arguments' => $args]; } return $callbacks; } diff --git a/core/includes/common.inc b/core/includes/common.inc index 037c5b0..323a666 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -249,7 +249,7 @@ function check_url($uri) { */ function format_size($size, $langcode = NULL) { if ($size < Bytes::KILOBYTE) { - return \Drupal::translation()->formatPlural($size, '1 byte', '@count bytes', array(), array('langcode' => $langcode)); + return \Drupal::translation()->formatPlural($size, '1 byte', '@count bytes', [], ['langcode' => $langcode]); } else { $size = $size / Bytes::KILOBYTE; // Convert bytes to kilobytes. @@ -352,7 +352,7 @@ function date_iso8601($date) { * A ; separated string ready for insertion in a HTTP header. No escaping is * performed for HTML entities, so this string is not safe to be printed. */ -function drupal_http_header_attributes(array $attributes = array()) { +function drupal_http_header_attributes(array $attributes = []) { foreach ($attributes as $attribute => &$data) { if (is_array($data)) { $data = implode(' ', $data); @@ -433,18 +433,18 @@ function drupal_clear_css_cache() { * @see hook_js_alter() */ function drupal_js_defaults($data = NULL) { - return array( + return [ 'type' => 'file', 'group' => JS_DEFAULT, 'weight' => 0, 'scope' => 'header', 'cache' => TRUE, 'preprocess' => TRUE, - 'attributes' => array(), + 'attributes' => [], 'version' => NULL, 'data' => $data, - 'browsers' => array(), - ); + 'browsers' => [], + ]; } /** @@ -704,12 +704,12 @@ function drupal_process_states(&$elements) { */ function drupal_attach_tabledrag(&$element, array $options) { // Add default values to elements. - $options = $options + array( + $options = $options + [ 'subgroup' => NULL, 'source' => NULL, 'hidden' => TRUE, 'limit' => 0 - ); + ]; $group = $options['group']; @@ -719,14 +719,14 @@ function drupal_attach_tabledrag(&$element, array $options) { // If a subgroup or source isn't set, assume it is the same as the group. $target = isset($options['subgroup']) ? $options['subgroup'] : $group; $source = isset($options['source']) ? $options['source'] : $target; - $element['#attached']['drupalSettings']['tableDrag'][$options['table_id']][$group][$tabledrag_id] = array( + $element['#attached']['drupalSettings']['tableDrag'][$options['table_id']][$group][$tabledrag_id] = [ 'target' => $target, 'source' => $source, 'relationship' => $options['relationship'], 'action' => $options['action'], 'hidden' => $options['hidden'], 'limit' => $options['limit'], - ); + ]; $element['#attached']['library'][] = 'core/drupal.tabledrag'; } @@ -827,7 +827,7 @@ function drupal_pre_render_link($element) { * properties of the parent are used. */ function drupal_pre_render_links($element) { - $element += array('#links' => array(), '#attached' => array()); + $element += ['#links' => [], '#attached' => []]; foreach (Element::children($element) as $key) { $child = &$element[$key]; // If the child has links which have not been printed yet and the user has @@ -1115,7 +1115,7 @@ function drupal_flush_all_caches() { // Rebuild and reboot a new kernel. A simple DrupalKernel reboot is not // sufficient, since the list of enabled modules might have been adjusted // above due to changed code. - $files = array(); + $files = []; foreach ($module_data as $name => $extension) { if ($extension->status) { $files[$name] = $extension; @@ -1217,7 +1217,7 @@ function drupal_check_incompatibility($v, $current_version) { * validation system. */ function archiver_get_extensions() { - $valid_extensions = array(); + $valid_extensions = []; foreach (\Drupal::service('plugin.manager.archiver')->getDefinitions() as $archive) { foreach ($archive['extensions'] as $extension) { foreach (explode('.', $extension) as $part) { @@ -1246,9 +1246,9 @@ function archiver_get_archiver($file) { // Archivers can only work on local paths $filepath = drupal_realpath($file); if (!is_file($filepath)) { - throw new Exception(t('Archivers can only operate on local files: %file not supported', array('%file' => $file))); + throw new Exception(t('Archivers can only operate on local files: %file not supported', ['%file' => $file])); } - return \Drupal::service('plugin.manager.archiver')->getInstance(array('filepath' => $filepath)); + return \Drupal::service('plugin.manager.archiver')->getInstance(['filepath' => $filepath]); } /** @@ -1270,7 +1270,7 @@ function drupal_get_updaters() { if (!isset($updaters)) { $updaters = \Drupal::moduleHandler()->invokeAll('updater_info'); \Drupal::moduleHandler()->alter('updater_info', $updaters); - uasort($updaters, array(SortArray::class, 'sortByWeightElement')); + uasort($updaters, [SortArray::class, 'sortByWeightElement']); } return $updaters; } @@ -1290,7 +1290,7 @@ function drupal_get_filetransfer_info() { if (!isset($info)) { $info = \Drupal::moduleHandler()->invokeAll('filetransfer_info'); \Drupal::moduleHandler()->alter('filetransfer_info', $info); - uasort($info, array(SortArray::class, 'sortByWeightElement')); + uasort($info, [SortArray::class, 'sortByWeightElement']); } return $info; } diff --git a/core/includes/database.inc b/core/includes/database.inc index ff03885..d4cb593 100644 --- a/core/includes/database.inc +++ b/core/includes/database.inc @@ -53,7 +53,7 @@ * @see \Drupal\Core\Database\Connection::query() * @see \Drupal\Core\Database\Connection::defaultOptions() */ -function db_query($query, array $args = array(), array $options = array()) { +function db_query($query, array $args = [], array $options = []) { if (empty($options['target'])) { $options['target'] = 'default'; } @@ -91,7 +91,7 @@ function db_query($query, array $args = array(), array $options = array()) { * @see \Drupal\Core\Database\Connection::queryRange() * @see \Drupal\Core\Database\Connection::defaultOptions() */ -function db_query_range($query, $from, $count, array $args = array(), array $options = array()) { +function db_query_range($query, $from, $count, array $args = [], array $options = []) { if (empty($options['target'])) { $options['target'] = 'default'; } @@ -127,7 +127,7 @@ function db_query_range($query, $from, $count, array $args = array(), array $opt * @see \Drupal\Core\Database\Connection::queryTemporary() * @see \Drupal\Core\Database\Connection::defaultOptions() */ -function db_query_temporary($query, array $args = array(), array $options = array()) { +function db_query_temporary($query, array $args = [], array $options = []) { if (empty($options['target'])) { $options['target'] = 'default'; } @@ -154,7 +154,7 @@ function db_query_temporary($query, array $args = array(), array $options = arra * @see \Drupal\Core\Database\Connection::insert() * @see \Drupal\Core\Database\Connection::defaultOptions() */ -function db_insert($table, array $options = array()) { +function db_insert($table, array $options = []) { if (empty($options['target']) || $options['target'] == 'replica') { $options['target'] = 'default'; } @@ -180,7 +180,7 @@ function db_insert($table, array $options = array()) { * @see \Drupal\Core\Database\Connection::merge() * @see \Drupal\Core\Database\Connection::defaultOptions() */ -function db_merge($table, array $options = array()) { +function db_merge($table, array $options = []) { if (empty($options['target']) || $options['target'] == 'replica') { $options['target'] = 'default'; } @@ -206,7 +206,7 @@ function db_merge($table, array $options = array()) { * @see \Drupal\Core\Database\Connection::update() * @see \Drupal\Core\Database\Connection::defaultOptions() */ -function db_update($table, array $options = array()) { +function db_update($table, array $options = []) { if (empty($options['target']) || $options['target'] == 'replica') { $options['target'] = 'default'; } @@ -232,7 +232,7 @@ function db_update($table, array $options = array()) { * @see \Drupal\Core\Database\Connection::delete() * @see \Drupal\Core\Database\Connection::defaultOptions() */ -function db_delete($table, array $options = array()) { +function db_delete($table, array $options = []) { if (empty($options['target']) || $options['target'] == 'replica') { $options['target'] = 'default'; } @@ -258,7 +258,7 @@ function db_delete($table, array $options = array()) { * @see \Drupal\Core\Database\Connection::truncate() * @see \Drupal\Core\Database\Connection::defaultOptions() */ -function db_truncate($table, array $options = array()) { +function db_truncate($table, array $options = []) { if (empty($options['target']) || $options['target'] == 'replica') { $options['target'] = 'default'; } @@ -288,7 +288,7 @@ function db_truncate($table, array $options = array()) { * @see \Drupal\Core\Database\Connection::select() * @see \Drupal\Core\Database\Connection::defaultOptions() */ -function db_select($table, $alias = NULL, array $options = array()) { +function db_select($table, $alias = NULL, array $options = []) { if (empty($options['target'])) { $options['target'] = 'default'; } @@ -315,7 +315,7 @@ function db_select($table, $alias = NULL, array $options = array()) { * @see \Drupal\Core\Database\Connection::startTransaction() * @see \Drupal\Core\Database\Connection::defaultOptions() */ -function db_transaction($name = NULL, array $options = array()) { +function db_transaction($name = NULL, array $options = []) { if (empty($options['target'])) { $options['target'] = 'default'; } @@ -451,7 +451,7 @@ function db_driver() { * * @see \Drupal\Core\Database\Database::closeConnection() */ -function db_close(array $options = array()) { +function db_close(array $options = []) { if (empty($options['target'])) { $options['target'] = NULL; } @@ -752,7 +752,7 @@ function db_drop_table($table) { * @see \Drupal\Core\Database\Schema::addField() * @see db_change_field() */ -function db_add_field($table, $field, $spec, $keys_new = array()) { +function db_add_field($table, $field, $spec, $keys_new = []) { return Database::getConnection()->schema()->addField($table, $field, $spec, $keys_new); } @@ -1020,7 +1020,7 @@ function db_drop_index($table, $name) { * * @see \Drupal\Core\Database\Schema::changeField() */ -function db_change_field($table, $field, $field_new, $spec, $keys_new = array()) { +function db_change_field($table, $field, $field_new, $spec, $keys_new = []) { return Database::getConnection()->schema()->changeField($table, $field, $field_new, $spec, $keys_new); } diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 03d40a9..d5c5f54 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -80,7 +80,7 @@ function entity_get_bundles($entity_type = NULL) { function entity_load($entity_type, $id, $reset = FALSE) { $controller = \Drupal::entityManager()->getStorage($entity_type); if ($reset) { - $controller->resetCache(array($id)); + $controller->resetCache([$id]); } return $controller->load($id); } @@ -305,7 +305,7 @@ function entity_delete_multiple($entity_type, array $ids) { * @see \Drupal\Core\Entity\EntityTypeManagerInterface::getStorage() * @see \Drupal\Core\Entity\EntityStorageInterface::create() */ -function entity_create($entity_type, array $values = array()) { +function entity_create($entity_type, array $values = []) { return \Drupal::entityManager() ->getStorage($entity_type) ->create($values); @@ -483,12 +483,12 @@ function entity_get_display($entity_type, $bundle, $view_mode) { // configuration entries are only created when a display object is explicitly // configured and saved. if (!$display) { - $display = EntityViewDisplay::create(array( + $display = EntityViewDisplay::create([ 'targetEntityType' => $entity_type, 'bundle' => $bundle, 'mode' => $view_mode, 'status' => TRUE, - )); + ]); } return $display; @@ -563,12 +563,12 @@ function entity_get_form_display($entity_type, $bundle, $form_mode) { // configuration entries are only created when an entity form display is // explicitly configured and saved. if (!$entity_form_display) { - $entity_form_display = EntityFormDisplay::create(array( + $entity_form_display = EntityFormDisplay::create([ 'targetEntityType' => $entity_type, 'bundle' => $bundle, 'mode' => $form_mode, 'status' => TRUE, - )); + ]); } return $entity_form_display; diff --git a/core/includes/errors.inc b/core/includes/errors.inc index e3ad1c8..40e2903 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -21,23 +21,23 @@ * @ingroup logging_severity_levels */ function drupal_error_levels() { - $types = array( - E_ERROR => array('Error', RfcLogLevel::ERROR), - E_WARNING => array('Warning', RfcLogLevel::WARNING), - E_PARSE => array('Parse error', RfcLogLevel::ERROR), - E_NOTICE => array('Notice', RfcLogLevel::NOTICE), - E_CORE_ERROR => array('Core error', RfcLogLevel::ERROR), - E_CORE_WARNING => array('Core warning', RfcLogLevel::WARNING), - E_COMPILE_ERROR => array('Compile error', RfcLogLevel::ERROR), - E_COMPILE_WARNING => array('Compile warning', RfcLogLevel::WARNING), - E_USER_ERROR => array('User error', RfcLogLevel::ERROR), - E_USER_WARNING => array('User warning', RfcLogLevel::WARNING), - E_USER_NOTICE => array('User notice', RfcLogLevel::NOTICE), - E_STRICT => array('Strict warning', RfcLogLevel::DEBUG), - E_RECOVERABLE_ERROR => array('Recoverable fatal error', RfcLogLevel::ERROR), - E_DEPRECATED => array('Deprecated function', RfcLogLevel::DEBUG), - E_USER_DEPRECATED => array('User deprecated function', RfcLogLevel::DEBUG), - ); + $types = [ + E_ERROR => ['Error', RfcLogLevel::ERROR], + E_WARNING => ['Warning', RfcLogLevel::WARNING], + E_PARSE => ['Parse error', RfcLogLevel::ERROR], + E_NOTICE => ['Notice', RfcLogLevel::NOTICE], + E_CORE_ERROR => ['Core error', RfcLogLevel::ERROR], + E_CORE_WARNING => ['Core warning', RfcLogLevel::WARNING], + E_COMPILE_ERROR => ['Compile error', RfcLogLevel::ERROR], + E_COMPILE_WARNING => ['Compile warning', RfcLogLevel::WARNING], + E_USER_ERROR => ['User error', RfcLogLevel::ERROR], + E_USER_WARNING => ['User warning', RfcLogLevel::WARNING], + E_USER_NOTICE => ['User notice', RfcLogLevel::NOTICE], + E_STRICT => ['Strict warning', RfcLogLevel::DEBUG], + E_RECOVERABLE_ERROR => ['Recoverable fatal error', RfcLogLevel::ERROR], + E_DEPRECATED => ['Deprecated function', RfcLogLevel::DEBUG], + E_USER_DEPRECATED => ['User deprecated function', RfcLogLevel::DEBUG], + ]; return $types; } @@ -70,7 +70,7 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c // in PHP, we allow them to trigger a fatal error by emitting a user error // using trigger_error(). $to_string = $error_level == E_USER_ERROR && substr($caller['function'], -strlen('__toString()')) == '__toString()'; - _drupal_log_error(array( + _drupal_log_error([ '%type' => isset($types[$error_level]) ? $severity_msg : 'Unknown error', // The standard PHP error handler considers that the error messages // are HTML. We mimick this behavior here. @@ -81,7 +81,7 @@ function _drupal_error_handler_real($error_level, $message, $filename, $line, $c 'severity_level' => $severity_level, 'backtrace' => $backtrace, '@backtrace_string' => (new \Exception())->getTraceAsString(), - ), $recoverable || $to_string); + ], $recoverable || $to_string); } } @@ -139,15 +139,15 @@ function _drupal_log_error($error, $fatal = FALSE) { // $number does not use drupal_static as it should not be reset // as it uniquely identifies each PHP error. static $number = 0; - $assertion = array( + $assertion = [ $error['@message'], $error['%type'], - array( + [ 'function' => $error['%function'], 'file' => $error['%file'], 'line' => $error['%line'], - ), - ); + ], + ]; // For non-fatal errors (e.g. PHP notices) _drupal_log_error can be called // multiple times per request. In that case the response is typically // generated outside of the error handler, e.g., in a controller. As a @@ -257,10 +257,10 @@ function _drupal_log_error($error, $fatal = FALSE) { if ($is_installer) { // install_display_output() prints the output and ends script execution. - $output = array( + $output = [ '#title' => 'Error', '#markup' => $message, - ); + ]; install_display_output($output, $GLOBALS['install_state'], $response->headers->all()); exit; } diff --git a/core/includes/file.inc b/core/includes/file.inc index fe4bf54..3de707a 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -366,7 +366,7 @@ function file_save_htaccess($directory, $private = TRUE, $force_overwrite = FALS return drupal_chmod($htaccess_path, 0444); } else { - $variables = array('%directory' => $directory, '@htaccess' => $htaccess_lines); + $variables = ['%directory' => $directory, '@htaccess' => $htaccess_lines]; \Drupal::logger('security')->error("Security warning: Couldn't write .htaccess file. Please create a .htaccess file in your %directory directory which contains the following lines:
@htaccess
", $variables); return FALSE; } @@ -455,7 +455,7 @@ function file_unmanaged_copy($source, $destination = NULL, $replace = FILE_EXIST $real_destination = drupal_realpath($destination) ?: $destination; // Perform the copy operation. if (!@copy($real_source, $real_destination)) { - \Drupal::logger('file')->error('The specified file %file could not be copied to %destination.', array('%file' => $source, '%destination' => $destination)); + \Drupal::logger('file')->error('The specified file %file could not be copied to %destination.', ['%file' => $source, '%destination' => $destination]); return FALSE; } // Set the permissions on the new file. @@ -500,12 +500,12 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E // Assert that the source file actually exists. if (!file_exists($source)) { // @todo Replace drupal_set_message() calls with exceptions instead. - drupal_set_message(t('The specified file %file could not be moved/copied because no file by that name exists. Please check that you supplied the correct filename.', array('%file' => $original_source)), 'error'); + drupal_set_message(t('The specified file %file could not be moved/copied because no file by that name exists. Please check that you supplied the correct filename.', ['%file' => $original_source]), 'error'); if (($realpath = drupal_realpath($original_source)) !== FALSE) { - $logger->notice('File %file (%realpath) could not be moved/copied because it does not exist.', array('%file' => $original_source, '%realpath' => $realpath)); + $logger->notice('File %file (%realpath) could not be moved/copied because it does not exist.', ['%file' => $original_source, '%realpath' => $realpath]); } else { - $logger->notice('File %file could not be moved/copied because it does not exist.', array('%file' => $original_source)); + $logger->notice('File %file could not be moved/copied because it does not exist.', ['%file' => $original_source]); } return FALSE; } @@ -526,8 +526,8 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E $dirname = drupal_dirname($destination); if (!file_prepare_directory($dirname)) { // The destination is not valid. - $logger->notice('File %file could not be moved/copied because the destination directory %destination is not configured correctly.', array('%file' => $original_source, '%destination' => $dirname)); - drupal_set_message(t('The specified file %file could not be moved/copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', array('%file' => $original_source)), 'error'); + $logger->notice('File %file could not be moved/copied because the destination directory %destination is not configured correctly.', ['%file' => $original_source, '%destination' => $dirname]); + drupal_set_message(t('The specified file %file could not be moved/copied because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.', ['%file' => $original_source]), 'error'); return FALSE; } } @@ -535,8 +535,8 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E // Determine whether we can perform this operation based on overwrite rules. $destination = file_destination($destination, $replace); if ($destination === FALSE) { - drupal_set_message(t('The file %file could not be moved/copied because a file by that name already exists in the destination directory.', array('%file' => $original_source)), 'error'); - $logger->notice('File %file could not be moved/copied because a file by that name already exists in the destination directory (%destination)', array('%file' => $original_source, '%destination' => $destination)); + drupal_set_message(t('The file %file could not be moved/copied because a file by that name already exists in the destination directory.', ['%file' => $original_source]), 'error'); + $logger->notice('File %file could not be moved/copied because a file by that name already exists in the destination directory (%destination)', ['%file' => $original_source, '%destination' => $destination]); return FALSE; } @@ -544,8 +544,8 @@ function file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_E $real_source = drupal_realpath($source); $real_destination = drupal_realpath($destination); if ($source == $destination || ($real_source !== FALSE) && ($real_source == $real_destination)) { - drupal_set_message(t('The specified file %file was not moved/copied because it would overwrite itself.', array('%file' => $source)), 'error'); - $logger->notice('File %file could not be moved/copied because it would overwrite itself.', array('%file' => $source)); + drupal_set_message(t('The specified file %file was not moved/copied because it would overwrite itself.', ['%file' => $source]), 'error'); + $logger->notice('File %file could not be moved/copied because it would overwrite itself.', ['%file' => $source]); return FALSE; } // Make sure the .htaccess files are present. @@ -651,7 +651,7 @@ function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXIST // implemented. It's not necessary to use drupal_unlink() as the Windows // issue has already been resolved above. if (!@copy($real_source, $real_destination) || !@unlink($real_source)) { - \Drupal::logger('file')->error('The specified file %file could not be moved to %destination.', array('%file' => $source, '%destination' => $destination)); + \Drupal::logger('file')->error('The specified file %file could not be moved to %destination.', ['%file' => $source, '%destination' => $destination]); return FALSE; } } @@ -720,7 +720,7 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) { $filename = $new_filename . '.' . $final_extension; if ($alerts && $original != $filename) { - drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', array('%filename' => $filename))); + drupal_set_message(t('For security reasons, your upload has been renamed to %filename.', ['%filename' => $filename])); } } @@ -761,7 +761,7 @@ function file_create_filename($basename, $directory) { $basename = preg_replace('/[\x00-\x1F]/u', '_', $basename); if (substr(PHP_OS, 0, 3) == 'WIN') { // These characters are not allowed in Windows filenames - $basename = str_replace(array(':', '*', '?', '"', '<', '>', '|'), '_', $basename); + $basename = str_replace([':', '*', '?', '"', '<', '>', '|'], '_', $basename); } // A URI or path may already have a trailing slash or look like "public://". @@ -809,7 +809,7 @@ function file_create_filename($basename, $directory) { * @see \Drupal\file\FileUsage\FileUsageBase::delete() */ function file_delete($fid) { - return file_delete_multiple(array($fid)); + return file_delete_multiple([$fid]); } /** @@ -851,18 +851,18 @@ function file_unmanaged_delete($path) { } $logger = \Drupal::logger('file'); if (is_dir($path)) { - $logger->error('%path is a directory and cannot be removed using file_unmanaged_delete().', array('%path' => $path)); + $logger->error('%path is a directory and cannot be removed using file_unmanaged_delete().', ['%path' => $path]); return FALSE; } // Return TRUE for non-existent file, but log that nothing was actually // deleted, as the current state is the intended result. if (!file_exists($path)) { - $logger->notice('The file %path was not deleted because it does not exist.', array('%path' => $path)); + $logger->notice('The file %path was not deleted because it does not exist.', ['%path' => $path]); return TRUE; } // We cannot handle anything other than files and directories. Log an error // for everything else (sockets, symbolic links, etc). - $logger->error('The file %path is not of a recognized type so it was not deleted.', array('%path' => $path)); + $logger->error('The file %path is not of a recognized type so it was not deleted.', ['%path' => $path]); return FALSE; } @@ -998,14 +998,14 @@ function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EX * An associative array (keyed on the chosen key) of objects with 'uri', * 'filename', and 'name' properties corresponding to the matched files. */ -function file_scan_directory($dir, $mask, $options = array(), $depth = 0) { +function file_scan_directory($dir, $mask, $options = [], $depth = 0) { // Merge in defaults. - $options += array( + $options += [ 'callback' => 0, 'recurse' => TRUE, 'key' => 'uri', 'min_depth' => 0, - ); + ]; // Normalize $dir only once. if ($depth == 0) { $dir = file_stream_wrapper_uri_normalize($dir); @@ -1024,8 +1024,8 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) { $default_nomask = '/^' . implode('|', $ignore_directories) . '$/'; } - $options['key'] = in_array($options['key'], array('uri', 'filename', 'name')) ? $options['key'] : 'uri'; - $files = array(); + $options['key'] = in_array($options['key'], ['uri', 'filename', 'name']) ? $options['key'] : 'uri'; + $files = []; // Avoid warnings when opendir does not have the permissions to open a // directory. if (is_dir($dir)) { @@ -1066,7 +1066,7 @@ function file_scan_directory($dir, $mask, $options = array(), $depth = 0) { closedir($handle); } else { - \Drupal::logger('file')->error('@dir can not be opened', array('@dir' => $dir)); + \Drupal::logger('file')->error('@dir can not be opened', ['@dir' => $dir]); } } @@ -1216,7 +1216,7 @@ function file_directory_temp() { * A string containing the path to the temporary directory. */ function file_directory_os_temp() { - $directories = array(); + $directories = []; // Has PHP been set with an upload_tmp_dir? if (ini_get('upload_tmp_dir')) { diff --git a/core/includes/form.inc b/core/includes/form.inc index d44f404..c2c6798 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -29,8 +29,8 @@ */ function template_preprocess_select(&$variables) { $element = $variables['element']; - Element::setAttributes($element, array('id', 'name', 'size')); - RenderElement::setAttributes($element, array('form-select')); + Element::setAttributes($element, ['id', 'name', 'size']); + RenderElement::setAttributes($element, ['form-select']); $variables['attributes'] = $element['#attributes']; $variables['options'] = form_select_options($element); @@ -161,7 +161,7 @@ function form_select_options($element, $choices = NULL) { * empty if no elements were found. FALSE if optgroups were found. */ function form_get_options($element, $key) { - $keys = array(); + $keys = []; foreach ($element['#options'] as $index => $choice) { if (is_array($choice)) { return FALSE; @@ -191,9 +191,9 @@ function form_get_options($element, $key) { */ function template_preprocess_fieldset(&$variables) { $element = $variables['element']; - Element::setAttributes($element, array('id')); + Element::setAttributes($element, ['id']); RenderElement::setAttributes($element); - $variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : array(); + $variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : []; $variables['prefix'] = isset($element['#field_prefix']) ? $element['#field_prefix'] : NULL; $variables['suffix'] = isset($element['#field_suffix']) ? $element['#field_suffix'] : NULL; $variables['title_display'] = isset($element['#title_display']) ? $element['#title_display'] : NULL; @@ -207,7 +207,7 @@ function template_preprocess_fieldset(&$variables) { $variables['legend']['attributes'] = new Attribute(); // Add 'visually-hidden' class to legend span. if ($variables['title_display'] == 'invisible') { - $variables['legend_span']['attributes'] = new Attribute(array('class' => 'visually-hidden')); + $variables['legend_span']['attributes'] = new Attribute(['class' => 'visually-hidden']); } else { $variables['legend_span']['attributes'] = new Attribute(); @@ -273,7 +273,7 @@ function template_preprocess_details(&$variables) { */ function template_preprocess_radios(&$variables) { $element = $variables['element']; - $variables['attributes'] = array(); + $variables['attributes'] = []; if (isset($element['#id'])) { $variables['attributes']['id'] = $element['#id']; } @@ -295,7 +295,7 @@ function template_preprocess_radios(&$variables) { */ function template_preprocess_checkboxes(&$variables) { $element = $variables['element']; - $variables['attributes'] = array(); + $variables['attributes'] = []; if (isset($element['#id'])) { $variables['attributes']['id'] = $element['#id']; } @@ -354,7 +354,7 @@ function template_preprocess_form(&$variables) { if (isset($element['#action'])) { $element['#attributes']['action'] = UrlHelper::stripDangerousProtocols($element['#action']); } - Element::setAttributes($element, array('method', 'id')); + Element::setAttributes($element, ['method', 'id']); if (empty($element['#attributes']['accept-charset'])) { $element['#attributes']['accept-charset'] = "UTF-8"; } @@ -375,8 +375,8 @@ function template_preprocess_form(&$variables) { */ function template_preprocess_textarea(&$variables) { $element = $variables['element']; - Element::setAttributes($element, array('id', 'name', 'rows', 'cols', 'placeholder')); - RenderElement::setAttributes($element, array('form-textarea')); + Element::setAttributes($element, ['id', 'name', 'rows', 'cols', 'placeholder']); + RenderElement::setAttributes($element, ['form-textarea']); $variables['wrapper_attributes'] = new Attribute(); $variables['attributes'] = new Attribute($element['#attributes']); $variables['value'] = $element['#value']; @@ -429,10 +429,10 @@ function template_preprocess_form_element(&$variables) { // This function is invoked as theme wrapper, but the rendered form element // may not necessarily have been processed by // \Drupal::formBuilder()->doBuildForm(). - $element += array( + $element += [ '#title_display' => 'before', - '#wrapper_attributes' => array(), - ); + '#wrapper_attributes' => [], + ]; $variables['attributes'] = $element['#wrapper_attributes']; // Add element #id for #type 'item'. @@ -477,8 +477,8 @@ function template_preprocess_form_element(&$variables) { // Add label_display and label variables to template. $variables['label_display'] = $element['#title_display']; - $variables['label'] = array('#theme' => 'form_element_label'); - $variables['label'] += array_intersect_key($element, array_flip(array('#id', '#required', '#title', '#title_display'))); + $variables['label'] = ['#theme' => 'form_element_label']; + $variables['label'] += array_intersect_key($element, array_flip(['#id', '#required', '#title', '#title_display'])); $variables['children'] = $element['#children']; } @@ -511,7 +511,7 @@ function template_preprocess_form_element_label(&$variables) { $variables['title'] = ['#markup' => $element['#title']]; } - $variables['attributes'] = array(); + $variables['attributes'] = []; // Pass elements title_display to template. $variables['title_display'] = $element['#title_display']; @@ -717,27 +717,27 @@ function batch_set($batch_definition) { // Initialize the batch if needed. if (empty($batch)) { - $batch = array( - 'sets' => array(), + $batch = [ + 'sets' => [], 'has_form_submits' => FALSE, - ); + ]; } // Base and default properties for the batch set. - $init = array( - 'sandbox' => array(), - 'results' => array(), + $init = [ + 'sandbox' => [], + 'results' => [], 'success' => FALSE, 'start' => 0, 'elapsed' => 0, - ); - $defaults = array( + ]; + $defaults = [ 'title' => t('Processing'), 'init_message' => t('Initializing.'), 'progress_message' => t('Completed @current of @total.'), 'error_message' => t('An error has occurred.'), - 'css' => array(), - ); + 'css' => [], + ]; $batch_set = $init + $batch_definition + $defaults; // Tweak init_message to avoid the bottom of the page flickering down after @@ -761,7 +761,7 @@ function batch_set($batch_definition) { $index = $batch['current_set'] + 1; $slice1 = array_slice($batch['sets'], 0, $index); $slice2 = array_slice($batch['sets'], $index); - $batch['sets'] = array_merge($slice1, array($batch_set), $slice2); + $batch['sets'] = array_merge($slice1, [$batch_set], $slice2); _batch_populate_queue($batch, $index); } } @@ -798,7 +798,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N if (isset($batch)) { // Add process information - $process_info = array( + $process_info = [ 'current_set' => 0, 'progressive' => TRUE, 'url' => isset($url) ? $url : Url::fromRoute('system.batch_page.html'), @@ -806,7 +806,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N 'batch_redirect' => $redirect, 'theme' => \Drupal::theme()->getActiveTheme()->getName(), 'redirect_callback' => $redirect_callback, - ); + ]; $batch += $process_info; // The batch is now completely built. Allow other modules to make changes @@ -837,7 +837,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N $query_options['op'] = 'finished'; $error_url->setOption('query', $query_options); - $batch['error_message'] = t('Please continue to the error page', array(':error_url' => $error_url->toString(TRUE)->getGeneratedUrl())); + $batch['error_message'] = t('Please continue to the error page', [':error_url' => $error_url->toString(TRUE)->getGeneratedUrl()]); // Clear the way for the redirection to the batch processing page, by // saving and unsetting the 'destination', if there is any. @@ -884,7 +884,7 @@ function &batch_get() { // that are part of the Batch API and need to reset the batch information may // call batch_get() and manipulate the result by reference. Functions that are // not part of the Batch API can also do this, but shouldn't. - static $batch = array(); + static $batch = []; return $batch; } @@ -905,12 +905,12 @@ function _batch_populate_queue(&$batch, $set_id) { $batch_set = &$batch['sets'][$set_id]; if (isset($batch_set['operations'])) { - $batch_set += array( - 'queue' => array( + $batch_set += [ + 'queue' => [ 'name' => 'drupal_batch:' . $batch['id'] . ':' . $set_id, 'class' => $batch['progressive'] ? 'Drupal\Core\Queue\Batch' : 'Drupal\Core\Queue\BatchMemory', - ), - ); + ], + ]; $queue = _batch_queue($batch_set); $queue->createQueue(); @@ -935,7 +935,7 @@ function _batch_queue($batch_set) { static $queues; if (!isset($queues)) { - $queues = array(); + $queues = []; } if (isset($batch_set['queue'])) { diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index ceb9982..43e3b69 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -90,11 +90,11 @@ * * @see install_state_defaults() */ -function install_drupal($class_loader, $settings = array()) { +function install_drupal($class_loader, $settings = []) { // Support the old way of calling this function with just a settings array. // @todo Remove this when Drush is updated in the Drupal testing // infrastructure in https://www.drupal.org/node/2389243 - if (is_array($class_loader) && $settings === array()) { + if (is_array($class_loader) && $settings === []) { $settings = $class_loader; $class_loader = require __DIR__ . '/../../autoload.php'; } @@ -104,7 +104,7 @@ function install_drupal($class_loader, $settings = array()) { // as well as a boolean indicating whether or not this is an interactive // installation. $interactive = empty($settings); - $install_state = $settings + array('interactive' => $interactive) + install_state_defaults(); + $install_state = $settings + ['interactive' => $interactive] + install_state_defaults(); try { // Begin the page request. This adds information about the current state of @@ -119,10 +119,10 @@ function install_drupal($class_loader, $settings = array()) { if (!$install_state['interactive']) { throw $e; } - $output = array( + $output = [ '#title' => $e->getTitle(), '#markup' => $e->getMessage(), - ); + ]; } // After execution, all tasks might be complete, in which case @@ -180,7 +180,7 @@ function install_drupal($class_loader, $settings = array()) { * @see \Drupal\Core\Form\FormBuilderInterface::submitForm() */ function install_state_defaults() { - $defaults = array( + $defaults = [ // The current task being processed. 'active_task' => NULL, // The last task that was completed during the previous installation @@ -205,7 +205,7 @@ function install_state_defaults() { // installation task that the form submission is for, and the values are // used as the $form_state->getValues() array that is passed on to the form // submission via \Drupal::formBuilder()->submitForm(). - 'forms' => array(), + 'forms' => [], // This becomes TRUE only at the end of the installation process, after // all available tasks have been completed and Drupal is fully installed. // It is used by the installer to store correct information in the database @@ -222,16 +222,16 @@ function install_state_defaults() { // and 'langcode' (the code of the chosen installation language), since // these settings need to persist from page request to page request before // the database is available for storage. - 'parameters' => array(), + 'parameters' => [], // Whether or not the parameters have changed during the current page // request. For interactive installations, this will trigger a page // redirect. 'parameters_changed' => FALSE, // An array of information about the chosen installation profile. This will // be filled in based on the profile's .info.yml file. - 'profile_info' => array(), + 'profile_info' => [], // An array of available installation profiles. - 'profiles' => array(), + 'profiles' => [], // The name of the theme to use during installation. 'theme' => 'seven', // The server URL where the interface translation files can be downloaded. @@ -259,11 +259,11 @@ function install_state_defaults() { 'task_not_complete' => FALSE, // A list of installation tasks which have already been performed during // the current page request. - 'tasks_performed' => array(), + 'tasks_performed' => [], // An array of translation files URIs available for the installation. Keyed // by the translation language code. - 'translations' => array(), - ); + 'translations' => [], + ]; return $defaults; } @@ -351,7 +351,7 @@ function install_begin_request($class_loader, &$install_state) { // Register the stream wrapper manager. $container ->register('stream_wrapper_manager', 'Drupal\Core\StreamWrapper\StreamWrapperManager') - ->addMethodCall('setContainer', array(new Reference('service_container'))); + ->addMethodCall('setContainer', [new Reference('service_container')]); $container ->register('file_system', 'Drupal\Core\File\FileSystem') ->addArgument(new Reference('stream_wrapper_manager')) @@ -427,7 +427,7 @@ function install_begin_request($class_loader, &$install_state) { // Add list of all available profiles to the installation state. $listing = new ExtensionDiscovery($container->get('app.root')); - $listing->setProfileDirectories(array()); + $listing->setProfileDirectories([]); $install_state['profiles'] += $listing->scan('profile'); // Prime drupal_get_filename()'s static cache. @@ -451,7 +451,7 @@ function install_begin_request($class_loader, &$install_state) { // Set the default language to the selected language, if any. if (isset($install_state['parameters']['langcode'])) { - $default_language = new Language(array('id' => $install_state['parameters']['langcode'])); + $default_language = new Language(['id' => $install_state['parameters']['langcode']]); $container->get('language.default')->set($default_language); \Drupal::translation()->setDefaultLangcode($install_state['parameters']['langcode']); } @@ -594,7 +594,7 @@ function install_run_task($task, &$install_state) { } // Create a one item list of batches if only one batch was provided. if (isset($batches['operations'])) { - $batches = array($batches); + $batches = [$batches]; } foreach ($batches as $batch) { batch_set($batch); @@ -724,26 +724,26 @@ function install_tasks($install_state) { // Start with the core installation tasks that run before handing control // to the installation profile. - $tasks = array( - 'install_select_language' => array( + $tasks = [ + 'install_select_language' => [ 'display_name' => t('Choose language'), 'run' => INSTALL_TASK_RUN_IF_REACHED, - ), - 'install_download_translation' => array( + ], + 'install_download_translation' => [ 'run' => $needs_download ? INSTALL_TASK_RUN_IF_REACHED : INSTALL_TASK_SKIP, - ), - 'install_select_profile' => array( + ], + 'install_select_profile' => [ 'display_name' => t('Choose profile'), 'display' => empty($install_state['profile_info']['distribution']['name']) && count($install_state['profiles']) != 1, 'run' => INSTALL_TASK_RUN_IF_REACHED, - ), - 'install_load_profile' => array( + ], + 'install_load_profile' => [ 'run' => INSTALL_TASK_RUN_IF_REACHED, - ), - 'install_verify_requirements' => array( + ], + 'install_verify_requirements' => [ 'display_name' => t('Verify requirements'), - ), - 'install_settings_form' => array( + ], + 'install_settings_form' => [ 'display_name' => t('Set up database'), 'type' => 'form', // Even though the form only allows the user to enter database settings, @@ -751,39 +751,39 @@ function install_tasks($install_state) { // since the form submit handler is where settings.php is rewritten. 'run' => $install_state['settings_verified'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED, 'function' => 'Drupal\Core\Installer\Form\SiteSettingsForm', - ), - 'install_write_profile' => array( - ), - 'install_verify_database_ready' => array( + ], + 'install_write_profile' => [ + ], + 'install_verify_database_ready' => [ 'run' => $install_state['database_ready'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED, - ), - 'install_base_system' => array( + ], + 'install_base_system' => [ 'run' => $install_state['base_system_verified'] ? INSTALL_TASK_SKIP : INSTALL_TASK_RUN_IF_NOT_COMPLETED, - ), + ], // All tasks below are executed in a regular, full Drupal environment. - 'install_bootstrap_full' => array( + 'install_bootstrap_full' => [ 'run' => INSTALL_TASK_RUN_IF_REACHED, - ), - 'install_profile_modules' => array( + ], + 'install_profile_modules' => [ 'display_name' => t('Install site'), 'type' => 'batch', - ), - 'install_profile_themes' => array( - ), - 'install_install_profile' => array( - ), - 'install_import_translations' => array( + ], + 'install_profile_themes' => [ + ], + 'install_install_profile' => [ + ], + 'install_import_translations' => [ 'display_name' => t('Set up translations'), 'display' => $needs_translations, 'type' => 'batch', 'run' => $needs_translations ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP, - ), - 'install_configure_form' => array( + ], + 'install_configure_form' => [ 'display_name' => t('Configure site'), 'type' => 'form', 'function' => 'Drupal\Core\Installer\Form\SiteConfigureForm', - ), - ); + ], + ]; // Now add any tasks defined by the installation profile. if (!empty($install_state['parameters']['profile'])) { @@ -804,16 +804,16 @@ function install_tasks($install_state) { } // Finish by adding the remaining core tasks. - $tasks += array( - 'install_finish_translations' => array( + $tasks += [ + 'install_finish_translations' => [ 'display_name' => t('Finish translations'), 'display' => $needs_translations, 'type' => 'batch', 'run' => $needs_translations ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP, - ), - 'install_finished' => array( - ), - ); + ], + 'install_finished' => [ + ], + ]; // Allow the installation profile to modify the full list of tasks. if (!empty($install_state['parameters']['profile'])) { @@ -828,13 +828,13 @@ function install_tasks($install_state) { // Fill in default parameters for each task before returning the list. foreach ($tasks as $task_name => &$task) { - $task += array( + $task += [ 'display_name' => NULL, 'display' => !empty($task['display_name']), 'type' => 'normal', 'run' => INSTALL_TASK_RUN_IF_NOT_COMPLETED, 'function' => $task_name, - ); + ]; } return $tasks; } @@ -855,7 +855,7 @@ function install_tasks($install_state) { * @see maintenance-task-list.html.twig */ function install_tasks_to_display($install_state) { - $displayed_tasks = array(); + $displayed_tasks = []; foreach (install_tasks($install_state) as $name => $task) { if ($task['display']) { $displayed_tasks[$name] = $task['display_name']; @@ -969,39 +969,39 @@ function install_display_output($output, $install_state) { // resulting in /subfolder/install.php being found through search engines. // When settings.php is writeable this can be used via an external database // leading a malicious user to gain php access to the server. - $noindex_meta_tag = array( + $noindex_meta_tag = [ '#tag' => 'meta', - '#attributes' => array( + '#attributes' => [ 'name' => 'robots', 'content' => 'noindex, nofollow', - ), - ); + ], + ]; $output['#attached']['html_head'][] = [$noindex_meta_tag, 'install_meta_robots']; // Only show the task list if there is an active task; otherwise, the page // request has ended before tasks have even been started, so there is nothing // meaningful to show. - $regions = array(); + $regions = []; if (isset($install_state['active_task'])) { // Let the theming function know when every step of the installation has // been completed. $active_task = $install_state['installation_finished'] ? NULL : $install_state['active_task']; - $task_list = array( + $task_list = [ '#theme' => 'maintenance_task_list', '#items' => install_tasks_to_display($install_state), '#active' => $active_task, - ); + ]; $regions['sidebar_first'] = $task_list; } $bare_html_page_renderer = \Drupal::service('bare_html_page_renderer'); $response = $bare_html_page_renderer->renderBarePage($output, $output['#title'], 'install_page', $regions); - $default_headers = array( + $default_headers = [ 'Expires' => 'Sun, 19 Nov 1978 05:00:00 GMT', 'Last-Modified' => gmdate(DATE_RFC1123, REQUEST_TIME), 'Cache-Control' => 'no-cache, must-revalidate', 'ETag' => '"' . REQUEST_TIME . '"', - ); + ]; $response->headers->add($default_headers); $response->send(); exit; @@ -1052,13 +1052,13 @@ function install_base_system(&$install_state) { // Enable the user module so that sessions can be recorded during the // upcoming bootstrap step. - \Drupal::service('module_installer')->install(array('user'), FALSE); + \Drupal::service('module_installer')->install(['user'], FALSE); // Save the list of other modules to install for the upcoming tasks. // State can be set to the database now that system.module is installed. $modules = $install_state['profile_info']['dependencies']; - \Drupal::state()->set('install_profile_modules', array_diff($modules, array('system'))); + \Drupal::state()->set('install_profile_modules', array_diff($modules, ['system'])); $install_state['base_system_verified'] = TRUE; } @@ -1125,13 +1125,13 @@ function install_verify_database_ready() { * Checks a database connection and returns any errors. */ function install_database_errors($database, $settings_file) { - $errors = array(); + $errors = []; // Check database type. $database_types = drupal_get_database_types(); $driver = $database['driver']; if (!isset($database_types[$driver])) { - $errors['driver'] = t("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", array('%settings_file' => $settings_file, '@drupal' => drupal_install_profile_distribution_name(), '%driver' => $driver)); + $errors['driver'] = t("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", ['%settings_file' => $settings_file, '@drupal' => drupal_install_profile_distribution_name(), '%driver' => $driver]); } else { // Run driver specific validation @@ -1243,10 +1243,10 @@ function _install_select_profile(&$install_state) { * @see file_scan_directory() */ function install_find_translations() { - $translations = array(); + $translations = []; $files = \Drupal::service('string_translator.file_translation')->findTranslationFiles(); // English does not need a translation file. - array_unshift($files, (object) array('name' => 'en')); + array_unshift($files, (object) ['name' => 'en']); foreach ($files as $uri => $file) { // Strip off the file name component before the language code. $langcode = preg_replace('!^(.+\.)?([^\.]+)$!', '\2', $file->name); @@ -1367,7 +1367,7 @@ function install_retrieve_file($uri, $destination) { } try { - $response = \Drupal::httpClient()->get($uri, array('headers' => array('Accept' => 'text/plain'))); + $response = \Drupal::httpClient()->get($uri, ['headers' => ['Accept' => 'text/plain']]); $data = (string) $response->getBody(); if (empty($data)) { return FALSE; @@ -1474,14 +1474,14 @@ function install_profile_modules(&$install_state) { // as those will not be handled by the module installer. install_core_entity_type_definitions(); - $modules = \Drupal::state()->get('install_profile_modules') ?: array(); + $modules = \Drupal::state()->get('install_profile_modules') ?: []; $files = system_rebuild_module_data(); \Drupal::state()->delete('install_profile_modules'); // Always install required modules first. Respect the dependencies between // the modules. - $required = array(); - $non_required = array(); + $required = []; + $non_required = []; // Add modules that other modules depend on. foreach ($modules as $module) { @@ -1501,15 +1501,15 @@ function install_profile_modules(&$install_state) { arsort($required); arsort($non_required); - $operations = array(); + $operations = []; foreach ($required + $non_required as $module => $weight) { - $operations[] = array('_install_module_batch', array($module, $files[$module]->info['name'])); + $operations[] = ['_install_module_batch', [$module, $files[$module]->info['name']]]; } - $batch = array( + $batch = [ 'operations' => $operations, - 'title' => t('Installing @drupal', array('@drupal' => drupal_install_profile_distribution_name())), + 'title' => t('Installing @drupal', ['@drupal' => drupal_install_profile_distribution_name()]), 'error_message' => t('The installation has encountered an error.'), - ); + ]; return $batch; } @@ -1552,7 +1552,7 @@ function install_profile_themes(&$install_state) { * An array of information about the current installation state. */ function install_install_profile(&$install_state) { - \Drupal::service('module_installer')->install(array(drupal_get_profile()), FALSE); + \Drupal::service('module_installer')->install([drupal_get_profile()], FALSE); // Install all available optional config. During installation the module order // is determined by dependencies. If there are no dependencies between modules // then the order in which they are installed is dependent on random factors @@ -1595,21 +1595,21 @@ function install_download_additional_translations_operations(&$install_state) { ->save(); \Drupal::service('language.default')->set($language); if (empty($install_state['profile_info']['keep_english'])) { - entity_delete_multiple('configurable_language', array('en')); + entity_delete_multiple('configurable_language', ['en']); } } // If there is more than one language or the single one is not English, we // should download/import translations. $languages = \Drupal::languageManager()->getLanguages(); - $operations = array(); + $operations = []; foreach ($languages as $langcode => $language) { // The installer language was already downloaded. Check downloads for the // other languages if any. Ignore any download errors here, since we // are in the middle of an install process and there is no way back. We // will not import what we cannot download. if ($langcode != 'en' && $langcode != $install_state['parameters']['langcode']) { - $operations[] = array('install_check_translations', array($langcode, $install_state['server_pattern'])); + $operations[] = ['install_check_translations', [$langcode, $install_state['server_pattern']]]; } } return $operations; @@ -1632,26 +1632,26 @@ function install_import_translations(&$install_state) { $operations = install_download_additional_translations_operations($install_state); $languages = \Drupal::languageManager()->getLanguages(); if (count($languages) > 1 || !isset($languages['en'])) { - $operations[] = array('_install_prepare_import', array(array_keys($languages), $install_state['server_pattern'])); + $operations[] = ['_install_prepare_import', [array_keys($languages), $install_state['server_pattern']]]; // Set up a batch to import translations for drupal core. Translation import // for contrib modules happens in install_import_translations_remaining. foreach ($languages as $language) { if (locale_translation_use_remote_source()) { - $operations[] = array('locale_translation_batch_fetch_download', array('drupal', $language->getId())); + $operations[] = ['locale_translation_batch_fetch_download', ['drupal', $language->getId()]]; } - $operations[] = array('locale_translation_batch_fetch_import', array('drupal', $language->getId(), array())); + $operations[] = ['locale_translation_batch_fetch_import', ['drupal', $language->getId(), []]]; } module_load_include('fetch.inc', 'locale'); - $batch = array( + $batch = [ 'operations' => $operations, 'title' => t('Updating translations.'), 'progress_message' => '', 'error_message' => t('Error importing translation files'), 'finished' => 'locale_translation_batch_fetch_finished', 'file' => drupal_get_path('module', 'locale') . '/locale.batch.inc', - ); + ]; return $batch; } } @@ -1666,11 +1666,11 @@ function install_import_translations(&$install_state) { */ function _install_prepare_import($langcodes, $server_pattern) { \Drupal::moduleHandler()->loadInclude('locale', 'bulk.inc'); - $matches = array(); + $matches = []; foreach ($langcodes as $langcode) { // Get the translation files located in the translations directory. - $files = locale_translate_get_interface_translation_files(array('drupal'), array($langcode)); + $files = locale_translate_get_interface_translation_files(['drupal'], [$langcode]); // Pick the first file which matches the language, if any. $file = reset($files); if (is_object($file)) { @@ -1683,17 +1683,17 @@ function _install_prepare_import($langcodes, $server_pattern) { // we check if at least the major version number is available. if ($info['major']) { $core = $info['major'] . '.x'; - $data = array( + $data = [ 'name' => 'drupal', 'project_type' => 'module', 'core' => $core, 'version' => $version, 'server_pattern' => $server_pattern, 'status' => 1, - ); + ]; \Drupal::service('locale.project')->set($data['name'], $data); module_load_include('compare.inc', 'locale'); - locale_translation_check_projects_local(array('drupal'), array($langcode)); + locale_translation_check_projects_local(['drupal'], [$langcode]); } } } @@ -1722,16 +1722,16 @@ function install_finish_translations(&$install_state) { // using a batch. $projects = locale_translation_build_projects(); $languages = \Drupal::languageManager()->getLanguages(); - $batches = array(); + $batches = []; if (count($projects) > 1) { $options = _locale_translation_default_update_options(); - if ($batch = locale_translation_batch_update_build(array(), array_keys($languages), $options)) { + if ($batch = locale_translation_batch_update_build([], array_keys($languages), $options)) { $batches[] = $batch; } } // Creates configuration translations. - $batches[] = locale_config_batch_update_components(array(), array_keys($languages)); + $batches[] = locale_config_batch_update_components([], array_keys($languages)); return $batches; } @@ -1768,9 +1768,9 @@ function install_finished(&$install_state) { user_login_finalize($account); } - $success_message = t('Congratulations, you installed @drupal!', array( + $success_message = t('Congratulations, you installed @drupal!', [ '@drupal' => drupal_install_profile_distribution_name(), - )); + ]); drupal_set_message($success_message); } @@ -1780,9 +1780,9 @@ function install_finished(&$install_state) { * Performs batch installation of modules. */ function _install_module_batch($module, $module_name, &$context) { - \Drupal::service('module_installer')->install(array($module), FALSE); + \Drupal::service('module_installer')->install([$module], FALSE); $context['results'][] = $module; - $context['message'] = t('Installed %module module.', array('%module' => $module_name)); + $context['message'] = t('Installed %module module.', ['%module' => $module_name]); } /** @@ -1799,7 +1799,7 @@ function _install_module_batch($module, $module_name, &$context) { * error with detailed information. */ function install_check_translations($langcode, $server_pattern) { - $requirements = array(); + $requirements = []; $readable = FALSE; $writable = FALSE; @@ -1828,12 +1828,12 @@ function install_check_translations($langcode, $server_pattern) { } // Build URL for the translation file and the translation server. - $variables = array( + $variables = [ '%project' => 'drupal', '%version' => \Drupal::VERSION, '%core' => \Drupal::CORE_COMPATIBILITY, '%language' => $langcode, - ); + ]; $translation_url = strtr($server_pattern, $variables); $elements = parse_url($translation_url); @@ -1857,73 +1857,73 @@ function install_check_translations($langcode, $server_pattern) { // If the translations directory does not exists, throw an error. if (!$translations_directory_exists) { - $requirements['translations directory exists'] = array( + $requirements['translations directory exists'] = [ 'title' => t('Translations directory'), 'value' => t('The translations directory does not exist.'), 'severity' => REQUIREMENT_ERROR, - 'description' => t('The installer requires that you create a translations directory as part of the installation process. Create the directory %translations_directory . More details about installing Drupal are available in INSTALL.txt.', array('%translations_directory' => $translations_directory, ':install_txt' => base_path() . 'core/INSTALL.txt')), - ); + 'description' => t('The installer requires that you create a translations directory as part of the installation process. Create the directory %translations_directory . More details about installing Drupal are available in INSTALL.txt.', ['%translations_directory' => $translations_directory, ':install_txt' => base_path() . 'core/INSTALL.txt']), + ]; } else { - $requirements['translations directory exists'] = array( + $requirements['translations directory exists'] = [ 'title' => t('Translations directory'), - 'value' => t('The directory %translations_directory exists.', array('%translations_directory' => $translations_directory)), - ); + 'value' => t('The directory %translations_directory exists.', ['%translations_directory' => $translations_directory]), + ]; // If the translations directory is not readable, throw an error. if (!$readable) { - $requirements['translations directory readable'] = array( + $requirements['translations directory readable'] = [ 'title' => t('Translations directory'), 'value' => t('The translations directory is not readable.'), 'severity' => REQUIREMENT_ERROR, - 'description' => t('The installer requires read permissions to %translations_directory at all times. The webhosting issues documentation section offers help on this and other topics.', array('%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions')), - ); + 'description' => t('The installer requires read permissions to %translations_directory at all times. The webhosting issues documentation section offers help on this and other topics.', ['%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']), + ]; } // If translations directory is not writable, throw an error. if (!$writable) { - $requirements['translations directory writable'] = array( + $requirements['translations directory writable'] = [ 'title' => t('Translations directory'), 'value' => t('The translations directory is not writable.'), 'severity' => REQUIREMENT_ERROR, - 'description' => t('The installer requires write permissions to %translations_directory during the installation process. The webhosting issues documentation section offers help on this and other topics.', array('%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions')), - ); + 'description' => t('The installer requires write permissions to %translations_directory during the installation process. The webhosting issues documentation section offers help on this and other topics.', ['%translations_directory' => $translations_directory, ':handbook_url' => 'https://www.drupal.org/server-permissions']), + ]; } else { - $requirements['translations directory writable'] = array( + $requirements['translations directory writable'] = [ 'title' => t('Translations directory'), 'value' => t('The translations directory is writable.'), - ); + ]; } } // If the translations server can not be contacted, throw an error. if (!$online) { - $requirements['online'] = array( + $requirements['online'] = [ 'title' => t('Internet'), 'value' => t('The translation server is offline.'), 'severity' => REQUIREMENT_ERROR, - 'description' => t('The installer requires to contact the translation server to download a translation file. Check your internet connection and verify that your website can reach the translation server at @server_url.', array(':server_url' => $server_url, '@server_url' => $server_url)), - ); + 'description' => t('The installer requires to contact the translation server to download a translation file. Check your internet connection and verify that your website can reach the translation server at @server_url.', [':server_url' => $server_url, '@server_url' => $server_url]), + ]; } else { - $requirements['online'] = array( + $requirements['online'] = [ 'title' => t('Internet'), 'value' => t('The translation server is online.'), - ); + ]; // If translation file is not found at the translation server, throw an // error. if (!$translation_available) { - $requirements['translation available'] = array( + $requirements['translation available'] = [ 'title' => t('Translation'), - 'value' => t('The %language translation is not available.', array('%language' => $language)), + 'value' => t('The %language translation is not available.', ['%language' => $language]), 'severity' => REQUIREMENT_ERROR, - 'description' => t('The %language translation file is not available at the translation server. Choose a different language or select English and translate your website later.', array('%language' => $language, ':url' => $_SERVER['SCRIPT_NAME'])), - ); + 'description' => t('The %language translation file is not available at the translation server. Choose a different language or select English and translate your website later.', ['%language' => $language, ':url' => $_SERVER['SCRIPT_NAME']]), + ]; } else { - $requirements['translation available'] = array( + $requirements['translation available'] = [ 'title' => t('Translation'), - 'value' => t('The %language translation is available.', array('%language' => $language)), - ); + 'value' => t('The %language translation is available.', ['%language' => $language]), + ]; } } @@ -1931,12 +1931,12 @@ function install_check_translations($langcode, $server_pattern) { $translation_downloaded = install_retrieve_file($translation_url, $translations_directory); if (!$translation_downloaded) { - $requirements['translation downloaded'] = array( + $requirements['translation downloaded'] = [ 'title' => t('Translation'), - 'value' => t('The %language translation could not be downloaded.', array('%language' => $language)), + 'value' => t('The %language translation could not be downloaded.', ['%language' => $language]), 'severity' => REQUIREMENT_ERROR, - 'description' => t('The %language translation file could not be downloaded. Choose a different language or select English and translate your website later.', array('%language' => $language, ':url' => $_SERVER['SCRIPT_NAME'])), - ); + 'description' => t('The %language translation file could not be downloaded. Choose a different language or select English and translate your website later.', ['%language' => $language, ':url' => $_SERVER['SCRIPT_NAME']]), + ]; } } @@ -1958,14 +1958,14 @@ function install_check_requirements($install_state) { // If Drupal is not set up already, we need to try to create the default // settings and services files. - $default_files = array(); - $default_files['settings.php'] = array( + $default_files = []; + $default_files['settings.php'] = [ 'file' => 'settings.php', 'file_default' => 'default.settings.php', 'title_default' => t('Default settings file'), 'description_default' => t('The default settings file does not exist.'), 'title' => t('Settings file'), - ); + ]; foreach ($default_files as $default_file_info) { $readable = FALSE; @@ -1987,15 +1987,15 @@ function install_check_requirements($install_state) { // If the default $default_file does not exist, or is not readable, // report an error. if (!drupal_verify_install_file($default_file, FILE_EXIST | FILE_READABLE)) { - $requirements["default $file file exists"] = array( + $requirements["default $file file exists"] = [ 'title' => $default_file_info['title_default'], 'value' => $default_file_info['description_default'], 'severity' => REQUIREMENT_ERROR, - 'description' => t('The @drupal installer requires that the %default-file file not be modified in any way from the original download.', array( + 'description' => t('The @drupal installer requires that the %default-file file not be modified in any way from the original download.', [ '@drupal' => drupal_install_profile_distribution_name(), '%default-file' => $default_file - )), - ); + ]), + ]; } // Otherwise, if $file does not exist yet, we can try to copy // $default_file to create it. @@ -2046,68 +2046,68 @@ function install_check_requirements($install_state) { // If the $file does not exist, throw an error. if (!$exists) { - $requirements["$file file exists"] = array( + $requirements["$file file exists"] = [ 'title' => $default_file_info['title'], - 'value' => t('The %file does not exist.', array('%file' => $default_file_info['title'])), + 'value' => t('The %file does not exist.', ['%file' => $default_file_info['title']]), 'severity' => REQUIREMENT_ERROR, - 'description' => t('The @drupal installer requires that you create a %file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in INSTALL.txt.', array( + 'description' => t('The @drupal installer requires that you create a %file as part of the installation process. Copy the %default_file file to %file. More details about installing Drupal are available in INSTALL.txt.', [ '@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, '%default_file' => $default_file, ':install_txt' => base_path() . 'core/INSTALL.txt' - )), - ); + ]), + ]; } else { - $requirements["$file file exists"] = array( + $requirements["$file file exists"] = [ 'title' => $default_file_info['title'], - 'value' => t('The %file exists.', array('%file' => $file)), - ); + 'value' => t('The %file exists.', ['%file' => $file]), + ]; // If the $file is not readable, throw an error. if (!$readable) { - $requirements["$file file readable"] = array( + $requirements["$file file readable"] = [ 'title' => $default_file_info['title'], - 'value' => t('The %file is not readable.', array('%file' => $default_file_info['title'])), + 'value' => t('The %file is not readable.', ['%file' => $default_file_info['title']]), 'severity' => REQUIREMENT_ERROR, - 'description' => t('@drupal requires read permissions to %file at all times. The webhosting issues documentation section offers help on this and other topics.', array( + 'description' => t('@drupal requires read permissions to %file at all times. The webhosting issues documentation section offers help on this and other topics.', [ '@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, ':handbook_url' => 'https://www.drupal.org/server-permissions' - )), - ); + ]), + ]; } // If the $file is not writable, throw an error. if (!$writable) { - $requirements["$file file writeable"] = array( + $requirements["$file file writeable"] = [ 'title' => $default_file_info['title'], - 'value' => t('The %file is not writable.', array('%file' => $default_file_info['title'])), + 'value' => t('The %file is not writable.', ['%file' => $default_file_info['title']]), 'severity' => REQUIREMENT_ERROR, - 'description' => t('The @drupal installer requires write permissions to %file during the installation process. The webhosting issues documentation section offers help on this and other topics.', array( + 'description' => t('The @drupal installer requires write permissions to %file during the installation process. The webhosting issues documentation section offers help on this and other topics.', [ '@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, ':handbook_url' => 'https://www.drupal.org/server-permissions' - )), - ); + ]), + ]; } else { - $requirements["$file file"] = array( + $requirements["$file file"] = [ 'title' => $default_file_info['title'], - 'value' => t('The @file is writable.', array('@file' => $default_file_info['title'])), - ); + 'value' => t('The @file is writable.', ['@file' => $default_file_info['title']]), + ]; } if (!empty($settings_file_ownership_error)) { - $requirements["$file file ownership"] = array( + $requirements["$file file ownership"] = [ 'title' => $default_file_info['title'], - 'value' => t('The @file is owned by the web server.', array('@file' => $default_file_info['title'])), + 'value' => t('The @file is owned by the web server.', ['@file' => $default_file_info['title']]), 'severity' => REQUIREMENT_ERROR, - 'description' => t('The @drupal installer failed to create a %file file with proper file ownership. Log on to your web server, remove the existing %file file, and create a new one by copying the %default_file file to %file. More details about installing Drupal are available in INSTALL.txt. The webhosting issues documentation section offers help on this and other topics.', array( + 'description' => t('The @drupal installer failed to create a %file file with proper file ownership. Log on to your web server, remove the existing %file file, and create a new one by copying the %default_file file to %file. More details about installing Drupal are available in INSTALL.txt. The webhosting issues documentation section offers help on this and other topics.', [ '@drupal' => drupal_install_profile_distribution_name(), '%file' => $file, '%default_file' => $default_file, ':install_txt' => base_path() . 'core/INSTALL.txt', ':handbook_url' => 'https://www.drupal.org/server-permissions' - )), - ); + ]), + ]; } } } @@ -2145,17 +2145,17 @@ function install_display_requirements($install_state, $requirements) { $build['report']['#requirements'] = $requirements; if ($severity == REQUIREMENT_WARNING) { $build['#title'] = t('Requirements review'); - $build['#suffix'] = t('Check the messages and retry, or you may choose to continue anyway.', array(':retry' => drupal_requirements_url(REQUIREMENT_ERROR), ':cont' => drupal_requirements_url($severity))); + $build['#suffix'] = t('Check the messages and retry, or you may choose to continue anyway.', [':retry' => drupal_requirements_url(REQUIREMENT_ERROR), ':cont' => drupal_requirements_url($severity)]); } else { $build['#title'] = t('Requirements problem'); - $build['#suffix'] = t('Check the messages and try again.', array(':url' => drupal_requirements_url($severity))); + $build['#suffix'] = t('Check the messages and try again.', [':url' => drupal_requirements_url($severity)]); } return $build; } else { // Throw an exception showing any unmet requirements. - $failures = array(); + $failures = []; foreach ($requirements as $requirement) { // Skip warnings altogether for non-interactive installations; these // proceed in a single request so there is no good opportunity (and no @@ -2180,10 +2180,10 @@ function install_display_requirements($install_state, $requirements) { function install_write_profile($install_state) { if (Settings::get('install_profile') !== $install_state['parameters']['profile']) { // Remember the profile which was used. - $settings['settings']['install_profile'] = (object) array( + $settings['settings']['install_profile'] = (object) [ 'value' => $install_state['parameters']['profile'], 'required' => TRUE, - ); + ]; drupal_rewrite_settings($settings); } } diff --git a/core/includes/install.inc b/core/includes/install.inc index 3a9c2bc..b156406 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -96,7 +96,7 @@ function drupal_load_updates() { function drupal_install_profile_distribution_name() { // During installation, the profile information is stored in the global // installation state (it might not be saved anywhere yet). - $info = array(); + $info = []; if (drupal_installation_attempted()) { global $install_state; if (isset($install_state['profile_info'])) { @@ -158,14 +158,14 @@ function drupal_detect_database_types() { * An array of available database driver installer objects. */ function drupal_get_database_types() { - $databases = array(); - $drivers = array(); + $databases = []; + $drivers = []; // The internal database driver name is any valid PHP identifier. $mask = '/^' . DRUPAL_PHP_FUNCTION_PATTERN . '$/'; - $files = file_scan_directory(DRUPAL_ROOT . '/core/lib/Drupal/Core/Database/Driver', $mask, array('recurse' => FALSE)); + $files = file_scan_directory(DRUPAL_ROOT . '/core/lib/Drupal/Core/Database/Driver', $mask, ['recurse' => FALSE]); if (is_dir(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database')) { - $files += file_scan_directory(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database/', $mask, array('recurse' => FALSE)); + $files += file_scan_directory(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database/', $mask, ['recurse' => FALSE]); } foreach ($files as $file) { if (file_exists($file->uri . '/Install/Tasks.php')) { @@ -183,7 +183,7 @@ function drupal_get_database_types() { if (isset($databases['mysql'])) { $mysql_database = $databases['mysql']; unset($databases['mysql']); - $databases = array('mysql' => $mysql_database) + $databases; + $databases = ['mysql' => $mysql_database] + $databases; } return $databases; @@ -213,13 +213,13 @@ function drupal_get_database_types() { * $config_directories['sync'] = 'config_hash/sync' * @endcode */ -function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { +function drupal_rewrite_settings($settings = [], $settings_file = NULL) { if (!isset($settings_file)) { $settings_file = \Drupal::service('site.path') . '/settings.php'; } // Build list of setting names and insert the values into the global namespace. - $variable_names = array(); - $settings_settings = array(); + $variable_names = []; + $settings_settings = []; foreach ($settings as $setting => $data) { if ($setting != 'settings') { _drupal_rewrite_settings_global($GLOBALS[$setting], $data); @@ -248,7 +248,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { $value = $token; } // Do not operate on whitespace. - if (!in_array($type, array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT))) { + if (!in_array($type, [T_WHITESPACE, T_COMMENT, T_DOC_COMMENT])) { switch ($state) { case 'default': if ($type === T_VARIABLE && isset($variable_names[$value])) { @@ -335,7 +335,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { // Write the new settings file. if (file_put_contents($settings_file, $buffer) === FALSE) { - throw new Exception(t('Failed to modify %settings. Verify the file permissions.', array('%settings' => $settings_file))); + throw new Exception(t('Failed to modify %settings. Verify the file permissions.', ['%settings' => $settings_file])); } else { // In case any $settings variables were written, import them into the @@ -352,7 +352,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { } } else { - throw new Exception(t('Failed to open %settings. Verify the file permissions.', array('%settings' => $settings_file))); + throw new Exception(t('Failed to open %settings. Verify the file permissions.', ['%settings' => $settings_file])); } } @@ -375,7 +375,7 @@ function _drupal_rewrite_settings_is_simple($type, $value) { $is_integer = $type == T_LNUMBER; $is_float = $type == T_DNUMBER; $is_string = $type == T_CONSTANT_ENCAPSED_STRING; - $is_boolean_or_null = $type == T_STRING && in_array(strtoupper($value), array('TRUE', 'FALSE', 'NULL')); + $is_boolean_or_null = $type == T_STRING && in_array(strtoupper($value), ['TRUE', 'FALSE', 'NULL']); return $is_integer || $is_float || $is_string || $is_boolean_or_null; } @@ -504,10 +504,10 @@ function drupal_install_config_directories() { // Bail out using a similar error message as in system_requirements(). if (!file_prepare_directory($config_directories[CONFIG_SYNC_DIRECTORY], FILE_CREATE_DIRECTORY) && !file_exists($config_directories[CONFIG_SYNC_DIRECTORY])) { - throw new Exception(t('The directory %directory could not be created. To proceed with the installation, either create the directory or ensure that the installer has the permissions to create it automatically. For more information, see the online handbook.', array( + throw new Exception(t('The directory %directory could not be created. To proceed with the installation, either create the directory or ensure that the installer has the permissions to create it automatically. For more information, see the online handbook.', [ '%directory' => config_get_config_directory(CONFIG_SYNC_DIRECTORY), ':handbook_url' => 'https://www.drupal.org/server-permissions', - ))); + ])); } elseif (is_writable($config_directories[CONFIG_SYNC_DIRECTORY])) { // Put a README.txt into the sync config directory. This is required so that @@ -560,7 +560,7 @@ function drupal_verify_profile($install_state) { // Get the list of available modules for the selected installation profile. $listing = new ExtensionDiscovery(\Drupal::root()); - $present_modules = array(); + $present_modules = []; foreach ($listing->scan('module') as $present_module) { $present_modules[] = $present_module->getName(); } @@ -572,7 +572,7 @@ function drupal_verify_profile($install_state) { // Verify that all of the profile's required modules are present. $missing_modules = array_diff($info['dependencies'], $present_modules); - $requirements = array(); + $requirements = []; if ($missing_modules) { $build = [ @@ -581,16 +581,16 @@ function drupal_verify_profile($install_state) { ]; foreach ($missing_modules as $module) { - $build['#items'][] = array('#markup' => '' . Unicode::ucfirst($module) . ''); + $build['#items'][] = ['#markup' => '' . Unicode::ucfirst($module) . '']; } $modules_list = \Drupal::service('renderer')->renderPlain($build); - $requirements['required_modules'] = array( + $requirements['required_modules'] = [ 'title' => t('Required modules'), 'value' => t('Required modules not found.'), 'severity' => REQUIREMENT_ERROR, - 'description' => t('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as /modules. Missing modules: @modules', array('@modules' => $modules_list)), - ); + 'description' => t('The following modules are required but were not found. Move them into the appropriate modules subdirectory, such as /modules. Missing modules: @modules', ['@modules' => $modules_list]), + ]; } return $requirements; } @@ -622,7 +622,7 @@ function drupal_install_system($install_state) { \Drupal::service('config.installer')->installDefaultConfig('core', 'core'); // Install System module and rebuild the newly available routes. - $kernel->getContainer()->get('module_installer')->install(array('system'), FALSE); + $kernel->getContainer()->get('module_installer')->install(['system'], FALSE); \Drupal::service('router.builder')->rebuild(); // Ensure default language is saved. @@ -663,7 +663,7 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') { // Verify file permissions. if (isset($mask)) { - $masks = array(FILE_EXIST, FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE); + $masks = [FILE_EXIST, FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE]; foreach ($masks as $current_mask) { if ($mask & $current_mask) { switch ($current_mask) { @@ -729,7 +729,7 @@ function drupal_verify_install_file($file, $mask = NULL, $type = 'file') { */ function drupal_install_mkdir($file, $mask, $message = TRUE) { $mod = 0; - $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE); + $masks = [FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE]; foreach ($masks as $m) { if ($mask & $m) { switch ($m) { @@ -783,7 +783,7 @@ function drupal_install_fix_file($file, $mask, $message = TRUE) { } $mod = fileperms($file) & 0777; - $masks = array(FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE); + $masks = [FILE_READABLE, FILE_WRITABLE, FILE_EXECUTABLE, FILE_NOT_READABLE, FILE_NOT_WRITABLE, FILE_NOT_EXECUTABLE]; // FILE_READABLE, FILE_WRITABLE, and FILE_EXECUTABLE permission strings // can theoretically be 0400, 0200, and 0100 respectively, but to be safe @@ -845,10 +845,10 @@ function drupal_install_fix_file($file, $mask, $message = TRUE) { */ function install_goto($path) { global $base_url; - $headers = array( + $headers = [ // Not a permanent redirect. 'Cache-Control' => 'no-cache', - ); + ]; $response = new RedirectResponse($base_url . '/' . $path, 302, $headers); $response->send(); } @@ -880,7 +880,7 @@ function install_goto($path) { * @see drupal_requirements_url() * @see Drupal\Component\Utility\UrlHelper::filterBadProtocol() */ -function drupal_current_script_url($query = array()) { +function drupal_current_script_url($query = []) { $uri = $_SERVER['SCRIPT_NAME']; $query = array_merge(UrlHelper::filterQueryParameters(\Drupal::request()->query->all()), $query); if (!empty($query)) { @@ -910,7 +910,7 @@ function drupal_current_script_url($query = array()) { * @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol() */ function drupal_requirements_url($severity) { - $query = array(); + $query = []; // If there are no errors, only warnings, append 'continue=1' to the URL so // the user can bypass this screen on the next page load. if ($severity == REQUIREMENT_WARNING) { @@ -932,7 +932,7 @@ function drupal_check_profile($profile) { $info = install_profile_info($profile); // Collect requirement testing results. - $requirements = array(); + $requirements = []; // Performs an ExtensionDiscovery scan as the system module is unavailable and // we don't yet know where all the modules are located. @@ -986,14 +986,14 @@ function drupal_requirements_severity(&$requirements) { function drupal_check_module($module) { module_load_install($module); // Check requirements - $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', array('install')); + $requirements = \Drupal::moduleHandler()->invoke($module, 'requirements', ['install']); if (is_array($requirements) && drupal_requirements_severity($requirements) == REQUIREMENT_ERROR) { // Print any error messages foreach ($requirements as $requirement) { if (isset($requirement['severity']) && $requirement['severity'] == REQUIREMENT_ERROR) { $message = $requirement['description']; if (isset($requirement['value']) && $requirement['value']) { - $message = t('@requirements_message (Currently using @item version @version)', array('@requirements_message' => $requirement['description'], '@item' => $requirement['title'], '@version' => $requirement['value'])); + $message = t('@requirements_message (Currently using @item version @version)', ['@requirements_message' => $requirement['description'], '@item' => $requirement['title'], '@version' => $requirement['value']]); } drupal_set_message($message, 'error'); } @@ -1051,27 +1051,27 @@ function drupal_check_module($module) { * The info array. */ function install_profile_info($profile, $langcode = 'en') { - $cache = &drupal_static(__FUNCTION__, array()); + $cache = &drupal_static(__FUNCTION__, []); if (!isset($cache[$profile][$langcode])) { // Set defaults for module info. - $defaults = array( - 'dependencies' => array(), - 'themes' => array('stark'), + $defaults = [ + 'dependencies' => [], + 'themes' => ['stark'], 'description' => '', 'version' => NULL, 'hidden' => FALSE, 'php' => DRUPAL_MINIMUM_PHP, - ); + ]; $profile_file = drupal_get_path('profile', $profile) . "/$profile.info.yml"; $info = \Drupal::service('info_parser')->parse($profile_file); $info += $defaults; // drupal_required_modules() includes the current profile as a dependency. // Remove that dependency, since a module cannot depend on itself. - $required = array_diff(drupal_required_modules(), array($profile)); + $required = array_diff(drupal_required_modules(), [$profile]); - $locale = !empty($langcode) && $langcode != 'en' ? array('locale') : array(); + $locale = !empty($langcode) && $langcode != 'en' ? ['locale'] : []; $info['dependencies'] = array_unique(array_merge($required, $info['dependencies'], $locale)); diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 9dbbc20..a75d008 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -28,27 +28,27 @@ */ function template_preprocess_menu_local_task(&$variables) { $link = $variables['element']['#link']; - $link += array( - 'localized_options' => array(), - ); + $link += [ + 'localized_options' => [], + ]; $link_text = $link['title']; if (!empty($variables['element']['#active'])) { $variables['is_active'] = TRUE; // Add text to indicate active tab for non-visual users. - $active = SafeMarkup::format('@label', array('@label' => t('(active tab)'))); - $link_text = t('@local-task-title@active', array('@local-task-title' => $link_text, '@active' => $active)); + $active = SafeMarkup::format('@label', ['@label' => t('(active tab)')]); + $link_text = t('@local-task-title@active', ['@local-task-title' => $link_text, '@active' => $active]); } $link['localized_options']['set_active_class'] = TRUE; - $variables['link'] = array( + $variables['link'] = [ '#type' => 'link', '#title' => $link_text, '#url' => $link['url'], '#options' => $link['localized_options'], - ); + ]; } /** @@ -64,32 +64,32 @@ function template_preprocess_menu_local_task(&$variables) { */ function template_preprocess_menu_local_action(&$variables) { $link = $variables['element']['#link']; - $link += array( - 'localized_options' => array(), - ); + $link += [ + 'localized_options' => [], + ]; $link['localized_options']['attributes']['class'][] = 'button'; $link['localized_options']['attributes']['class'][] = 'button-action'; $link['localized_options']['set_active_class'] = TRUE; - $variables['link'] = array( + $variables['link'] = [ '#type' => 'link', '#title' => $link['title'], '#options' => $link['localized_options'], '#url' => $link['url'], - ); + ]; } /** * Returns an array containing the names of system-defined (default) menus. */ function menu_list_system_menus() { - return array( + return [ 'tools' => 'Tools', 'admin' => 'Administration', 'account' => 'User account menu', 'main' => 'Main navigation', 'footer' => 'Footer menu', - ); + ]; } /** @@ -144,12 +144,12 @@ function menu_secondary_local_tasks() { * Returns a renderable element for the primary and secondary tabs. */ function menu_local_tabs() { - $build = array( + $build = [ '#theme' => 'menu_local_tasks', '#primary' => menu_primary_local_tasks(), '#secondary' => menu_secondary_local_tasks(), - ); - return !empty($build['#primary']) || !empty($build['#secondary']) ? $build : array(); + ]; + return !empty($build['#primary']) || !empty($build['#secondary']) ? $build : []; } /** diff --git a/core/includes/module.inc b/core/includes/module.inc index d80d74b..e3f446c 100644 --- a/core/includes/module.inc +++ b/core/includes/module.inc @@ -27,19 +27,19 @@ function system_list($type) { $lists = $cached->data; } else { - $lists = array( - 'theme' => array(), - 'filepaths' => array(), - ); + $lists = [ + 'theme' => [], + 'filepaths' => [], + ]; // ThemeHandler maintains the 'system.theme.data' state record. - $theme_data = \Drupal::state()->get('system.theme.data', array()); + $theme_data = \Drupal::state()->get('system.theme.data', []); foreach ($theme_data as $name => $theme) { $lists['theme'][$name] = $theme; - $lists['filepaths'][] = array( + $lists['filepaths'][] = [ 'type' => 'theme', 'name' => $name, 'filepath' => $theme->getPathname(), - ); + ]; } \Drupal::cache('bootstrap')->set('system_list', $lists); } @@ -146,7 +146,7 @@ function module_load_include($type, $module, $name = NULL) { function drupal_required_modules() { $listing = new ExtensionDiscovery(\Drupal::root()); $files = $listing->scan('module'); - $required = array(); + $required = []; // Unless called by the installer, an installation profile is required and // must always be loaded. drupal_get_profile() also returns the installation @@ -191,7 +191,7 @@ function module_set_weight($module, $weight) { $current_module_filenames = $module_handler->getModuleList(); $current_modules = array_fill_keys(array_keys($current_module_filenames), 0); $current_modules = module_config_sort(array_merge($current_modules, $extension_config->get('module'))); - $module_filenames = array(); + $module_filenames = []; foreach ($current_modules as $name => $weight) { $module_filenames[$name] = $current_module_filenames[$name]; } @@ -222,7 +222,7 @@ function module_config_sort($data) { // two modules and weights (spaces added for clarity): // - Block with weight -5: 0 0000000000000000005 block // - Node with weight 0: 1 0000000000000000000 node - $sort = array(); + $sort = []; foreach ($data as $name => $weight) { // Prefix negative weights with 0, positive weights with 1. // +/- signs cannot be used, since + (ASCII 43) is before - (ASCII 45). diff --git a/core/includes/pager.inc b/core/includes/pager.inc index 6b6bbb7..62e8278 100644 --- a/core/includes/pager.inc +++ b/core/includes/pager.inc @@ -147,7 +147,7 @@ function pager_default_initialize($total, $limit, $element = 0) { function pager_get_query_parameters() { $query = &drupal_static(__FUNCTION__); if (!isset($query)) { - $query = UrlHelper::filterQueryParameters(\Drupal::request()->query->all(), array('page')); + $query = UrlHelper::filterQueryParameters(\Drupal::request()->query->all(), ['page']); } return $query; } @@ -216,19 +216,19 @@ function template_preprocess_pager(&$variables) { // Create the "first" and "previous" links if we are not on the first page. if ($pager_page_array[$element] > 0) { - $items['first'] = array(); - $options = array( + $items['first'] = []; + $options = [ 'query' => pager_query_add_page($parameters, $element, 0), - ); + ]; $items['first']['href'] = \Drupal::url($route_name, $route_parameters, $options); if (isset($tags[0])) { $items['first']['text'] = $tags[0]; } - $items['previous'] = array(); - $options = array( + $items['previous'] = []; + $options = [ 'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] - 1), - ); + ]; $items['previous']['href'] = \Drupal::url($route_name, $route_parameters, $options); if (isset($tags[1])) { $items['previous']['text'] = $tags[1]; @@ -242,9 +242,9 @@ function template_preprocess_pager(&$variables) { } // Now generate the actual pager piece. for (; $i <= $pager_last && $i <= $pager_max; $i++) { - $options = array( + $options = [ 'query' => pager_query_add_page($parameters, $element, $i - 1), - ); + ]; $items['pages'][$i]['href'] = \Drupal::url($route_name, $route_parameters, $options); if ($i == $pager_current) { $variables['current'] = $i; @@ -258,19 +258,19 @@ function template_preprocess_pager(&$variables) { // Create the "next" and "last" links if we are not on the last page. if ($pager_page_array[$element] < ($pager_max - 1)) { - $items['next'] = array(); - $options = array( + $items['next'] = []; + $options = [ 'query' => pager_query_add_page($parameters, $element, $pager_page_array[$element] + 1), - ); + ]; $items['next']['href'] = \Drupal::url($route_name, $route_parameters, $options); if (isset($tags[3])) { $items['next']['text'] = $tags[3]; } - $items['last'] = array(); - $options = array( + $items['last'] = []; + $options = [ 'query' => pager_query_add_page($parameters, $element, $pager_max - 1), - ); + ]; $items['last']['href'] = \Drupal::url($route_name, $route_parameters, $options); if (isset($tags[4])) { $items['last']['text'] = $tags[4]; diff --git a/core/includes/schema.inc b/core/includes/schema.inc index 4712d3b..8c46e25 100644 --- a/core/includes/schema.inc +++ b/core/includes/schema.inc @@ -28,9 +28,9 @@ function drupal_get_schema_versions($module) { $updates = &drupal_static(__FUNCTION__, NULL); if (!isset($updates[$module])) { - $updates = array(); + $updates = []; foreach (\Drupal::moduleHandler()->getModuleList() as $loaded_module => $filename) { - $updates[$loaded_module] = array(); + $updates[$loaded_module] = []; } // Prepare regular expression to match all possible defined hook_update_N(). @@ -74,15 +74,15 @@ function drupal_get_schema_versions($module) { * module is not installed. */ function drupal_get_installed_schema_version($module, $reset = FALSE, $array = FALSE) { - static $versions = array(); + static $versions = []; if ($reset) { - $versions = array(); + $versions = []; } if (!$versions) { if (!$versions = \Drupal::keyValue('system.schema')->getAll()) { - $versions = array(); + $versions = []; } } @@ -162,12 +162,12 @@ function drupal_get_module_schema($module, $table = NULL) { if (isset($schema[$table])) { return $schema[$table]; } - return array(); + return []; } elseif (!empty($schema)) { return $schema; } - return array(); + return []; } /** diff --git a/core/includes/tablesort.inc b/core/includes/tablesort.inc index 95642b3..d8f1624 100644 --- a/core/includes/tablesort.inc +++ b/core/includes/tablesort.inc @@ -41,7 +41,7 @@ function tablesort_init($header) { function tablesort_header(&$cell_content, array &$cell_attributes, array $header, array $ts) { // Special formatting for the currently sorted column header. if (isset($cell_attributes['field'])) { - $title = t('sort by @s', array('@s' => $cell_content)); + $title = t('sort by @s', ['@s' => $cell_content]); if ($cell_content == $ts['name']) { // aria-sort is a WAI-ARIA property that indicates if items in a table // or grid are sorted in ascending or descending order. See @@ -49,10 +49,10 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header $cell_attributes['aria-sort'] = ($ts['sort'] == 'asc') ? 'ascending' : 'descending'; $ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc'); $cell_attributes['class'][] = 'is-active'; - $tablesort_indicator = array( + $tablesort_indicator = [ '#theme' => 'tablesort_indicator', '#style' => $ts['sort'], - ); + ]; $image = drupal_render($tablesort_indicator); } else { @@ -60,12 +60,12 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header $ts['sort'] = 'asc'; $image = ''; } - $cell_content = \Drupal::l(SafeMarkup::format('@cell_content@image', array('@cell_content' => $cell_content, '@image' => $image)), new Url('', [], [ - 'attributes' => array('title' => $title), - 'query' => array_merge($ts['query'], array( + $cell_content = \Drupal::l(SafeMarkup::format('@cell_content@image', ['@cell_content' => $cell_content, '@image' => $image]), new Url('', [], [ + 'attributes' => ['title' => $title], + 'query' => array_merge($ts['query'], [ 'sort' => $ts['sort'], 'order' => $cell_content, - )), + ]), ])); unset($cell_attributes['field'], $cell_attributes['sort']); @@ -80,7 +80,7 @@ function tablesort_header(&$cell_content, array &$cell_attributes, array $header * page request except for those pertaining to table sorting. */ function tablesort_get_query_parameters() { - return UrlHelper::filterQueryParameters(\Drupal::request()->query->all(), array('sort', 'order')); + return UrlHelper::filterQueryParameters(\Drupal::request()->query->all(), ['sort', 'order']); } /** @@ -112,12 +112,12 @@ function tablesort_get_order($headers) { if (!isset($default)) { $default = reset($headers); if (!is_array($default)) { - $default = array('data' => $default); + $default = ['data' => $default]; } } - $default += array('data' => NULL, 'field' => NULL); - return array('name' => $default['data'], 'sql' => $default['field']); + $default += ['data' => NULL, 'field' => NULL]; + return ['name' => $default['data'], 'sql' => $default['field']]; } /** diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 9b89250..571a914 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -102,13 +102,13 @@ function theme_get_registry($complete = TRUE) { * @see \Drupal\Core\Extension\ThemeHandler::$defaultFeatures */ function _system_default_theme_features() { - return array( + return [ 'favicon', 'logo', 'node_user_picture', 'comment_user_picture', 'comment_user_verification', - ); + ]; } /** @@ -158,11 +158,11 @@ function drupal_find_theme_functions($cache, $prefixes) { foreach ($matches as $match) { $new_hook = substr($match, strlen($prefix) + 1); $arg_name = isset($info['variables']) ? 'variables' : 'render element'; - $implementations[$new_hook] = array( + $implementations[$new_hook] = [ 'function' => $match, $arg_name => $info[$arg_name], 'base hook' => $hook, - ); + ]; } } } @@ -170,9 +170,9 @@ function drupal_find_theme_functions($cache, $prefixes) { // that in what is returned so that the registry knows that the theme has // this implementation. if (function_exists($prefix . '_' . $hook)) { - $implementations[$hook] = array( + $implementations[$hook] = [ 'function' => $prefix . '_' . $hook, - ); + ]; } } } @@ -191,12 +191,12 @@ function drupal_find_theme_functions($cache, $prefixes) { * The path to search. */ function drupal_find_theme_templates($cache, $extension, $path) { - $implementations = array(); + $implementations = []; // Collect paths to all sub-themes grouped by base themes. These will be // used for filtering. This allows base themes to have sub-themes in its // folder hierarchy without affecting the base themes template discovery. - $theme_paths = array(); + $theme_paths = []; foreach (\Drupal::service('theme_handler')->listInfo() as $theme_info) { if (!empty($theme_info->base_theme)) { $theme_paths[$theme_info->base_theme][$theme_info->getName()] = $theme_info->getPath(); @@ -210,12 +210,12 @@ function drupal_find_theme_templates($cache, $extension, $path) { } } $theme = \Drupal::theme()->getActiveTheme()->getName(); - $subtheme_paths = isset($theme_paths[$theme]) ? $theme_paths[$theme] : array(); + $subtheme_paths = isset($theme_paths[$theme]) ? $theme_paths[$theme] : []; // Escape the periods in the extension. $regex = '/' . str_replace('.', '\.', $extension) . '$/'; // Get a listing of all template files in the path to search. - $files = file_scan_directory($path, $regex, array('key' => 'filename')); + $files = file_scan_directory($path, $regex, ['key' => 'filename']); // Find templates that implement registered theme hooks and include that in // what is returned so that the registry knows that the theme has this @@ -231,21 +231,21 @@ function drupal_find_theme_templates($cache, $extension, $path) { // for the purposes of searching. $hook = strtr($template, '-', '_'); if (isset($cache[$hook])) { - $implementations[$hook] = array( + $implementations[$hook] = [ 'template' => $template, 'path' => dirname($file->uri), - ); + ]; } // Match templates based on the 'template' filename. foreach ($cache as $hook => $info) { if (isset($info['template'])) { - $template_candidates = array($info['template'], str_replace($info['theme path'] . '/templates/', '', $info['template'])); + $template_candidates = [$info['template'], str_replace($info['theme path'] . '/templates/', '', $info['template'])]; if (in_array($template, $template_candidates)) { - $implementations[$hook] = array( + $implementations[$hook] = [ 'template' => $template, 'path' => dirname($file->uri), - ); + ]; } } } @@ -272,12 +272,12 @@ function drupal_find_theme_templates($cache, $extension, $path) { // Put the underscores back in for the hook name and register this // pattern. $arg_name = isset($info['variables']) ? 'variables' : 'render element'; - $implementations[strtr($file, '-', '_')] = array( + $implementations[strtr($file, '-', '_')] = [ 'template' => $file, 'path' => dirname($files[$match]->uri), $arg_name => $info[$arg_name], 'base hook' => $hook, - ); + ]; } } } @@ -305,7 +305,7 @@ function drupal_find_theme_templates($cache, $extension, $path) { */ function theme_get_setting($setting_name, $theme = NULL) { /** @var \Drupal\Core\Theme\ThemeSettings[] $cache */ - $cache = &drupal_static(__FUNCTION__, array()); + $cache = &drupal_static(__FUNCTION__, []); // If no key is given, use the current theme if we can determine it. if (!isset($theme)) { @@ -488,7 +488,7 @@ function theme_settings_convert_to_config(array $theme_settings, Config $config) elseif (substr($key, 0, 7) == 'toggle_') { $config->set('features.' . Unicode::substr($key, 7), $value); } - elseif (!in_array($key, array('theme', 'logo_upload'))) { + elseif (!in_array($key, ['theme', 'logo_upload'])) { $config->set($key, $value); } } @@ -545,7 +545,7 @@ function template_preprocess_time(&$variables) { function template_preprocess_datetime_form(&$variables) { $element = $variables['element']; - $variables['attributes'] = array(); + $variables['attributes'] = []; if (isset($element['#id'])) { $variables['attributes']['id'] = $element['#id']; } @@ -658,34 +658,34 @@ function template_preprocess_links(&$variables) { if (!empty($heading)) { // Convert a string heading into an array, using a

tag by default. if (is_string($heading)) { - $heading = array('text' => $heading); + $heading = ['text' => $heading]; } // Merge in default array properties into $heading. - $heading += array( + $heading += [ 'level' => 'h2', - 'attributes' => array(), - ); + 'attributes' => [], + ]; // Convert the attributes array into an Attribute object. $heading['attributes'] = new Attribute($heading['attributes']); } - $variables['links'] = array(); + $variables['links'] = []; foreach ($links as $key => $link) { - $item = array(); - $link += array( + $item = []; + $link += [ 'ajax' => NULL, 'url' => NULL, - ); + ]; - $li_attributes = array(); + $li_attributes = []; $keys = ['title', 'url']; - $link_element = array( + $link_element = [ '#type' => 'link', '#title' => $link['title'], '#options' => array_diff_key($link, array_combine($keys, $keys)), '#url' => $link['url'], '#ajax' => $link['ajax'], - ); + ]; // Handle links and ensure that the active class is added on the LIs, but // only if the 'set_active_class' option is not empty. @@ -773,7 +773,7 @@ function template_preprocess_image(&$variables) { // Generate a srcset attribute conforming to the spec at // http://www.w3.org/html/wg/drafts/html/master/embedded-content.html#attr-img-srcset if (!empty($variables['srcset'])) { - $srcset = array(); + $srcset = []; foreach ($variables['srcset'] as $src) { // URI is mandatory. $source = file_url_transform_relative(file_create_url($src['uri'])); @@ -788,7 +788,7 @@ function template_preprocess_image(&$variables) { $variables['attributes']['srcset'] = implode(', ', $srcset); } - foreach (array('width', 'height', 'alt', 'title', 'sizes') as $key) { + foreach (['width', 'height', 'alt', 'title', 'sizes'] as $key) { if (isset($variables[$key])) { // If the property has already been defined in the attributes, // do not override, including NULL. @@ -902,11 +902,11 @@ function template_preprocess_table(&$variables) { } else { $cols = $colgroup; - $colgroup_attributes = array(); + $colgroup_attributes = []; } - $colgroup = array(); + $colgroup = []; $colgroup['attributes'] = new Attribute($colgroup_attributes); - $colgroup['cols'] = array(); + $colgroup['cols'] = []; // Build columns. if (is_array($cols) && !empty($cols)) { @@ -918,10 +918,10 @@ function template_preprocess_table(&$variables) { } // Build an associative array of responsive classes keyed by column. - $responsive_classes = array(); + $responsive_classes = []; // Format the table header: - $ts = array(); + $ts = []; $header_columns = 0; if (!empty($variables['header'])) { $ts = tablesort_init($variables['header']); @@ -973,7 +973,7 @@ function template_preprocess_table(&$variables) { // tablesort_header() removes the 'sort' and 'field' keys. $cell_attributes = new Attribute($cell); } - $variables['header'][$col_key] = array(); + $variables['header'][$col_key] = []; $variables['header'][$col_key]['tag'] = $is_header ? 'th' : 'td'; $variables['header'][$col_key]['attributes'] = $cell_attributes; $variables['header'][$col_key]['content'] = $cell_content; @@ -982,12 +982,12 @@ function template_preprocess_table(&$variables) { $variables['header_columns'] = $header_columns; // Rows and footer have the same structure. - $sections = array('rows' , 'footer'); + $sections = ['rows' , 'footer']; foreach ($sections as $section) { if (!empty($variables[$section])) { foreach ($variables[$section] as $row_key => $row) { $cells = $row; - $row_attributes = array(); + $row_attributes = []; // Check if we're dealing with a simple or complex row if (isset($row['data'])) { @@ -1001,9 +1001,9 @@ function template_preprocess_table(&$variables) { } // Build row. - $variables[$section][$row_key] = array(); + $variables[$section][$row_key] = []; $variables[$section][$row_key]['attributes'] = new Attribute($row_attributes); - $variables[$section][$row_key]['cells'] = array(); + $variables[$section][$row_key]['cells'] = []; if (!empty($cells)) { // Reset the responsive index. $responsive_index = -1; @@ -1013,7 +1013,7 @@ function template_preprocess_table(&$variables) { if (!is_array($cell)) { $cell_content = $cell; - $cell_attributes = array(); + $cell_attributes = []; $is_header = FALSE; } else { @@ -1073,7 +1073,7 @@ function template_preprocess_table(&$variables) { function template_preprocess_item_list(&$variables) { $variables['wrapper_attributes'] = new Attribute($variables['wrapper_attributes']); foreach ($variables['items'] as &$item) { - $attributes = array(); + $attributes = []; // If the item value is an array, then it is a render array. if (is_array($item)) { // List items support attributes via the '#wrapper_attributes' property. @@ -1112,10 +1112,10 @@ function template_preprocess_item_list(&$variables) { } // Set the item's value and attributes for the template. - $item = array( + $item = [ 'value' => $item, 'attributes' => new Attribute($attributes), - ); + ]; } } @@ -1133,7 +1133,7 @@ function template_preprocess_container(&$variables) { $variables['has_parent'] = FALSE; $element = $variables['element']; // Ensure #attributes is set. - $element += array('#attributes' => array()); + $element += ['#attributes' => []]; // Special handling for form elements. if (isset($element['#array_parents'])) { @@ -1222,16 +1222,16 @@ function template_preprocess(&$variables, $hook, $info) { */ function _template_preprocess_default_variables() { // Variables that don't depend on a database connection. - $variables = array( - 'attributes' => array(), - 'title_attributes' => array(), - 'content_attributes' => array(), - 'title_prefix' => array(), - 'title_suffix' => array(), + $variables = [ + 'attributes' => [], + 'title_attributes' => [], + 'content_attributes' => [], + 'title_prefix' => [], + 'title_suffix' => [], 'db_is_active' => !defined('MAINTENANCE_MODE'), 'is_admin' => FALSE, 'logged_in' => FALSE, - ); + ]; // Give modules a chance to alter the default template variables. \Drupal::moduleHandler()->alter('template_preprocess_default_variables', $variables); @@ -1296,19 +1296,19 @@ function template_preprocess_html(&$variables) { $variables['page']['#title'] = (string) \Drupal::service('renderer')->render($variables['page']['#title']); } if (!empty($variables['page']['#title'])) { - $head_title = array( + $head_title = [ // Marking the title as safe since it has had the tags stripped. 'title' => Markup::create(trim(strip_tags($variables['page']['#title']))), 'name' => $site_config->get('name'), - ); + ]; } // @todo Remove once views is not bypassing the view subscriber anymore. // @see https://www.drupal.org/node/2068471 elseif ($is_front_page) { - $head_title = array( + $head_title = [ 'title' => t('Home'), 'name' => $site_config->get('name'), - ); + ]; } else { $head_title = ['name' => $site_config->get('name')]; @@ -1348,7 +1348,7 @@ function template_preprocess_page(&$variables) { foreach (\Drupal::theme()->getActiveTheme()->getRegions() as $region) { if (!isset($variables['page'][$region])) { - $variables['page'][$region] = array(); + $variables['page'][$region] = []; } } @@ -1408,7 +1408,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') { // page__node__1 // page__node__edit - $suggestions = array(); + $suggestions = []; $prefix = $base; foreach ($args as $arg) { // Remove slashes or null per SA-CORE-2009-003 and change - (hyphen) to _ @@ -1423,7 +1423,7 @@ function theme_get_suggestions($args, $base, $delimiter = '__') { // converted to underscores so here we must convert any hyphens in path // arguments to underscores here before fetching theme hook suggestions // to ensure the templates are appropriately recognized. - $arg = str_replace(array("/", "\\", "\0", '-'), array('', '', '', '_'), $arg); + $arg = str_replace(["/", "\\", "\0", '-'], ['', '', '', '_'], $arg); // The percent acts as a wildcard for numeric arguments since // asterisks are not valid filename characters on many filesystems. if (is_numeric($arg)) { @@ -1556,7 +1556,7 @@ function template_preprocess_field(&$variables, $hook) { // on those keys is faster than calling Element::children() or looping on all // keys within $element, since that requires traversal of all element // properties. - $variables['items'] = array(); + $variables['items'] = []; $delta = 0; while (!empty($element[$delta])) { $variables['items'][$delta]['content'] = $element[$delta]; @@ -1591,31 +1591,31 @@ function template_preprocess_field_multiple_value_form(&$variables) { if ($variables['multiple']) { $table_id = Html::getUniqueId($element['#field_name'] . '_values'); $order_class = $element['#field_name'] . '-delta-order'; - $header_attributes = new Attribute(array('class' => array('label'))); + $header_attributes = new Attribute(['class' => ['label']]); if (!empty($element['#required'])) { $header_attributes['class'][] = 'js-form-required'; $header_attributes['class'][] = 'form-required'; } - $header = array( - array( - 'data' => array( + $header = [ + [ + 'data' => [ '#prefix' => '', - 'title' => array( + 'title' => [ '#markup' => $element['#title'], - ), + ], '#suffix' => '

', - ), + ], 'colspan' => 2, - 'class' => array('field-label'), - ), - t('Order', array(), array('context' => 'Sort order')), - ); - $rows = array(); + 'class' => ['field-label'], + ], + t('Order', [], ['context' => 'Sort order']), + ]; + $rows = []; // Sort items according to '_weight' (needed when the form comes back after // preview or failed validation). - $items = array(); - $variables['button'] = array(); + $items = []; + $variables['button'] = []; foreach (Element::children($element) as $key) { if ($key === 'add_more') { $variables['button'] = &$element[$key]; @@ -1628,40 +1628,40 @@ function template_preprocess_field_multiple_value_form(&$variables) { // Add the items as table rows. foreach ($items as $item) { - $item['_weight']['#attributes']['class'] = array($order_class); + $item['_weight']['#attributes']['class'] = [$order_class]; // Remove weight form element from item render array so it can be rendered // in a separate table column. $delta_element = $item['_weight']; unset($item['_weight']); - $cells = array( - array('data' => '', 'class' => array('field-multiple-drag')), - array('data' => $item), - array('data' => $delta_element, 'class' => array('delta-order')), - ); - $rows[] = array( + $cells = [ + ['data' => '', 'class' => ['field-multiple-drag']], + ['data' => $item], + ['data' => $delta_element, 'class' => ['delta-order']], + ]; + $rows[] = [ 'data' => $cells, - 'class' => array('draggable'), - ); + 'class' => ['draggable'], + ]; } - $variables['table'] = array( + $variables['table'] = [ '#type' => 'table', '#header' => $header, '#rows' => $rows, - '#attributes' => array( + '#attributes' => [ 'id' => $table_id, - 'class' => array('field-multiple-table'), - ), - '#tabledrag' => array( - array( + 'class' => ['field-multiple-table'], + ], + '#tabledrag' => [ + [ 'action' => 'order', 'relationship' => 'sibling', 'group' => $order_class, - ), - ), - ); + ], + ], + ]; if (!empty($element['#description'])) { $description_id = $element['#attributes']['aria-describedby']; @@ -1674,7 +1674,7 @@ function template_preprocess_field_multiple_value_form(&$variables) { } } else { - $variables['elements'] = array(); + $variables['elements'] = []; foreach (Element::children($element) as $key) { $variables['elements'][] = $element[$key]; } @@ -1691,10 +1691,10 @@ function template_preprocess_field_multiple_value_form(&$variables) { * - links: A list of \Drupal\Core\Link objects which should be rendered. */ function template_preprocess_breadcrumb(&$variables) { - $variables['breadcrumb'] = array(); + $variables['breadcrumb'] = []; /** @var \Drupal\Core\Link $link */ foreach ($variables['links'] as $key => $link) { - $variables['breadcrumb'][$key] = array('text' => $link->getText(), 'url' => $link->getUrl()->toString()); + $variables['breadcrumb'][$key] = ['text' => $link->getText(), 'url' => $link->getUrl()->toString()]; } } @@ -1713,39 +1713,39 @@ function _field_multiple_value_form_sort_helper($a, $b) { * Provides theme registration for themes across .inc files. */ function drupal_common_theme() { - return array( + return [ // From theme.inc. - 'html' => array( + 'html' => [ 'render element' => 'html', - ), - 'page' => array( + ], + 'page' => [ 'render element' => 'page', - ), - 'page_title' => array( - 'variables' => array('title' => NULL), - ), - 'region' => array( + ], + 'page_title' => [ + 'variables' => ['title' => NULL], + ], + 'region' => [ 'render element' => 'elements', - ), - 'time' => array( - 'variables' => array('timestamp' => NULL, 'text' => NULL, 'attributes' => array()), - ), - 'datetime_form' => array( + ], + 'time' => [ + 'variables' => ['timestamp' => NULL, 'text' => NULL, 'attributes' => []], + ], + 'datetime_form' => [ 'render element' => 'element', - ), - 'datetime_wrapper' => array( + ], + 'datetime_wrapper' => [ 'render element' => 'element', - ), - 'status_messages' => array( + ], + 'status_messages' => [ 'variables' => ['status_headings' => [], 'message_list' => NULL], - ), - 'links' => array( - 'variables' => array('links' => array(), 'attributes' => array('class' => array('links')), 'heading' => array(), 'set_active_class' => FALSE), - ), - 'dropbutton_wrapper' => array( - 'variables' => array('children' => NULL), - ), - 'image' => array( + ], + 'links' => [ + 'variables' => ['links' => [], 'attributes' => ['class' => ['links']], 'heading' => [], 'set_active_class' => FALSE], + ], + 'dropbutton_wrapper' => [ + 'variables' => ['children' => NULL], + ], + 'image' => [ // HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft // allows the alt attribute to be omitted in some cases. Therefore, // default the alt attribute to an empty string, but allow code providing @@ -1759,107 +1759,107 @@ function drupal_common_theme() { // - http://dev.w3.org/html5/spec/Overview.html#alt // The title attribute is optional in all cases, so it is omitted by // default. - 'variables' => array('uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array(), 'sizes' => NULL, 'srcset' => array(), 'style_name' => NULL), - ), - 'breadcrumb' => array( - 'variables' => array('links' => array()), - ), - 'table' => array( - 'variables' => array('header' => NULL, 'rows' => NULL, 'footer' => NULL, 'attributes' => array(), 'caption' => NULL, 'colgroups' => array(), 'sticky' => FALSE, 'responsive' => TRUE, 'empty' => ''), - ), - 'tablesort_indicator' => array( - 'variables' => array('style' => NULL), - ), - 'mark' => array( - 'variables' => array('status' => MARK_NEW), - ), - 'item_list' => array( - 'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'wrapper_attributes' => array(), 'attributes' => array(), 'empty' => NULL, 'context' => array()), - ), - 'feed_icon' => array( - 'variables' => array('url' => NULL, 'title' => NULL), - ), - 'progress_bar' => array( - 'variables' => array('label' => NULL, 'percent' => NULL, 'message' => NULL), - ), - 'indentation' => array( - 'variables' => array('size' => 1), - ), + 'variables' => ['uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => [], 'sizes' => NULL, 'srcset' => [], 'style_name' => NULL], + ], + 'breadcrumb' => [ + 'variables' => ['links' => []], + ], + 'table' => [ + 'variables' => ['header' => NULL, 'rows' => NULL, 'footer' => NULL, 'attributes' => [], 'caption' => NULL, 'colgroups' => [], 'sticky' => FALSE, 'responsive' => TRUE, 'empty' => ''], + ], + 'tablesort_indicator' => [ + 'variables' => ['style' => NULL], + ], + 'mark' => [ + 'variables' => ['status' => MARK_NEW], + ], + 'item_list' => [ + 'variables' => ['items' => [], 'title' => '', 'list_type' => 'ul', 'wrapper_attributes' => [], 'attributes' => [], 'empty' => NULL, 'context' => []], + ], + 'feed_icon' => [ + 'variables' => ['url' => NULL, 'title' => NULL], + ], + 'progress_bar' => [ + 'variables' => ['label' => NULL, 'percent' => NULL, 'message' => NULL], + ], + 'indentation' => [ + 'variables' => ['size' => 1], + ], // From theme.maintenance.inc. - 'maintenance_page' => array( + 'maintenance_page' => [ 'render element' => 'page', - ), - 'install_page' => array( + ], + 'install_page' => [ 'render element' => 'page', - ), - 'maintenance_task_list' => array( - 'variables' => array('items' => NULL, 'active' => NULL, 'variant' => NULL), - ), - 'authorize_report' => array( + ], + 'maintenance_task_list' => [ + 'variables' => ['items' => NULL, 'active' => NULL, 'variant' => NULL], + ], + 'authorize_report' => [ 'variables' => ['messages' => [], 'attributes' => []], 'includes' => ['core/includes/theme.maintenance.inc'], 'template' => 'authorize-report', - ), + ], // From pager.inc. - 'pager' => array( + 'pager' => [ 'render element' => 'pager', - ), + ], // From menu.inc. - 'menu' => array( - 'variables' => array('menu_name' => NULL, 'items' => array(), 'attributes' => array()), - ), - 'menu_local_task' => array( + 'menu' => [ + 'variables' => ['menu_name' => NULL, 'items' => [], 'attributes' => []], + ], + 'menu_local_task' => [ 'render element' => 'element', - ), - 'menu_local_action' => array( + ], + 'menu_local_action' => [ 'render element' => 'element', - ), - 'menu_local_tasks' => array( - 'variables' => array('primary' => array(), 'secondary' => array()), - ), + ], + 'menu_local_tasks' => [ + 'variables' => ['primary' => [], 'secondary' => []], + ], // From form.inc. - 'input' => array( + 'input' => [ 'render element' => 'element', - ), - 'select' => array( + ], + 'select' => [ 'render element' => 'element', - ), - 'fieldset' => array( + ], + 'fieldset' => [ 'render element' => 'element', - ), - 'details' => array( + ], + 'details' => [ 'render element' => 'element', - ), - 'radios' => array( + ], + 'radios' => [ 'render element' => 'element', - ), - 'checkboxes' => array( + ], + 'checkboxes' => [ 'render element' => 'element', - ), - 'form' => array( + ], + 'form' => [ 'render element' => 'element', - ), - 'textarea' => array( + ], + 'textarea' => [ 'render element' => 'element', - ), - 'form_element' => array( + ], + 'form_element' => [ 'render element' => 'element', - ), - 'form_element_label' => array( + ], + 'form_element_label' => [ 'render element' => 'element', - ), - 'vertical_tabs' => array( + ], + 'vertical_tabs' => [ 'render element' => 'element', - ), - 'container' => array( + ], + 'container' => [ 'render element' => 'element', - ), + ], // From field system. - 'field' => array( + 'field' => [ 'render element' => 'element', - ), - 'field_multiple_value_form' => array( + ], + 'field_multiple_value_form' => [ 'render element' => 'element', - ), - ); + ], + ]; } diff --git a/core/includes/unicode.inc b/core/includes/unicode.inc index f0df33e..c40a293 100644 --- a/core/includes/unicode.inc +++ b/core/includes/unicode.inc @@ -11,24 +11,24 @@ * Returns Unicode library status and errors. */ function unicode_requirements() { - $libraries = array( + $libraries = [ Unicode::STATUS_SINGLEBYTE => t('Standard PHP'), Unicode::STATUS_MULTIBYTE => t('PHP Mbstring Extension'), Unicode::STATUS_ERROR => t('Error'), - ); - $severities = array( + ]; + $severities = [ Unicode::STATUS_SINGLEBYTE => REQUIREMENT_WARNING, Unicode::STATUS_MULTIBYTE => NULL, Unicode::STATUS_ERROR => REQUIREMENT_ERROR, - ); + ]; $failed_check = Unicode::check(); $library = Unicode::getStatus(); - $requirements['unicode'] = array( + $requirements['unicode'] = [ 'title' => t('Unicode library'), 'value' => $libraries[$library], 'severity' => $severities[$library], - ); + ]; switch ($failed_check) { case 'mb_strlen': $requirements['unicode']['description'] = t('Operations on Unicode strings are emulated on a best-effort basis. Install the PHP mbstring extension for improved Unicode support.'); @@ -92,7 +92,7 @@ function drupal_xml_parser_create(&$data) { } // Unsupported encodings are converted here into UTF-8. - $php_supported = array('utf-8', 'iso-8859-1', 'us-ascii'); + $php_supported = ['utf-8', 'iso-8859-1', 'us-ascii']; if (!in_array(strtolower($encoding), $php_supported)) { $out = Unicode::convertToUtf8($data, $encoding); if ($out !== FALSE) { @@ -100,7 +100,7 @@ function drupal_xml_parser_create(&$data) { $data = preg_replace('/^(<\?xml[^>]+encoding)="(.+?)"/', '\\1="utf-8"', $out); } else { - \Drupal::logger('php')->warning('Could not convert XML encoding %s to UTF-8.', array('%s' => $encoding)); + \Drupal::logger('php')->warning('Could not convert XML encoding %s to UTF-8.', ['%s' => $encoding]); return FALSE; } } diff --git a/core/includes/update.inc b/core/includes/update.inc index 2c020db..730dcf8 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -17,7 +17,7 @@ function update_fix_compatibility() { $extension_config = \Drupal::configFactory()->getEditable('core.extension'); $save = FALSE; - foreach (array('module', 'theme') as $type) { + foreach (['module', 'theme'] as $type) { foreach ($extension_config->get($type) as $name => $weight) { if (update_check_incompatibility($name, $type)) { $extension_config->clear("$type.$name"); @@ -68,23 +68,23 @@ function update_check_incompatibility($name, $type = 'module') { * A requirements info array. */ function update_system_schema_requirements() { - $requirements = array(); + $requirements = []; $system_schema = drupal_get_installed_schema_version('system'); $requirements['minimum schema']['title'] = 'Minimum schema version'; if ($system_schema >= \Drupal::CORE_MINIMUM_SCHEMA_VERSION) { - $requirements['minimum schema'] += array( + $requirements['minimum schema'] += [ 'value' => 'The installed schema version meets the minimum.', 'description' => 'Schema version: ' . $system_schema, - ); + ]; } else { - $requirements['minimum schema'] += array( + $requirements['minimum schema'] += [ 'value' => 'The installed schema version does not meet the minimum.', 'severity' => REQUIREMENT_ERROR, 'description' => 'Your system schema version is ' . $system_schema . '. Updating directly from a schema version prior to 8000 is not supported. You must migrate your site to Drupal 8 first.', - ); + ]; } return $requirements; @@ -95,7 +95,7 @@ function update_system_schema_requirements() { */ function update_check_requirements() { // Check requirements of all loaded modules. - $requirements = \Drupal::moduleHandler()->invokeAll('requirements', array('update')); + $requirements = \Drupal::moduleHandler()->invokeAll('requirements', ['update']); $requirements += update_system_schema_requirements(); return $requirements; } @@ -168,11 +168,11 @@ function update_do_one($module, $number, $dependency_map, &$context) { // If this update was aborted in a previous step, or has a dependency that // was aborted in a previous step, go no further. - if (!empty($context['results']['#abort']) && array_intersect($context['results']['#abort'], array_merge($dependency_map, array($function)))) { + if (!empty($context['results']['#abort']) && array_intersect($context['results']['#abort'], array_merge($dependency_map, [$function]))) { return; } - $ret = array(); + $ret = []; if (function_exists($function)) { try { $ret['results']['query'] = $function($context['sandbox']); @@ -187,7 +187,7 @@ function update_do_one($module, $number, $dependency_map, &$context) { $variables = Error::decodeException($e); unset($variables['backtrace']); - $ret['#abort'] = array('success' => FALSE, 'query' => t('%type: @message in %function (line %line of %file).', $variables)); + $ret['#abort'] = ['success' => FALSE, 'query' => t('%type: @message in %function (line %line of %file).', $variables)]; } } @@ -197,10 +197,10 @@ function update_do_one($module, $number, $dependency_map, &$context) { } if (!isset($context['results'][$module])) { - $context['results'][$module] = array(); + $context['results'][$module] = []; } if (!isset($context['results'][$module][$number])) { - $context['results'][$module][$number] = array(); + $context['results'][$module][$number] = []; } $context['results'][$module][$number] = array_merge($context['results'][$module][$number], $ret); @@ -266,7 +266,7 @@ function update_invoke_post_update($function, &$context) { unset($context['sandbox']['#finished']); } if (!isset($context['results'][$module][$name])) { - $context['results'][$module][$name] = array(); + $context['results'][$module][$name] = []; } $context['results'][$module][$name] = array_merge($context['results'][$module][$name], $ret); @@ -298,7 +298,7 @@ function update_invoke_post_update($function, &$context) { */ function update_get_update_list() { // Make sure that the system module is first in the list of updates. - $ret = array('system' => array()); + $ret = ['system' => []]; $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE); foreach ($modules as $module => $schema_version) { @@ -332,7 +332,7 @@ function update_get_update_list() { if ($update > $schema_version) { // The description for an update comes from its Doxygen. $func = new ReflectionFunction($module . '_update_' . $update); - $description = str_replace(array("\n", '*', '/'), '', $func->getDocComment()); + $description = str_replace(["\n", '*', '/'], '', $func->getDocComment()); $ret[$module]['pending'][$update] = "$update - $description"; if (!isset($ret[$module]['start'])) { $ret[$module]['start'] = $update; @@ -400,7 +400,7 @@ function update_resolve_dependencies($starting_updates) { // Perform the depth-first search and sort on the results. $graph_object = new Graph($graph); $graph = $graph_object->searchAndSort(); - uasort($graph, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); + uasort($graph, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']); foreach ($graph as $function => &$data) { $module = $data['module']; @@ -416,7 +416,7 @@ function update_resolve_dependencies($starting_updates) { } elseif (!isset($data['allowed'])) { $data['allowed'] = TRUE; - $data['missing_dependencies'] = array(); + $data['missing_dependencies'] = []; } // Now that we have finished processing this function, remove it from the // graph if it was not part of the original list. This ensures that we @@ -448,9 +448,9 @@ function update_resolve_dependencies($starting_updates) { function update_get_update_function_list($starting_updates) { // Go through each module and find all updates that we need (including the // first update that was requested and any updates that run after it). - $update_functions = array(); + $update_functions = []; foreach ($starting_updates as $module => $version) { - $update_functions[$module] = array(); + $update_functions[$module] = []; $updates = drupal_get_schema_versions($module); if ($updates !== FALSE) { $max_version = max($updates); @@ -512,7 +512,7 @@ function update_get_update_function_list($starting_updates) { function update_build_dependency_graph($update_functions) { // Initialize an array that will define a directed graph representing the // dependencies between update functions. - $graph = array(); + $graph = []; // Go through each update function and build an initial list of dependencies. foreach ($update_functions as $module => $functions) { @@ -600,7 +600,7 @@ function update_already_performed($module, $number) { * @see hook_update_dependencies() */ function update_retrieve_dependencies() { - $return = array(); + $return = []; // Get a list of installed modules, arranged so that we invoke their hooks in // the same order that \Drupal::moduleHandler()->invokeAll() does. foreach (\Drupal::keyValue('system.schema')->getAll() as $module => $schema) { @@ -675,7 +675,7 @@ function update_replace_permissions($replace) { foreach ($role_names as $role_name) { $rid = substr($role_name, $cut); $config = \Drupal::config("user.role.$rid"); - $permissions = $config->get('permissions') ?: array(); + $permissions = $config->get('permissions') ?: []; foreach ($replace as $old_permission => $new_permissions) { if (($index = array_search($old_permission, $permissions)) !== FALSE) { unset($permissions[$index]); @@ -707,7 +707,7 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) { // Initialize master language list. if (!isset($languages)) { // Initialize local language list cache. - $languages = array(); + $languages = []; // Fill in master language list based on current configuration. $default = \Drupal::languageManager()->getDefaultLanguage(); @@ -721,20 +721,20 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) { foreach ($language_entities as $langcode_config_name) { $langcode = substr($langcode_config_name, strlen('language.entity.')); $info = \Drupal::config($langcode_config_name)->get(); - $languages[$langcode] = new Language(array( + $languages[$langcode] = new Language([ 'default' => ($info['id'] == $default->getId()), 'name' => $info['label'], 'id' => $info['id'], 'direction' => $info['direction'], 'locked' => $info['locked'], 'weight' => $info['weight'], - )); + ]); } Language::sort($languages); } else { // No language module, so use the default language only. - $languages = array($default->getId() => $default); + $languages = [$default->getId() => $default]; // Add the special languages, they will be filtered later if needed. $languages += \Drupal::languageManager()->getDefaultLockedLanguages($default->getWeight()); } @@ -743,13 +743,13 @@ function update_language_list($flags = LanguageInterface::STATE_CONFIGURABLE) { // Filter the full list of languages based on the value of the $all flag. By // default we remove the locked languages, but the caller may request for // those languages to be added as well. - $filtered_languages = array(); + $filtered_languages = []; // Add the site's default language if flagged as allowed value. if ($flags & LanguageInterface::STATE_SITE_DEFAULT) { $default = \Drupal::languageManager()->getDefaultLanguage(); // Rename the default language. - $default->setName(t("Site's default language (@lang_name)", array('@lang_name' => $default->getName()))); + $default->setName(t("Site's default language (@lang_name)", ['@lang_name' => $default->getName()])); $filtered_languages[LanguageInterface::LANGCODE_SITE_DEFAULT] = $default; } diff --git a/core/lib/Drupal.php b/core/lib/Drupal.php index f62e914..0fe562e 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -539,7 +539,7 @@ public static function urlGenerator() { * Instead create a \Drupal\Core\Url object directly, for example using * Url::fromRoute(). */ - public static function url($route_name, $route_parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE) { + public static function url($route_name, $route_parameters = [], $options = [], $collect_bubbleable_metadata = FALSE) { return static::getContainer()->get('url_generator')->generateFromRoute($route_name, $route_parameters, $options, $collect_bubbleable_metadata); } diff --git a/core/lib/Drupal/Component/Annotation/Plugin.php b/core/lib/Drupal/Component/Annotation/Plugin.php index 29f3675..790440d 100644 --- a/core/lib/Drupal/Component/Annotation/Plugin.php +++ b/core/lib/Drupal/Component/Annotation/Plugin.php @@ -52,7 +52,7 @@ public function __construct($values) { * The parsed annotation as a definition. */ protected function parse(array $values) { - $definitions = array(); + $definitions = []; foreach ($values as $key => $value) { if ($value instanceof AnnotationInterface) { $definitions[$key] = $value->get(); diff --git a/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php index e564fd0..c49d9dc 100644 --- a/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php +++ b/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php @@ -68,7 +68,7 @@ class AnnotatedClassDiscovery implements DiscoveryInterface { * @param string[] $annotation_namespaces * (optional) Additional namespaces to be scanned for annotation classes. */ - function __construct($plugin_namespaces = array(), $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin', array $annotation_namespaces = []) { + function __construct($plugin_namespaces = [], $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin', array $annotation_namespaces = []) { $this->pluginNamespaces = $plugin_namespaces; $this->pluginDefinitionAnnotationName = $plugin_definition_annotation_name; $this->annotationNamespaces = $annotation_namespaces; @@ -104,7 +104,7 @@ protected function getAnnotationReader() { * {@inheritdoc} */ public function getDefinitions() { - $definitions = array(); + $definitions = []; $reader = $this->getAnnotationReader(); diff --git a/core/lib/Drupal/Component/Annotation/PluginID.php b/core/lib/Drupal/Component/Annotation/PluginID.php index 6120d19..462ebd4 100644 --- a/core/lib/Drupal/Component/Annotation/PluginID.php +++ b/core/lib/Drupal/Component/Annotation/PluginID.php @@ -22,11 +22,11 @@ class PluginID extends AnnotationBase { * {@inheritdoc} */ public function get() { - return array( + return [ 'id' => $this->value, 'class' => $this->class, 'provider' => $this->provider, - ); + ]; } /** diff --git a/core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php b/core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php index 3d8f77b..f914b69 100644 --- a/core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php +++ b/core/lib/Drupal/Component/Bridge/ZfExtensionManagerSfContainer.php @@ -25,7 +25,7 @@ class ZfExtensionManagerSfContainer implements ReaderManagerInterface, WriterMan * * @see \Drupal\Component\Bridge\ZfExtensionManagerSfContainer::canonicalizeName(). */ - protected $canonicalNamesReplacements = array('-' => '', '_' => '', ' ' => '', '\\' => '', '/' => ''); + protected $canonicalNamesReplacements = ['-' => '', '_' => '', ' ' => '', '\\' => '', '/' => '']; /** * The prefix to be used when retrieving plugins from the container. diff --git a/core/lib/Drupal/Component/Datetime/DateTimePlus.php b/core/lib/Drupal/Component/Datetime/DateTimePlus.php index 56bd92f..776bfbe 100644 --- a/core/lib/Drupal/Component/Datetime/DateTimePlus.php +++ b/core/lib/Drupal/Component/Datetime/DateTimePlus.php @@ -41,14 +41,14 @@ class DateTimePlus { /** * An array of possible date parts. */ - protected static $dateParts = array( + protected static $dateParts = [ 'year', 'month', 'day', 'hour', 'minute', 'second', - ); + ]; /** * The value of the time value passed to the constructor. @@ -88,7 +88,7 @@ class DateTimePlus { /** * An array of errors encountered when creating this date. */ - protected $errors = array(); + protected $errors = []; /** * The DateTime object. @@ -108,7 +108,7 @@ class DateTimePlus { * @return static * A new DateTimePlus object. */ - public static function createFromDateTime(\DateTime $datetime, $settings = array()) { + public static function createFromDateTime(\DateTime $datetime, $settings = []) { return new static($datetime->format(static::FORMAT), $datetime->getTimezone(), $settings); } @@ -133,7 +133,7 @@ public static function createFromDateTime(\DateTime $datetime, $settings = array * @throws \Exception * If the array date values or value combination is not correct. */ - public static function createFromArray(array $date_parts, $timezone = NULL, $settings = array()) { + public static function createFromArray(array $date_parts, $timezone = NULL, $settings = []) { $date_parts = static::prepareArray($date_parts, TRUE); if (static::checkArray($date_parts)) { // Even with validation, we can end up with a value that the @@ -167,7 +167,7 @@ public static function createFromArray(array $date_parts, $timezone = NULL, $set * @throws \Exception * If the timestamp is not numeric. */ - public static function createFromTimestamp($timestamp, $timezone = NULL, $settings = array()) { + public static function createFromTimestamp($timestamp, $timezone = NULL, $settings = []) { if (!is_numeric($timestamp)) { throw new \Exception('The timestamp must be numeric.'); } @@ -206,7 +206,7 @@ public static function createFromTimestamp($timestamp, $timezone = NULL, $settin * If the a date cannot be created from the given format, or if the * created date does not match the input value. */ - public static function createFromFormat($format, $time, $timezone = NULL, $settings = array()) { + public static function createFromFormat($format, $time, $timezone = NULL, $settings = []) { if (!isset($settings['validate_format'])) { $settings['validate_format'] = TRUE; } @@ -257,7 +257,7 @@ public static function createFromFormat($format, $time, $timezone = NULL, $setti * - debug: (optional) Boolean choice to leave debug values in the * date object for debugging purposes. Defaults to FALSE. */ - public function __construct($time = 'now', $timezone = NULL, $settings = array()) { + public function __construct($time = 'now', $timezone = NULL, $settings = []) { // Unpack settings. $this->langcode = !empty($settings['langcode']) ? $settings['langcode'] : NULL; @@ -309,7 +309,7 @@ public function __call($method, $args) { if (!method_exists($this->dateTimeObject, $method)) { throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_class($this), $method)); } - return call_user_func_array(array($this->dateTimeObject, $method), $args); + return call_user_func_array([$this->dateTimeObject, $method], $args); } /** @@ -345,7 +345,7 @@ public static function __callStatic($method, $args) { if (!method_exists('\DateTime', $method)) { throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', get_called_class(), $method)); } - return call_user_func_array(array('\DateTime', $method), $args); + return call_user_func_array(['\DateTime', $method], $args); } /** @@ -528,24 +528,24 @@ public static function arrayToISO($array, $force_valid_date = FALSE) { public static function prepareArray($array, $force_valid_date = FALSE) { if ($force_valid_date) { $now = new \DateTime(); - $array += array( + $array += [ 'year' => $now->format('Y'), 'month' => 1, 'day' => 1, 'hour' => 0, 'minute' => 0, 'second' => 0, - ); + ]; } else { - $array += array( + $array += [ 'year' => '', 'month' => '', 'day' => '', 'hour' => '', 'minute' => '', 'second' => '', - ); + ]; } return $array; } @@ -576,7 +576,7 @@ public static function checkArray($array) { } // Testing for valid time is reversed. Missing time is OK, // but incorrect values are not. - foreach (array('hour', 'minute', 'second') as $key) { + foreach (['hour', 'minute', 'second'] as $key) { if (array_key_exists($key, $array)) { $value = $array[$key]; switch ($key) { @@ -627,7 +627,7 @@ public static function datePad($value, $size = 2) { * @return string * The formatted value of the date. */ - public function format($format, $settings = array()) { + public function format($format, $settings = []) { // If there were construction errors, we can't format the date. if ($this->hasErrors()) { diff --git a/core/lib/Drupal/Component/DependencyInjection/Container.php b/core/lib/Drupal/Component/DependencyInjection/Container.php index 452a2c8..6737369 100644 --- a/core/lib/Drupal/Component/DependencyInjection/Container.php +++ b/core/lib/Drupal/Component/DependencyInjection/Container.php @@ -57,42 +57,42 @@ class Container implements IntrospectableContainerInterface, ResettableContainer * * @var array */ - protected $parameters = array(); + protected $parameters = []; /** * The aliases of the container. * * @var array */ - protected $aliases = array(); + protected $aliases = []; /** * The service definitions of the container. * * @var array */ - protected $serviceDefinitions = array(); + protected $serviceDefinitions = []; /** * The instantiated services. * * @var array */ - protected $services = array(); + protected $services = []; /** * The instantiated private services. * * @var array */ - protected $privateServices = array(); + protected $privateServices = []; /** * The currently loading services. * * @var array */ - protected $loading = array(); + protected $loading = []; /** * Whether the container parameters can still be changed. @@ -116,14 +116,14 @@ class Container implements IntrospectableContainerInterface, ResettableContainer * - machine_format: Whether this container definition uses the optimized * machine-readable container format. */ - public function __construct(array $container_definition = array()) { + public function __construct(array $container_definition = []) { if (!empty($container_definition) && (!isset($container_definition['machine_format']) || $container_definition['machine_format'] !== TRUE)) { throw new InvalidArgumentException('The non-optimized format is not supported by this class. Use an optimized machine-readable format instead, e.g. as produced by \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper.'); } - $this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : array(); - $this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : array(); - $this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : array(); + $this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : []; + $this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : []; + $this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : []; $this->frozen = isset($container_definition['frozen']) ? $container_definition['frozen'] : FALSE; // Register the service_container with itself. @@ -228,7 +228,7 @@ protected function createService(array $definition, $id) { throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The service container does not know how to construct this service. The service will need to be set before it is first used.', $id)); } - $arguments = array(); + $arguments = []; if (isset($definition['arguments'])) { $arguments = $definition['arguments']; @@ -238,14 +238,14 @@ protected function createService(array $definition, $id) { } if (isset($definition['file'])) { - $file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters(array($definition['file']))); + $file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters([$definition['file']])); require_once $file; } if (isset($definition['factory'])) { $factory = $definition['factory']; if (is_array($factory)) { - $factory = $this->resolveServicesAndParameters(array($factory[0], $factory[1])); + $factory = $this->resolveServicesAndParameters([$factory[0], $factory[1]]); } elseif (!is_string($factory)) { throw new RuntimeException(sprintf('Cannot create service "%s" because of invalid factory', $id)); @@ -254,7 +254,7 @@ protected function createService(array $definition, $id) { $service = call_user_func_array($factory, $arguments); } else { - $class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters(array($definition['class']))); + $class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters([$definition['class']])); $length = isset($definition['arguments_count']) ? $definition['arguments_count'] : count($arguments); // Optimize class instantiation for services with up to 10 parameters as @@ -322,14 +322,14 @@ protected function createService(array $definition, $id) { if (isset($definition['calls'])) { foreach ($definition['calls'] as $call) { $method = $call[0]; - $arguments = array(); + $arguments = []; if (!empty($call[1])) { $arguments = $call[1]; if ($arguments instanceof \stdClass) { $arguments = $this->resolveServicesAndParameters($arguments); } } - call_user_func_array(array($service, $method), $arguments); + call_user_func_array([$service, $method], $arguments); } } @@ -362,7 +362,7 @@ protected function createService(array $definition, $id) { * {@inheritdoc} */ public function set($id, $service, $scope = ContainerInterface::SCOPE_CONTAINER) { - if (!in_array($scope, array('container', 'request')) || ('request' === $scope && 'request' !== $id)) { + if (!in_array($scope, ['container', 'request']) || ('request' === $scope && 'request' !== $id)) { @trigger_error('The concept of container scopes is deprecated since version 2.8 and will be removed in 3.0. Omit the third parameter.', E_USER_DEPRECATED); } @@ -549,7 +549,7 @@ protected function resolveServicesAndParameters($arguments) { * An array of strings with suitable alternatives. */ protected function getAlternatives($search_key, array $keys) { - $alternatives = array(); + $alternatives = []; foreach ($keys as $key) { $lev = levenshtein($search_key, $key); if ($lev <= strlen($search_key) / 3 || strpos($key, $search_key) !== FALSE) { diff --git a/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php b/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php index 984ec50..577fa25 100644 --- a/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php +++ b/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php @@ -48,7 +48,7 @@ class OptimizedPhpArrayDumper extends Dumper { /** * {@inheritdoc} */ - public function dump(array $options = array()) { + public function dump(array $options = []) { return serialize($this->getArray()); } @@ -59,7 +59,7 @@ public function dump(array $options = array()) { * A PHP array representation of the service container. */ public function getArray() { - $definition = array(); + $definition = []; $this->aliases = $this->getAliases(); $definition['aliases'] = $this->getAliases(); $definition['parameters'] = $this->getParameters(); @@ -76,7 +76,7 @@ public function getArray() { * The aliases. */ protected function getAliases() { - $alias_definitions = array(); + $alias_definitions = []; $aliases = $this->container->getAliases(); foreach ($aliases as $alias => $id) { @@ -98,7 +98,7 @@ protected function getAliases() { */ protected function getParameters() { if (!$this->container->getParameterBag()->all()) { - return array(); + return []; } $parameters = $this->container->getParameterBag()->all(); @@ -114,10 +114,10 @@ protected function getParameters() { */ protected function getServiceDefinitions() { if (!$this->container->getDefinitions()) { - return array(); + return []; } - $services = array(); + $services = []; foreach ($this->container->getDefinitions() as $id => $definition) { // Only store public service definitions, references to shared private // services are handled in ::getReferenceCall(). @@ -142,7 +142,7 @@ protected function getServiceDefinitions() { * An array of prepared parameters. */ protected function prepareParameters(array $parameters, $escape = TRUE) { - $filtered = array(); + $filtered = []; foreach ($parameters as $key => $value) { if (is_array($value)) { $value = $this->prepareParameters($value, $escape); @@ -167,7 +167,7 @@ protected function prepareParameters(array $parameters, $escape = TRUE) { * The escaped parameters. */ protected function escape(array $parameters) { - $args = array(); + $args = []; foreach ($parameters as $key => $value) { if (is_array($value)) { @@ -198,7 +198,7 @@ protected function escape(array $parameters) { * scope different from SCOPE_CONTAINER and SCOPE_PROTOTYPE. */ protected function getServiceDefinition(Definition $definition) { - $service = array(); + $service = []; if ($definition->getClass()) { $service['class'] = $definition->getClass(); } @@ -278,11 +278,11 @@ protected function getServiceDefinition(Definition $definition) { * The PHP array representation of the method calls. */ protected function dumpMethodCalls(array $calls) { - $code = array(); + $code = []; foreach ($calls as $key => $call) { $method = $call[0]; - $arguments = array(); + $arguments = []; if (!empty($call[1])) { $arguments = $this->dumpCollection($call[1]); } @@ -308,7 +308,7 @@ protected function dumpMethodCalls(array $calls) { * The collection in a suitable format. */ protected function dumpCollection($collection, &$resolve = FALSE) { - $code = array(); + $code = []; foreach ($collection as $key => $value) { if (is_array($value)) { @@ -331,11 +331,11 @@ protected function dumpCollection($collection, &$resolve = FALSE) { return $collection; } - return (object) array( + return (object) [ 'type' => 'collection', 'value' => $code, 'resolve' => $resolve, - ); + ]; } /** @@ -350,7 +350,7 @@ protected function dumpCollection($collection, &$resolve = FALSE) { protected function dumpCallable($callable) { if (is_array($callable)) { $callable[0] = $this->dumpValue($callable[0]); - $callable = array($callable[0], $callable[1]); + $callable = [$callable[0], $callable[1]]; } return $callable; @@ -376,12 +376,12 @@ protected function getPrivateServiceCall($id, Definition $definition, $shared = $hash = hash('sha1', serialize($service_definition)); $id = 'private__' . $hash; } - return (object) array( + return (object) [ 'type' => 'private_service', 'id' => $id, 'value' => $service_definition, 'shared' => $shared, - ); + ]; } /** @@ -398,7 +398,7 @@ protected function getPrivateServiceCall($id, Definition $definition, $shared = */ protected function dumpValue($value) { if (is_array($value)) { - $code = array(); + $code = []; foreach ($value as $k => $v) { $code[$k] = $this->dumpValue($v); } @@ -481,11 +481,11 @@ protected function getReferenceCall($id, Reference $reference = NULL) { * A suitable representation of the service reference. */ protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { - return (object) array( + return (object) [ 'type' => 'service', 'id' => $id, 'invalidBehavior' => $invalid_behavior, - ); + ]; } /** @@ -498,10 +498,10 @@ protected function getServiceCall($id, $invalid_behavior = ContainerInterface::E * A suitable representation of the parameter reference. */ protected function getParameterCall($name) { - return (object) array( + return (object) [ 'type' => 'parameter', 'name' => $name, - ); + ]; } /** diff --git a/core/lib/Drupal/Component/DependencyInjection/Dumper/PhpArrayDumper.php b/core/lib/Drupal/Component/DependencyInjection/Dumper/PhpArrayDumper.php index 7be318f..a6fa2b9 100644 --- a/core/lib/Drupal/Component/DependencyInjection/Dumper/PhpArrayDumper.php +++ b/core/lib/Drupal/Component/DependencyInjection/Dumper/PhpArrayDumper.php @@ -30,7 +30,7 @@ public function getArray() { * {@inheritdoc} */ protected function dumpCollection($collection, &$resolve = FALSE) { - $code = array(); + $code = []; foreach ($collection as $key => $value) { if (is_array($value)) { diff --git a/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php b/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php index 3ec2086..83d558c 100644 --- a/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php +++ b/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php @@ -27,16 +27,16 @@ class PhpArrayContainer extends Container { /** * {@inheritdoc} */ - public function __construct(array $container_definition = array()) { + public function __construct(array $container_definition = []) { if (isset($container_definition['machine_format']) && $container_definition['machine_format'] === TRUE) { throw new InvalidArgumentException('The machine-optimized format is not supported by this class. Use a human-readable format instead, e.g. as produced by \Drupal\Component\DependencyInjection\Dumper\PhpArrayDumper.'); } // Do not call the parent's constructor as it would bail on the // machine-optimized format. - $this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : array(); - $this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : array(); - $this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : array(); + $this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : []; + $this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : []; + $this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : []; $this->frozen = isset($container_definition['frozen']) ? $container_definition['frozen'] : FALSE; // Register the service_container with itself. @@ -57,20 +57,20 @@ protected function createService(array $definition, $id) { throw new RuntimeException(sprintf('You have requested a synthetic service ("%s"). The service container does not know how to construct this service. The service will need to be set before it is first used.', $id)); } - $arguments = array(); + $arguments = []; if (isset($definition['arguments'])) { $arguments = $this->resolveServicesAndParameters($definition['arguments']); } if (isset($definition['file'])) { - $file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters(array($definition['file']))); + $file = $this->frozen ? $definition['file'] : current($this->resolveServicesAndParameters([$definition['file']])); require_once $file; } if (isset($definition['factory'])) { $factory = $definition['factory']; if (is_array($factory)) { - $factory = $this->resolveServicesAndParameters(array($factory[0], $factory[1])); + $factory = $this->resolveServicesAndParameters([$factory[0], $factory[1]]); } elseif (!is_string($factory)) { throw new RuntimeException(sprintf('Cannot create service "%s" because of invalid factory', $id)); @@ -79,7 +79,7 @@ protected function createService(array $definition, $id) { $service = call_user_func_array($factory, $arguments); } else { - $class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters(array($definition['class']))); + $class = $this->frozen ? $definition['class'] : current($this->resolveServicesAndParameters([$definition['class']])); $length = isset($definition['arguments_count']) ? $definition['arguments_count'] : count($arguments); // Optimize class instantiation for services with up to 10 parameters as @@ -147,12 +147,12 @@ protected function createService(array $definition, $id) { if (isset($definition['calls'])) { foreach ($definition['calls'] as $call) { $method = $call[0]; - $arguments = array(); + $arguments = []; if (!empty($call[1])) { $arguments = $call[1]; $arguments = $this->resolveServicesAndParameters($arguments); } - call_user_func_array(array($service, $method), $arguments); + call_user_func_array([$service, $method], $arguments); } } diff --git a/core/lib/Drupal/Component/Diff/Diff.php b/core/lib/Drupal/Component/Diff/Diff.php index 2e35611..d9042bc 100644 --- a/core/lib/Drupal/Component/Diff/Diff.php +++ b/core/lib/Drupal/Component/Diff/Diff.php @@ -49,7 +49,7 @@ public function __construct($from_lines, $to_lines) { */ public function reverse() { $rev = $this; - $rev->edits = array(); + $rev->edits = []; foreach ($this->edits as $edit) { $rev->edits[] = $edit->reverse(); } @@ -96,7 +96,7 @@ public function lcs() { * @return array The original sequence of strings. */ public function orig() { - $lines = array(); + $lines = []; foreach ($this->edits as $edit) { if ($edit->orig) { @@ -115,7 +115,7 @@ public function orig() { * @return array The sequence of strings. */ public function closing() { - $lines = array(); + $lines = []; foreach ($this->edits as $edit) { if ($edit->closing) { diff --git a/core/lib/Drupal/Component/Diff/DiffFormatter.php b/core/lib/Drupal/Component/Diff/DiffFormatter.php index ce08b00..375d432 100644 --- a/core/lib/Drupal/Component/Diff/DiffFormatter.php +++ b/core/lib/Drupal/Component/Diff/DiffFormatter.php @@ -48,7 +48,7 @@ class DiffFormatter { public function format(Diff $diff) { $xi = $yi = 1; $block = FALSE; - $context = array(); + $context = []; $nlead = $this->leading_context_lines; $ntrail = $this->trailing_context_lines; @@ -77,7 +77,7 @@ public function format(Diff $diff) { $context = array_slice($context, sizeof($context) - $nlead); $x0 = $xi - sizeof($context); $y0 = $yi - sizeof($context); - $block = array(); + $block = []; if ($context) { $block[] = new DiffOpCopy($context); } diff --git a/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php b/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php index b27886d..7885c6f 100644 --- a/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php +++ b/core/lib/Drupal/Component/Diff/Engine/DiffEngine.php @@ -38,9 +38,9 @@ public function diff($from_lines, $to_lines) { $n_from = sizeof($from_lines); $n_to = sizeof($to_lines); - $this->xchanged = $this->ychanged = array(); - $this->xv = $this->yv = array(); - $this->xind = $this->yind = array(); + $this->xchanged = $this->ychanged = []; + $this->xv = $this->yv = []; + $this->xind = $this->yind = []; unset($this->seq); unset($this->in_seq); unset($this->lcs); @@ -93,14 +93,14 @@ public function diff($from_lines, $to_lines) { $this->_shift_boundaries($to_lines, $this->ychanged, $this->xchanged); // Compute the edit operations. - $edits = array(); + $edits = []; $xi = $yi = 0; while ($xi < $n_from || $yi < $n_to) { $this::USE_ASSERTS && assert($yi < $n_to || $this->xchanged[$xi]); $this::USE_ASSERTS && assert($xi < $n_from || $this->ychanged[$yi]); // Skip matching "snake". - $copy = array(); + $copy = []; while ( $xi < $n_from && $yi < $n_to && !$this->xchanged[$xi] && !$this->ychanged[$yi]) { $copy[] = $from_lines[$xi++]; ++$yi; @@ -109,11 +109,11 @@ public function diff($from_lines, $to_lines) { $edits[] = new DiffOpCopy($copy); } // Find deletes & adds. - $delete = array(); + $delete = []; while ($xi < $n_from && $this->xchanged[$xi]) { $delete[] = $from_lines[$xi++]; } - $add = array(); + $add = []; while ($yi < $n_to && $this->ychanged[$yi]) { $add[] = $to_lines[$yi++]; } @@ -167,7 +167,7 @@ protected function _diag($xoff, $xlim, $yoff, $ylim, $nchunks) { // Things seems faster (I'm not sure I understand why) // when the shortest sequence in X. $flip = TRUE; - list($xoff, $xlim, $yoff, $ylim) = array($yoff, $ylim, $xoff, $xlim); + list($xoff, $xlim, $yoff, $ylim) = [$yoff, $ylim, $xoff, $xlim]; } if ($flip) { @@ -182,8 +182,8 @@ protected function _diag($xoff, $xlim, $yoff, $ylim, $nchunks) { } $this->lcs = 0; $this->seq[0] = $yoff - 1; - $this->in_seq = array(); - $ymids[0] = array(); + $this->in_seq = []; + $ymids[0] = []; $numer = $xlim - $xoff + $nchunks - 1; $x = $xoff; @@ -228,16 +228,16 @@ protected function _diag($xoff, $xlim, $yoff, $ylim, $nchunks) { } } - $seps[] = $flip ? array($yoff, $xoff) : array($xoff, $yoff); + $seps[] = $flip ? [$yoff, $xoff] : [$xoff, $yoff]; $ymid = $ymids[$this->lcs]; for ($n = 0; $n < $nchunks - 1; $n++) { $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $n) / $nchunks); $y1 = $ymid[$n] + 1; - $seps[] = $flip ? array($y1, $x1) : array($x1, $y1); + $seps[] = $flip ? [$y1, $x1] : [$x1, $y1]; } - $seps[] = $flip ? array($ylim, $xlim) : array($xlim, $ylim); + $seps[] = $flip ? [$ylim, $xlim] : [$xlim, $ylim]; - return array($this->lcs, $seps); + return [$this->lcs, $seps]; } protected function _lcs_pos($ypos) { diff --git a/core/lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php b/core/lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php index 532c701..eb7d943 100644 --- a/core/lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php +++ b/core/lib/Drupal/Component/Diff/Engine/HWLDFWordAccumulator.php @@ -20,7 +20,7 @@ class HWLDFWordAccumulator { */ const NBSP = ' '; - protected $lines = array(); + protected $lines = []; protected $line = ''; diff --git a/core/lib/Drupal/Component/Diff/WordLevelDiff.php b/core/lib/Drupal/Component/Diff/WordLevelDiff.php index a19c687..a8c2f80 100644 --- a/core/lib/Drupal/Component/Diff/WordLevelDiff.php +++ b/core/lib/Drupal/Component/Diff/WordLevelDiff.php @@ -22,8 +22,8 @@ public function __construct($orig_lines, $closing_lines) { } protected function _split($lines) { - $words = array(); - $stripped = array(); + $words = []; + $stripped = []; $first = TRUE; foreach ($lines as $line) { // If the line is too long, just pretend the entire line is one big word @@ -46,7 +46,7 @@ protected function _split($lines) { } } } - return array($words, $stripped); + return [$words, $stripped]; } public function orig() { diff --git a/core/lib/Drupal/Component/Discovery/YamlDirectoryDiscovery.php b/core/lib/Drupal/Component/Discovery/YamlDirectoryDiscovery.php index 6d0eceb..db2c3cc 100644 --- a/core/lib/Drupal/Component/Discovery/YamlDirectoryDiscovery.php +++ b/core/lib/Drupal/Component/Discovery/YamlDirectoryDiscovery.php @@ -65,7 +65,7 @@ public function __construct(array $directories, $file_cache_key_suffix, $key = ' * {@inheritdoc} */ public function findAll() { - $all = array(); + $all = []; $files = $this->findFiles(); diff --git a/core/lib/Drupal/Component/Discovery/YamlDiscovery.php b/core/lib/Drupal/Component/Discovery/YamlDiscovery.php index ea5c9c2..f13e60b 100644 --- a/core/lib/Drupal/Component/Discovery/YamlDiscovery.php +++ b/core/lib/Drupal/Component/Discovery/YamlDiscovery.php @@ -22,7 +22,7 @@ class YamlDiscovery implements DiscoverableInterface { * * @var array */ - protected $directories = array(); + protected $directories = []; /** * Constructs a YamlDiscovery object. @@ -42,7 +42,7 @@ public function __construct($name, array $directories) { * {@inheritdoc} */ public function findAll() { - $all = array(); + $all = []; $files = $this->findFiles(); $provider_by_files = array_flip($files); @@ -86,7 +86,7 @@ protected function decode($file) { * @return array */ protected function findFiles() { - $files = array(); + $files = []; foreach ($this->directories as $provider => $directory) { $file = $directory . '/' . $provider . '.' . $this->name . '.yml'; if (file_exists($file)) { diff --git a/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php b/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php index a933b06..6c1e200 100644 --- a/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php +++ b/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php @@ -230,14 +230,14 @@ public function removeListener($event_name, $listener) { public function addSubscriber(EventSubscriberInterface $subscriber) { foreach ($subscriber->getSubscribedEvents() as $event_name => $params) { if (is_string($params)) { - $this->addListener($event_name, array($subscriber, $params)); + $this->addListener($event_name, [$subscriber, $params]); } elseif (is_string($params[0])) { - $this->addListener($event_name, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0); + $this->addListener($event_name, [$subscriber, $params[0]], isset($params[1]) ? $params[1] : 0); } else { foreach ($params as $listener) { - $this->addListener($event_name, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0); + $this->addListener($event_name, [$subscriber, $listener[0]], isset($listener[1]) ? $listener[1] : 0); } } } @@ -250,11 +250,11 @@ public function removeSubscriber(EventSubscriberInterface $subscriber) { foreach ($subscriber->getSubscribedEvents() as $event_name => $params) { if (is_array($params) && is_array($params[0])) { foreach ($params as $listener) { - $this->removeListener($event_name, array($subscriber, $listener[0])); + $this->removeListener($event_name, [$subscriber, $listener[0]]); } } else { - $this->removeListener($event_name, array($subscriber, is_string($params) ? $params : $params[0])); + $this->removeListener($event_name, [$subscriber, is_string($params) ? $params : $params[0]]); } } } diff --git a/core/lib/Drupal/Component/Gettext/PoHeader.php b/core/lib/Drupal/Component/Gettext/PoHeader.php index 5922301..806beba 100644 --- a/core/lib/Drupal/Component/Gettext/PoHeader.php +++ b/core/lib/Drupal/Component/Gettext/PoHeader.php @@ -191,9 +191,9 @@ public function __toString() { * @throws Exception */ function parsePluralForms($pluralforms) { - $plurals = array(); + $plurals = []; // First, delete all whitespace. - $pluralforms = strtr($pluralforms, array(" " => "", "\t" => "")); + $pluralforms = strtr($pluralforms, [" " => "", "\t" => ""]); // Select the parts that define nplurals and plural. $nplurals = strstr($pluralforms, "nplurals="); @@ -215,7 +215,7 @@ function parsePluralForms($pluralforms) { // If the number of plurals is zero, we return a default result. if ($nplurals == 0) { - return array($nplurals, array('default' => 0)); + return [$nplurals, ['default' => 0]]; } // Calculate possible plural positions of different plural values. All known @@ -233,7 +233,7 @@ function parsePluralForms($pluralforms) { }); $plurals['default'] = $default; - return array($nplurals, $plurals); + return [$nplurals, $plurals]; } else { throw new \Exception('The plural formula could not be parsed.'); @@ -250,7 +250,7 @@ function parsePluralForms($pluralforms) { * An associative array of key-value pairs. */ private function parseHeader($header) { - $header_parsed = array(); + $header_parsed = []; $lines = array_map('trim', explode("\n", $header)); foreach ($lines as $line) { if ($line) { @@ -275,17 +275,17 @@ private function parseHeader($header) { */ private function parseArithmetic($string) { // Operator precedence table. - $precedence = array("(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8); + $precedence = ["(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8]; // Right associativity. - $right_associativity = array("?" => 1, ":" => 1); + $right_associativity = ["?" => 1, ":" => 1]; $tokens = $this->tokenizeFormula($string); // Parse by converting into infix notation then back into postfix // Operator stack - holds math operators and symbols. - $operator_stack = array(); + $operator_stack = []; // Element Stack - holds data to be operated on. - $element_stack = array(); + $element_stack = []; foreach ($tokens as $token) { $current_token = $token; @@ -373,7 +373,7 @@ private function parseArithmetic($string) { */ private function tokenizeFormula($formula) { $formula = str_replace(" ", "", $formula); - $tokens = array(); + $tokens = []; for ($i = 0; $i < strlen($formula); $i++) { if (is_numeric($formula[$i])) { $num = $formula[$i]; diff --git a/core/lib/Drupal/Component/Gettext/PoItem.php b/core/lib/Drupal/Component/Gettext/PoItem.php index c557964..33cfc32 100644 --- a/core/lib/Drupal/Component/Gettext/PoItem.php +++ b/core/lib/Drupal/Component/Gettext/PoItem.php @@ -171,7 +171,7 @@ function setComment($comment) { * * @param array values */ - public function setFromArray(array $values = array()) { + public function setFromArray(array $values = []) { if (isset($values['context'])) { $this->setContext($values['context']); } diff --git a/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php b/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php index 37070cb..c8da6e6 100644 --- a/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php +++ b/core/lib/Drupal/Component/Gettext/PoMemoryWriter.php @@ -18,7 +18,7 @@ class PoMemoryWriter implements PoWriterInterface { * Constructor, initialize empty items. */ function __construct() { - $this->_items = array(); + $this->_items = []; } /** diff --git a/core/lib/Drupal/Component/Gettext/PoStreamReader.php b/core/lib/Drupal/Component/Gettext/PoStreamReader.php index faaa95f..c44f9a1 100644 --- a/core/lib/Drupal/Component/Gettext/PoStreamReader.php +++ b/core/lib/Drupal/Component/Gettext/PoStreamReader.php @@ -39,7 +39,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface { * * @var array */ - private $_current_item = array(); + private $_current_item = []; /** * Current plural index for plural translations. @@ -261,14 +261,14 @@ private function readLine() { $this->_line_number++; // Initialize common values for error logging. - $log_vars = array( + $log_vars = [ '%uri' => $this->getURI(), '%line' => $this->_line_number, - ); + ]; // Trim away the linefeed. \\n might appear at the end of the string if // another line continuing the same string follows. We can remove that. - $line = trim(strtr($line, array("\\\n" => ""))); + $line = trim(strtr($line, ["\\\n" => ""])); if (!strncmp('#', $line, 1)) { // Lines starting with '#' are comments. @@ -282,7 +282,7 @@ private function readLine() { $this->setItemFromArray($this->_current_item); // Start a new entry for the comment. - $this->_current_item = array(); + $this->_current_item = []; $this->_current_item['#'][] = substr($line, 1); $this->_context = 'COMMENT'; @@ -319,7 +319,7 @@ private function readLine() { if (is_string($this->_current_item['msgid'])) { // The first value was stored as string. Now we know the context is // plural, it is converted to array. - $this->_current_item['msgid'] = array($this->_current_item['msgid']); + $this->_current_item['msgid'] = [$this->_current_item['msgid']]; } $this->_current_item['msgid'][] = $quoted; @@ -334,7 +334,7 @@ private function readLine() { $this->setItemFromArray($this->_current_item); // Start a new context for the msgid. - $this->_current_item = array(); + $this->_current_item = []; } elseif ($this->_context == 'MSGID') { // We are currently already in the context, meaning we passed an id with no data. @@ -363,7 +363,7 @@ private function readLine() { if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) { // We are currently in string context, save current item. $this->setItemFromArray($this->_current_item); - $this->_current_item = array(); + $this->_current_item = []; } elseif (!empty($this->_current_item['msgctxt'])) { // A context cannot apply to another context. @@ -421,7 +421,7 @@ private function readLine() { return FALSE; } if (!isset($this->_current_item['msgstr']) || !is_array($this->_current_item['msgstr'])) { - $this->_current_item['msgstr'] = array(); + $this->_current_item['msgstr'] = []; } $this->_current_item['msgstr'][$this->_current_plural_index] = $quoted; @@ -500,7 +500,7 @@ private function readLine() { // Empty line read or EOF of PO stream, close out the last entry. if (($this->_context == 'MSGSTR') || ($this->_context == 'MSGSTR_ARR')) { $this->setItemFromArray($this->_current_item); - $this->_current_item = array(); + $this->_current_item = []; } elseif ($this->_context != 'COMMENT') { $this->_errors[] = SafeMarkup::format('The translation stream %uri ended unexpectedly at line %line.', $log_vars); diff --git a/core/lib/Drupal/Component/Graph/Graph.php b/core/lib/Drupal/Component/Graph/Graph.php index 5d8d5ca..b155faa 100644 --- a/core/lib/Drupal/Component/Graph/Graph.php +++ b/core/lib/Drupal/Component/Graph/Graph.php @@ -56,13 +56,13 @@ public function __construct($graph) { * identifier. */ public function searchAndSort() { - $state = array( + $state = [ // The order of last visit of the depth first search. This is the reverse // of the topological order if the graph is acyclic. - 'last_visit_order' => array(), + 'last_visit_order' => [], // The components of the graph. - 'components' => array(), - ); + 'components' => [], + ]; // Perform the actual search. foreach ($this->graph as $start => $data) { $this->depthFirstSearch($state, $start); @@ -71,7 +71,7 @@ public function searchAndSort() { // We do such a numbering that every component starts with 0. This is useful // for module installs as we can install every 0 weighted module in one // request, and then every 1 weighted etc. - $component_weights = array(); + $component_weights = []; foreach ($state['last_visit_order'] as $vertex) { $component = $this->graph[$vertex]['component']; @@ -108,7 +108,7 @@ protected function depthFirstSearch(&$state, $start, &$component = NULL) { return; } // Mark $start as visited. - $this->graph[$start]['paths'] = array(); + $this->graph[$start]['paths'] = []; // Assign $start to the current component. $this->graph[$start]['component'] = $component; diff --git a/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php b/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php index 5dc159f..5795638 100644 --- a/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php +++ b/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.php @@ -83,7 +83,7 @@ public function deleteAll() { * {@inheritdoc} */ public function listAll() { - $names = array(); + $names = []; if (file_exists($this->directory)) { foreach (new \DirectoryIterator($this->directory) as $fileinfo) { if (!$fileinfo->isDot()) { diff --git a/core/lib/Drupal/Component/PhpStorage/FileStorage.php b/core/lib/Drupal/Component/PhpStorage/FileStorage.php index 1e6a2b3..f1bf183 100644 --- a/core/lib/Drupal/Component/PhpStorage/FileStorage.php +++ b/core/lib/Drupal/Component/PhpStorage/FileStorage.php @@ -246,7 +246,7 @@ protected function unlink($path) { * {@inheritdoc} */ public function listAll() { - $names = array(); + $names = []; if (file_exists($this->directory)) { foreach (new \DirectoryIterator($this->directory) as $fileinfo) { if (!$fileinfo->isDot()) { diff --git a/core/lib/Drupal/Component/Plugin/Context/Context.php b/core/lib/Drupal/Component/Plugin/Context/Context.php index 3713d48..8a225d4 100644 --- a/core/lib/Drupal/Component/Plugin/Context/Context.php +++ b/core/lib/Drupal/Component/Plugin/Context/Context.php @@ -79,7 +79,7 @@ public function getConstraints() { if (empty($this->contextDefinition['class'])) { throw new ContextException("An error was encountered while trying to validate the context."); } - return array(new Type($this->contextDefinition['class'])); + return [new Type($this->contextDefinition['class'])]; } /** diff --git a/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php b/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php index 96318ac..b9f6e02 100644 --- a/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php +++ b/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php @@ -67,7 +67,7 @@ protected function createContextFromConfiguration(array $context_configuration) */ public function getContextDefinitions() { $definition = $this->getPluginDefinition(); - return !empty($definition['context']) ? $definition['context'] : array(); + return !empty($definition['context']) ? $definition['context'] : []; } /** @@ -114,7 +114,7 @@ public function setContext($name, ContextInterface $context) { * {@inheritdoc} */ public function getContextValues() { - $values = array(); + $values = []; foreach ($this->getContextDefinitions() as $name => $definition) { $values[$name] = isset($this->context[$name]) ? $this->context[$name]->getContextValue() : NULL; } diff --git a/core/lib/Drupal/Component/Plugin/Derivative/DeriverBase.php b/core/lib/Drupal/Component/Plugin/Derivative/DeriverBase.php index 0c97c6d..f49ab99 100644 --- a/core/lib/Drupal/Component/Plugin/Derivative/DeriverBase.php +++ b/core/lib/Drupal/Component/Plugin/Derivative/DeriverBase.php @@ -12,7 +12,7 @@ * * @var array */ - protected $derivatives = array(); + protected $derivatives = []; /** * {@inheritdoc} diff --git a/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php index 2028f40..49e78db 100644 --- a/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php +++ b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php @@ -20,7 +20,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface { * @var \Drupal\Component\Plugin\Derivative\DeriverInterface[] * Keys are base plugin IDs. */ - protected $derivers = array(); + protected $derivers = []; /** * The decorated plugin discovery. @@ -93,7 +93,7 @@ public function getDefinitions() { * DiscoveryInterface::getDefinitions(). */ protected function getDerivatives(array $base_plugin_definitions) { - $plugin_definitions = array(); + $plugin_definitions = []; foreach ($base_plugin_definitions as $base_plugin_id => $plugin_definition) { $deriver = $this->getDeriver($base_plugin_id, $plugin_definition); if ($deriver) { @@ -136,7 +136,7 @@ protected function decodePluginId($plugin_id) { return explode(':', $plugin_id, 2); } - return array($plugin_id, NULL); + return [$plugin_id, NULL]; } /** @@ -229,7 +229,7 @@ protected function mergeDerivativeDefinition($base_plugin_definition, $derivativ // Use this definition as defaults if a plugin already defined itself as // this derivative, but filter out empty values first. $filtered_base = array_filter($base_plugin_definition); - $derivative_definition = $filtered_base + ($derivative_definition ?: array()); + $derivative_definition = $filtered_base + ($derivative_definition ?: []); // Add back any empty keys that the derivative didn't have. return $derivative_definition + $base_plugin_definition; } @@ -238,7 +238,7 @@ protected function mergeDerivativeDefinition($base_plugin_definition, $derivativ * Passes through all unknown calls onto the decorated object. */ public function __call($method, $args) { - return call_user_func_array(array($this->decorated, $method), $args); + return call_user_func_array([$this->decorated, $method], $args); } } diff --git a/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php b/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php index f7ee671..2818602 100644 --- a/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php +++ b/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscovery.php @@ -15,7 +15,7 @@ class StaticDiscovery implements DiscoveryInterface { */ public function getDefinitions() { if (!$this->definitions) { - $this->definitions = array(); + $this->definitions = []; } return $this->definitions; } diff --git a/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscoveryDecorator.php b/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscoveryDecorator.php index 889d146..968dcb9 100644 --- a/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscoveryDecorator.php +++ b/core/lib/Drupal/Component/Plugin/Discovery/StaticDiscoveryDecorator.php @@ -61,7 +61,7 @@ public function getDefinitions() { * Passes through all unknown calls onto the decorated object */ public function __call($method, $args) { - return call_user_func_array(array($this->decorated, $method), $args); + return call_user_func_array([$this->decorated, $method], $args); } } diff --git a/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php b/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php index 2cca811..1f203fb 100644 --- a/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php +++ b/core/lib/Drupal/Component/Plugin/Factory/DefaultFactory.php @@ -49,7 +49,7 @@ public function __construct(DiscoveryInterface $discovery, $plugin_interface = N /** * {@inheritdoc} */ - public function createInstance($plugin_id, array $configuration = array()) { + public function createInstance($plugin_id, array $configuration = []) { $plugin_definition = $this->discovery->getDefinition($plugin_id); $plugin_class = static::getPluginClass($plugin_id, $plugin_definition, $this->interface); return new $plugin_class($configuration, $plugin_id, $plugin_definition); diff --git a/core/lib/Drupal/Component/Plugin/Factory/FactoryInterface.php b/core/lib/Drupal/Component/Plugin/Factory/FactoryInterface.php index f1d07ff..8cf046b 100644 --- a/core/lib/Drupal/Component/Plugin/Factory/FactoryInterface.php +++ b/core/lib/Drupal/Component/Plugin/Factory/FactoryInterface.php @@ -21,6 +21,6 @@ * @throws \Drupal\Component\Plugin\Exception\PluginException * If the instance cannot be created, such as if the ID is invalid. */ - public function createInstance($plugin_id, array $configuration = array()); + public function createInstance($plugin_id, array $configuration = []); } diff --git a/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php b/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php index 9954422..8a42ce3 100644 --- a/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php +++ b/core/lib/Drupal/Component/Plugin/Factory/ReflectionFactory.php @@ -13,7 +13,7 @@ class ReflectionFactory extends DefaultFactory { /** * {@inheritdoc} */ - public function createInstance($plugin_id, array $configuration = array()) { + public function createInstance($plugin_id, array $configuration = []) { $plugin_definition = $this->discovery->getDefinition($plugin_id); $plugin_class = static::getPluginClass($plugin_id, $plugin_definition, $this->interface); @@ -51,7 +51,7 @@ public function createInstance($plugin_id, array $configuration = array()) { */ protected function getInstanceArguments(\ReflectionClass $reflector, $plugin_id, $plugin_definition, array $configuration) { - $arguments = array(); + $arguments = []; foreach ($reflector->getMethod('__construct')->getParameters() as $param) { $param_name = $param->getName(); diff --git a/core/lib/Drupal/Component/Plugin/FallbackPluginManagerInterface.php b/core/lib/Drupal/Component/Plugin/FallbackPluginManagerInterface.php index 7af6c8a..0a85e67 100644 --- a/core/lib/Drupal/Component/Plugin/FallbackPluginManagerInterface.php +++ b/core/lib/Drupal/Component/Plugin/FallbackPluginManagerInterface.php @@ -18,6 +18,6 @@ * @return string * The id of an existing plugin to use when the plugin does not exist. */ - public function getFallbackPluginId($plugin_id, array $configuration = array()); + public function getFallbackPluginId($plugin_id, array $configuration = []); } diff --git a/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php b/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php index 1d90af7..b55b04e 100644 --- a/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php +++ b/core/lib/Drupal/Component/Plugin/LazyPluginCollection.php @@ -14,14 +14,14 @@ * * @var array */ - protected $pluginInstances = array(); + protected $pluginInstances = []; /** * Stores the IDs of all potential plugin instances. * * @var array */ - protected $instanceIDs = array(); + protected $instanceIDs = []; /** * Initializes and stores a plugin. @@ -53,7 +53,7 @@ * Clears all instantiated plugins. */ public function clear() { - $this->pluginInstances = array(); + $this->pluginInstances = []; } /** diff --git a/core/lib/Drupal/Component/Plugin/PluginManagerBase.php b/core/lib/Drupal/Component/Plugin/PluginManagerBase.php index 5fb32a2..34416ff 100644 --- a/core/lib/Drupal/Component/Plugin/PluginManagerBase.php +++ b/core/lib/Drupal/Component/Plugin/PluginManagerBase.php @@ -68,7 +68,7 @@ public function getDefinitions() { /** * {@inheritdoc} */ - public function createInstance($plugin_id, array $configuration = array()) { + public function createInstance($plugin_id, array $configuration = []) { // If this PluginManager has fallback capabilities catch // PluginNotFoundExceptions. if ($this instanceof FallbackPluginManagerInterface) { diff --git a/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php b/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php index c20168d..3cd8d68 100644 --- a/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php +++ b/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php @@ -44,7 +44,7 @@ class PhpTransliteration implements TransliterationInterface { * * @var array */ - protected $languageOverrides = array(); + protected $languageOverrides = []; /** * Non-language-specific transliteration tables. @@ -56,7 +56,7 @@ class PhpTransliteration implements TransliterationInterface { * * @var array */ - protected $genericMap = array(); + protected $genericMap = []; /** * Constructs a transliteration object. @@ -83,9 +83,9 @@ public function removeDiacritics($string) { // few characters that aren't accented letters mixed in. So define the // ranges and the excluded characters. $range1 = $code > 0x00bf && $code < 0x017f; - $exclusions_range1 = array(0x00d0, 0x00d7, 0x00f0, 0x00f7, 0x0138, 0x014a, 0x014b); + $exclusions_range1 = [0x00d0, 0x00d7, 0x00f0, 0x00f7, 0x0138, 0x014a, 0x014b]; $range2 = $code > 0x01cc && $code < 0x0250; - $exclusions_range2 = array(0x01DD, 0x01f7, 0x021c, 0x021d, 0x0220, 0x0221, 0x0241, 0x0242, 0x0245); + $exclusions_range2 = [0x01DD, 0x01f7, 0x021c, 0x021d, 0x0220, 0x0221, 0x0241, 0x0242, 0x0245]; $replacement = $character; if (($range1 && !in_array($code, $exclusions_range1)) || ($range2 && !in_array($code, $exclusions_range2))) { @@ -246,7 +246,7 @@ protected function readLanguageOverrides($langcode) { include $file; } if (!isset($overrides) || !is_array($overrides)) { - $overrides = array($langcode => array()); + $overrides = [$langcode => []]; } $this->languageOverrides[$langcode] = $overrides[$langcode]; } @@ -274,7 +274,7 @@ protected function readGenericData($bank) { include $file; } if (!isset($base) || !is_array($base)) { - $base = array(); + $base = []; } // Save this data. diff --git a/core/lib/Drupal/Component/Transliteration/data/de.php b/core/lib/Drupal/Component/Transliteration/data/de.php index a0b7e78..49a08c5 100644 --- a/core/lib/Drupal/Component/Transliteration/data/de.php +++ b/core/lib/Drupal/Component/Transliteration/data/de.php @@ -5,11 +5,11 @@ * German transliteration data for the PhpTransliteration class. */ -$overrides['de'] = array( +$overrides['de'] = [ 0xC4 => 'Ae', 0xD6 => 'Oe', 0xDC => 'Ue', 0xE4 => 'ae', 0xF6 => 'oe', 0xFC => 'ue', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/dk.php b/core/lib/Drupal/Component/Transliteration/data/dk.php index 4a3056a..e46b013 100644 --- a/core/lib/Drupal/Component/Transliteration/data/dk.php +++ b/core/lib/Drupal/Component/Transliteration/data/dk.php @@ -5,9 +5,9 @@ * Danish transliteration data for the PhpTransliteration class. */ -$overrides['dk'] = array( +$overrides['dk'] = [ 0xC5 => 'Aa', 0xD8 => 'Oe', 0xE5 => 'aa', 0xF8 => 'oe', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/eo.php b/core/lib/Drupal/Component/Transliteration/data/eo.php index 565af19..e115866 100644 --- a/core/lib/Drupal/Component/Transliteration/data/eo.php +++ b/core/lib/Drupal/Component/Transliteration/data/eo.php @@ -5,7 +5,7 @@ * Esperanto transliteration data for the PhpTransliteration class. */ -$overrides['eo'] = array( +$overrides['eo'] = [ 0x18 => 'Cx', 0x19 => 'cx', 0x11C => 'Gx', @@ -18,4 +18,4 @@ 0x15D => 'sx', 0x16C => 'Ux', 0x16D => 'ux', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/kg.php b/core/lib/Drupal/Component/Transliteration/data/kg.php index 1f8ad05..549f075 100644 --- a/core/lib/Drupal/Component/Transliteration/data/kg.php +++ b/core/lib/Drupal/Component/Transliteration/data/kg.php @@ -5,7 +5,7 @@ * Kyrgyz transliteration data for the PhpTransliteration class. */ -$overrides['kg'] = array( +$overrides['kg'] = [ 0x41 => 'E', 0x416 => 'C', 0x419 => 'J', @@ -28,4 +28,4 @@ 0x4AF => 'w', 0x4E8 => 'Q', 0x4E9 => 'q', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x00.php b/core/lib/Drupal/Component/Transliteration/data/x00.php index 8685680..fd7c3f7 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x00.php +++ b/core/lib/Drupal/Component/Transliteration/data/x00.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ // Note: to save memory plain ASCII mappings have been left out. 0x80 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0x90 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', @@ -15,4 +15,4 @@ 0xD0 => 'D', 'N', 'O', 'O', 'O', 'O', 'O', '*', 'O', 'U', 'U', 'U', 'U', 'Y', 'TH', 'ss', 0xE0 => 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 0xF0 => 'd', 'n', 'o', 'o', 'o', 'o', 'o', '/', 'o', 'u', 'u', 'u', 'u', 'y', 'th', 'y', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x01.php b/core/lib/Drupal/Component/Transliteration/data/x01.php index 535692a..a30aaa0 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x01.php +++ b/core/lib/Drupal/Component/Transliteration/data/x01.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 0x10 => 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 0x20 => 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', @@ -22,4 +22,4 @@ 0xD0 => 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', '@', 'A', 'a', 0xE0 => 'A', 'a', 'AE', 'ae', 'G', 'g', 'G', 'g', 'K', 'k', 'O', 'o', 'O', 'o', 'ZH', 'zh', 0xF0 => 'j', 'DZ', 'Dz', 'dz', 'G', 'g', 'HV', 'W', 'N', 'n', 'A', 'a', 'AE', 'ae', 'O', 'o', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x02.php b/core/lib/Drupal/Component/Transliteration/data/x02.php index b57d54b..ba94207 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x02.php +++ b/core/lib/Drupal/Component/Transliteration/data/x02.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'A', 'a', 'A', 'a', 'E', 'e', 'E', 'e', 'I', 'i', 'I', 'i', 'O', 'o', 'O', 'o', 0x10 => 'R', 'r', 'R', 'r', 'U', 'u', 'U', 'u', 'S', 's', 'T', 't', 'Y', 'y', 'H', 'h', 0x20 => 'N', 'd', 'OU', 'ou', 'Z', 'z', 'A', 'a', 'E', 'e', 'O', 'o', 'O', 'o', 'O', 'o', @@ -22,4 +22,4 @@ 0xD0 => ':', '.', '`', '\'', '^', 'V', '+', '-', 'V', '.', '@', ',', '~', '"', 'R', 'X', 0xE0 => 'G', 'l', 's', 'x', '?', '', '', '', '', '', '', '', 'V', '=', '"', NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x03.php b/core/lib/Drupal/Component/Transliteration/data/x03.php index 0984281..f61602d 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x03.php +++ b/core/lib/Drupal/Component/Transliteration/data/x03.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0x10 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0x20 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', @@ -22,4 +22,4 @@ 0xD0 => 'b', 'th', 'Y', 'Y', 'Y', 'ph', 'p', '&', NULL, NULL, 'St', 'st', 'W', 'w', 'Q', 'q', 0xE0 => 'Sp', 'sp', 'Sh', 'sh', 'F', 'f', 'Kh', 'kh', 'H', 'h', 'G', 'g', 'CH', 'ch', 'Ti', 'ti', 0xF0 => 'k', 'r', 's', 'j', 'TH', 'e', NULL, 'S', 's', 'S', 'S', 's', NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x04.php b/core/lib/Drupal/Component/Transliteration/data/x04.php index a8fee7d..1be0d43 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x04.php +++ b/core/lib/Drupal/Component/Transliteration/data/x04.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'E', 'E', 'D', 'G', 'E', 'Z', 'I', 'I', 'J', 'L', 'N', 'C', 'K', 'I', 'U', 'D', 0x10 => 'A', 'B', 'V', 'G', 'D', 'E', 'Z', 'Z', 'I', 'I', 'K', 'L', 'M', 'N', 'O', 'P', 0x20 => 'R', 'S', 'T', 'U', 'F', 'H', 'C', 'C', 'S', 'S', '', 'Y', '', 'E', 'U', 'A', @@ -22,4 +22,4 @@ 0xD0 => 'A', 'a', 'A', 'a', 'AE', 'ae', 'E', 'e', '@', '@', '@', '@', 'Z', 'z', 'Z', 'z', 0xE0 => 'Dz', 'dz', 'I', 'i', 'I', 'i', 'O', 'o', 'O', 'o', 'O', 'o', 'E', 'e', 'U', 'u', 0xF0 => 'U', 'u', 'U', 'u', 'C', 'c', NULL, NULL, 'Y', 'y', NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x05.php b/core/lib/Drupal/Component/Transliteration/data/x05.php index 29b5232..f39fa5b 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x05.php +++ b/core/lib/Drupal/Component/Transliteration/data/x05.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => '', 'b', 'g', 'd', 'h', 'w', 'z', 'h', 't', 'y', 'k', 'k', 'l', 'm', 'm', 'n', 0xE0 => 'n', 's', '`', 'p', 'p', 'z', 'z', 'q', 'r', 's', 't', NULL, NULL, NULL, NULL, NULL, 0xF0 => 'ww', 'wy', 'yy', '\'', '"', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x06.php b/core/lib/Drupal/Component/Transliteration/data/x06.php index 68ea125..6999d90 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x06.php +++ b/core/lib/Drupal/Component/Transliteration/data/x06.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ',', NULL, NULL, NULL, 0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ';', NULL, NULL, NULL, '?', 0x20 => NULL, '', 'a', 'a', 'w', 'a', 'y', 'a', 'b', 't', 't', 'th', 'j', 'h', 'kh', 'd', @@ -22,4 +22,4 @@ 0xD0 => '', '', 'y', 'y\'', '.', 'ae', '', '', '', '', '', '', '', '@', '#', '', 0xE0 => '', '', '', '', '', '', '', '', '', '^', '', '', '', '', NULL, NULL, 0xF0 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Sh', 'D', 'Gh', '&', '+m', NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x07.php b/core/lib/Drupal/Component/Transliteration/data/x07.php index c141b66..3587313 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x07.php +++ b/core/lib/Drupal/Component/Transliteration/data/x07.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => '//', '/', ',', '!', '!', '-', ',', ',', ';', '?', '~', '{', '}', '*', NULL, '', 0x10 => '\'', '', 'b', 'g', 'g', 'd', 'dr', 'h', 'w', 'z', 'h', 't', 't', 'y', 'yh', 'k', 0x20 => 'l', 'm', 'n', 's', 's', '`', 'p', 'p', 's', 'q', 'r', 'sh', 't', NULL, NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x09.php b/core/lib/Drupal/Component/Transliteration/data/x09.php index 88c2845..6250925 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x09.php +++ b/core/lib/Drupal/Component/Transliteration/data/x09.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, 'N', 'N', 'h', NULL, 'a', 'a', 'i', 'i', 'u', 'u', 'r', 'l', 'e', 'e', 'e', 0x10 => 'ai', 'o', 'o', 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta', 0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', 'na', 'pa', 'pha', 'ba', 'bha', 'ma', 'ya', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, '+', NULL, NULL, NULL, NULL, 'da', 'dha', NULL, 'ya', 0xE0 => 'r', 'l', 'L', 'LL', NULL, NULL, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0xF0 => 'ra', 'ra', 'Rs', 'Rs', '1/', '2/', '3/', '4/', ' 1 - 1/', '/16', '', NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x0a.php b/core/lib/Drupal/Component/Transliteration/data/x0a.php index 5d14d3f..0dc613f 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x0a.php +++ b/core/lib/Drupal/Component/Transliteration/data/x0a.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, 'N', NULL, NULL, 'a', 'a', 'i', 'i', 'u', 'u', NULL, NULL, NULL, NULL, 'e', 0x10 => 'ai', NULL, NULL, 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta', 0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', NULL, 'pa', 'pha', 'ba', 'bha', 'ma', 'ya', @@ -22,4 +22,4 @@ 0xD0 => '\'om', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => 'r', 'l', NULL, NULL, NULL, NULL, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x0b.php b/core/lib/Drupal/Component/Transliteration/data/x0b.php index e700c6d..2f95b1b 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x0b.php +++ b/core/lib/Drupal/Component/Transliteration/data/x0b.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, 'N', 'm', 'h', NULL, 'a', 'a', 'i', 'i', 'u', 'u', 'r', 'l', NULL, NULL, 'e', 0x10 => 'ai', NULL, NULL, 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta', 0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', NULL, 'pa', 'pha', 'ba', 'bha', 'ma', 'ya', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, '+', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0xF0 => '10', '100', '1000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x0c.php b/core/lib/Drupal/Component/Transliteration/data/x0c.php index 51f7f50..1638bfd 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x0c.php +++ b/core/lib/Drupal/Component/Transliteration/data/x0c.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, 'm', 'm', 'h', NULL, 'a', 'a', 'i', 'i', 'u', 'u', 'r', 'l', NULL, 'e', 'e', 0x10 => 'ai', NULL, 'o', 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta', 0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', NULL, 'pa', 'pha', 'ba', 'bha', 'ma', 'ya', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, '+', '+', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'la', NULL, 0xE0 => 'r', 'l', NULL, NULL, NULL, NULL, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x0d.php b/core/lib/Drupal/Component/Transliteration/data/x0d.php index d92a68c..8aa517b 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x0d.php +++ b/core/lib/Drupal/Component/Transliteration/data/x0d.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, 'm', 'h', NULL, 'a', 'a', 'i', 'i', 'u', 'u', 'r', 'l', NULL, 'e', 'e', 0x10 => 'ai', NULL, 'o', 'o', 'au', 'ka', 'kha', 'ga', 'gha', 'na', 'ca', 'cha', 'ja', 'jha', 'na', 'ta', 0x20 => 'tha', 'da', 'dha', 'na', 'ta', 'tha', 'da', 'dha', 'na', NULL, 'pa', 'pha', 'ba', 'bha', 'ma', 'ya', @@ -22,4 +22,4 @@ 0xD0 => 'ae', 'aae', 'i', 'ii', 'u', NULL, 'uu', NULL, 'R', 'e', 'ee', 'ai', 'o', 'oo', 'au', 'L', 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, 'RR', 'LL', ' . ', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x0e.php b/core/lib/Drupal/Component/Transliteration/data/x0e.php index 03fb5a9..13a589d 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x0e.php +++ b/core/lib/Drupal/Component/Transliteration/data/x0e.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, 'k', 'kh', 'kh', 'kh', 'kh', 'kh', 'ng', 'c', 'ch', 'ch', 's', 'ch', 'y', 'd', 't', 0x10 => 'th', 'th', 'th', 'n', 'd', 't', 'th', 'th', 'th', 'n', 'b', 'p', 'ph', 'f', 'ph', 'f', 0x20 => 'ph', 'm', 'y', 'r', 'v', 'l', 'l', 'w', 's', 's', 's', 'h', 'l', 'x', 'h', '~', @@ -22,4 +22,4 @@ 0xD0 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', NULL, NULL, 'hn', 'hm', NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x0f.php b/core/lib/Drupal/Component/Transliteration/data/x0f.php index addfa75..32262e5 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x0f.php +++ b/core/lib/Drupal/Component/Transliteration/data/x0f.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'AUM', '', '', '', '', '', '', '', ' // ', ' * ', '', '-', ' / ', ' / ', ' // ', ' -/ ', 0x10 => ' +/ ', ' X/ ', ' /XX/ ', ' /X/ ', ',', '', '', '', '', '', '', '', '', '', '', '', 0x20 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.5', '1.5', '2.5', '3.5', '4.5', '5.5', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x10.php b/core/lib/Drupal/Component/Transliteration/data/x10.php index 9aedcce..cb1b13d 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x10.php +++ b/core/lib/Drupal/Component/Transliteration/data/x10.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'k', 'kh', 'g', 'gh', 'ng', 'c', 'ch', 'j', 'jh', 'ny', 'nny', 'tt', 'tth', 'dd', 'ddh', 'nn', 0x10 => 'tt', 'th', 'd', 'dh', 'n', 'p', 'ph', 'b', 'bh', 'm', 'y', 'r', 'l', 'w', 's', 'h', 0x20 => 'll', 'a', NULL, 'i', 'ii', 'u', 'uu', 'e', NULL, 'o', 'au', NULL, 'aa', 'i', 'ii', 'u', @@ -22,4 +22,4 @@ 0xD0 => 'a', 'b', 'g', 'd', 'e', 'v', 'z', 't', 'i', 'k', 'l', 'm', 'n', 'o', 'p', 'zh', 0xE0 => 'r', 's', 't', 'u', 'p', 'k', 'gh', 'q', 'sh', 'ch', 'ts', 'dz', 'c', 'ch', 'kh', 'j', 0xF0 => 'h', 'e', 'y', 'ui', 'q', 'oe', 'f', NULL, NULL, NULL, NULL, ' // ', NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x11.php b/core/lib/Drupal/Component/Transliteration/data/x11.php index 66d2fe6..bf1a13e 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x11.php +++ b/core/lib/Drupal/Component/Transliteration/data/x11.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'g', 'kk', 'n', 'd', 'tt', 'l', 'm', 'b', 'pp', 's', 'ss', '', 'j', 'jj', 'ch', 'k', 0x10 => 't', 'p', 'h', 'ng', 'nn', 'nd', 'nb', 'dg', 'rn', 'rr', 'rh', 'rN', 'mb', 'mN', 'bg', 'bn', 0x20 => '', 'bs', 'bsg', 'bst', 'bsb', 'bss', 'bsj', 'bj', 'bc', 'bt', 'bp', 'bN', 'bbN', 'sg', 'sn', 'sd', @@ -22,4 +22,4 @@ 0xD0 => 'll', 'lmg', 'lms', 'lbs', 'lbh', 'rNp', 'lss', 'lZ', 'lk', 'lQ', 'mg', 'ml', 'mb', 'ms', 'mss', 'mZ', 0xE0 => 'mc', 'mh', 'mN', 'bl', 'bp', 'ph', 'pN', 'sg', 'sd', 'sl', 'sb', 'Z', 'g', 'ss', '', 'kh', 0xF0 => 'N', 'Ns', 'NZ', 'pb', 'pN', 'hn', 'hl', 'hm', 'hb', 'Q', NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x12.php b/core/lib/Drupal/Component/Transliteration/data/x12.php index 1248209..43fdd36 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x12.php +++ b/core/lib/Drupal/Component/Transliteration/data/x12.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ha', 'hu', 'hi', 'haa', 'hee', 'he', 'ho', NULL, 'la', 'lu', 'li', 'laa', 'lee', 'le', 'lo', 'lwa', 0x10 => 'hha', 'hhu', 'hhi', 'hhaa', 'hhee', 'hhe', 'hho', 'hhwa', 'ma', 'mu', 'mi', 'maa', 'mee', 'me', 'mo', 'mwa', 0x20 => 'sza', 'szu', 'szi', 'szaa', 'szee', 'sze', 'szo', 'szwa', 'ra', 'ru', 'ri', 'raa', 'ree', 're', 'ro', 'rwa', @@ -22,4 +22,4 @@ 0xD0 => '`a', '`u', '`i', '`aa', '`ee', '`e', '`o', NULL, 'za', 'zu', 'zi', 'zaa', 'zee', 'ze', 'zo', 'zwa', 0xE0 => 'zha', 'zhu', 'zhi', 'zhaa', 'zhee', 'zhe', 'zho', 'zhwa', 'ya', 'yu', 'yi', 'yaa', 'yee', 'ye', 'yo', NULL, 0xF0 => 'da', 'du', 'di', 'daa', 'dee', 'de', 'do', 'dwa', 'dda', 'ddu', 'ddi', 'ddaa', 'ddee', 'dde', 'ddo', 'ddwa', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x13.php b/core/lib/Drupal/Component/Transliteration/data/x13.php index 73976a8..a6a5936 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x13.php +++ b/core/lib/Drupal/Component/Transliteration/data/x13.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ja', 'ju', 'ji', 'jaa', 'jee', 'je', 'jo', 'jwa', 'ga', 'gu', 'gi', 'gaa', 'gee', 'ge', 'go', NULL, 0x10 => 'gwa', NULL, 'gwi', 'gwaa', 'gwee', 'gwe', NULL, NULL, 'gga', 'ggu', 'ggi', 'ggaa', 'ggee', 'gge', 'ggo', NULL, 0x20 => 'tha', 'thu', 'thi', 'thaa', 'thee', 'the', 'tho', 'thwa', 'cha', 'chu', 'chi', 'chaa', 'chee', 'che', 'cho', 'chwa', @@ -22,4 +22,4 @@ 0xD0 => 'so', 'su', 'sv', 'da', 'ta', 'de', 'te', 'di', 'ti', 'do', 'du', 'dv', 'dla', 'tla', 'tle', 'tli', 0xE0 => 'tlo', 'tlu', 'tlv', 'tsa', 'tse', 'tsi', 'tso', 'tsu', 'tsv', 'wa', 'we', 'wi', 'wo', 'wu', 'wv', 'ya', 0xF0 => 'ye', 'yi', 'yo', 'yu', 'yv', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x14.php b/core/lib/Drupal/Component/Transliteration/data/x14.php index 8b4995e..e752a07 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x14.php +++ b/core/lib/Drupal/Component/Transliteration/data/x14.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, 'ai', 'aai', 'i', 'ii', 'u', 'uu', 'oo', 'ee', 'i', 'a', 'aa', 'we', 'we', 'wi', 'wi', 0x10 => 'wii', 'wii', 'wo', 'wo', 'woo', 'woo', 'woo', 'wa', 'wa', 'waa', 'waa', 'waa', 'ai', 'w', '\'', 't', 0x20 => 'k', 'sh', 's', 'n', 'w', 'n', NULL, 'w', 'c', '?', 'l', 'en', 'in', 'on', 'an', 'pai', @@ -22,4 +22,4 @@ 0xD0 => 'n', 'ng', 'nh', 'lai', 'laai', 'li', 'lii', 'lu', 'luu', 'loo', 'la', 'laa', 'lwe', 'lwe', 'lwi', 'lwi', 0xE0 => 'lwii', 'lwii', 'lwo', 'lwo', 'lwoo', 'lwoo', 'lwa', 'lwa', 'lwaa', 'lwaa', 'l', 'l', 'l', 'sai', 'saai', 'si', 0xF0 => 'sii', 'su', 'suu', 'soo', 'sa', 'saa', 'swe', 'swe', 'swi', 'swi', 'swii', 'swii', 'swo', 'swo', 'swoo', 'swoo', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x15.php b/core/lib/Drupal/Component/Transliteration/data/x15.php index e40fc68..4265783 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x15.php +++ b/core/lib/Drupal/Component/Transliteration/data/x15.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'swa', 'swa', 'swaa', 'swaa', 'swaa', 's', 's', 'sw', 's', 'sk', 'skw', 'sW', 'spwa', 'stwa', 'skwa', 'scwa', 0x10 => 'she', 'shi', 'shii', 'sho', 'shoo', 'sha', 'shaa', 'shwe', 'shwe', 'shwi', 'shwi', 'shwii', 'shwii', 'shwo', 'shwo', 'shwoo', 0x20 => 'shwoo', 'shwa', 'shwa', 'shwaa', 'shwaa', 'sh', 'jai', 'yaai', 'ji', 'jii', 'ju', 'juu', 'yoo', 'ja', 'jaa', 'ywe', @@ -22,4 +22,4 @@ 0xD0 => 'wu', 'wo', 'we', 'wee', 'wi', 'wa', 'hwu', 'hwo', 'hwe', 'hwee', 'hwi', 'hwa', 'thu', 'tho', 'the', 'thee', 0xE0 => 'thi', 'tha', 'ttu', 'tto', 'tte', 'ttee', 'tti', 'tta', 'pu', 'po', 'pe', 'pee', 'pi', 'pa', 'p', 'gu', 0xF0 => 'go', 'ge', 'gee', 'gi', 'ga', 'khu', 'kho', 'khe', 'khee', 'khi', 'kha', 'kku', 'kko', 'kke', 'kkee', 'kki', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x16.php b/core/lib/Drupal/Component/Transliteration/data/x16.php index 9d97747..dbb3d60 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x16.php +++ b/core/lib/Drupal/Component/Transliteration/data/x16.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'kka', 'kk', 'nu', 'no', 'ne', 'nee', 'ni', 'na', 'mu', 'mo', 'me', 'mee', 'mi', 'ma', 'yu', 'yo', 0x10 => 'ye', 'yee', 'yi', 'ya', 'ju', 'ju', 'jo', 'je', 'jee', 'ji', 'ji', 'ja', 'jju', 'jjo', 'jje', 'jjee', 0x20 => 'jji', 'jja', 'lu', 'lo', 'le', 'lee', 'li', 'la', 'dlu', 'dlo', 'dle', 'dlee', 'dli', 'dla', 'lhu', 'lho', @@ -22,4 +22,4 @@ 0xD0 => 't', 'd', 'b', 'b', 'p', 'p', 'e', 'm', 'm', 'm', 'l', 'l', 'ng', 'ng', 'd', 'o', 0xE0 => 'ear', 'ior', 'qu', 'qu', 'qu', 's', 'yr', 'yr', 'yr', 'q', 'x', '.', ':', '+', '17', '18', 0xF0 => '19', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x17.php b/core/lib/Drupal/Component/Transliteration/data/x17.php index f98d03a..f08a09d 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x17.php +++ b/core/lib/Drupal/Component/Transliteration/data/x17.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => '', '', '', '', '.', ' // ', ':', '+', '++', ' * ', ' /// ', 'KR', '\'', NULL, NULL, NULL, 0xE0 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x18.php b/core/lib/Drupal/Component/Transliteration/data/x18.php index 05c85a4..b46d30d 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x18.php +++ b/core/lib/Drupal/Component/Transliteration/data/x18.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => ' @ ', ' ... ', ',', '. ', ': ', ' // ', '', '-', ',', '. ', '', '', '', '', '', NULL, 0x10 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', NULL, NULL, NULL, NULL, NULL, NULL, 0x20 => 'a', 'e', 'i', 'o', 'u', 'O', 'U', 'ee', 'n', 'ng', 'b', 'p', 'q', 'g', 'm', 'l', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x1d.php b/core/lib/Drupal/Component/Transliteration/data/x1d.php index ab6b5d4..1d6bacf 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x1d.php +++ b/core/lib/Drupal/Component/Transliteration/data/x1d.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'A', 'AE', NULL, 'B', 'C', 'D', 'D', 'E', NULL, NULL, 'J', 'K', 'L', 'M', NULL, 'O', 0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'P', NULL, NULL, 'T', 'U', NULL, NULL, NULL, 0x20 => 'V', 'W', 'Z', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x1e.php b/core/lib/Drupal/Component/Transliteration/data/x1e.php index 71b45bb..592deec 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x1e.php +++ b/core/lib/Drupal/Component/Transliteration/data/x1e.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'A', 'a', 'B', 'b', 'B', 'b', 'B', 'b', 'C', 'c', 'D', 'd', 'D', 'd', 'D', 'd', 0x10 => 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'F', 'f', 0x20 => 'G', 'g', 'H', 'h', 'H', 'h', 'H', 'h', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', @@ -22,4 +22,4 @@ 0xD0 => 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 0xE0 => 'O', 'o', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 0xF0 => 'U', 'u', 'Y', 'y', 'Y', 'y', 'Y', 'y', 'Y', 'y', 'LL', 'll', 'V', 'v', 'Y', 'y', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x1f.php b/core/lib/Drupal/Component/Transliteration/data/x1f.php index 9e0a60e..33fa4bc 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x1f.php +++ b/core/lib/Drupal/Component/Transliteration/data/x1f.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 0x10 => 'e', 'e', 'e', 'e', 'e', 'e', NULL, NULL, 'E', 'E', 'E', 'E', 'E', 'E', NULL, NULL, 0x20 => 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'E', 'E', 'E', 'E', 'E', 'E', 'E', 'E', @@ -22,4 +22,4 @@ 0xD0 => 'i', 'i', 'i', 'i', NULL, NULL, 'i', 'i', 'I', 'I', 'I', 'I', NULL, '`\'', '`\'', '`~', 0xE0 => 'y', 'y', 'y', 'y', 'r', 'r', 'y', 'y', 'Y', 'Y', 'Y', 'Y', 'R', '"`', '"\'', '`', 0xF0 => NULL, NULL, 'o', 'o', 'o', NULL, 'o', 'o', 'O', 'O', 'O', 'O', 'O', '\'', '`', NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x20.php b/core/lib/Drupal/Component/Transliteration/data/x20.php index e106953..a556d49 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x20.php +++ b/core/lib/Drupal/Component/Transliteration/data/x20.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', '', '', 0x10 => '-', '-', '-', '-', '-', '-', '||', '_', '\'', '\'', ',', '\'', '"', '"', ',,', '"', 0x20 => '+', '++', '*', '*>', '.', '..', '...', '.', ' @@ -25,4 +25,4 @@ 0xD0 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0xE0 => '', '', '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x21.php b/core/lib/Drupal/Component/Transliteration/data/x21.php index 1da0f41..44645a9 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x21.php +++ b/core/lib/Drupal/Component/Transliteration/data/x21.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'a/c', 'a/s', 'C', '', '', 'c/o', 'c/u', '', '', '', 'g', 'H', 'x', 'H', 'h', '', 0x10 => 'I', 'I', 'L', 'l', 'lb', 'N', 'No', '(p)', 'P', 'P', 'Q', 'R', 'R', 'R', 'Rx', '', 0x20 => '(sm)', 'TEL', '(tm)', '', 'Z', '', 'O', 'mho', 'Z', '', 'K', 'A', 'B', 'C', 'e', 'e', @@ -22,4 +22,4 @@ 0xD0 => '=', '|', '=', '|', '=', '|', '\\', '/', '\\', '/', '=', '=', '~', '~', '|', '|', 0xE0 => '-', '|', '-', '|', '-', '-', '-', '|', '-', '|', '|', '|', '|', '|', '|', '|', 0xF0 => '-', '\\', '\\', '|', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x22.php b/core/lib/Drupal/Component/Transliteration/data/x22.php index e346ffb..fa28978 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x22.php +++ b/core/lib/Drupal/Component/Transliteration/data/x22.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x10 => NULL, NULL, '-', NULL, NULL, '/', '\\', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x20 => NULL, NULL, NULL, '|', '|', '||', '||', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x23.php b/core/lib/Drupal/Component/Transliteration/data/x23.php index 3cef84f..e38c438 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x23.php +++ b/core/lib/Drupal/Component/Transliteration/data/x23.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '<', '>', NULL, NULL, NULL, NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x24.php b/core/lib/Drupal/Component/Transliteration/data/x24.php index 3e7b33b..17ffeee 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x24.php +++ b/core/lib/Drupal/Component/Transliteration/data/x24.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0x10 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0x20 => '', '', '', '', '', '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0xE0 => '', '', '', '', '', '', '', '', '', '', '', NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x25.php b/core/lib/Drupal/Component/Transliteration/data/x25.php index 786bfce..b24b056 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x25.php +++ b/core/lib/Drupal/Component/Transliteration/data/x25.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => '-', '-', '|', '|', '-', '-', '|', '|', '-', '-', '|', '|', '+', '+', '+', '+', 0x10 => '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', 0x20 => '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', '+', @@ -22,4 +22,4 @@ 0xD0 => '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', '*', 0xE0 => '*', '*', '*', '*', '*', '*', '*', '#', '#', '#', '#', '#', '^', '^', '^', 'O', 0xF0 => '#', '#', '#', '#', '#', '#', '#', '#', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x26.php b/core/lib/Drupal/Component/Transliteration/data/x26.php index c7dc406..3ef34ee 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x26.php +++ b/core/lib/Drupal/Component/Transliteration/data/x26.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0x10 => '', '', '', '', NULL, NULL, NULL, NULL, NULL, '', '', '', '', '', '', '', 0x20 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x27.php b/core/lib/Drupal/Component/Transliteration/data/x27.php index 9c001d2..f067a78 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x27.php +++ b/core/lib/Drupal/Component/Transliteration/data/x27.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0x10 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0x20 => '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x28.php b/core/lib/Drupal/Component/Transliteration/data/x28.php index 456f8e4..ce1789d 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x28.php +++ b/core/lib/Drupal/Component/Transliteration/data/x28.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => ' ', 'a', '1', 'b', '\'', 'k', '2', 'l', '@', 'c', 'i', 'f', '/', 'm', 's', 'p', 0x10 => '"', 'e', '3', 'h', '9', 'o', '6', 'r', '^', 'd', 'j', 'g', '>', 'n', 't', 'q', 0x20 => ',', '*', '5', '<', '-', 'u', '8', 'v', '.', '%', '[', '$', '+', 'x', '!', '&', @@ -22,4 +22,4 @@ 0xD0 => '[d578]', '[d1578]', '[d2578]', '[d12578]', '[d3578]', '[d13578]', '[d23578]', '[d123578]', '[d4578]', '[d14578]', '[d24578]', '[d124578]', '[d34578]', '[d134578]', '[d234578]', '[d1234578]', 0xE0 => '[d678]', '[d1678]', '[d2678]', '[d12678]', '[d3678]', '[d13678]', '[d23678]', '[d123678]', '[d4678]', '[d14678]', '[d24678]', '[d124678]', '[d34678]', '[d134678]', '[d234678]', '[d1234678]', 0xF0 => '[d5678]', '[d15678]', '[d25678]', '[d125678]', '[d35678]', '[d135678]', '[d235678]', '[d1235678]', '[d45678]', '[d145678]', '[d245678]', '[d1245678]', '[d345678]', '[d1345678]', '[d2345678]', '[d12345678]', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x29.php b/core/lib/Drupal/Component/Transliteration/data/x29.php index 98390e6..cd18ef9 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x29.php +++ b/core/lib/Drupal/Component/Transliteration/data/x29.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x2a.php b/core/lib/Drupal/Component/Transliteration/data/x2a.php index 93349c5..24013a3 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x2a.php +++ b/core/lib/Drupal/Component/Transliteration/data/x2a.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x2e.php b/core/lib/Drupal/Component/Transliteration/data/x2e.php index f9b3b33..e62f56a 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x2e.php +++ b/core/lib/Drupal/Component/Transliteration/data/x2e.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x10 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x20 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => 'jin', 'chang', 'chang', 'zhang', 'men', NULL, 'fu', 'yu', 'qing', 'wei', 'ye', 'feng', 'fei', 'shi', NULL, 'shi', 0xE0 => 'shi', NULL, 'ma', 'gu', 'gui', 'yu', 'niao', 'lu', 'mai', 'huang', 'mian', 'qi', 'qi', 'chi', 'chi', 'long', 0xF0 => 'long', 'gui', 'gui', 'gui', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x2f.php b/core/lib/Drupal/Component/Transliteration/data/x2f.php index a5e7029..ecf6f0b 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x2f.php +++ b/core/lib/Drupal/Component/Transliteration/data/x2f.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'yi', 'gun', 'zhu', 'pie', 'yi', 'jue', 'er', 'tou', 'ren', 'er', 'ru', 'ba', 'jiong', 'mi', 'bing', 'ji', 0x10 => 'qian', 'dao', 'li', 'bao', 'bi', 'fang', 'xi', 'shi', 'bo', 'jie', 'chang', 'si', 'you', 'kou', 'wei', 'tu', 0x20 => 'shi', 'zhi', 'sui', 'xi', 'da', 'nu', 'zi', 'mian', 'cun', 'xiao', 'you', 'shi', 'che', 'shan', 'chuan', 'gong', @@ -22,4 +22,4 @@ 0xD0 => 'bi', 'qi', 'chi', 'long', 'gui', 'yue', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x30.php b/core/lib/Drupal/Component/Transliteration/data/x30.php index c92c0a6..3fe8567 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x30.php +++ b/core/lib/Drupal/Component/Transliteration/data/x30.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => ' ', ',', '.', '"', '[JIS]', '"', '/', 'ling', '<', '>', '<<', '>>', '[', '] ', '{', '} ', 0x10 => '[(', ')] ', '@', 'X ', '[', ']', '[[', ']] ', '[', ']', '[', ']', '~ ', '"', '"', ',,', 0x20 => '@', '1', '2', '3', '4', '5', '6', '7', '8', '9', '', '', '', '', '', '', @@ -22,4 +22,4 @@ 0xD0 => 'ha', 'ha', 'hi', 'hi', 'hi', 'fu', 'fu', 'fu', 'he', 'he', 'he', 'ho', 'ho', 'ho', 'ma', 'mi', 0xE0 => 'mu', 'me', 'mo', '~ya', 'ya', '~yu', 'yu', '~yo', 'yo', 'ra', 'ri', 'ru', 're', 'ro', '~wa', 'wa', 0xF0 => 'wi', 'we', 'wo', 'n', 'u', '~ka', '~ke', 'wa', 'wi', 'we', 'wo', '', '', '"', '"', NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x31.php b/core/lib/Drupal/Component/Transliteration/data/x31.php index 95b59f4..59cedde 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x31.php +++ b/core/lib/Drupal/Component/Transliteration/data/x31.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, NULL, NULL, NULL, 'b', 'p', 'm1', 'f', 'd', 't', 'n1', 'l', 'g', 'k', 'h', 0x10 => 'j', 'q', 'x', 'zhi1', 'chi1', 'shi1', 'ri1', 'zi1', 'ci1', 'si1', 'a1', 'o1', 'e1', 'eh1', 'ai1', 'ei1', 0x20 => 'ao1', 'ou1', 'an1', 'en1', 'ang1', 'eng1', 'er1', 'yi1', 'wu1', 'yu1', 'V', 'NG', 'GN', NULL, NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x32.php b/core/lib/Drupal/Component/Transliteration/data/x32.php index 25cc5f3..20ffe76 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x32.php +++ b/core/lib/Drupal/Component/Transliteration/data/x32.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => '(g)', '(n)', '(d)', '(l)', '(m)', '(b)', '(s)', '()', '(j)', '(ch)', '(k)', '(t)', '(p)', '(h)', '(ga)', '(na)', 0x10 => '(da)', '(la)', '(ma)', '(ba)', '(sa)', '(a)', '(ja)', '(cha)', '(ka)', '(ta)', '(pa)', '(ha)', '(ju)', NULL, NULL, NULL, 0x20 => '(1) ', '(2) ', '(3) ', '(4) ', '(5) ', '(6) ', '(7) ', '(8) ', '(9) ', '(10) ', '(Yue) ', '(Huo) ', '(Shui) ', '(Mu) ', '(Jin) ', '(Tu) ', @@ -22,4 +22,4 @@ 0xD0 => 'a', 'i', 'u', 'u', 'o', 'ka', 'ki', 'ku', 'ke', 'ko', 'sa', 'si', 'su', 'se', 'so', 'ta', 0xE0 => 'ti', 'tu', 'te', 'to', 'na', 'ni', 'nu', 'ne', 'no', 'ha', 'hi', 'hu', 'he', 'ho', 'ma', 'mi', 0xF0 => 'mu', 'me', 'mo', 'ya', 'yu', 'yo', 'ra', 'ri', 'ru', 're', 'ro', 'wa', 'wi', 'we', 'wo', NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x33.php b/core/lib/Drupal/Component/Transliteration/data/x33.php index 8094290..9eae128 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x33.php +++ b/core/lib/Drupal/Component/Transliteration/data/x33.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'apartment', 'alpha', 'ampere', 'are', 'inning', 'inch', 'won', 'escudo', 'acre', 'ounce', 'ohm', 'kai-ri', 'carat', 'calorie', 'gallon', 'gamma', 0x10 => 'giga', 'guinea', 'curie', 'guilder', 'kilo', 'kilogram', 'kilometer', 'kilowatt', 'gram', 'gram ton', 'cruzeiro', 'krone', 'case', 'koruna', 'co-op', 'cycle', 0x20 => 'centime', 'shilling', 'centi', 'cent', 'dozen', 'desi', 'dollar', 'ton', 'nano', 'knot', 'heights', 'percent', 'parts', 'barrel', 'piaster', 'picul', @@ -22,4 +22,4 @@ 0xD0 => 'lm', 'ln', 'log', 'lx', 'mb', 'mil', 'mol', 'pH', 'p.m.', 'PPM', 'PR', 'sr', 'Sv', 'Wb', 'V/m', 'A/m', 0xE0 => '1d', '2d', '3d', '4d', '5d', '6d', '7d', '8d', '9d', '10d', '11d', '12d', '13d', '14d', '15d', '16d', 0xF0 => '17d', '18d', '19d', '20d', '21d', '22d', '23d', '24d', '25d', '26d', '27d', '28d', '29d', '30d', '31d', NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x34.php b/core/lib/Drupal/Component/Transliteration/data/x34.php index 1281649..ef4dcea 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x34.php +++ b/core/lib/Drupal/Component/Transliteration/data/x34.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'qiu', 'tian', NULL, NULL, 'kua', 'wu', 'yin', NULL, NULL, NULL, NULL, NULL, 'yi', NULL, NULL, NULL, 0x10 => NULL, NULL, NULL, NULL, NULL, NULL, 'xie', NULL, NULL, NULL, NULL, NULL, 'chou', NULL, NULL, NULL, 0x20 => NULL, 'nuo', NULL, NULL, 'dan', NULL, NULL, NULL, 'xu', 'xing', NULL, 'xiong', 'liu', 'lin', 'xiang', 'yong', @@ -22,4 +22,4 @@ 0xD0 => 'lu', 'xing', NULL, 'nan', 'xie', NULL, 'bi', 'jie', 'su', NULL, 'gong', NULL, 'you', 'xing', 'qia', 'pi', 0xE0 => 'dian', 'fu', 'luo', 'qia', 'qia', 'tang', 'bai', 'gan', 'ci', 'xuan', 'lang', NULL, NULL, 'she', NULL, 'li', 0xF0 => 'hua', 'tou', 'pian', 'di', 'ruan', 'e', 'qie', 'yi', 'zhuo', 'rui', 'jian', NULL, 'chi', 'chong', 'xi', NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x35.php b/core/lib/Drupal/Component/Transliteration/data/x35.php index 08b6f5d..e3e0b88 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x35.php +++ b/core/lib/Drupal/Component/Transliteration/data/x35.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'lue', 'deng', 'lin', 'jue', 'su', 'xiao', 'zan', NULL, NULL, 'zhu', 'zhan', 'jian', 'zou', 'chua', 'xie', 'li', 0x10 => NULL, 'chi', 'xi', 'jian', NULL, 'ji', NULL, 'fei', 'chu', 'beng', 'jie', NULL, 'ba', 'liang', 'kuai', NULL, 0x20 => 'xia', 'bie', 'jue', 'lei', 'xin', 'bai', 'yang', 'lu', 'bei', 'e', 'lu', NULL, NULL, 'che', 'nuo', 'xuan', @@ -22,4 +22,4 @@ 0xD0 => NULL, 'bai', 'ai', 'zhui', 'qian', 'gou', 'dan', 'bei', 'bo', 'chu', 'li', 'xiao', 'xiu', NULL, NULL, NULL, 0xE0 => NULL, NULL, 'hong', 'ti', 'cu', 'kuo', 'lao', 'zhi', 'xie', 'xi', NULL, 'qie', 'zha', 'xi', NULL, NULL, 0xF0 => 'cong', 'ji', 'huo', 'ta', 'yan', 'xu', 'po', 'sai', NULL, NULL, NULL, 'guo', 'ye', 'xiang', 'xue', 'he', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x36.php b/core/lib/Drupal/Component/Transliteration/data/x36.php index f015cbe..975949b 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x36.php +++ b/core/lib/Drupal/Component/Transliteration/data/x36.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'zuo', 'yi', 'ci', NULL, 'leng', 'xian', 'tai', 'rong', 'yi', 'zhi', 'xi', 'xian', 'ju', 'ji', 'han', NULL, 0x10 => 'pao', 'li', NULL, 'lan', 'sai', 'han', 'yan', 'qu', NULL, 'yan', 'han', 'kan', 'chi', 'nie', 'huo', NULL, 0x20 => 'bi', 'xia', 'weng', 'xuan', 'wan', 'you', 'qin', 'xu', 'nie', 'bi', 'hao', 'jing', 'ao', 'ao', NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => 'sou', 'can', 'dou', 'xi', 'feng', 'yi', 'suo', 'qie', 'po', 'xin', 'tong', 'xin', 'you', 'bei', 'long', NULL, 0xE0 => NULL, NULL, NULL, 'yun', 'li', 'ta', 'lan', 'man', 'qiang', 'zhou', 'yan', 'xi', 'lu', 'xi', 'sao', 'fan', 0xF0 => NULL, 'wei', 'fa', 'yi', 'nao', 'cheng', 'tan', 'ji', 'shu', 'pian', 'an', 'kua', 'cha', NULL, 'xian', 'zhi', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x37.php b/core/lib/Drupal/Component/Transliteration/data/x37.php index b3a9b7c..f584aea 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x37.php +++ b/core/lib/Drupal/Component/Transliteration/data/x37.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, 'feng', 'lian', 'xun', 'xu', 'mi', 'hui', 'mu', 'yong', 'zhan', 'yi', 'nou', 'tang', 'xi', 'yun', 0x10 => 'shu', 'fu', 'yi', 'da', NULL, 'lian', 'cao', 'can', 'ju', 'lu', 'su', 'nen', 'ao', 'an', 'qian', NULL, 0x20 => 'cui', 'cong', NULL, 'ran', 'nian', 'mai', 'xin', 'yue', 'nai', 'ao', 'shen', 'ma', NULL, NULL, 'lan', 'xi', @@ -22,4 +22,4 @@ 0xD0 => 'mang', 'bo', 'qun', 'qi', 'han', NULL, 'long', NULL, 'tiao', 'ze', 'qi', 'zan', 'mi', 'pei', 'zhan', 'xiang', 0xE0 => 'gang', NULL, 'qi', NULL, 'lu', NULL, 'yun', 'e', 'duan', 'min', 'wei', 'quan', 'sou', 'min', 'tu', NULL, 0xF0 => 'ming', 'yao', 'jue', 'li', 'kuai', 'gang', 'yuan', 'da', NULL, 'lao', 'lou', 'qian', 'ao', 'biao', 'yong', 'mang', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x38.php b/core/lib/Drupal/Component/Transliteration/data/x38.php index b807b9c..c175ad5 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x38.php +++ b/core/lib/Drupal/Component/Transliteration/data/x38.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'dao', NULL, 'ao', NULL, 'xi', 'fu', 'dan', 'jiu', 'run', 'tong', 'qu', 'e', 'qi', 'ji', 'ji', 'hua', 0x10 => 'jiao', 'zui', 'biao', 'meng', 'bai', 'wei', 'yi', 'ao', 'yu', 'hao', 'dui', 'wo', 'ni', 'cuan', NULL, 'li', 0x20 => 'lu', 'niao', 'huai', 'li', NULL, 'lu', 'feng', 'mi', 'yu', NULL, 'ju', NULL, NULL, 'zhan', 'peng', 'yi', @@ -22,4 +22,4 @@ 0xD0 => 'bian', 'rong', 'ceng', 'can', 'ding', NULL, NULL, NULL, NULL, 'di', 'tong', 'ta', 'xing', 'song', 'duo', 'xi', 0xE0 => 'tao', NULL, 'ti', 'shan', 'jian', 'zhi', 'wei', 'yin', NULL, NULL, 'huan', 'zhong', 'qi', 'zong', NULL, 'xie', 0xF0 => 'xie', 'ze', 'wei', NULL, NULL, 'ta', 'zhan', 'ning', NULL, NULL, NULL, 'yi', 'ren', 'shu', 'cha', 'zhuo', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x39.php b/core/lib/Drupal/Component/Transliteration/data/x39.php index d96877d..b550c1c 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x39.php +++ b/core/lib/Drupal/Component/Transliteration/data/x39.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, 'mian', 'ji', 'fang', 'pei', 'ai', 'fan', 'ao', 'qin', 'qia', 'xiao', 'fen', 'gan', 'qiao', 'ge', 'tong', 0x10 => 'chan', 'you', 'gao', 'ben', 'fu', 'chu', 'zhu', NULL, 'zhou', NULL, 'hang', 'nin', 'jue', 'chong', 'cha', 'kong', 0x20 => 'lie', 'li', 'yu', NULL, 'yu', 'hai', 'li', 'hou', 'gong', 'ke', 'yuan', 'de', 'hui', NULL, 'guang', 'jiong', @@ -22,4 +22,4 @@ 0xD0 => 'song', 'hui', 'yu', 'gua', 'guai', 'liu', 'e', 'zi', 'zi', 'bi', 'wa', NULL, 'lie', NULL, NULL, 'kuai', 0xE0 => NULL, 'hai', 'yin', 'zhu', 'chong', 'xian', 'xuan', NULL, 'qiu', 'pei', 'gui', 'er', 'gong', 'qiong', 'hu', 'lao', 0xF0 => 'li', 'chen', 'san', 'zhuo', 'wo', 'pou', 'keng', 'tun', 'peng', 'te', 'ta', 'zhuo', 'biao', 'gu', 'hu', NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x3a.php b/core/lib/Drupal/Component/Transliteration/data/x3a.php index e1ae1ad..dd38ed1 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x3a.php +++ b/core/lib/Drupal/Component/Transliteration/data/x3a.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'bing', 'zhi', 'dong', 'dui', 'zhou', 'nei', 'lin', 'po', 'ji', 'min', 'wei', 'che', 'gou', 'bang', 'ru', 'tan', 0x10 => 'bu', 'zong', 'kui', 'lao', 'han', 'ying', 'zhi', 'jie', 'xing', 'xie', 'xun', 'shan', 'qian', 'xie', 'su', 'hai', 0x20 => 'mi', 'hun', 'pi', NULL, 'hui', 'na', 'song', 'ben', 'chou', 'jie', 'huang', 'lan', NULL, 'hu', 'dou', 'huo', @@ -22,4 +22,4 @@ 0xD0 => 'yao', 'zhi', 'gong', 'qi', 'gen', NULL, NULL, 'hou', 'mi', 'fu', 'hu', 'guang', 'tan', 'di', NULL, 'yan', 0xE0 => NULL, NULL, 'qu', NULL, 'chang', 'ming', 'tao', 'bao', 'an', NULL, NULL, 'xian', NULL, NULL, NULL, 'mao', 0xF0 => 'lang', 'nan', 'bei', 'chen', NULL, 'fei', 'zhou', 'ji', 'jie', 'shu', NULL, 'kun', 'die', 'lu', NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x3b.php b/core/lib/Drupal/Component/Transliteration/data/x3b.php index 4ce0a1e..8fc526c 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x3b.php +++ b/core/lib/Drupal/Component/Transliteration/data/x3b.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, 'yu', 'tai', 'chan', 'man', 'min', 'huan', 'wen', 'nuan', 'huan', 'hou', 'jing', 'bo', 'xian', 'li', 0x10 => 'jin', NULL, 'mang', 'piao', 'hao', 'yang', NULL, 'xian', 'su', 'wei', 'che', 'xi', 'jin', 'ceng', 'he', 'fen', 0x20 => 'shai', 'ling', NULL, 'dui', 'qi', 'pu', 'yue', 'bo', NULL, 'hui', 'die', 'yan', 'ju', 'jiao', 'nan', 'lie', @@ -22,4 +22,4 @@ 0xD0 => 'fang', NULL, NULL, 'ta', 'cui', 'xi', 'de', 'xian', 'kuan', 'zhe', 'ta', 'hu', 'cui', 'lu', 'juan', 'lu', 0xE0 => 'qian', 'pao', 'zhen', NULL, 'li', 'cao', 'qi', NULL, NULL, 'ti', 'ling', 'qu', 'lian', 'lu', 'shu', 'gong', 0xF0 => 'zhe', 'pao', 'jin', 'qing', NULL, NULL, 'zong', 'pu', 'jin', 'biao', 'jian', 'gun', NULL, NULL, 'zao', 'lie', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x3c.php b/core/lib/Drupal/Component/Transliteration/data/x3c.php index 31267d9..c60d936 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x3c.php +++ b/core/lib/Drupal/Component/Transliteration/data/x3c.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'li', 'luo', 'shen', 'mian', 'jian', 'di', 'bei', NULL, 'lian', NULL, 'xian', 'pin', 'que', 'long', 'zui', NULL, 0x10 => 'jue', 'shan', 'xue', NULL, 'xie', NULL, 'lan', 'qi', 'yi', 'nuo', 'li', 'yue', NULL, 'yi', 'chi', 'ji', 0x20 => 'hang', 'xie', 'keng', 'zi', 'he', 'xi', 'qu', 'hai', 'xia', 'hai', 'gui', 'chan', 'xun', 'xu', 'shen', 'kou', @@ -22,4 +22,4 @@ 0xD0 => 'zha', 'yi', 'bian', NULL, 'dui', 'lan', 'yi', 'chai', 'chong', 'xuan', 'xu', 'yu', 'xiu', NULL, NULL, NULL, 0xE0 => 'ta', 'guo', NULL, NULL, NULL, 'long', 'xie', 'che', 'jian', 'tan', 'pi', 'zan', 'xuan', 'xian', 'niao', NULL, 0xF0 => NULL, NULL, NULL, NULL, 'mi', 'ji', 'nou', 'hu', 'hua', 'wang', 'you', 'ze', 'bi', 'mi', 'qiang', 'xie', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x3d.php b/core/lib/Drupal/Component/Transliteration/data/x3d.php index f83e669..78b3131 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x3d.php +++ b/core/lib/Drupal/Component/Transliteration/data/x3d.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'fan', 'yi', 'tan', 'lei', 'yong', NULL, 'jin', 'she', 'yin', 'ji', NULL, 'su', NULL, NULL, NULL, 'wang', 0x10 => 'mian', 'su', 'yi', 'shai', 'xi', 'ji', 'luo', 'you', 'mao', 'zha', 'sui', 'zhi', 'bian', 'li', NULL, NULL, 0x20 => NULL, NULL, NULL, NULL, NULL, 'qiao', 'guan', 'xi', 'zhen', 'yong', 'nie', 'jun', 'xie', 'yao', 'xie', 'zhi', @@ -22,4 +22,4 @@ 0xD0 => 'hui', NULL, 'yu', 'zong', 'yan', 'qiu', 'zhao', 'jiong', 'tai', NULL, NULL, NULL, NULL, NULL, NULL, 'tui', 0xE0 => 'lin', 'jiong', 'zha', 'xing', 'hu', NULL, 'xu', NULL, NULL, NULL, 'cui', 'qing', 'mo', NULL, 'zao', 'beng', 0xF0 => 'chi', NULL, NULL, 'yan', 'ge', 'mo', 'bei', 'juan', 'die', 'zhao', NULL, 'wu', 'yan', NULL, 'jue', 'xian', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x3e.php b/core/lib/Drupal/Component/Transliteration/data/x3e.php index 1c2e517..f4b1fd4 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x3e.php +++ b/core/lib/Drupal/Component/Transliteration/data/x3e.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'tai', 'han', NULL, 'dian', 'ji', 'jie', NULL, 'zuan', NULL, 'xie', 'lai', 'fan', 'huo', 'xi', 'nie', 'mi', 0x10 => 'ran', 'cuan', 'yin', 'mi', NULL, 'jue', 'qu', 'tong', 'wan', 'zhe', 'li', 'shao', 'kong', 'xian', 'zhe', 'zhi', 0x20 => 'tiao', 'shu', 'bei', 'ye', 'pian', 'chan', 'hu', 'ken', 'jiu', 'an', 'chun', 'qian', 'bei', 'ba', 'fen', 'ke', @@ -22,4 +22,4 @@ 0xD0 => NULL, 'ji', 'jun', 'zou', 'duo', 'jue', 'dai', 'bei', NULL, NULL, NULL, NULL, NULL, 'la', 'bin', 'sui', 0xE0 => 'tu', 'xue', NULL, NULL, NULL, NULL, NULL, 'duo', NULL, NULL, 'sui', 'bi', 'tu', 'se', 'can', 'tu', 0xF0 => 'mian', 'jin', 'lu', NULL, NULL, 'zhan', 'bi', 'ji', 'zen', 'xuan', 'li', NULL, NULL, 'sui', 'yong', 'shu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x3f.php b/core/lib/Drupal/Component/Transliteration/data/x3f.php index 7b60158..1d22728 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x3f.php +++ b/core/lib/Drupal/Component/Transliteration/data/x3f.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, 'e', NULL, NULL, NULL, NULL, 'qiong', 'luo', 'zhen', 'tun', 'gu', 'yu', 'lei', 'bo', 'nei', 0x10 => 'pian', 'lian', 'tang', 'lian', 'wen', 'dang', 'li', 'ting', 'wa', 'zhou', 'gang', 'xing', 'ang', 'fan', 'peng', 'bo', 0x20 => 'tuo', 'shu', 'yi', 'bo', 'qie', 'tou', 'gong', 'tong', 'han', 'cheng', 'jie', 'huan', 'xing', 'dian', 'chai', 'dong', @@ -22,4 +22,4 @@ 0xD0 => NULL, 'yao', 'dao', 'jia', 'lei', 'yan', 'lu', 'tui', 'ying', 'pi', 'luo', 'li', 'bie', NULL, 'mao', 'bai', 0xE0 => 'huang', NULL, 'yao', 'he', 'chun', 'he', 'ning', 'chou', 'li', 'tang', 'huan', 'bi', 'ba', 'che', 'yang', 'da', 0xF0 => 'ao', 'xue', NULL, 'zi', 'da', 'ran', 'bang', 'cuo', 'wan', 'ta', 'bao', 'gan', 'yan', 'xi', 'zhu', 'ya', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x40.php b/core/lib/Drupal/Component/Transliteration/data/x40.php index 9e7c307..ba952e9 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x40.php +++ b/core/lib/Drupal/Component/Transliteration/data/x40.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'fan', 'you', 'an', 'tui', 'meng', 'she', 'jin', 'gu', 'ji', 'qiao', 'jiao', 'yan', 'xi', 'kan', 'mian', 'xuan', 0x10 => 'shan', 'wo', 'qian', 'huan', 'ren', 'zhen', 'tian', 'jue', 'xie', 'qi', 'ang', 'mei', 'gu', NULL, 'tao', 'fan', 0x20 => 'ju', 'chan', 'shun', 'bi', 'mao', 'shuo', 'gu', 'hong', 'hua', 'luo', 'hang', 'jia', 'quan', 'gai', 'huang', 'bu', @@ -22,4 +22,4 @@ 0xD0 => NULL, 'ban', 'he', 'gou', 'hong', 'lao', 'wu', 'bo', 'keng', 'lu', 'cu', 'lian', 'yi', 'qiao', 'shu', NULL, 0xE0 => 'xuan', 'jin', 'qin', 'hui', 'su', 'chuang', 'dun', 'long', NULL, 'nao', 'tan', 'dan', 'wei', 'gan', 'da', 'li', 0xF0 => 'ca', 'xian', 'pan', 'la', 'zhu', 'niao', 'huai', 'ying', 'xian', 'lan', 'mo', 'ba', NULL, 'gui', 'bi', 'fu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x41.php b/core/lib/Drupal/Component/Transliteration/data/x41.php index f32b7e5..bb33c8b 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x41.php +++ b/core/lib/Drupal/Component/Transliteration/data/x41.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'huo', 'yi', 'liu', NULL, 'yin', 'juan', 'huo', 'cheng', 'dou', 'e', NULL, 'yan', 'zhui', 'zha', 'qi', 'yu', 0x10 => 'quan', 'huo', 'nie', 'huang', 'ju', 'she', NULL, NULL, 'peng', 'ming', 'cao', 'lou', 'li', 'chuang', NULL, 'cui', 0x20 => 'shan', 'dan', 'qi', NULL, 'lai', 'ling', 'liao', 'reng', 'yu', 'yi', 'diao', 'qi', 'yi', 'nian', 'fu', 'jian', @@ -22,4 +22,4 @@ 0xD0 => 'li', 'ba', 'jie', 'xu', 'luo', NULL, 'yun', 'zhong', 'hu', 'yin', NULL, 'zhi', 'qian', NULL, 'gan', 'jian', 0xE0 => 'zhu', 'zhu', 'ku', 'nie', 'rui', 'ze', 'ang', 'zhi', 'gong', 'yi', 'chi', 'ji', 'zhu', 'lao', 'ren', 'rong', 0xF0 => 'zheng', 'na', 'ce', NULL, NULL, 'yi', 'jue', 'bie', 'cheng', 'jun', 'dou', 'wei', 'yi', 'zhe', 'yan', NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x42.php b/core/lib/Drupal/Component/Transliteration/data/x42.php index 27e7338..d5043fc 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x42.php +++ b/core/lib/Drupal/Component/Transliteration/data/x42.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'san', 'lun', 'ping', 'zhao', 'han', 'yu', 'dai', 'zhao', 'fei', 'sha', 'ling', 'ta', 'qu', 'mang', 'ye', 'bao', 0x10 => 'gui', 'gua', 'nan', 'ge', NULL, 'shi', 'ke', 'suo', 'ci', 'zhou', 'tai', 'kuai', 'qin', 'xu', 'du', 'ce', 0x20 => 'huan', 'cong', 'sai', 'zheng', 'qian', 'jin', 'zong', 'wei', NULL, NULL, 'xi', 'na', 'pu', 'sou', 'ju', 'zhen', @@ -22,4 +22,4 @@ 0xD0 => 'yue', 'lie', NULL, 'zhou', 'bi', 'ren', 'yu', NULL, 'chuo', 'er', 'yi', 'mi', 'qing', NULL, 'wang', 'ji', 0xE0 => 'bu', NULL, 'bie', 'fan', 'yue', 'li', 'fan', 'qu', 'fu', 'er', 'e', 'zheng', 'tian', 'yu', 'jin', 'qi', 0xF0 => 'ju', 'lai', 'che', 'bei', 'niu', 'yi', 'xu', 'mou', 'xun', 'fu', NULL, 'nin', 'ting', 'beng', 'zha', 'wei', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x43.php b/core/lib/Drupal/Component/Transliteration/data/x43.php index 8291d9d..81efa7d 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x43.php +++ b/core/lib/Drupal/Component/Transliteration/data/x43.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ke', 'yao', 'ou', 'xiao', 'geng', 'tang', 'gui', 'hui', 'ta', NULL, 'yao', 'da', 'qi', 'jin', 'lue', 'mi', 0x10 => 'mi', 'jian', 'lu', 'fan', 'ou', 'mi', 'jie', 'fu', 'bie', 'huang', 'su', 'yao', 'nie', 'jin', 'lian', 'bo', 0x20 => 'jian', 'ti', 'ling', 'zuan', 'shi', 'yin', 'dao', 'chou', 'ca', 'mie', 'yan', 'lan', 'chong', 'jiao', 'shuang', 'quan', @@ -22,4 +22,4 @@ 0xD0 => 'jue', 'di', 'pian', 'guan', 'niu', 'ren', 'zhen', 'gai', 'pi', 'tan', 'chao', 'chun', 'he', 'zhuan', 'mo', 'bie', 0xE0 => 'qi', 'shi', 'bi', 'jue', 'si', NULL, 'gua', 'na', 'hui', 'xi', 'er', 'xiu', 'mou', NULL, 'xi', 'zhi', 0xF0 => 'run', 'ju', 'die', 'zhe', 'shao', 'meng', 'bi', 'han', 'yu', 'xian', 'pang', 'neng', 'can', 'bu', NULL, 'qi', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x44.php b/core/lib/Drupal/Component/Transliteration/data/x44.php index af44abb..8bbb726 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x44.php +++ b/core/lib/Drupal/Component/Transliteration/data/x44.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ji', 'zhuo', 'lu', 'jun', 'xian', 'xi', 'cai', 'wen', 'zhi', 'zi', 'kun', 'cong', 'tian', 'chu', 'di', 'chun', 0x10 => 'qiu', 'zhe', 'zha', 'rou', 'bin', 'ji', 'xi', 'zhu', 'jue', 'ge', 'ji', 'da', 'chen', 'suo', 'ruo', 'xiang', 0x20 => 'huang', 'qi', 'zhu', 'sun', 'chai', 'weng', 'ke', 'kao', 'gu', 'gai', 'fan', 'cong', 'cao', 'zhi', 'chan', 'lei', @@ -22,4 +22,4 @@ 0xD0 => 'chun', 'ping', 'kuai', 'chou', NULL, 'tuo', 'qiong', 'cong', 'gao', 'kua', 'qu', 'qu', 'zhi', 'meng', 'li', 'zhou', 0xE0 => 'ta', 'zhi', 'gu', 'liang', 'hu', 'la', 'dian', 'ci', 'ying', NULL, NULL, 'qi', NULL, 'cha', 'mao', 'du', 0xF0 => 'yin', 'chai', 'rui', 'hen', 'ruan', 'fu', 'lai', 'xing', 'jian', 'yi', 'mei', NULL, 'mang', 'ji', 'suo', 'han', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x45.php b/core/lib/Drupal/Component/Transliteration/data/x45.php index 0ba25ac..88a0b27 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x45.php +++ b/core/lib/Drupal/Component/Transliteration/data/x45.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, 'li', 'zi', 'zu', 'yao', 'ge', 'li', 'qi', 'gong', 'li', 'bing', 'suo', NULL, NULL, 'su', 'chou', 0x10 => 'jian', 'xie', 'bei', 'xu', 'jing', 'pu', 'ling', 'xiang', 'zuo', 'diao', 'chun', 'qing', 'nan', 'zhai', 'lu', 'yi', 0x20 => 'shao', 'yu', 'hua', 'li', 'pa', NULL, NULL, 'li', NULL, NULL, 'shuang', NULL, 'yi', 'ning', 'si', 'ku', @@ -22,4 +22,4 @@ 0xD0 => 'shi', 'yi', 'bing', 'cong', 'hou', 'wan', 'di', 'ji', 'ge', 'han', 'bo', 'xiu', 'liu', 'can', 'can', 'yi', 0xE0 => 'xuan', 'yan', 'zao', 'han', 'yong', 'zong', NULL, 'kang', 'yu', 'qi', 'zhe', 'ma', NULL, NULL, 'shuang', 'jin', 0xF0 => 'guan', 'pu', 'lin', NULL, 'ting', 'jiang', 'la', 'yi', 'yong', 'ci', 'yan', 'jie', 'xun', 'wei', 'xian', 'ning', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x46.php b/core/lib/Drupal/Component/Transliteration/data/x46.php index 3311641..032f083 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x46.php +++ b/core/lib/Drupal/Component/Transliteration/data/x46.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'fu', 'ge', NULL, 'mo', 'zhu', 'nai', 'xian', 'wen', 'li', 'can', 'mie', 'jian', 'ni', 'chai', 'wan', 'xu', 0x10 => 'nu', 'mai', 'zui', 'kan', 'ka', 'hang', NULL, NULL, 'yu', 'wei', 'zhu', NULL, NULL, 'yi', NULL, 'diao', 0x20 => 'fu', 'bi', 'zhu', 'zi', 'shu', 'xia', 'ni', NULL, 'jiao', 'xun', 'chong', 'nou', 'rong', 'zhi', 'sang', NULL, @@ -22,4 +22,4 @@ 0xD0 => 'ci', 'mi', 'bian', NULL, 'na', 'yu', 'e', 'zhi', 'ren', 'xu', 'lue', 'hui', 'xun', 'nao', 'han', 'jia', 0xE0 => 'dou', 'hua', 'tu', 'ping', 'cu', 'xi', 'song', 'mi', 'xin', 'wu', 'qiong', 'zhang', 'tao', 'xing', 'jiu', 'ju', 0xF0 => 'hun', 'ti', 'man', 'yan', 'ji', 'shou', 'lei', 'wan', 'che', 'can', 'jie', 'you', 'hui', 'zha', 'su', 'ge', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x47.php b/core/lib/Drupal/Component/Transliteration/data/x47.php index 58a79c4..4981e9f 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x47.php +++ b/core/lib/Drupal/Component/Transliteration/data/x47.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'nao', 'xi', NULL, 'dui', 'chi', 'wei', 'zhe', 'gun', 'chao', 'chi', 'zao', 'hui', 'luan', 'liao', 'lao', 'tuo', 0x10 => 'hui', 'wu', 'ao', 'she', 'sui', 'mai', 'tan', 'xin', 'jing', 'an', 'ta', 'chan', 'wei', 'tuan', 'ji', 'chen', 0x20 => 'che', 'yu', 'xian', 'xin', NULL, NULL, NULL, 'nao', NULL, 'yan', 'qiu', 'jiang', 'song', 'jun', 'liao', 'ju', @@ -22,4 +22,4 @@ 0xD0 => 'li', 'yue', 'quan', 'cheng', 'fu', 'cha', 'tang', 'shi', 'hang', 'qie', 'qi', 'bo', 'na', 'tou', 'chu', 'cu', 0xE0 => 'yue', 'zhi', 'chen', 'chu', 'bi', 'meng', 'ba', 'tian', 'min', 'lie', 'feng', 'cheng', 'qiu', 'tiao', 'fu', 'kuo', 0xF0 => 'jian', NULL, NULL, NULL, 'zhen', 'qiu', 'zuo', 'chi', 'kui', 'lie', 'bei', 'du', 'wu', NULL, 'zhuo', 'lu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x48.php b/core/lib/Drupal/Component/Transliteration/data/x48.php index 668713d..c5ee78f 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x48.php +++ b/core/lib/Drupal/Component/Transliteration/data/x48.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'tang', NULL, 'chu', 'liang', 'tian', 'kun', 'chang', 'jue', 'tu', 'huan', 'fei', 'bi', NULL, 'xia', 'wo', 'ji', 0x10 => 'qu', 'kui', 'hu', 'qiu', 'sui', 'cai', NULL, 'qiu', 'pi', 'pang', 'wa', 'yao', 'rong', 'xun', 'cu', 'die', 0x20 => 'chi', 'cuo', 'meng', 'xuan', 'duo', 'bie', 'zhe', 'chu', 'chan', 'gui', 'duan', 'zou', 'deng', 'lai', 'teng', 'yue', @@ -22,4 +22,4 @@ 0xD0 => 'ying', 'chan', NULL, 'li', 'suo', 'ma', 'ma', NULL, 'tang', 'pei', 'lou', 'qi', 'cuo', 'tu', 'e', 'can', 0xE0 => 'jie', 'yi', 'ji', 'dang', 'jue', 'bi', 'lei', 'yi', 'chun', 'chun', 'po', 'li', 'zai', 'tai', 'po', 'cu', 0xF0 => 'ju', 'xu', 'fan', NULL, 'xu', 'er', 'huo', 'zhu', 'ran', 'fa', 'juan', 'han', 'liang', 'zhi', 'mi', 'yu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x49.php b/core/lib/Drupal/Component/Transliteration/data/x49.php index d9bde7a..75c9baf 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x49.php +++ b/core/lib/Drupal/Component/Transliteration/data/x49.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, 'cen', 'mei', 'yin', 'mian', 'tu', 'kui', NULL, NULL, 'mi', 'rong', 'yu', 'qiang', 'mi', 'ju', 'pi', 0x10 => 'jin', 'wang', 'ji', 'meng', 'jian', 'xue', 'bao', 'gan', 'chan', 'li', 'li', 'qiu', 'dun', 'ying', 'yun', 'chen', 0x20 => 'zhi', 'ran', NULL, 'lue', 'kai', 'gui', 'yue', 'hui', 'pi', 'cha', 'duo', 'chan', 'sha', 'shi', 'she', 'xing', @@ -22,4 +22,4 @@ 0xD0 => NULL, 'di', 'lai', 'zhou', 'nian', 'cheng', 'jian', 'bi', 'zhuan', 'ling', 'hao', 'bang', 'tang', 'chi', 'ma', 'xian', 0xE0 => 'shuan', 'yong', 'qu', NULL, 'pu', 'hui', 'wei', 'yi', 'ye', NULL, 'che', 'hao', 'bin', NULL, 'xian', 'chan', 0xF0 => 'hun', NULL, 'han', 'ci', 'zhi', 'qi', 'kui', 'rou', NULL, 'ying', 'xiong', NULL, 'hu', 'cui', NULL, 'que', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x4a.php b/core/lib/Drupal/Component/Transliteration/data/x4a.php index 60e658b..12d5aee 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x4a.php +++ b/core/lib/Drupal/Component/Transliteration/data/x4a.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'di', 'wu', 'qiu', NULL, 'yan', 'liao', 'bi', NULL, 'bin', NULL, 'yuan', 'nue', 'bao', 'ying', 'hong', 'ci', 0x10 => 'qia', 'ti', 'yu', 'lei', 'bao', NULL, 'ji', 'fu', 'xian', 'cen', 'hu', 'se', 'beng', 'qing', 'yu', 'wa', 0x20 => 'ai', 'han', 'dan', 'ge', 'di', 'huo', 'pang', NULL, 'zhui', 'ling', 'mai', 'mai', 'lian', 'xiao', 'xue', 'zhen', @@ -22,4 +22,4 @@ 0xD0 => 'lin', 'yi', 'men', 'wu', 'qi', 'die', 'chen', 'xia', 'he', 'sang', 'gua', 'hou', 'ao', 'fu', 'qiao', 'hun', 0xE0 => 'pi', 'yan', 'si', 'xi', 'ming', 'kui', 'ge', NULL, 'ao', 'san', 'shuang', 'lou', 'zhen', 'hui', 'chan', NULL, 0xF0 => 'lin', 'na', 'han', 'du', 'jin', 'mian', 'fan', 'e', 'chao', 'hong', 'hong', 'yu', 'xue', 'pao', 'bi', 'chao', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x4b.php b/core/lib/Drupal/Component/Transliteration/data/x4b.php index 625a880..8b542e0 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x4b.php +++ b/core/lib/Drupal/Component/Transliteration/data/x4b.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'you', 'yi', 'xue', 'sa', 'xu', 'li', 'li', 'yuan', 'dui', 'huo', 'sha', 'leng', 'pou', 'hu', 'guo', 'bu', 0x10 => 'rui', 'wei', 'sou', 'an', 'yu', 'xiang', 'heng', 'yang', 'xiao', 'yao', NULL, 'bi', NULL, 'heng', 'tao', 'liu', 0x20 => NULL, 'zhu', NULL, 'xi', 'zan', 'yi', 'dou', 'yuan', 'jiu', NULL, 'bo', 'ti', 'ying', NULL, 'yi', 'nian', @@ -22,4 +22,4 @@ 0xD0 => 'hai', 'kuang', 'heng', 'kui', 'ze', 'ting', 'lang', 'bi', 'huan', 'po', 'yao', 'wan', 'ti', 'sui', 'kua', 'dui', 0xE0 => 'ao', 'jian', 'mo', 'kui', 'kuai', 'an', 'ma', 'qing', 'qiao', NULL, 'kao', 'hao', 'duo', 'xian', 'nai', 'suo', 0xF0 => 'jie', 'pi', 'pa', 'song', 'chang', 'nie', 'man', 'song', 'ci', 'xian', 'kuo', NULL, 'di', 'pou', 'tiao', 'zu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x4c.php b/core/lib/Drupal/Component/Transliteration/data/x4c.php index aa1852c..38398a2 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x4c.php +++ b/core/lib/Drupal/Component/Transliteration/data/x4c.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'wo', 'fei', 'cai', 'peng', 'sai', NULL, 'rou', 'qi', 'cuo', 'pan', 'bo', 'man', 'zong', 'ci', 'kui', 'ji', 0x10 => 'lan', NULL, 'meng', 'mian', 'pan', 'lu', 'zuan', NULL, 'liu', 'yi', 'wen', 'li', 'li', 'zeng', 'zhu', 'hun', 0x20 => 'shen', 'chi', 'xing', 'wang', 'dong', 'huo', 'pi', 'hu', 'mei', 'che', 'mei', 'chao', 'ju', 'nou', NULL, 'yi', @@ -22,4 +22,4 @@ 0xD0 => 'ci', 'you', 'yuan', 'lao', 'ju', 'fu', 'nie', 'e', 'e', 'xing', 'kan', 'yan', 'tu', 'pou', 'beng', 'ming', 0xE0 => 'shui', 'yan', 'qi', 'yuan', 'bie', NULL, 'xuan', 'hou', 'huang', 'yao', 'juan', 'kui', 'e', 'ji', 'mo', 'chong', 0xF0 => 'bao', 'wu', 'zhen', 'xu', 'ta', 'chi', 'xi', 'cong', 'ma', 'kou', 'yan', 'can', NULL, 'he', 'deng', 'ran', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x4d.php b/core/lib/Drupal/Component/Transliteration/data/x4d.php index b77e988..fb9737f 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x4d.php +++ b/core/lib/Drupal/Component/Transliteration/data/x4d.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'tong', 'yu', 'xiang', 'nao', 'shun', 'fen', 'pu', 'ling', 'ao', 'huan', 'yi', 'huan', 'meng', 'ying', 'lei', 'yan', 0x10 => 'bao', 'die', 'ling', 'shi', 'jiao', 'lie', 'jing', 'ju', 'ti', 'pi', 'gang', 'xiao', 'wai', 'chuai', 'di', 'huan', 0x20 => 'yao', 'li', 'mi', 'hu', 'sheng', 'jia', 'yin', 'wei', NULL, 'piao', 'lu', 'ling', 'yi', 'cai', 'shan', 'hu', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x4e.php b/core/lib/Drupal/Component/Transliteration/data/x4e.php index 868c80d..1d83344 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x4e.php +++ b/core/lib/Drupal/Component/Transliteration/data/x4e.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'yi', 'ding', 'kao', 'qi', 'shang', 'xia', 'han', 'wan', 'zhang', 'san', 'shang', 'xia', 'ji', 'bu', 'yu', 'mian', 0x10 => 'gai', 'chou', 'chou', 'zhuan', 'qie', 'pi', 'shi', 'shi', 'qiu', 'bing', 'ye', 'cong', 'dong', 'si', 'cheng', 'diu', 0x20 => 'qiu', 'liang', 'diu', 'you', 'liang', 'yan', 'bing', 'sang', 'gun', 'jiu', 'ge', 'ya', 'qiang', 'zhong', 'ji', 'jie', @@ -22,4 +22,4 @@ 0xD0 => 'san', 'lun', 'bing', 'cang', 'zi', 'shi', 'ta', 'zhang', 'fu', 'xian', 'xian', 'tuo', 'hong', 'tong', 'ren', 'qian', 0xE0 => 'gan', 'ge', 'bo', 'dai', 'ling', 'yi', 'chao', 'chang', 'sa', 'shang', 'yi', 'mu', 'men', 'ren', 'jia', 'chao', 0xF0 => 'yang', 'qian', 'zhong', 'pi', 'wo', 'wu', 'jian', 'jia', 'yao', 'feng', 'cang', 'ren', 'wang', 'fen', 'di', 'fang', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x4f.php b/core/lib/Drupal/Component/Transliteration/data/x4f.php index 01144a5..ee4723b 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x4f.php +++ b/core/lib/Drupal/Component/Transliteration/data/x4f.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'zhong', 'qi', 'pei', 'yu', 'diao', 'dun', 'wu', 'yi', 'xin', 'kang', 'yi', 'ji', 'ai', 'wu', 'ji', 'fu', 0x10 => 'fa', 'xiu', 'jin', 'pi', 'dan', 'fu', 'tang', 'zhong', 'you', 'huo', 'hui', 'yu', 'cui', 'chuan', 'san', 'wei', 0x20 => 'chuan', 'che', 'ya', 'xian', 'shang', 'chang', 'lun', 'cang', 'xun', 'xin', 'wei', 'zhu', 'ze', 'xian', 'nu', 'bo', @@ -22,4 +22,4 @@ 0xD0 => 'li', 'yong', 'hun', 'jing', 'qian', 'san', 'pei', 'su', 'fu', 'xi', 'li', 'fu', 'ping', 'bao', 'yu', 'qi', 0xE0 => 'xia', 'xin', 'xiu', 'yu', 'di', 'che', 'chou', 'zhi', 'yan', 'lia', 'li', 'lai', 'si', 'jian', 'xiu', 'fu', 0xF0 => 'huo', 'ju', 'xiao', 'pai', 'jian', 'biao', 'chu', 'fei', 'feng', 'ya', 'an', 'bei', 'yu', 'xin', 'bi', 'hu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x50.php b/core/lib/Drupal/Component/Transliteration/data/x50.php index f3e3e53..1fd5d9d 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x50.php +++ b/core/lib/Drupal/Component/Transliteration/data/x50.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'chang', 'zhi', 'bing', 'jiu', 'yao', 'cui', 'lia', 'wan', 'lai', 'cang', 'zong', 'ge', 'guan', 'bei', 'tian', 'shu', 0x10 => 'shu', 'men', 'dao', 'tan', 'jue', 'chui', 'xing', 'peng', 'tang', 'hou', 'yi', 'qi', 'ti', 'gan', 'jing', 'jie', 0x20 => 'sui', 'chang', 'jie', 'fang', 'zhi', 'kong', 'juan', 'zong', 'ju', 'qian', 'ni', 'lun', 'zhuo', 'wo', 'luo', 'song', @@ -22,4 +22,4 @@ 0xD0 => 'shan', 'qiao', 'jiong', 'tui', 'zun', 'pu', 'xi', 'lao', 'chang', 'guang', 'liao', 'qi', 'cheng', 'chan', 'wei', 'ji', 0xE0 => 'bo', 'hui', 'chuan', 'tie', 'dan', 'jiao', 'jiu', 'seng', 'fen', 'xian', 'ju', 'e', 'jiao', 'jian', 'tong', 'lin', 0xF0 => 'bo', 'gu', 'xian', 'su', 'xian', 'jiang', 'min', 'ye', 'jin', 'jia', 'qiao', 'pi', 'feng', 'zhou', 'ai', 'sai', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x51.php b/core/lib/Drupal/Component/Transliteration/data/x51.php index 3f00d5a..f5ad008 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x51.php +++ b/core/lib/Drupal/Component/Transliteration/data/x51.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'yi', 'jun', 'nong', 'chan', 'yi', 'dang', 'jing', 'xuan', 'kuai', 'jian', 'chu', 'dan', 'jiao', 'sha', 'zai', 'can', 0x10 => 'bin', 'an', 'ru', 'tai', 'chou', 'chai', 'lan', 'ni', 'jin', 'qian', 'meng', 'wu', 'ning', 'qiong', 'ni', 'chang', 0x20 => 'lie', 'lei', 'lu', 'kuang', 'bao', 'yu', 'biao', 'zan', 'zhi', 'si', 'you', 'hao', 'chen', 'chen', 'li', 'teng', @@ -22,4 +22,4 @@ 0xD0 => 'yin', 'cou', 'yi', 'li', 'chuang', 'ming', 'zhun', 'cui', 'si', 'duo', 'jin', 'lin', 'lin', 'ning', 'xi', 'du', 0xE0 => 'ji', 'fan', 'fan', 'fan', 'feng', 'ju', 'chu', 'zheng', 'feng', 'mu', 'zhi', 'fu', 'feng', 'ping', 'feng', 'kai', 0xF0 => 'huang', 'kai', 'gan', 'deng', 'ping', 'qian', 'xiong', 'kuai', 'tu', 'ao', 'chu', 'ji', 'dang', 'han', 'han', 'zao', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x52.php b/core/lib/Drupal/Component/Transliteration/data/x52.php index c09eddd..a3df0ee 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x52.php +++ b/core/lib/Drupal/Component/Transliteration/data/x52.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'dao', 'diao', 'dao', 'ren', 'ren', 'chuang', 'fen', 'qie', 'yi', 'ji', 'kan', 'qian', 'cun', 'chu', 'wen', 'ji', 0x10 => 'dan', 'xing', 'hua', 'wan', 'jue', 'li', 'yue', 'lie', 'liu', 'ze', 'gang', 'chuang', 'fu', 'chu', 'qu', 'ju', 0x20 => 'shan', 'min', 'ling', 'zhong', 'pan', 'bie', 'jie', 'jie', 'pao', 'li', 'shan', 'bie', 'chan', 'jing', 'gua', 'geng', @@ -22,4 +22,4 @@ 0xD0 => 'meng', 'chi', 'lei', 'kai', 'mian', 'dong', 'xu', 'xu', 'kan', 'wu', 'yi', 'xun', 'weng', 'sheng', 'lao', 'mu', 0xE0 => 'lu', 'piao', 'shi', 'ji', 'qin', 'jiang', 'chao', 'quan', 'xiang', 'yi', 'jue', 'fan', 'juan', 'tong', 'ju', 'dan', 0xF0 => 'xie', 'mai', 'xun', 'xun', 'lu', 'li', 'che', 'rang', 'quan', 'bao', 'shao', 'yun', 'jiu', 'bao', 'gou', 'wu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x53.php b/core/lib/Drupal/Component/Transliteration/data/x53.php index 0af1ffc..bee5a96 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x53.php +++ b/core/lib/Drupal/Component/Transliteration/data/x53.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'yun', 'wen', 'bi', 'gai', 'gai', 'bao', 'cong', 'yi', 'xiong', 'peng', 'ju', 'tao', 'ge', 'pu', 'e', 'pao', 0x10 => 'fu', 'gong', 'da', 'jiu', 'qiong', 'bi', 'hua', 'bei', 'nao', 'shi', 'fang', 'jiu', 'yi', 'za', 'jiang', 'kang', 0x20 => 'jiang', 'kuang', 'hu', 'xia', 'qu', 'bian', 'gui', 'qie', 'zang', 'kuang', 'fei', 'hu', 'yu', 'gui', 'kui', 'hui', @@ -22,4 +22,4 @@ 0xD0 => 'ba', 'fa', 'ruo', 'shi', 'shu', 'zhuo', 'qu', 'shou', 'bian', 'xu', 'jia', 'pan', 'sou', 'gao', 'wei', 'sou', 0xE0 => 'die', 'rui', 'cong', 'kou', 'gu', 'ju', 'ling', 'gua', 'dao', 'kou', 'zhi', 'jiao', 'zhao', 'ba', 'ding', 'ke', 0xF0 => 'tai', 'chi', 'shi', 'you', 'qiu', 'po', 'ye', 'hao', 'si', 'tan', 'chi', 'le', 'diao', 'ji', 'liao', 'hong', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x54.php b/core/lib/Drupal/Component/Transliteration/data/x54.php index 85b0476..ae03398 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x54.php +++ b/core/lib/Drupal/Component/Transliteration/data/x54.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'mie', 'xu', 'mang', 'chi', 'ge', 'xuan', 'yao', 'zi', 'he', 'ji', 'diao', 'cun', 'tong', 'ming', 'hou', 'li', 0x10 => 'tu', 'xiang', 'zha', 'xia', 'ye', 'lu', 'ya', 'ma', 'ou', 'huo', 'yi', 'jun', 'chou', 'lin', 'tun', 'yin', 0x20 => 'fei', 'bi', 'qin', 'qin', 'jie', 'bu', 'fou', 'ba', 'dun', 'fen', 'e', 'han', 'ting', 'keng', 'shun', 'qi', @@ -22,4 +22,4 @@ 0xD0 => 'kuang', 'ya', 'da', 'xiao', 'bi', 'hui', 'nian', 'hua', 'xing', 'kuai', 'duo', 'fen', 'ji', 'nong', 'mou', 'yo', 0xE0 => 'hao', 'yuan', 'long', 'pou', 'mang', 'ge', 'o', 'chi', 'shao', 'li', 'na', 'zu', 'he', 'ku', 'xiao', 'xian', 0xF0 => 'lao', 'bo', 'zhe', 'zha', 'liang', 'ba', 'mie', 'lie', 'sui', 'fu', 'bu', 'han', 'heng', 'geng', 'shuo', 'ge', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x55.php b/core/lib/Drupal/Component/Transliteration/data/x55.php index 3f16ee5..af2d777 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x55.php +++ b/core/lib/Drupal/Component/Transliteration/data/x55.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'you', 'yan', 'gu', 'gu', 'bei', 'han', 'suo', 'chun', 'yi', 'ai', 'jia', 'tu', 'xian', 'wan', 'li', 'xi', 0x10 => 'tang', 'zuo', 'qiu', 'che', 'wu', 'zao', 'ya', 'dou', 'qi', 'di', 'qin', 'ma', 'mo', 'gong', 'dou', 'qu', 0x20 => 'lao', 'liang', 'suo', 'zao', 'huan', 'lang', 'sha', 'ji', 'zuo', 'wo', 'feng', 'jin', 'hu', 'qi', 'shou', 'wei', @@ -22,4 +22,4 @@ 0xD0 => 'hai', 'ke', 'da', 'sang', 'chen', 'ru', 'sou', 'wa', 'ji', 'pang', 'wu', 'qian', 'shi', 'ge', 'zi', 'jie', 0xE0 => 'luo', 'weng', 'wa', 'si', 'chi', 'hao', 'suo', 'Jia ', 'hai', 'suo', 'qin', 'nie', 'he', 'zhi', 'sai', 'n', 0xF0 => 'ge', 'na', 'dia', 'ai', 'qiang', 'tong', 'bi', 'ao', 'ao', 'lian', 'zui', 'zhe', 'mo', 'sou', 'sou', 'tan', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x56.php b/core/lib/Drupal/Component/Transliteration/data/x56.php index 8f34d3c..3d35d44 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x56.php +++ b/core/lib/Drupal/Component/Transliteration/data/x56.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'di', 'qi', 'jiao', 'chong', 'jiao', 'kai', 'tan', 'shan', 'cao', 'jia', 'ai', 'xiao', 'piao', 'lou', 'ga', 'gu', 0x10 => 'xiao', 'hu', 'hui', 'guo', 'ou', 'xian', 'ze', 'chang', 'xu', 'po', 'de', 'ma', 'ma', 'hu', 'lei', 'du', 0x20 => 'ga', 'tang', 'ye', 'beng', 'ying', 'sai', 'jiao', 'mi', 'xiao', 'hua', 'mai', 'ran', 'chuai', 'peng', 'lao', 'xiao', @@ -22,4 +22,4 @@ 0xD0 => 'za', 'zhu', 'lan', 'nie', 'nang', 'lan', 'lo', 'wei', 'hui', 'yin', 'qiu', 'si', 'nin', 'jian', 'hui', 'xin', 0xE0 => 'yin', 'nan', 'tuan', 'tuan', 'dun', 'kang', 'yuan', 'jiong', 'pian', 'yun', 'cong', 'hu', 'hui', 'yuan', 'e', 'guo', 0xF0 => 'kun', 'cong', 'tong', 'tu', 'wei', 'lun', 'guo', 'qun', 'ri', 'ling', 'gu', 'guo', 'tai', 'guo', 'tu', 'you', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x57.php b/core/lib/Drupal/Component/Transliteration/data/x57.php index 7983c7a..f337892 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x57.php +++ b/core/lib/Drupal/Component/Transliteration/data/x57.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'guo', 'yin', 'hun', 'pu', 'yu', 'han', 'yuan', 'lun', 'quan', 'yu', 'qing', 'guo', 'chuan', 'wei', 'yuan', 'quan', 0x10 => 'ku', 'fu', 'yuan', 'yuan', 'ya', 'tu', 'tu', 'tu', 'tuan', 'lue', 'hui', 'yi', 'huan', 'luan', 'luan', 'tu', 0x20 => 'ya', 'tu', 'ting', 'sheng', 'pu', 'lu', 'kuai', 'ya', 'zai', 'wei', 'ge', 'yu', 'wu', 'gui', 'pi', 'yi', @@ -22,4 +22,4 @@ 0xD0 => 'jin', 'zhe', 'lie', 'lie', 'bu', 'cheng', 'hua', 'bu', 'shi', 'xun', 'guo', 'jiong', 'ye', 'nian', 'di', 'yu', 0xE0 => 'bu', 'ya', 'quan', 'sui', 'pi', 'qing', 'wan', 'ju', 'lun', 'zheng', 'kong', 'chong', 'dong', 'dai', 'tan', 'an', 0xF0 => 'cai', 'chu', 'beng', 'kan', 'zhi', 'duo', 'yi', 'zhi', 'yi', 'pei', 'ji', 'zhun', 'qi', 'sao', 'ju', 'ni', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x58.php b/core/lib/Drupal/Component/Transliteration/data/x58.php index 73a217c..1e62555 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x58.php +++ b/core/lib/Drupal/Component/Transliteration/data/x58.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ku', 'ke', 'tang', 'kun', 'ni', 'jian', 'dui', 'jin', 'gang', 'yu', 'e', 'peng', 'gu', 'tu', 'leng', 'fang', 0x10 => 'ya', 'qian', 'kun', 'an', 'shen', 'duo', 'nao', 'tu', 'cheng', 'yin', 'hun', 'bi', 'lian', 'guo', 'die', 'zhuan', 0x20 => 'hou', 'bao', 'bao', 'yu', 'di', 'mao', 'jie', 'ruan', 'ye', 'geng', 'kan', 'zong', 'yu', 'huang', 'e', 'yao', @@ -22,4 +22,4 @@ 0xD0 => 'xi', 'he', 'ai', 'ya', 'dao', 'hao', 'ruan', 'jin', 'lei', 'kuang', 'lu', 'yan', 'tan', 'wei', 'huai', 'long', 0xE0 => 'long', 'rui', 'li', 'lin', 'rang', 'chan', 'xun', 'yan', 'lei', 'ba', 'wan', 'shi', 'ren', 'san', 'zhuang', 'zhuang', 0xF0 => 'sheng', 'yi', 'mai', 'ke', 'zhu', 'zhuang', 'hu', 'hu', 'kun', 'yi', 'hu', 'xu', 'kun', 'shou', 'mang', 'zun', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x59.php b/core/lib/Drupal/Component/Transliteration/data/x59.php index 5755e53..5df464c 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x59.php +++ b/core/lib/Drupal/Component/Transliteration/data/x59.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'shou', 'yi', 'zhi', 'gu', 'chu', 'jiang', 'feng', 'bei', 'zhai', 'bian', 'sui', 'qun', 'ling', 'fu', 'cuo', 'xia', 0x10 => 'xiong', 'xie', 'nao', 'xia', 'kui', 'xi', 'wai', 'yuan', 'mao', 'su', 'duo', 'duo', 'ye', 'qing', 'wai', 'gou', 0x20 => 'gou', 'qi', 'meng', 'meng', 'yin', 'huo', 'chen', 'da', 'ze', 'tian', 'tai', 'fu', 'guai', 'yao', 'yang', 'hang', @@ -22,4 +22,4 @@ 0xD0 => 'jie', 'gu', 'si', 'xing', 'wei', 'zi', 'ju', 'shan', 'pin', 'ren', 'yao', 'dong', 'jiang', 'shu', 'ji', 'gai', 0xE0 => 'xiang', 'hua', 'juan', 'jiao', 'gou', 'lao', 'jian', 'jian', 'yi', 'nian', 'zhi', 'ji', 'ji', 'xian', 'heng', 'guang', 0xF0 => 'jun', 'kua', 'yan', 'ming', 'lie', 'pei', 'e', 'you', 'yan', 'cha', 'shen', 'yin', 'shi', 'gui', 'quan', 'zi', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x5a.php b/core/lib/Drupal/Component/Transliteration/data/x5a.php index 306fce9..49b18ae 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x5a.php +++ b/core/lib/Drupal/Component/Transliteration/data/x5a.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'song', 'wei', 'hong', 'wa', 'lou', 'ya', 'rao', 'jiao', 'luan', 'ping', 'xian', 'shao', 'li', 'cheng', 'xie', 'mang', 0x10 => 'fu', 'suo', 'mei', 'wei', 'ke', 'chuo', 'chuo', 'ting', 'niang', 'xing', 'nan', 'yu', 'na', 'pou', 'nei', 'juan', 0x20 => 'shen', 'zhi', 'han', 'di', 'zhuang', 'e', 'pin', 'tui', 'xian', 'mian', 'wu', 'yan', 'wu', 'ai', 'yan', 'yu', @@ -22,4 +22,4 @@ 0xD0 => 'nao', 'bao', 'ai', 'pi', 'pin', 'yi', 'piao', 'yu', 'lei', 'xuan', 'man', 'yi', 'zhang', 'kang', 'yong', 'ni', 0xE0 => 'li', 'di', 'gui', 'yan', 'jin', 'zhuan', 'chang', 'ze', 'han', 'nen', 'lao', 'mo', 'zhe', 'hu', 'hu', 'ao', 0xF0 => 'nen', 'qiang', 'ma', 'pie', 'gu', 'wu', 'qiao', 'tuo', 'zhan', 'mao', 'xian', 'xian', 'mo', 'liao', 'lian', 'hua', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x5b.php b/core/lib/Drupal/Component/Transliteration/data/x5b.php index 8f6c4ad..0c6a1b4 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x5b.php +++ b/core/lib/Drupal/Component/Transliteration/data/x5b.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'gui', 'deng', 'zhi', 'xu', 'yi', 'hua', 'xi', 'kui', 'rao', 'xi', 'yan', 'chan', 'jiao', 'mei', 'fan', 'fan', 0x10 => 'xian', 'yi', 'hui', 'jiao', 'fu', 'shi', 'bi', 'shan', 'sui', 'qiang', 'lian', 'huan', 'xin', 'niao', 'dong', 'yi', 0x20 => 'can', 'ai', 'niang', 'ning', 'ma', 'tiao', 'chou', 'jin', 'ci', 'yu', 'pin', 'rong', 'ru', 'nai', 'yan', 'tai', @@ -22,4 +22,4 @@ 0xD0 => 'mei', 'qin', 'han', 'yu', 'shi', 'ning', 'jin', 'ning', 'zhi', 'yu', 'bao', 'kuan', 'ning', 'qin', 'mo', 'cha', 0xE0 => 'ju', 'gua', 'qin', 'hu', 'wu', 'liao', 'shi', 'ning', 'zhai', 'shen', 'wei', 'xie', 'kuan', 'hui', 'liao', 'jun', 0xF0 => 'huan', 'yi', 'yi', 'bao', 'qin', 'chong', 'bao', 'feng', 'cun', 'dui', 'si', 'xun', 'dao', 'lu', 'dui', 'shou', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x5c.php b/core/lib/Drupal/Component/Transliteration/data/x5c.php index a4173f2..fd28352 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x5c.php +++ b/core/lib/Drupal/Component/Transliteration/data/x5c.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'po', 'feng', 'zhuan', 'fu', 'she', 'ke', 'jiang', 'jiang', 'zhuan', 'wei', 'zun', 'xun', 'shu', 'dui', 'dao', 'xiao', 0x10 => 'jie', 'shao', 'er', 'er', 'er', 'ga', 'jian', 'shu', 'chen', 'shang', 'shang', 'mo', 'ga', 'chang', 'liao', 'xian', 0x20 => 'xian', 'kun', 'you', 'wang', 'you', 'liao', 'liao', 'yao', 'mang', 'wang', 'wang', 'wang', 'ga', 'yao', 'duo', 'kui', @@ -22,4 +22,4 @@ 0xD0 => 'gai', 'quan', 'dong', 'yi', 'mu', 'shi', 'an', 'wei', 'huan', 'zhi', 'mi', 'li', 'ji', 'tong', 'wei', 'you', 0xE0 => 'gu', 'xia', 'li', 'yao', 'jiao', 'zheng', 'luan', 'jiao', 'e', 'e', 'yu', 'xie', 'bu', 'qiao', 'qun', 'feng', 0xF0 => 'feng', 'nao', 'li', 'you', 'xian', 'hong', 'dao', 'shen', 'cheng', 'tu', 'geng', 'jun', 'hao', 'xia', 'yin', 'yu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x5d.php b/core/lib/Drupal/Component/Transliteration/data/x5d.php index f6e5415..bfa89e1 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x5d.php +++ b/core/lib/Drupal/Component/Transliteration/data/x5d.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'lang', 'kan', 'lao', 'lai', 'xian', 'que', 'kong', 'chong', 'chong', 'ta', 'lin', 'hua', 'ju', 'lai', 'qi', 'min', 0x10 => 'kun', 'kun', 'zu', 'gu', 'cui', 'ya', 'ya', 'gang', 'lun', 'lun', 'leng', 'jue', 'duo', 'zheng', 'guo', 'yin', 0x20 => 'dong', 'han', 'zheng', 'wei', 'xiao', 'pi', 'yan', 'song', 'jie', 'beng', 'zu', 'ku', 'dong', 'zhan', 'gu', 'yin', @@ -22,4 +22,4 @@ 0xD0 => 'chao', 'cuan', 'luan', 'dian', 'dian', 'nie', 'yan', 'yan', 'yan', 'kui', 'yan', 'chuan', 'kuai', 'chuan', 'zhou', 'huang', 0xE0 => 'jing', 'xun', 'chao', 'chao', 'lie', 'gong', 'zuo', 'qiao', 'ju', 'gong', 'ju', 'wu', 'pu', 'pu', 'cha', 'qiu', 0xF0 => 'qiu', 'ji', 'yi', 'si', 'ba', 'zhi', 'zhao', 'xiang', 'yi', 'jin', 'xun', 'juan', 'ba', 'xun', 'jin', 'fu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x5e.php b/core/lib/Drupal/Component/Transliteration/data/x5e.php index 75c829d..5d02629 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x5e.php +++ b/core/lib/Drupal/Component/Transliteration/data/x5e.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'za', 'bi', 'shi', 'bu', 'ding', 'shuai', 'fan', 'nie', 'shi', 'fen', 'pa', 'zhi', 'xi', 'hu', 'dan', 'wei', 0x10 => 'zhang', 'tang', 'dai', 'mo', 'pei', 'pa', 'tie', 'bo', 'lian', 'zhi', 'zhou', 'bo', 'zhi', 'di', 'mo', 'yi', 0x20 => 'yi', 'ping', 'qia', 'juan', 'ru', 'shuai', 'dai', 'zheng', 'shui', 'qiao', 'zhen', 'shi', 'qun', 'xi', 'bang', 'dai', @@ -22,4 +22,4 @@ 0xD0 => 'jiu', 'jin', 'ao', 'kuo', 'lou', 'yin', 'liao', 'dai', 'lu', 'yi', 'chu', 'chan', 'tu', 'si', 'xin', 'miao', 0xE0 => 'chang', 'wu', 'fei', 'guang', 'ku', 'kuai', 'bi', 'qiang', 'xie', 'lin', 'lin', 'liao', 'lu', 'ji', 'ying', 'xian', 0xF0 => 'ting', 'yong', 'li', 'ting', 'yin', 'xun', 'yan', 'ting', 'di', 'pai', 'jian', 'hui', 'nai', 'hui', 'gong', 'nian', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x5f.php b/core/lib/Drupal/Component/Transliteration/data/x5f.php index 675ad3e..25fe4ac 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x5f.php +++ b/core/lib/Drupal/Component/Transliteration/data/x5f.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'kai', 'bian', 'yi', 'qi', 'nong', 'fen', 'ju', 'yan', 'yi', 'zang', 'bi', 'yi', 'yi', 'er', 'san', 'shi', 0x10 => 'er', 'shi', 'shi', 'gong', 'diao', 'yin', 'hu', 'fu', 'hong', 'wu', 'tui', 'chi', 'jiang', 'ba', 'shen', 'di', 0x20 => 'zhang', 'jue', 'tao', 'fu', 'di', 'mi', 'xian', 'hu', 'chao', 'nu', 'jing', 'zhen', 'yi', 'mi', 'quan', 'wan', @@ -22,4 +22,4 @@ 0xD0 => 'tan', 'te', 'te', 'gan', 'qi', 'shi', 'cun', 'zhi', 'wang', 'mang', 'xi', 'fan', 'ying', 'tian', 'min', 'wen', 0xE0 => 'zhong', 'chong', 'wu', 'ji', 'wu', 'xi', 'jia', 'you', 'wan', 'cong', 'song', 'kuai', 'yu', 'bian', 'zhi', 'qi', 0xF0 => 'cui', 'chen', 'tai', 'tun', 'qian', 'nian', 'hun', 'xiong', 'niu', 'kuang', 'xian', 'xin', 'kang', 'hu', 'kai', 'fen', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x60.php b/core/lib/Drupal/Component/Transliteration/data/x60.php index 8186748..27467cc 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x60.php +++ b/core/lib/Drupal/Component/Transliteration/data/x60.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'huai', 'tai', 'song', 'wu', 'ou', 'chang', 'chuang', 'ju', 'yi', 'bao', 'chao', 'min', 'pei', 'zuo', 'zen', 'yang', 0x10 => 'ju', 'ban', 'nu', 'nao', 'zheng', 'pa', 'bu', 'tie', 'hu', 'hu', 'ju', 'da', 'lian', 'si', 'chou', 'di', 0x20 => 'dai', 'yi', 'tu', 'you', 'fu', 'ji', 'peng', 'xing', 'yuan', 'ni', 'guai', 'fu', 'xi', 'bi', 'you', 'qie', @@ -22,4 +22,4 @@ 0xD0 => 'yu', 'huo', 'he', 'quan', 'tan', 'ti', 'ti', 'nie', 'wang', 'chuo', 'hu', 'hun', 'xi', 'chang', 'xin', 'wei', 0xE0 => 'hui', 'e', 'suo', 'zong', 'jian', 'yong', 'dian', 'ju', 'can', 'cheng', 'de', 'bei', 'qie', 'can', 'dan', 'guan', 0xF0 => 'duo', 'nao', 'yun', 'xiang', 'zhui', 'die', 'huang', 'chun', 'qiong', 're', 'xing', 'ce', 'bian', 'min', 'zong', 'ti', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x61.php b/core/lib/Drupal/Component/Transliteration/data/x61.php index 21b7a80..9890aff 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x61.php +++ b/core/lib/Drupal/Component/Transliteration/data/x61.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'qiao', 'chou', 'bei', 'xuan', 'wei', 'ge', 'qian', 'wei', 'yu', 'yu', 'bi', 'xuan', 'huan', 'min', 'bi', 'yi', 0x10 => 'mian', 'yong', 'kai', 'dang', 'yin', 'e', 'chen', 'mao', 'qia', 'ke', 'yu', 'ai', 'qie', 'yan', 'nuo', 'gan', 0x20 => 'yun', 'zong', 'sai', 'leng', 'fen', 'ying', 'kui', 'kui', 'que', 'gong', 'yun', 'su', 'su', 'qi', 'yao', 'song', @@ -22,4 +22,4 @@ 0xD0 => 'huai', 'men', 'lan', 'ai', 'lin', 'yan', 'kuo', 'xia', 'chi', 'yu', 'yin', 'dai', 'meng', 'ai', 'meng', 'dui', 0xE0 => 'qi', 'mo', 'lan', 'men', 'chou', 'zhi', 'nuo', 'nuo', 'yan', 'yang', 'bo', 'zhi', 'kuang', 'kuang', 'you', 'fu', 0xF0 => 'liu', 'mie', 'cheng', 'hui', 'chan', 'meng', 'lan', 'huai', 'xuan', 'rang', 'chan', 'ji', 'ju', 'huan', 'she', 'yi', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x62.php b/core/lib/Drupal/Component/Transliteration/data/x62.php index 0de5674..9f2315b 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x62.php +++ b/core/lib/Drupal/Component/Transliteration/data/x62.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'lian', 'nan', 'mi', 'tang', 'jue', 'gang', 'gang', 'zhuang', 'ge', 'yue', 'wu', 'jian', 'xu', 'shu', 'rong', 'xi', 0x10 => 'cheng', 'wo', 'jie', 'ge', 'jian', 'qiang', 'huo', 'qiang', 'zhan', 'dong', 'qi', 'jia', 'die', 'zei', 'jia', 'ji', 0x20 => 'zhi', 'kan', 'ji', 'kui', 'gai', 'deng', 'zhan', 'qiang', 'ge', 'jian', 'jie', 'yu', 'jian', 'yan', 'lu', 'hu', @@ -22,4 +22,4 @@ 0xD0 => 'guai', 'qian', 'ju', 'ta', 'ba', 'tuo', 'tuo', 'ao', 'ju', 'zhuo', 'pan', 'zhao', 'bai', 'bai', 'di', 'ni', 0xE0 => 'ju', 'kuo', 'long', 'jian', 'qia', 'yong', 'lan', 'ning', 'bo', 'ze', 'qian', 'hen', 'kuo', 'shi', 'jie', 'zheng', 0xF0 => 'nin', 'gong', 'gong', 'quan', 'shuan', 'cun', 'za', 'kao', 'yi', 'xie', 'ce', 'hui', 'pin', 'zhuai', 'shi', 'na', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x63.php b/core/lib/Drupal/Component/Transliteration/data/x63.php index 9108c93..e74aa0f 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x63.php +++ b/core/lib/Drupal/Component/Transliteration/data/x63.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'bai', 'chi', 'gua', 'zhi', 'kuo', 'duo', 'duo', 'zhi', 'qie', 'an', 'nong', 'zhen', 'ge', 'jiao', 'kua', 'dong', 0x10 => 'na', 'tiao', 'lie', 'zha', 'lu', 'die', 'wa', 'jue', 'lie', 'ju', 'zhi', 'luan', 'ya', 'wo', 'ta', 'xie', 0x20 => 'nao', 'dang', 'jiao', 'zheng', 'ji', 'hui', 'xian', 'yu', 'ai', 'tuo', 'nuo', 'cuo', 'bo', 'geng', 'ti', 'zhen', @@ -22,4 +22,4 @@ 0xD0 => 'ti', 'nie', 'cha', 'shi', 'zong', 'zhen', 'yi', 'xun', 'yong', 'bian', 'yang', 'huan', 'yan', 'zan', 'an', 'xu', 0xE0 => 'ya', 'wo', 'ke', 'chuai', 'ji', 'ti', 'la', 'la', 'chen', 'kai', 'jiu', 'jiu', 'tu', 'jie', 'hui', 'gen', 0xF0 => 'chong', 'xiao', 'die', 'xie', 'yuan', 'qian', 'ye', 'cha', 'zha', 'bei', 'yao', 'wei', 'beng', 'lan', 'wen', 'qin', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x64.php b/core/lib/Drupal/Component/Transliteration/data/x64.php index 68f1e05..29e7caa 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x64.php +++ b/core/lib/Drupal/Component/Transliteration/data/x64.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'chan', 'ge', 'lou', 'zong', 'geng', 'jiao', 'gou', 'qin', 'rong', 'que', 'chou', 'chuai', 'zhan', 'sun', 'sun', 'bo', 0x10 => 'chu', 'rong', 'bang', 'cuo', 'sao', 'ke', 'yao', 'dao', 'zhi', 'nu', 'la', 'jian', 'sou', 'qiu', 'gao', 'xian', 0x20 => 'shuo', 'sang', 'jin', 'mie', 'e', 'chui', 'nuo', 'shan', 'ta', 'zha', 'tang', 'pan', 'ban', 'da', 'li', 'tao', @@ -22,4 +22,4 @@ 0xD0 => 'huan', 'jie', 'qin', 'kuai', 'dan', 'xie', 'ka', 'pi', 'bai', 'ao', 'ju', 'ye', 'e', 'meng', 'sou', 'mi', 0xE0 => 'ji', 'tai', 'zhuo', 'dao', 'xing', 'lan', 'ca', 'ju', 'ye', 'ru', 'ye', 'ye', 'ni', 'wo', 'ji', 'bin', 0xF0 => 'ning', 'ge', 'zhi', 'zhi', 'kuo', 'mo', 'jian', 'xie', 'lie', 'tan', 'bai', 'sou', 'lu', 'lue', 'rao', 'ti', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x65.php b/core/lib/Drupal/Component/Transliteration/data/x65.php index ff100d4..f8b74f8 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x65.php +++ b/core/lib/Drupal/Component/Transliteration/data/x65.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'pan', 'yang', 'lei', 'ca', 'shu', 'zan', 'nian', 'xian', 'jun', 'huo', 'li', 'la', 'huan', 'ying', 'lu', 'long', 0x10 => 'qian', 'qian', 'zan', 'qian', 'lan', 'xian', 'ying', 'mei', 'rang', 'chan', 'ying', 'cuan', 'xie', 'she', 'luo', 'jun', 0x20 => 'mi', 'li', 'zan', 'luan', 'tan', 'zuan', 'li', 'dian', 'wa', 'dang', 'jiao', 'jue', 'lan', 'li', 'nang', 'zhi', @@ -22,4 +22,4 @@ 0xD0 => 'zhao', 'yi', 'liu', 'shao', 'jian', 'yu', 'yi', 'qi', 'zhi', 'fan', 'piao', 'fan', 'zhan', 'kuai', 'sui', 'yu', 0xE0 => 'wu', 'ji', 'ji', 'ji', 'huo', 'ri', 'dan', 'jiu', 'zhi', 'zao', 'xie', 'tiao', 'xun', 'xu', 'ga', 'la', 0xF0 => 'gan', 'han', 'tai', 'di', 'xu', 'chan', 'shi', 'kuang', 'yang', 'shi', 'wang', 'min', 'min', 'tun', 'chun', 'wu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x66.php b/core/lib/Drupal/Component/Transliteration/data/x66.php index edebef0..23aa7d4 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x66.php +++ b/core/lib/Drupal/Component/Transliteration/data/x66.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'yun', 'bei', 'ang', 'ze', 'ban', 'jie', 'kun', 'sheng', 'hu', 'fang', 'hao', 'gui', 'chang', 'xuan', 'ming', 'hun', 0x10 => 'fen', 'qin', 'hu', 'yi', 'xi', 'xin', 'yan', 'ze', 'fang', 'tan', 'shen', 'ju', 'yang', 'zan', 'bing', 'xing', 0x20 => 'ying', 'xuan', 'po', 'zhen', 'ling', 'chun', 'hao', 'mei', 'zuo', 'mo', 'bian', 'xu', 'hun', 'zhao', 'zong', 'shi', @@ -22,4 +22,4 @@ 0xD0 => 'xing', 'shen', 'jiao', 'bao', 'jing', 'yan', 'ai', 'ye', 'ru', 'shu', 'meng', 'xun', 'yao', 'pu', 'li', 'chen', 0xE0 => 'kuang', 'die', 'liao', 'yan', 'huo', 'lu', 'xi', 'rong', 'long', 'nang', 'luo', 'luan', 'shai', 'tang', 'yan', 'zhu', 0xF0 => 'yue', 'yue', 'qu', 'ye', 'geng', 'ye', 'hu', 'he', 'shu', 'cao', 'cao', 'sheng', 'man', 'ceng', 'ceng', 'ti', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x67.php b/core/lib/Drupal/Component/Transliteration/data/x67.php index d0e5d1a..2b5e33f 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x67.php +++ b/core/lib/Drupal/Component/Transliteration/data/x67.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'zui', 'can', 'xu', 'hui', 'yin', 'qie', 'fen', 'pi', 'yue', 'you', 'ruan', 'peng', 'fen', 'fu', 'ling', 'fei', 0x10 => 'qu', 'ti', 'nu', 'tiao', 'shuo', 'zhen', 'lang', 'lang', 'zui', 'ming', 'huang', 'wang', 'tun', 'chao', 'ji', 'qi', 0x20 => 'ying', 'zong', 'wang', 'tong', 'lang', 'lao', 'meng', 'long', 'mu', 'deng', 'wei', 'mo', 'ben', 'zha', 'shu', 'shu', @@ -22,4 +22,4 @@ 0xD0 => 'mou', 'gan', 'qi', 'ran', 'rou', 'mao', 'shao', 'song', 'zhe', 'xia', 'you', 'shen', 'gui', 'tuo', 'zha', 'nan', 0xE0 => 'ning', 'yong', 'di', 'zhi', 'zha', 'cha', 'dan', 'gu', 'bu', 'jiu', 'ao', 'fu', 'jian', 'ba', 'duo', 'ke', 0xF0 => 'nai', 'zhu', 'bi', 'liu', 'chai', 'shan', 'si', 'chu', 'pei', 'shi', 'guai', 'zha', 'yao', 'cheng', 'jiu', 'shi', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x68.php b/core/lib/Drupal/Component/Transliteration/data/x68.php index 84f9447..39662ff 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x68.php +++ b/core/lib/Drupal/Component/Transliteration/data/x68.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'zhi', 'liu', 'mei', 'li', 'rong', 'zha', 'zao', 'biao', 'zhan', 'zhi', 'long', 'dong', 'lu', 'sheng', 'li', 'lan', 0x10 => 'yong', 'shu', 'xun', 'shuan', 'qi', 'zhen', 'qi', 'li', 'yi', 'xiang', 'zhen', 'li', 'se', 'gua', 'kan', 'ben', 0x20 => 'ren', 'xiao', 'bai', 'ren', 'bing', 'zi', 'chou', 'yi', 'ci', 'xu', 'zhu', 'jian', 'zui', 'er', 'er', 'you', @@ -22,4 +22,4 @@ 0xD0 => 'fei', 'pai', 'bang', 'bang', 'hun', 'zong', 'cheng', 'zao', 'ji', 'li', 'peng', 'yu', 'yu', 'gu', 'jun', 'dong', 0xE0 => 'tang', 'gang', 'wang', 'di', 'cuo', 'fan', 'cheng', 'zhan', 'qi', 'yuan', 'yan', 'yu', 'quan', 'yi', 'sen', 'ren', 0xF0 => 'chui', 'leng', 'qi', 'zhuo', 'fu', 'ke', 'lai', 'zou', 'zou', 'zhao', 'guan', 'fen', 'fen', 'shen', 'qing', 'ni', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x69.php b/core/lib/Drupal/Component/Transliteration/data/x69.php index fcc08f2..4d094cb 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x69.php +++ b/core/lib/Drupal/Component/Transliteration/data/x69.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'wan', 'guo', 'lu', 'hao', 'jie', 'yi', 'chou', 'ju', 'ju', 'cheng', 'zuo', 'liang', 'qiang', 'zhi', 'chui', 'ya', 0x10 => 'ju', 'bei', 'jiao', 'zhuo', 'zi', 'bin', 'peng', 'ding', 'chu', 'chang', 'men', 'hua', 'jian', 'gui', 'xi', 'du', 0x20 => 'qian', 'dao', 'gui', 'dian', 'luo', 'zhi', 'quan', 'ming', 'fu', 'geng', 'peng', 'zhan', 'yi', 'tuo', 'sen', 'duo', @@ -22,4 +22,4 @@ 0xD0 => 'huai', 'mei', 'xu', 'gang', 'gao', 'zhuo', 'tuo', 'qiao', 'yang', 'dian', 'jia', 'kan', 'zui', 'dao', 'long', 'bin', 0xE0 => 'zhu', 'sang', 'xi', 'ji', 'lian', 'hui', 'yong', 'qian', 'guo', 'gai', 'gai', 'tuan', 'hua', 'qi', 'sen', 'cui', 0xF0 => 'peng', 'you', 'hu', 'jiang', 'hu', 'huan', 'gui', 'nie', 'yi', 'gao', 'kang', 'gui', 'gui', 'cao', 'man', 'jin', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x6a.php b/core/lib/Drupal/Component/Transliteration/data/x6a.php index d5557b8..4a34fa6 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x6a.php +++ b/core/lib/Drupal/Component/Transliteration/data/x6a.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'di', 'zhuang', 'le', 'lang', 'chen', 'cong', 'li', 'xiu', 'qing', 'shuang', 'fan', 'tong', 'guan', 'ze', 'su', 'lei', 0x10 => 'lu', 'liang', 'mi', 'lou', 'chao', 'su', 'ke', 'chu', 'tang', 'biao', 'lu', 'jiu', 'zhe', 'zha', 'shu', 'zhang', 0x20 => 'man', 'mo', 'niao', 'yang', 'tiao', 'peng', 'zhu', 'sha', 'xi', 'quan', 'heng', 'jian', 'cong', 'ji', 'yan', 'qiang', @@ -22,4 +22,4 @@ 0xD0 => 'lei', 'lei', 'sa', 'lu', 'li', 'cuan', 'lu', 'mie', 'hui', 'ou', 'lu', 'zhi', 'gao', 'du', 'yuan', 'li', 0xE0 => 'fei', 'zhuo', 'sou', 'lian', 'jiang', 'chu', 'qing', 'zhu', 'lu', 'yan', 'li', 'zhu', 'chen', 'jie', 'e', 'su', 0xF0 => 'huai', 'nie', 'yu', 'long', 'lai', 'jiao', 'xian', 'gui', 'ju', 'xiao', 'ling', 'ying', 'jian', 'yin', 'you', 'ying', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x6b.php b/core/lib/Drupal/Component/Transliteration/data/x6b.php index 98dbdd1..0df0329 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x6b.php +++ b/core/lib/Drupal/Component/Transliteration/data/x6b.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'xiang', 'nong', 'bo', 'chan', 'lan', 'ju', 'shuang', 'she', 'wei', 'cong', 'quan', 'qu', 'cang', 'jiu', 'yu', 'luo', 0x10 => 'li', 'cuan', 'luan', 'dang', 'jue', 'yan', 'lan', 'lan', 'zhu', 'lei', 'li', 'ba', 'nang', 'yu', 'ling', 'guang', 0x20 => 'qian', 'ci', 'huan', 'xin', 'yu', 'yi', 'qian', 'ou', 'xu', 'chao', 'chu', 'qi', 'kai', 'yi', 'jue', 'xi', @@ -22,4 +22,4 @@ 0xD0 => 'ai', 'jie', 'du', 'yu', 'bi', 'bi', 'bi', 'pi', 'pi', 'bi', 'chan', 'mao', 'hao', 'cai', 'pi', 'lie', 0xE0 => 'jia', 'zhan', 'sai', 'mu', 'tuo', 'xun', 'er', 'rong', 'xian', 'ju', 'mu', 'hao', 'qiu', 'dou', 'sha', 'tan', 0xF0 => 'pei', 'ju', 'duo', 'cui', 'bi', 'san', 'san', 'mao', 'sai', 'shu', 'yu', 'tuo', 'he', 'jian', 'ta', 'san', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x6c.php b/core/lib/Drupal/Component/Transliteration/data/x6c.php index 37501ff..52c6c42 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x6c.php +++ b/core/lib/Drupal/Component/Transliteration/data/x6c.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'lu', 'mu', 'mao', 'tong', 'rong', 'chang', 'pu', 'lu', 'zhan', 'sao', 'zhan', 'meng', 'lu', 'qu', 'die', 'shi', 0x10 => 'di', 'min', 'jue', 'mang', 'qi', 'pie', 'nai', 'qi', 'dao', 'xian', 'chuan', 'fen', 'yang', 'nei', 'bin', 'fu', 0x20 => 'shen', 'dong', 'qing', 'qi', 'yin', 'xi', 'hai', 'yang', 'an', 'ya', 'ke', 'qing', 'ya', 'dong', 'dan', 'lu', @@ -22,4 +22,4 @@ 0xD0 => 'le', 'you', 'gu', 'hong', 'gan', 'fa', 'mao', 'si', 'hu', 'ping', 'ci', 'fan', 'zhi', 'su', 'ning', 'cheng', 0xE0 => 'ling', 'pao', 'bo', 'qi', 'si', 'ni', 'ju', 'sa', 'zhu', 'sheng', 'lei', 'xuan', 'jue', 'fu', 'pan', 'min', 0xF0 => 'tai', 'yang', 'ji', 'yong', 'guan', 'beng', 'xue', 'long', 'lu', 'dan', 'luo', 'xie', 'po', 'ze', 'jing', 'yin', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x6d.php b/core/lib/Drupal/Component/Transliteration/data/x6d.php index 7c0efb3..db01546 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x6d.php +++ b/core/lib/Drupal/Component/Transliteration/data/x6d.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'pan', 'jie', 'yi', 'hui', 'hui', 'zai', 'cheng', 'yin', 'wei', 'hou', 'jian', 'yang', 'lie', 'si', 'ji', 'er', 0x10 => 'xing', 'fu', 'sa', 'se', 'zhi', 'yin', 'wu', 'xi', 'kao', 'zhu', 'jiang', 'luo', 'luo', 'an', 'dong', 'ti', 0x20 => 'mou', 'lei', 'yi', 'mi', 'quan', 'jin', 'po', 'wei', 'xiao', 'xie', 'hong', 'xu', 'su', 'kuang', 'tao', 'qie', @@ -22,4 +22,4 @@ 0xD0 => 'chang', 'shu', 'qi', 'fang', 'zhi', 'lu', 'nao', 'ju', 'tao', 'cong', 'lei', 'zhe', 'ping', 'fei', 'song', 'tian', 0xE0 => 'pi', 'dan', 'yu', 'ni', 'yu', 'lu', 'gan', 'mi', 'jing', 'ling', 'lun', 'yin', 'cui', 'qu', 'huai', 'yu', 0xF0 => 'nian', 'shen', 'biao', 'chun', 'hu', 'yuan', 'lai', 'hun', 'qing', 'yan', 'qian', 'tian', 'miao', 'zhi', 'yin', 'mi', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x6e.php b/core/lib/Drupal/Component/Transliteration/data/x6e.php index 50c7e50..ea795fe 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x6e.php +++ b/core/lib/Drupal/Component/Transliteration/data/x6e.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ben', 'yuan', 'wen', 'ruo', 'fei', 'qing', 'yuan', 'ke', 'ji', 'she', 'yuan', 'se', 'lu', 'zi', 'du', 'qi', 0x10 => 'jian', 'mian', 'pi', 'xi', 'yu', 'yuan', 'shen', 'shen', 'rou', 'huan', 'zhu', 'jian', 'nuan', 'yu', 'qiu', 'ting', 0x20 => 'qu', 'du', 'fan', 'zha', 'bo', 'wo', 'wo', 'di', 'wei', 'wen', 'ru', 'xie', 'ce', 'wei', 'he', 'gang', @@ -22,4 +22,4 @@ 0xD0 => 'jie', 'hua', 'ge', 'zi', 'tao', 'teng', 'sui', 'bi', 'jiao', 'hui', 'gun', 'yin', 'gao', 'long', 'zhi', 'yan', 0xE0 => 'she', 'man', 'ying', 'chun', 'lu', 'lan', 'luan', 'xiao', 'bin', 'tan', 'yu', 'xiu', 'hu', 'bi', 'biao', 'zhi', 0xF0 => 'jiang', 'kou', 'shen', 'shang', 'di', 'mi', 'ao', 'lu', 'hu', 'hu', 'you', 'chan', 'fan', 'yong', 'gun', 'man', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x6f.php b/core/lib/Drupal/Component/Transliteration/data/x6f.php index bcb08f8..1b63e5c 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x6f.php +++ b/core/lib/Drupal/Component/Transliteration/data/x6f.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'qing', 'yu', 'piao', 'ji', 'ya', 'chao', 'qi', 'xi', 'ji', 'lu', 'lou', 'long', 'jin', 'guo', 'cong', 'lou', 0x10 => 'zhi', 'gai', 'qiang', 'li', 'yan', 'cao', 'jiao', 'cong', 'chun', 'tuan', 'ou', 'teng', 'ye', 'xi', 'mi', 'tang', 0x20 => 'mo', 'shang', 'han', 'lian', 'lan', 'wa', 'chi', 'gan', 'feng', 'xuan', 'yi', 'man', 'zi', 'mang', 'kang', 'luo', @@ -22,4 +22,4 @@ 0xD0 => 'zhu', 'lai', 'bin', 'lian', 'mi', 'shi', 'shu', 'mi', 'ning', 'ying', 'ying', 'meng', 'jin', 'qi', 'bi', 'ji', 0xE0 => 'hao', 'ru', 'cui', 'wo', 'tao', 'yin', 'yin', 'dui', 'ci', 'huo', 'jing', 'lan', 'jun', 'ai', 'pu', 'zhuo', 0xF0 => 'wei', 'bin', 'gu', 'qian', 'ying', 'bin', 'kuo', 'fei', 'cang', 'me', 'jian', 'wei', 'luo', 'zan', 'lu', 'li', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x70.php b/core/lib/Drupal/Component/Transliteration/data/x70.php index a04c26a..6b83772 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x70.php +++ b/core/lib/Drupal/Component/Transliteration/data/x70.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'you', 'yang', 'lu', 'si', 'zhi', 'ying', 'du', 'wang', 'hui', 'xie', 'pan', 'shen', 'biao', 'chan', 'mo', 'liu', 0x10 => 'jian', 'pu', 'se', 'cheng', 'gu', 'bin', 'huo', 'xian', 'lu', 'qin', 'han', 'ying', 'rong', 'li', 'jing', 'xiao', 0x20 => 'ying', 'sui', 'wei', 'xie', 'huai', 'xue', 'zhu', 'long', 'lai', 'dui', 'fan', 'hu', 'lai', 'shu', 'ling', 'ying', @@ -22,4 +22,4 @@ 0xD0 => 'zhou', 'yao', 'shi', 'wei', 'tong', 'mie', 'zai', 'kai', 'hong', 'lao', 'xia', 'zhu', 'xuan', 'zheng', 'po', 'yan', 0xE0 => 'hui', 'guang', 'che', 'hui', 'kao', 'chen', 'fan', 'shao', 'ye', 'hui', NULL, 'tang', 'jin', 're', 'lie', 'xi', 0xF0 => 'fu', 'jiong', 'xie', 'pu', 'ting', 'zhuo', 'ting', 'wan', 'hai', 'peng', 'lang', 'yan', 'xu', 'feng', 'chi', 'rong', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x71.php b/core/lib/Drupal/Component/Transliteration/data/x71.php index bec4af6..df33f2f 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x71.php +++ b/core/lib/Drupal/Component/Transliteration/data/x71.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'hu', 'xi', 'shu', 'he', 'xun', 'ku', 'juan', 'xiao', 'xi', 'yan', 'han', 'zhuang', 'jun', 'di', 'xie', 'ji', 0x10 => 'wu', 'yan', 'lu', 'han', 'yan', 'huan', 'men', 'ju', 'dao', 'bei', 'fen', 'lin', 'kun', 'hun', 'tun', 'xi', 0x20 => 'cui', 'wu', 'hong', 'chao', 'fu', 'wo', 'jiao', 'cong', 'feng', 'ping', 'qiong', 'ruo', 'xi', 'qiong', 'xin', 'chao', @@ -22,4 +22,4 @@ 0xD0 => 'lin', 'tong', 'shao', 'fen', 'fan', 'yan', 'xun', 'lan', 'mei', 'tang', 'yi', 'jing', 'men', 'jing', 'jiao', 'ying', 0xE0 => 'yu', 'yi', 'xue', 'lan', 'tai', 'zao', 'can', 'sui', 'xi', 'que', 'cong', 'lian', 'hui', 'zhu', 'xie', 'ling', 0xF0 => 'wei', 'yi', 'xie', 'zhao', 'hui', 'da', 'nong', 'lan', 'ru', 'xian', 'kao', 'xun', 'jin', 'chou', 'dao', 'yao', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x72.php b/core/lib/Drupal/Component/Transliteration/data/x72.php index bea999b..7a84a0c 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x72.php +++ b/core/lib/Drupal/Component/Transliteration/data/x72.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'he', 'lan', 'biao', 'rong', 'li', 'mo', 'bao', 'ruo', 'lu', 'la', 'ao', 'xun', 'kuang', 'shuo', 'liao', 'li', 0x10 => 'lu', 'jue', 'liao', 'yan', 'xi', 'xie', 'long', 'ye', 'can', 'rang', 'yue', 'lan', 'cong', 'jue', 'chong', 'guan', 0x20 => 'ju', 'che', 'mi', 'tang', 'lan', 'zhu', 'lan', 'ling', 'cuan', 'yu', 'zhao', 'zhao', 'pa', 'zheng', 'pao', 'cheng', @@ -22,4 +22,4 @@ 0xD0 => 'hu', 'ling', 'fei', 'pi', 'ni', 'yao', 'you', 'gou', 'xue', 'ju', 'dan', 'bo', 'ku', 'xian', 'ning', 'huan', 0xE0 => 'hen', 'jiao', 'he', 'zhao', 'ji', 'xun', 'shan', 'ta', 'rong', 'shou', 'tong', 'lao', 'du', 'xia', 'shi', 'kuai', 0xF0 => 'zheng', 'yu', 'sun', 'yu', 'bi', 'mang', 'xi', 'juan', 'li', 'xia', 'yin', 'suan', 'lang', 'bei', 'zhi', 'yan', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x73.php b/core/lib/Drupal/Component/Transliteration/data/x73.php index 237fe05..62f3521 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x73.php +++ b/core/lib/Drupal/Component/Transliteration/data/x73.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'sha', 'li', 'han', 'xian', 'jing', 'pai', 'fei', 'xiao', 'bai', 'qi', 'ni', 'biao', 'yin', 'lai', 'lie', 'jian', 0x10 => 'qiang', 'kun', 'yan', 'guo', 'zong', 'mi', 'chang', 'yi', 'zhi', 'zheng', 'ya', 'meng', 'cai', 'cu', 'she', 'lie', 0x20 => 'dian', 'luo', 'hu', 'zong', 'gui', 'wei', 'feng', 'wo', 'yuan', 'xing', 'zhu', 'mao', 'wei', 'chuan', 'xian', 'tuan', @@ -22,4 +22,4 @@ 0xD0 => 'fa', 'long', 'jin', 'jiao', 'jian', 'li', 'guang', 'xian', 'zhou', 'gong', 'yan', 'xiu', 'yang', 'xu', 'luo', 'su', 0xE0 => 'zhu', 'qin', 'yin', 'xun', 'bao', 'er', 'xiang', 'yao', 'xia', 'hang', 'gui', 'chong', 'xu', 'ban', 'pei', 'lao', 0xF0 => 'dang', 'ying', 'hui', 'wen', 'e', 'cheng', 'di', 'wu', 'wu', 'cheng', 'jun', 'mei', 'bei', 'ting', 'xian', 'chu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x74.php b/core/lib/Drupal/Component/Transliteration/data/x74.php index e94a71c..c7d14a4 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x74.php +++ b/core/lib/Drupal/Component/Transliteration/data/x74.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'han', 'xuan', 'yan', 'qiu', 'xuan', 'lang', 'li', 'xiu', 'fu', 'liu', 'ya', 'xi', 'ling', 'li', 'jin', 'lian', 0x10 => 'suo', 'suo', 'feng', 'wan', 'dian', 'pin', 'zhan', 'se', 'min', 'yu', 'ju', 'chen', 'lai', 'wen', 'sheng', 'wei', 0x20 => 'tian', 'chu', 'zuo', 'beng', 'cheng', 'hu', 'qi', 'e', 'kun', 'chang', 'qi', 'beng', 'wan', 'lu', 'cong', 'guan', @@ -22,4 +22,4 @@ 0xD0 => 'lu', 'li', 'zan', 'lan', 'ying', 'mi', 'xiang', 'qiong', 'guan', 'dao', 'zan', 'huan', 'gua', 'bo', 'die', 'bo', 0xE0 => 'hu', 'zhi', 'piao', 'ban', 'rang', 'li', 'wa', 'Dekaguramu ', 'xiang', 'qian', 'ban', 'pen', 'fang', 'dan', 'weng', 'ou', 0xF0 => 'Deshiguramu ', 'Miriguramu ', 'wa', 'hu', 'ling', 'yi', 'ping', 'ci', 'bai', 'juan', 'chang', 'chi', 'Sarake ', 'dang', 'meng', 'bu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x75.php b/core/lib/Drupal/Component/Transliteration/data/x75.php index fd88d44..5db5531 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x75.php +++ b/core/lib/Drupal/Component/Transliteration/data/x75.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'zhui', 'ping', 'bian', 'zhou', 'zhen', 'Senchigura ', 'ci', 'ying', 'qi', 'xian', 'lou', 'di', 'ou', 'meng', 'zhuan', 'beng', 0x10 => 'lin', 'zeng', 'wu', 'pi', 'dan', 'weng', 'ying', 'yan', 'gan', 'dai', 'shen', 'tian', 'tian', 'han', 'chang', 'sheng', 0x20 => 'qing', 'shen', 'chan', 'chan', 'rui', 'sheng', 'su', 'shen', 'yong', 'shuai', 'lu', 'fu', 'yong', 'beng', 'feng', 'ning', @@ -22,4 +22,4 @@ 0xD0 => 'hui', 'tan', 'yang', 'chi', 'zhi', 'hen', 'ya', 'mei', 'dou', 'jing', 'xiao', 'tong', 'tu', 'mang', 'pi', 'xiao', 0xE0 => 'suan', 'fu', 'li', 'zhi', 'cuo', 'duo', 'wu', 'sha', 'lao', 'shou', 'huan', 'xian', 'yi', 'beng', 'zhang', 'guan', 0xF0 => 'tan', 'fei', 'ma', 'lin', 'chi', 'ji', 'tian', 'an', 'chi', 'bi', 'bi', 'min', 'gu', 'dui', 'e', 'wei', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x76.php b/core/lib/Drupal/Component/Transliteration/data/x76.php index abfbd36..eb3eafa 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x76.php +++ b/core/lib/Drupal/Component/Transliteration/data/x76.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'yu', 'cui', 'ya', 'zhu', 'cu', 'dan', 'shen', 'zhong', 'chi', 'yu', 'hou', 'feng', 'la', 'yang', 'chen', 'tu', 0x10 => 'yu', 'guo', 'wen', 'huan', 'ku', 'jia', 'yin', 'yi', 'lou', 'sao', 'jue', 'chi', 'xi', 'guan', 'yi', 'wen', 0x20 => 'ji', 'chuang', 'ban', 'hui', 'liu', 'chai', 'shou', 'nue', 'dian', 'da', 'bie', 'tan', 'zhang', 'biao', 'shen', 'cu', @@ -22,4 +22,4 @@ 0xD0 => 'yan', 'jian', 'he', 'yu', 'kui', 'fan', 'gai', 'dao', 'pan', 'fu', 'qiu', 'sheng', 'dao', 'lu', 'zhan', 'meng', 0xE0 => 'li', 'jin', 'xu', 'jian', 'pan', 'guan', 'an', 'lu', 'xu', 'zhou', 'dang', 'an', 'gu', 'li', 'mu', 'ding', 0xF0 => 'gan', 'xu', 'mang', 'wang', 'zhi', 'qi', 'yuan', 'tian', 'xiang', 'dun', 'xin', 'xi', 'pan', 'feng', 'dun', 'min', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x77.php b/core/lib/Drupal/Component/Transliteration/data/x77.php index 6a6c4b9..ecde8bb 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x77.php +++ b/core/lib/Drupal/Component/Transliteration/data/x77.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ming', 'sheng', 'shi', 'yun', 'mian', 'pan', 'fang', 'miao', 'dan', 'mei', 'mao', 'kan', 'xian', 'kou', 'shi', 'yang', 0x10 => 'zheng', 'yao', 'shen', 'huo', 'da', 'zhen', 'kuang', 'ju', 'shen', 'yi', 'sheng', 'mei', 'mo', 'zhu', 'zhen', 'zhen', 0x20 => 'mian', 'shi', 'yuan', 'die', 'ni', 'zi', 'zi', 'chao', 'zha', 'xuan', 'bing', 'mi', 'long', 'sui', 'tong', 'mi', @@ -22,4 +22,4 @@ 0xD0 => 'huo', 'lu', 'meng', 'long', 'guan', 'man', 'xi', 'chu', 'tang', 'kan', 'zhu', 'mao', 'jin', 'lin', 'yu', 'shuo', 0xE0 => 'ze', 'jue', 'shi', 'yi', 'shen', 'zhi', 'hou', 'shen', 'ying', 'ju', 'zhou', 'jiao', 'cuo', 'duan', 'ai', 'jiao', 0xF0 => 'zeng', 'yue', 'ba', 'shi', 'ding', 'qi', 'ji', 'zi', 'gan', 'wu', 'zhe', 'ku', 'gang', 'xi', 'fan', 'kuang', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x78.php b/core/lib/Drupal/Component/Transliteration/data/x78.php index b7e4041..c79005b 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x78.php +++ b/core/lib/Drupal/Component/Transliteration/data/x78.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'dang', 'ma', 'sha', 'dan', 'jue', 'li', 'fu', 'min', 'e', 'huo', 'kang', 'zhi', 'qi', 'kan', 'jie', 'bin', 0x10 => 'e', 'ya', 'pi', 'zhe', 'yan', 'sui', 'zhuan', 'che', 'dun', 'pan', 'yan', 'jin', 'feng', 'fa', 'mo', 'zha', 0x20 => 'ju', 'yu', 'ke', 'tuo', 'tuo', 'di', 'zhai', 'zhen', 'e', 'fu', 'mu', 'zhu', 'la', 'bian', 'nu', 'ping', @@ -22,4 +22,4 @@ 0xD0 => 'pan', 'wei', 'yun', 'dui', 'zhe', 'ke', 'la', 'zhuan', 'qing', 'gun', 'zhuan', 'chan', 'qi', 'ao', 'peng', 'liu', 0xE0 => 'lu', 'kan', 'chuang', 'chen', 'yin', 'lei', 'biao', 'qi', 'mo', 'qi', 'cui', 'zong', 'qing', 'chuo', 'lun', 'ji', 0xF0 => 'shan', 'lao', 'qu', 'zeng', 'deng', 'jian', 'xi', 'lin', 'ding', 'tan', 'huang', 'pan', 'za', 'qiao', 'di', 'li', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x79.php b/core/lib/Drupal/Component/Transliteration/data/x79.php index 7791564..babcfd2 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x79.php +++ b/core/lib/Drupal/Component/Transliteration/data/x79.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'jian', 'jiao', 'xi', 'zhang', 'qiao', 'dun', 'jian', 'yu', 'zhui', 'he', 'ke', 'ze', 'lei', 'ke', 'chu', 'ye', 0x10 => 'que', 'dang', 'yi', 'jiang', 'pi', 'pi', 'yu', 'pin', 'e', 'ai', 'ke', 'jian', 'yu', 'ruan', 'meng', 'pao', 0x20 => 'ci', 'bo', 'yang', 'ma', 'ca', 'xian', 'kuang', 'lei', 'lei', 'zhi', 'li', 'li', 'fan', 'que', 'pao', 'ying', @@ -22,4 +22,4 @@ 0xD0 => 'yun', 'ke', 'miao', 'zhi', 'jing', 'bi', 'zhi', 'yu', 'mi', 'ku', 'ban', 'pi', 'ni', 'li', 'you', 'zu', 0xE0 => 'pi', 'bo', 'ling', 'mo', 'cheng', 'nian', 'qin', 'yang', 'zuo', 'zhi', 'zhi', 'shu', 'ju', 'zi', 'huo', 'ji', 0xF0 => 'cheng', 'tong', 'zhi', 'huo', 'he', 'yin', 'zi', 'zhi', 'jie', 'ren', 'du', 'yi', 'zhu', 'hui', 'nong', 'fu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x7a.php b/core/lib/Drupal/Component/Transliteration/data/x7a.php index db12d9b..eebb257 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x7a.php +++ b/core/lib/Drupal/Component/Transliteration/data/x7a.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'xi', 'kao', 'lang', 'fu', 'xun', 'shui', 'lu', 'kun', 'gan', 'jing', 'ti', 'cheng', 'tu', 'shao', 'shui', 'ya', 0x10 => 'lun', 'lu', 'gu', 'zuo', 'ren', 'zhun', 'bang', 'bai', 'ji', 'zhi', 'zhi', 'kun', 'leng', 'peng', 'ke', 'bing', 0x20 => 'chou', 'zui', 'yu', 'su', 'lue', 'xiang', 'yi', 'xi', 'bian', 'ji', 'fu', 'pi', 'nuo', 'jie', 'zhong', 'zong', @@ -22,4 +22,4 @@ 0xD0 => 'chu', 'hong', 'qi', 'hao', 'sheng', 'fen', 'shu', 'miao', 'qu', 'zhan', 'zhu', 'ling', 'long', 'bing', 'jing', 'jing', 0xE0 => 'zhang', 'bai', 'si', 'jun', 'hong', 'tong', 'song', 'jing', 'diao', 'yi', 'shu', 'jing', 'qu', 'jie', 'ping', 'duan', 0xF0 => 'shao', 'zhuan', 'ceng', 'deng', 'cun', 'wai', 'jing', 'kan', 'jing', 'zhu', 'zhu', 'le', 'peng', 'yu', 'chi', 'gan', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x7b.php b/core/lib/Drupal/Component/Transliteration/data/x7b.php index 9db5911..29d7b03 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x7b.php +++ b/core/lib/Drupal/Component/Transliteration/data/x7b.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'mang', 'zhu', 'wan', 'du', 'ji', 'xiao', 'ba', 'suan', 'ji', 'qin', 'zhao', 'sun', 'ya', 'zhui', 'yuan', 'hu', 0x10 => 'hang', 'xiao', 'cen', 'bi', 'bi', 'jian', 'yi', 'dong', 'shan', 'sheng', 'da', 'di', 'zhu', 'na', 'chi', 'gu', 0x20 => 'li', 'qie', 'min', 'bao', 'tiao', 'si', 'fu', 'ce', 'ben', 'pei', 'da', 'zi', 'di', 'ling', 'ze', 'nu', @@ -22,4 +22,4 @@ 0xD0 => 'gu', 'kui', 'shi', 'lou', 'yun', 'he', 'tang', 'yue', 'chou', 'gao', 'fei', 'ruo', 'zheng', 'gou', 'nie', 'qian', 0xE0 => 'xiao', 'cuan', 'long', 'peng', 'du', 'li', 'bi', 'zhuo', 'chu', 'shai', 'chi', 'zhu', 'qiang', 'long', 'lan', 'jian', 0xF0 => 'bu', 'li', 'hui', 'bi', 'di', 'cong', 'yan', 'peng', 'can', 'zhuan', 'pi', 'piao', 'dou', 'yu', 'mie', 'tuan', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x7c.php b/core/lib/Drupal/Component/Transliteration/data/x7c.php index 49aa0a6..3fff1c7 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x7c.php +++ b/core/lib/Drupal/Component/Transliteration/data/x7c.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ze', 'shai', 'gui', 'yi', 'hu', 'chan', 'kou', 'cu', 'ping', 'zao', 'ji', 'gui', 'su', 'lou', 'ce', 'lu', 0x10 => 'nian', 'suo', 'cuan', 'diao', 'suo', 'le', 'duan', 'liang', 'xiao', 'bo', 'mi', 'shai', 'dang', 'liao', 'dan', 'dian', 0x20 => 'fu', 'jian', 'min', 'kui', 'dai', 'jiao', 'deng', 'huang', 'sun', 'lao', 'zan', 'xiao', 'lu', 'shi', 'zan', 'qi', @@ -22,4 +22,4 @@ 0xD0 => 'fu', 'nuo', 'bei', 'gu', 'xiu', 'gao', 'tang', 'qiu', 'jia', 'cao', 'zhuang', 'tang', 'mi', 'san', 'fen', 'zao', 0xE0 => 'kang', 'jiang', 'mo', 'san', 'san', 'nuo', 'xi', 'liang', 'jiang', 'kuai', 'bo', 'huan', 'shu', 'zong', 'xian', 'nuo', 0xF0 => 'tuan', 'nie', 'li', 'zuo', 'di', 'nie', 'tiao', 'lan', 'mi', 'si', 'jiu', 'xi', 'gong', 'zheng', 'jiu', 'you', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x7d.php b/core/lib/Drupal/Component/Transliteration/data/x7d.php index 1cfdab2..352293d 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x7d.php +++ b/core/lib/Drupal/Component/Transliteration/data/x7d.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ji', 'cha', 'zhou', 'xun', 'yue', 'hong', 'yu', 'he', 'wan', 'ren', 'wen', 'wen', 'qiu', 'na', 'zi', 'tou', 0x10 => 'niu', 'fou', 'ji', 'shu', 'chun', 'pi', 'zhen', 'sha', 'hong', 'zhi', 'ji', 'fen', 'yun', 'ren', 'dan', 'jin', 0x20 => 'su', 'fang', 'suo', 'cui', 'jiu', 'za', 'ba', 'jin', 'fu', 'zhi', 'ci', 'zi', 'chou', 'hong', 'za', 'lei', @@ -22,4 +22,4 @@ 0xD0 => 'fan', 'lu', 'xu', 'ying', 'shang', 'qi', 'xu', 'xiang', 'jian', 'ke', 'xian', 'ruan', 'mian', 'ji', 'duan', 'chong', 0xE0 => 'di', 'min', 'miao', 'yuan', 'xie', 'bao', 'si', 'qiu', 'bian', 'huan', 'geng', 'cong', 'mian', 'wei', 'fu', 'wei', 0xF0 => 'tou', 'gou', 'miao', 'xie', 'lian', 'zong', 'bian', 'yun', 'yin', 'ti', 'gua', 'zhi', 'yun', 'cheng', 'chan', 'dai', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x7e.php b/core/lib/Drupal/Component/Transliteration/data/x7e.php index e66acc5..a278c2d 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x7e.php +++ b/core/lib/Drupal/Component/Transliteration/data/x7e.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'xia', 'yuan', 'zong', 'xu', 'ying', 'wei', 'geng', 'xuan', 'ying', 'jin', 'yi', 'zhui', 'ni', 'bang', 'gu', 'pan', 0x10 => 'zhou', 'jian', 'ci', 'quan', 'shuang', 'yun', 'xia', 'cui', 'xi', 'rong', 'tao', 'fu', 'yun', 'chen', 'gao', 'ru', 0x20 => 'hu', 'zai', 'teng', 'xian', 'su', 'zhen', 'zong', 'tao', 'huang', 'cai', 'bi', 'feng', 'cu', 'li', 'suo', 'yan', @@ -22,4 +22,4 @@ 0xD0 => 'dai', 'bang', 'rong', 'jie', 'ku', 'rao', 'die', 'hang', 'hui', 'gei', 'xuan', 'jiang', 'luo', 'jue', 'jiao', 'tong', 0xE0 => 'geng', 'xiao', 'juan', 'xiu', 'xi', 'sui', 'tao', 'ji', 'ti', 'ji', 'xu', 'ling', 'ying', 'xu', 'qi', 'fei', 0xF0 => 'chuo', 'shang', 'gun', 'sheng', 'wei', 'mian', 'shou', 'beng', 'chou', 'tao', 'liu', 'quan', 'zong', 'zhan', 'wan', 'lu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x7f.php b/core/lib/Drupal/Component/Transliteration/data/x7f.php index 7f586dd..78e3243 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x7f.php +++ b/core/lib/Drupal/Component/Transliteration/data/x7f.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'zhui', 'zi', 'ke', 'xiang', 'jian', 'mian', 'lan', 'ti', 'miao', 'ji', 'yun', 'hui', 'si', 'duo', 'duan', 'bian', 0x10 => 'xian', 'gou', 'zhui', 'huan', 'di', 'lu', 'bian', 'min', 'yuan', 'jin', 'fu', 'ru', 'zhen', 'feng', 'cui', 'gao', 0x20 => 'chan', 'li', 'yi', 'jian', 'bin', 'piao', 'man', 'lei', 'ying', 'suo', 'mou', 'sao', 'xie', 'liao', 'shan', 'zeng', @@ -22,4 +22,4 @@ 0xD0 => 'zhi', 'qu', 'xi', 'xie', 'xiang', 'xi', 'xi', 'ke', 'qiao', 'hui', 'hui', 'xiao', 'sha', 'hong', 'jiang', 'di', 0xE0 => 'cui', 'fei', 'dao', 'sha', 'chi', 'zhu', 'jian', 'xuan', 'chi', 'pian', 'zong', 'wan', 'hui', 'hou', 'he', 'he', 0xF0 => 'han', 'ao', 'piao', 'yi', 'lian', 'hou', 'ao', 'lin', 'pen', 'qiao', 'ao', 'fan', 'yi', 'hui', 'xuan', 'dao', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x80.php b/core/lib/Drupal/Component/Transliteration/data/x80.php index 33b80ca..0cbf2aa 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x80.php +++ b/core/lib/Drupal/Component/Transliteration/data/x80.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'yao', 'lao', 'lao', 'kao', 'mao', 'zhe', 'qi', 'gou', 'gou', 'gou', 'die', 'die', 'er', 'shua', 'ruan', 'nai', 0x10 => 'nai', 'duan', 'lei', 'ting', 'zi', 'geng', 'chao', 'hao', 'yun', 'ba', 'pi', 'yi', 'si', 'qu', 'jia', 'ju', 0x20 => 'huo', 'chu', 'lao', 'lun', 'ji', 'tang', 'ou', 'lou', 'nou', 'jiang', 'pang', 'zha', 'lou', 'ji', 'lao', 'huo', @@ -22,4 +22,4 @@ 0xD0 => 'ku', 'zhi', 'ni', 'ping', 'zi', 'fu', 'pang', 'zhen', 'xian', 'zuo', 'pei', 'jia', 'sheng', 'zhi', 'bao', 'mu', 0xE0 => 'qu', 'hu', 'ke', 'chi', 'yin', 'xu', 'yang', 'long', 'dong', 'ka', 'lu', 'jing', 'nu', 'yan', 'pang', 'kua', 0xF0 => 'yi', 'guang', 'hai', 'ge', 'dong', 'chi', 'jiao', 'xiong', 'xiong', 'er', 'an', 'heng', 'pian', 'neng', 'zi', 'gui', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x81.php b/core/lib/Drupal/Component/Transliteration/data/x81.php index 81fb424..dd5afc1 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x81.php +++ b/core/lib/Drupal/Component/Transliteration/data/x81.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'cheng', 'tiao', 'zhi', 'cui', 'mei', 'xie', 'cui', 'xie', 'mai', 'mai', 'ji', 'xie', 'nin', 'kuai', 'sa', 'zang', 0x10 => 'qi', 'nao', 'mi', 'nong', 'luan', 'wan', 'bo', 'wen', 'wan', 'xiu', 'jiao', 'jing', 'you', 'heng', 'cuo', 'lie', 0x20 => 'shan', 'ting', 'mei', 'chun', 'shen', 'qian', 'de', 'juan', 'cu', 'xiu', 'xin', 'tuo', 'pao', 'cheng', 'nei', 'pu', @@ -22,4 +22,4 @@ 0xD0 => 'xun', 'nao', 'wo', 'zang', 'xian', 'biao', 'xing', 'kuan', 'la', 'yan', 'lu', 'huo', 'za', 'luo', 'qu', 'zang', 0xE0 => 'luan', 'ni', 'za', 'chen', 'qian', 'wo', 'guang', 'zang', 'lin', 'guang', 'zi', 'jiao', 'nie', 'chou', 'ji', 'gao', 0xF0 => 'chou', 'mian', 'nie', 'zhi', 'zhi', 'ge', 'jian', 'die', 'zhi', 'xiu', 'tai', 'zhen', 'jiu', 'xian', 'yu', 'cha', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x82.php b/core/lib/Drupal/Component/Transliteration/data/x82.php index 1013057..415fdb5 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x82.php +++ b/core/lib/Drupal/Component/Transliteration/data/x82.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'yao', 'yu', 'chong', 'xi', 'xi', 'jiu', 'yu', 'yu', 'xing', 'ju', 'jiu', 'xin', 'she', 'she', 'she', 'jiu', 0x10 => 'shi', 'tan', 'shu', 'shi', 'tian', 'tan', 'pu', 'pu', 'guan', 'hua', 'tian', 'chuan', 'shun', 'xia', 'wu', 'zhou', 0x20 => 'dao', 'chuan', 'shan', 'yi', 'fan', 'pa', 'tai', 'fan', 'ban', 'chuan', 'hang', 'fang', 'ban', 'bi', 'lu', 'zhong', @@ -22,4 +22,4 @@ 0xD0 => 'ti', 'yuan', 'ran', 'ling', 'tai', 'shao', 'di', 'miao', 'qing', 'li', 'yong', 'ke', 'mu', 'bei', 'bao', 'gou', 0xE0 => 'min', 'yi', 'yi', 'ju', 'pie', 'ruo', 'ku', 'ning', 'ni', 'bo', 'bing', 'shan', 'xiu', 'yao', 'xian', 'ben', 0xF0 => 'hong', 'ying', 'zha', 'dong', 'ju', 'die', 'nie', 'gan', 'hu', 'ping', 'mei', 'fu', 'sheng', 'gu', 'bi', 'wei', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x83.php b/core/lib/Drupal/Component/Transliteration/data/x83.php index 0c2a631..73fe3fc 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x83.php +++ b/core/lib/Drupal/Component/Transliteration/data/x83.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'fu', 'zhuo', 'mao', 'fan', 'jia', 'mao', 'mao', 'ba', 'ci', 'mo', 'zi', 'di', 'chi', 'ji', 'jing', 'long', 0x10 => 'cong', 'niao', 'yuan', 'xue', 'ying', 'qiong', 'ge', 'ming', 'li', 'rong', 'yin', 'gen', 'qian', 'chai', 'chen', 'yu', 0x20 => 'hao', 'zi', 'lie', 'wu', 'ji', 'gui', 'ci', 'jian', 'ci', 'gou', 'guang', 'mang', 'cha', 'jiao', 'jiao', 'fu', @@ -22,4 +22,4 @@ 0xD0 => 'pu', 'zai', 'gao', 'guo', 'fu', 'lun', 'chang', 'chou', 'song', 'chui', 'zhan', 'men', 'cai', 'ba', 'li', 'tu', 0xE0 => 'bo', 'han', 'bao', 'qin', 'juan', 'xi', 'qin', 'di', 'jie', 'pu', 'dang', 'jin', 'qiao', 'tai', 'geng', 'hua', 0xF0 => 'gu', 'ling', 'fei', 'qin', 'an', 'wang', 'beng', 'zhou', 'yan', 'ju', 'jian', 'lin', 'tan', 'shu', 'tian', 'dao', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x84.php b/core/lib/Drupal/Component/Transliteration/data/x84.php index 6839979..4714535 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x84.php +++ b/core/lib/Drupal/Component/Transliteration/data/x84.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'hu', 'qi', 'he', 'cui', 'tao', 'chun', 'bi', 'chang', 'huan', 'fei', 'lai', 'qi', 'meng', 'ping', 'wei', 'dan', 0x10 => 'sha', 'huan', 'yan', 'yi', 'tiao', 'qi', 'wan', 'ce', 'nai', 'zhen', 'tuo', 'jiu', 'tie', 'luo', 'bi', 'yi', 0x20 => 'meng', 'bo', 'pao', 'ding', 'ying', 'ying', 'ying', 'xiao', 'sa', 'qiu', 'ke', 'xiang', 'wan', 'yu', 'yu', 'fu', @@ -22,4 +22,4 @@ 0xD0 => 'ru', 'suo', 'xuan', 'bei', 'yao', 'gui', 'bi', 'zong', 'gun', 'zuo', 'tiao', 'ce', 'pei', 'lan', 'dan', 'ji', 0xE0 => 'li', 'shen', 'lang', 'yu', 'ling', 'ying', 'mo', 'diao', 'tiao', 'mao', 'tong', 'chu', 'peng', 'an', 'lian', 'cong', 0xF0 => 'xi', 'ping', 'qiu', 'jin', 'chun', 'jie', 'wei', 'tui', 'cao', 'yu', 'yi', 'zi', 'liao', 'bi', 'lu', 'xu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x85.php b/core/lib/Drupal/Component/Transliteration/data/x85.php index 7fb87f1..a5e4cd5 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x85.php +++ b/core/lib/Drupal/Component/Transliteration/data/x85.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'bu', 'zhang', 'lei', 'qiang', 'man', 'yan', 'ling', 'ji', 'biao', 'gun', 'han', 'di', 'su', 'lu', 'she', 'shang', 0x10 => 'di', 'mie', 'xun', 'man', 'bo', 'di', 'cuo', 'zhe', 'shen', 'xuan', 'wei', 'hu', 'ao', 'mi', 'lou', 'cu', 0x20 => 'zhong', 'cai', 'po', 'jiang', 'mi', 'cong', 'niao', 'hui', 'juan', 'yin', 'jian', 'nian', 'shu', 'yin', 'guo', 'chen', @@ -22,4 +22,4 @@ 0xD0 => 'miao', 'qiong', 'qie', 'xian', 'liao', 'ou', 'xian', 'su', 'lu', 'yi', 'xu', 'xie', 'li', 'yi', 'la', 'lei', 0xE0 => 'jiao', 'di', 'zhi', 'bei', 'teng', 'yao', 'mo', 'huan', 'biao', 'fan', 'sou', 'tan', 'tui', 'qiong', 'qiao', 'wei', 0xF0 => 'liu', 'hui', 'ou', 'gao', 'yun', 'bao', 'li', 'shu', 'chu', 'ai', 'lin', 'zao', 'xuan', 'qin', 'lai', 'huo', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x86.php b/core/lib/Drupal/Component/Transliteration/data/x86.php index 8615a1d..285c2d1 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x86.php +++ b/core/lib/Drupal/Component/Transliteration/data/x86.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'tuo', 'wu', 'rui', 'rui', 'qi', 'heng', 'lu', 'su', 'tui', 'meng', 'yun', 'ping', 'yu', 'xun', 'ji', 'jiong', 0x10 => 'xuan', 'mo', 'qiu', 'su', 'jiong', 'feng', 'nie', 'bo', 'rang', 'yi', 'xian', 'yu', 'ju', 'lian', 'lian', 'yin', 0x20 => 'qiang', 'ying', 'long', 'tou', 'wei', 'yue', 'ling', 'qu', 'yao', 'fan', 'mei', 'han', 'kui', 'lan', 'ji', 'dang', @@ -22,4 +22,4 @@ 0xD0 => 'qu', 'mou', 'ge', 'ci', 'hui', 'hui', 'mang', 'fu', 'yang', 'wa', 'lie', 'zhu', 'yi', 'xian', 'kuo', 'jiao', 0xE0 => 'li', 'yi', 'ping', 'qi', 'ha', 'she', 'yi', 'wang', 'mo', 'qiong', 'qie', 'gui', 'qiong', 'zhi', 'man', 'lao', 0xF0 => 'zhe', 'jia', 'nao', 'si', 'qi', 'xing', 'jie', 'qiu', 'shao', 'yong', 'jia', 'tui', 'che', 'bai', 'e', 'han', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x87.php b/core/lib/Drupal/Component/Transliteration/data/x87.php index be4f227..c9a1208 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x87.php +++ b/core/lib/Drupal/Component/Transliteration/data/x87.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'shu', 'xuan', 'feng', 'shen', 'shen', 'fu', 'xian', 'zhe', 'wu', 'fu', 'li', 'lang', 'bi', 'chu', 'yuan', 'you', 0x10 => 'jie', 'dan', 'yan', 'ting', 'dian', 'tui', 'hui', 'wo', 'zhi', 'song', 'fei', 'ju', 'mi', 'qi', 'qi', 'yu', 0x20 => 'jun', 'la', 'meng', 'qiang', 'si', 'xi', 'lun', 'li', 'die', 'tiao', 'tao', 'kun', 'han', 'han', 'yu', 'bang', @@ -22,4 +22,4 @@ 0xD0 => 'chang', 'zhang', 'mang', 'xiang', 'mo', 'zui', 'si', 'qiu', 'te', 'zhi', 'peng', 'peng', 'jiao', 'qu', 'bie', 'liao', 0xE0 => 'pan', 'gui', 'xi', 'ji', 'zhuan', 'huang', 'fei', 'lao', 'jue', 'jue', 'hui', 'yin', 'chan', 'jiao', 'shan', 'nao', 0xF0 => 'xiao', 'wu', 'chong', 'xun', 'si', 'chu', 'cheng', 'dang', 'li', 'xie', 'shan', 'yi', 'jing', 'da', 'chan', 'qi', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x88.php b/core/lib/Drupal/Component/Transliteration/data/x88.php index 8843060..45feb58 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x88.php +++ b/core/lib/Drupal/Component/Transliteration/data/x88.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ci', 'xiang', 'she', 'luo', 'qin', 'ying', 'chai', 'li', 'zei', 'xuan', 'lian', 'zhu', 'ze', 'xie', 'mang', 'xie', 0x10 => 'qi', 'rong', 'jian', 'meng', 'hao', 'ru', 'huo', 'zhuo', 'jie', 'pin', 'he', 'mie', 'fan', 'lei', 'jie', 'la', 0x20 => 'min', 'li', 'chun', 'li', 'qiu', 'nie', 'lu', 'du', 'xiao', 'zhu', 'long', 'li', 'long', 'feng', 'ye', 'beng', @@ -22,4 +22,4 @@ 0xD0 => 'juan', 'shen', 'pou', 'ge', 'yi', 'yu', 'zhen', 'liu', 'qiu', 'qun', 'ji', 'yi', 'bu', 'zhuang', 'shui', 'sha', 0xE0 => 'qun', 'li', 'lian', 'lian', 'ku', 'jian', 'fou', 'chan', 'bi', 'kun', 'tao', 'yuan', 'ling', 'chi', 'chang', 'chou', 0xF0 => 'duo', 'biao', 'liang', 'shang', 'pei', 'pei', 'fei', 'yuan', 'luo', 'guo', 'yan', 'du', 'ti', 'zhi', 'ju', 'yi', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x89.php b/core/lib/Drupal/Component/Transliteration/data/x89.php index 0504963..fbef66d 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x89.php +++ b/core/lib/Drupal/Component/Transliteration/data/x89.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ji', 'zhi', 'gua', 'ken', 'qi', 'ti', 'ti', 'fu', 'chong', 'xie', 'bian', 'die', 'kun', 'duan', 'xiu', 'xiu', 0x10 => 'he', 'yuan', 'bao', 'bao', 'fu', 'yu', 'tuan', 'yan', 'hui', 'bei', 'chu', 'lu', 'pao', 'dan', 'yun', 'ta', 0x20 => 'gou', 'da', 'huai', 'rong', 'yuan', 'ru', 'nai', 'jiong', 'suo', 'ban', 'tui', 'chi', 'sang', 'niao', 'ying', 'jie', @@ -22,4 +22,4 @@ 0xD0 => 'jin', 'qu', 'jiao', 'qiu', 'jin', 'cu', 'jue', 'zhi', 'chao', 'ji', 'gu', 'dan', 'zi', 'di', 'shang', 'hua', 0xE0 => 'quan', 'ge', 'shi', 'jie', 'gui', 'gong', 'chu', 'jie', 'hun', 'qiu', 'xing', 'su', 'ni', 'ji', 'lu', 'zhi', 0xF0 => 'zha', 'bi', 'xing', 'hu', 'shang', 'gong', 'zhi', 'xue', 'chu', 'xi', 'yi', 'li', 'jue', 'xi', 'yan', 'xi', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x8a.php b/core/lib/Drupal/Component/Transliteration/data/x8a.php index 111894c..03abb66 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x8a.php +++ b/core/lib/Drupal/Component/Transliteration/data/x8a.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'yan', 'yan', 'ding', 'fu', 'qiu', 'qiu', 'jiao', 'hong', 'ji', 'fan', 'xun', 'diao', 'hong', 'chai', 'tao', 'xu', 0x10 => 'jie', 'yi', 'ren', 'xun', 'yin', 'shan', 'qi', 'tuo', 'ji', 'xun', 'yin', 'e', 'fen', 'ya', 'yao', 'song', 0x20 => 'shen', 'yin', 'xin', 'jue', 'xiao', 'ne', 'chen', 'you', 'zhi', 'xiong', 'fang', 'xin', 'chao', 'she', 'xian', 'sa', @@ -22,4 +22,4 @@ 0xD0 => 'qian', 'zhuo', 'liang', 'jian', 'chu', 'hao', 'lun', 'shen', 'biao', 'huai', 'pian', 'yu', 'die', 'xu', 'pian', 'shi', 0xE0 => 'xuan', 'shi', 'hun', 'hua', 'e', 'zhong', 'di', 'xie', 'fu', 'pu', 'ting', 'jian', 'qi', 'yu', 'zi', 'zhuan', 0xF0 => 'xi', 'hui', 'yin', 'an', 'xian', 'nan', 'chen', 'feng', 'zhu', 'yang', 'yan', 'huang', 'xuan', 'ge', 'nuo', 'qi', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x8b.php b/core/lib/Drupal/Component/Transliteration/data/x8b.php index 0a535f7..2cdc115 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x8b.php +++ b/core/lib/Drupal/Component/Transliteration/data/x8b.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'mou', 'ye', 'wei', 'xing', 'teng', 'zhou', 'shan', 'jian', 'po', 'kui', 'huang', 'huo', 'ge', 'ying', 'mi', 'xiao', 0x10 => 'mi', 'xi', 'qiang', 'chen', 'xue', 'ti', 'su', 'bang', 'chi', 'qian', 'shi', 'jiang', 'yuan', 'xie', 'he', 'tao', 0x20 => 'yao', 'yao', 'zhi', 'yu', 'biao', 'cong', 'qing', 'li', 'mo', 'mo', 'shang', 'zhe', 'miu', 'jian', 'ze', 'jie', @@ -22,4 +22,4 @@ 0xD0 => 'bi', 'yi', 'yi', 'kuang', 'lei', 'shi', 'gua', 'shi', 'ji', 'hui', 'cheng', 'zhu', 'shen', 'hua', 'dan', 'gou', 0xE0 => 'quan', 'gui', 'xun', 'yi', 'zheng', 'gai', 'xiang', 'cha', 'hun', 'xu', 'zhou', 'jie', 'wu', 'yu', 'qiao', 'wu', 0xF0 => 'gao', 'you', 'hui', 'kuang', 'shuo', 'song', 'ei', 'qing', 'zhu', 'zou', 'nuo', 'du', 'zhuo', 'fei', 'ke', 'wei', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x8c.php b/core/lib/Drupal/Component/Transliteration/data/x8c.php index 5e805ad..8b3d3ba 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x8c.php +++ b/core/lib/Drupal/Component/Transliteration/data/x8c.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'yu', 'shui', 'shen', 'diao', 'chan', 'liang', 'zhun', 'sui', 'tan', 'shen', 'yi', 'mou', 'chen', 'die', 'huang', 'jian', 0x10 => 'xie', 'xue', 'ye', 'wei', 'e', 'yu', 'xuan', 'chan', 'zi', 'an', 'yan', 'di', 'mi', 'pian', 'xu', 'mo', 0x20 => 'dang', 'su', 'xie', 'yao', 'bang', 'shi', 'qian', 'mi', 'jin', 'man', 'zhe', 'jian', 'miu', 'tan', 'zen', 'qiao', @@ -22,4 +22,4 @@ 0xD0 => 'xun', 'zhen', 'she', 'bin', 'bin', 'qiu', 'she', 'chuan', 'zang', 'zhou', 'lai', 'zan', 'ci', 'chen', 'shang', 'tian', 0xE0 => 'pei', 'geng', 'xian', 'mai', 'jian', 'sui', 'fu', 'tan', 'cong', 'cong', 'zhi', 'ji', 'zhang', 'du', 'jin', 'xiong', 0xF0 => 'chun', 'yun', 'bao', 'zai', 'lai', 'feng', 'cang', 'ji', 'sheng', 'yi', 'zhuan', 'fu', 'gou', 'sai', 'ze', 'liao', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x8d.php b/core/lib/Drupal/Component/Transliteration/data/x8d.php index c4b8695..07fc8d7 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x8d.php +++ b/core/lib/Drupal/Component/Transliteration/data/x8d.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'yi', 'bai', 'chen', 'wan', 'zhi', 'zhui', 'biao', 'yun', 'zeng', 'dan', 'zan', 'yan', 'pu', 'shan', 'wan', 'ying', 0x10 => 'jin', 'gan', 'xian', 'zang', 'bi', 'du', 'shu', 'yan', 'shang', 'xuan', 'long', 'gan', 'zang', 'bei', 'zhen', 'fu', 0x20 => 'yuan', 'gong', 'cai', 'ze', 'xian', 'bai', 'zhang', 'huo', 'zhi', 'fan', 'tan', 'pin', 'bian', 'gou', 'zhu', 'guan', @@ -22,4 +22,4 @@ 0xD0 => 'ci', 'pao', 'qia', 'zhu', 'ju', 'dian', 'zhi', 'fu', 'pan', 'ju', 'shan', 'bo', 'ni', 'ju', 'li', 'gen', 0xE0 => 'yi', 'ji', 'duo', 'xian', 'jiao', 'duo', 'zhu', 'quan', 'kua', 'zhuai', 'gui', 'qiong', 'kui', 'xiang', 'chi', 'lu', 0xF0 => 'pian', 'zhi', 'jia', 'tiao', 'cai', 'jian', 'ta', 'qiao', 'bi', 'xian', 'duo', 'ji', 'ju', 'ji', 'shu', 'tu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x8e.php b/core/lib/Drupal/Component/Transliteration/data/x8e.php index 80ef740..c48ec1d 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x8e.php +++ b/core/lib/Drupal/Component/Transliteration/data/x8e.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'chu', 'jing', 'nie', 'xiao', 'bu', 'xue', 'cun', 'mu', 'shu', 'liang', 'yong', 'jiao', 'chou', 'qiao', 'mou', 'ta', 0x10 => 'jian', 'qi', 'wo', 'wei', 'chuo', 'jie', 'ji', 'nie', 'ju', 'ju', 'lun', 'lu', 'leng', 'huai', 'ju', 'chi', 0x20 => 'wan', 'quan', 'ti', 'bo', 'zu', 'qie', 'yi', 'cu', 'zong', 'cai', 'zong', 'peng', 'zhi', 'zheng', 'dian', 'zhi', @@ -22,4 +22,4 @@ 0xD0 => 'xin', 'dai', 'xuan', 'fan', 'ren', 'shan', 'kuang', 'shu', 'tun', 'chen', 'dai', 'e', 'na', 'qi', 'mao', 'ruan', 0xE0 => 'ren', 'qian', 'zhuan', 'hong', 'hu', 'qu', 'kuang', 'di', 'ling', 'dai', 'ao', 'zhen', 'fan', 'kuang', 'yang', 'peng', 0xF0 => 'bei', 'gu', 'gu', 'pao', 'zhu', 'rong', 'e', 'ba', 'zhou', 'zhi', 'yao', 'ke', 'yi', 'zhi', 'shi', 'ping', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x8f.php b/core/lib/Drupal/Component/Transliteration/data/x8f.php index a4cd21b..e7185a9 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x8f.php +++ b/core/lib/Drupal/Component/Transliteration/data/x8f.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'er', 'gong', 'ju', 'jiao', 'guang', 'he', 'kai', 'quan', 'zhou', 'zai', 'zhi', 'she', 'liang', 'yu', 'shao', 'you', 0x10 => 'wan', 'yin', 'zhe', 'wan', 'fu', 'qing', 'zhou', 'ni', 'leng', 'zhe', 'zhan', 'liang', 'zi', 'hui', 'wang', 'chuo', 0x20 => 'guo', 'kan', 'yi', 'peng', 'qian', 'gun', 'nian', 'ping', 'guan', 'bei', 'lun', 'pai', 'liang', 'ruan', 'rou', 'ji', @@ -22,4 +22,4 @@ 0xD0 => 'yun', 'jin', 'hang', 'ya', 'fan', 'wu', 'da', 'e', 'hai', 'zhe', 'zhong', 'jin', 'yuan', 'wei', 'lian', 'chi', 0xE0 => 'che', 'ni', 'tiao', 'zhi', 'yi', 'jiong', 'jia', 'chen', 'dai', 'er', 'di', 'po', 'zhu', 'die', 'ze', 'tao', 0xF0 => 'shu', 'tuo', 'qu', 'jing', 'hui', 'dong', 'you', 'mi', 'beng', 'ji', 'nai', 'yi', 'jie', 'zhui', 'lie', 'xun', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x90.php b/core/lib/Drupal/Component/Transliteration/data/x90.php index e2a817b..97821c45 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x90.php +++ b/core/lib/Drupal/Component/Transliteration/data/x90.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'tui', 'song', 'shi', 'tao', 'pang', 'hou', 'ni', 'dun', 'jiong', 'xuan', 'xun', 'bu', 'you', 'xiao', 'qiu', 'tou', 0x10 => 'zhu', 'qiu', 'di', 'di', 'tu', 'jing', 'ti', 'dou', 'yi', 'zhe', 'tong', 'guang', 'wu', 'shi', 'cheng', 'su', 0x20 => 'zao', 'qun', 'feng', 'lian', 'suo', 'hui', 'li', 'gu', 'lai', 'ben', 'cuo', 'jue', 'beng', 'huan', 'dai', 'lu', @@ -22,4 +22,4 @@ 0xD0 => 'kuai', 'zheng', 'lang', 'yun', 'yan', 'cheng', 'dou', 'xi', 'lu', 'fu', 'wu', 'fu', 'gao', 'hao', 'lang', 'jia', 0xE0 => 'geng', 'jun', 'ying', 'bo', 'xi', 'bei', 'li', 'yun', 'bu', 'xiao', 'qi', 'pi', 'qing', 'guo', 'zhou', 'tan', 0xF0 => 'zou', 'ping', 'lai', 'ni', 'chen', 'you', 'bu', 'xiang', 'dan', 'ju', 'yong', 'qiao', 'yi', 'dou', 'yan', 'mei', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x91.php b/core/lib/Drupal/Component/Transliteration/data/x91.php index 2de4466..4f10582 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x91.php +++ b/core/lib/Drupal/Component/Transliteration/data/x91.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ruo', 'bei', 'e', 'shu', 'juan', 'yu', 'yun', 'hou', 'kui', 'xiang', 'xiang', 'sou', 'tang', 'ming', 'xi', 'ru', 0x10 => 'chu', 'zi', 'zou', 'ye', 'wu', 'xiang', 'yun', 'hao', 'yong', 'bi', 'mao', 'chao', 'fu', 'liao', 'yin', 'zhuan', 0x20 => 'hu', 'qiao', 'yan', 'zhang', 'man', 'qiao', 'xu', 'deng', 'bi', 'xun', 'bi', 'zeng', 'wei', 'zheng', 'mao', 'shan', @@ -22,4 +22,4 @@ 0xD0 => 'li', 'jin', 'jin', 'qiu', 'yi', 'liao', 'dao', 'zhao', 'ding', 'po', 'qiu', 'ba', 'fu', 'zhen', 'zhi', 'ba', 0xE0 => 'luan', 'fu', 'nai', 'diao', 'shan', 'qiao', 'kou', 'chuan', 'zi', 'fan', 'hua', 'hua', 'han', 'gang', 'qi', 'mang', 0xF0 => 'ri', 'di', 'si', 'xi', 'yi', 'chai', 'shi', 'tu', 'xi', 'nu', 'qian', 'qiu', 'jian', 'pi', 'ye', 'jin', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x92.php b/core/lib/Drupal/Component/Transliteration/data/x92.php index 037b461..2602bf6 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x92.php +++ b/core/lib/Drupal/Component/Transliteration/data/x92.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ba', 'fang', 'chen', 'xing', 'dou', 'yue', 'qian', 'fu', 'pi', 'na', 'xin', 'e', 'jue', 'dun', 'gou', 'yin', 0x10 => 'qian', 'ban', 'sa', 'ren', 'chao', 'niu', 'fen', 'yun', 'ji', 'qin', 'pi', 'guo', 'hong', 'yin', 'jun', 'shi', 0x20 => 'yi', 'zhong', 'xi', 'gai', 'ri', 'huo', 'tai', 'kang', 'yuan', 'lu', 'e', 'wen', 'duo', 'zi', 'ni', 'tu', @@ -22,4 +22,4 @@ 0xD0 => 'hong', 'cuan', 'feng', 'chan', 'wan', 'zhi', 'si', 'xuan', 'hua', 'yu', 'tiao', 'gong', 'zhuo', 'lue', 'xing', 'qin', 0xE0 => 'shen', 'han', 'lue', 'ye', 'chu', 'zeng', 'ju', 'xian', 'tie', 'mang', 'pu', 'li', 'pan', 'rui', 'cheng', 'gao', 0xF0 => 'li', 'te', 'bing', 'zhu', 'zhen', 'tu', 'liu', 'zui', 'ju', 'chang', 'yuan', 'jian', 'gang', 'diao', 'tao', 'chang', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x93.php b/core/lib/Drupal/Component/Transliteration/data/x93.php index 34928a9..cecc317 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x93.php +++ b/core/lib/Drupal/Component/Transliteration/data/x93.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'lun', 'guo', 'ling', 'bei', 'lu', 'li', 'qiang', 'pou', 'juan', 'min', 'zui', 'peng', 'an', 'pi', 'xian', 'ya', 0x10 => 'zhui', 'lei', 'ke', 'kong', 'ta', 'kun', 'du', 'nei', 'chui', 'zi', 'zheng', 'ben', 'nie', 'zong', 'chun', 'tan', 0x20 => 'ding', 'qi', 'qian', 'zhui', 'ji', 'yu', 'jin', 'guan', 'mao', 'chang', 'tian', 'xi', 'lian', 'tao', 'gu', 'cuo', @@ -22,4 +22,4 @@ 0xD0 => 'liu', 'di', 'san', 'zong', 'yi', 'lu', 'ao', 'keng', 'qiang', 'cui', 'qi', 'chang', 'tang', 'man', 'yong', 'chan', 0xE0 => 'feng', 'jing', 'biao', 'shu', 'lou', 'xiu', 'cong', 'long', 'zan', 'jian', 'cao', 'li', 'xia', 'xi', 'kang', 'shuang', 0xF0 => 'beng', 'zhang', 'qian', 'cheng', 'lu', 'hua', 'ji', 'pu', 'hui', 'qiang', 'po', 'lin', 'se', 'xiu', 'san', 'cheng', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x94.php b/core/lib/Drupal/Component/Transliteration/data/x94.php index 9763fbc..1bb228a 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x94.php +++ b/core/lib/Drupal/Component/Transliteration/data/x94.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'kui', 'si', 'liu', 'nao', 'huang', 'pie', 'sui', 'fan', 'qiao', 'quan', 'yang', 'tang', 'xiang', 'jue', 'jiao', 'zun', 0x10 => 'liao', 'qie', 'lao', 'dui', 'xin', 'zan', 'ji', 'jian', 'zhong', 'deng', 'ya', 'ying', 'dui', 'jue', 'nou', 'zan', 0x20 => 'pu', 'tie', 'fan', 'zhang', 'ding', 'shan', 'kai', 'jian', 'fei', 'sui', 'lu', 'juan', 'hui', 'yu', 'lian', 'zhuo', @@ -22,4 +22,4 @@ 0xD0 => 'kao', 'lao', 'er', 'mang', 'ya', 'you', 'cheng', 'jia', 'ye', 'nao', 'zhi', 'dang', 'tong', 'lu', 'diao', 'yin', 0xE0 => 'kai', 'zha', 'zhu', 'xi', 'ding', 'diu', 'xian', 'hua', 'quan', 'sha', 'ha', 'diao', 'ge', 'ming', 'zheng', 'se', 0xF0 => 'jiao', 'yi', 'chan', 'chong', 'tang', 'an', 'yin', 'ru', 'zhu', 'lao', 'pu', 'wu', 'lai', 'te', 'lian', 'keng', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x95.php b/core/lib/Drupal/Component/Transliteration/data/x95.php index 84f2f89..fc95f36 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x95.php +++ b/core/lib/Drupal/Component/Transliteration/data/x95.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'xiao', 'suo', 'li', 'zeng', 'chu', 'guo', 'gao', 'e', 'xiu', 'cuo', 'lue', 'feng', 'xin', 'liu', 'kai', 'jian', 0x10 => 'rui', 'ti', 'lang', 'qin', 'ju', 'a', 'qiang', 'zhe', 'nuo', 'cuo', 'mao', 'ben', 'qi', 'de', 'ke', 'kun', 0x20 => 'chang', 'xi', 'gu', 'luo', 'chui', 'zhui', 'jin', 'zhi', 'xian', 'juan', 'huo', 'pei', 'tan', 'ding', 'jian', 'ju', @@ -22,4 +22,4 @@ 0xD0 => 'tian', 'nie', 'ta', 'kai', 'he', 'que', 'chuang', 'guan', 'dou', 'qi', 'kui', 'tang', 'guan', 'piao', 'kan', 'xi', 0xE0 => 'hui', 'chan', 'pi', 'dang', 'huan', 'ta', 'wen', 'ta', 'men', 'shuan', 'shan', 'yan', 'han', 'bi', 'wen', 'chuang', 0xF0 => 'run', 'wei', 'xian', 'hong', 'jian', 'min', 'kang', 'men', 'zha', 'nao', 'gui', 'wen', 'ta', 'min', 'lu', 'kai', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x96.php b/core/lib/Drupal/Component/Transliteration/data/x96.php index f665409..7f62e47 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x96.php +++ b/core/lib/Drupal/Component/Transliteration/data/x96.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'fa', 'ge', 'he', 'kun', 'jiu', 'yue', 'lang', 'du', 'yu', 'yan', 'chang', 'xi', 'wen', 'hun', 'yan', 'e', 0x10 => 'chan', 'lan', 'qu', 'hui', 'kuo', 'que', 'he', 'tian', 'da', 'que', 'han', 'huan', 'fu', 'fu', 'le', 'dui', 0x20 => 'xin', 'qian', 'wu', 'gai', 'zhi', 'yin', 'yang', 'dou', 'e', 'sheng', 'ban', 'pei', 'keng', 'yun', 'ruan', 'zhi', @@ -22,4 +22,4 @@ 0xD0 => 'hu', 'za', 'luo', 'yu', 'chou', 'diao', 'sui', 'han', 'wo', 'shuang', 'guan', 'chu', 'za', 'yong', 'ji', 'xi', 0xE0 => 'chou', 'liu', 'li', 'nan', 'xue', 'za', 'ji', 'ji', 'yu', 'yu', 'xue', 'na', 'fou', 'se', 'mu', 'wen', 0xF0 => 'fen', 'pang', 'yun', 'li', 'chi', 'yang', 'ling', 'lei', 'an', 'bao', 'wu', 'dian', 'dang', 'hu', 'wu', 'diao', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x97.php b/core/lib/Drupal/Component/Transliteration/data/x97.php index 1187fbb..f9296c7 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x97.php +++ b/core/lib/Drupal/Component/Transliteration/data/x97.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'xu', 'ji', 'mu', 'chen', 'xiao', 'zha', 'ting', 'zhen', 'pei', 'mei', 'ling', 'qi', 'zhou', 'huo', 'sha', 'fei', 0x10 => 'hong', 'zhan', 'yin', 'ni', 'zhu', 'tun', 'lin', 'ling', 'dong', 'ying', 'wu', 'ling', 'shuang', 'ling', 'xia', 'hong', 0x20 => 'yin', 'mai', 'mai', 'yun', 'liu', 'meng', 'bin', 'wu', 'wei', 'kuo', 'yin', 'xi', 'yi', 'ai', 'dan', 'teng', @@ -22,4 +22,4 @@ 0xD0 => 'ge', 'wei', 'qiao', 'han', 'chang', 'kuo', 'rou', 'yun', 'she', 'wei', 'ge', 'bai', 'tao', 'gou', 'yun', 'gao', 0xE0 => 'bi', 'wei', 'sui', 'du', 'wa', 'du', 'wei', 'ren', 'fu', 'han', 'wei', 'yun', 'tao', 'jiu', 'jiu', 'xian', 0xF0 => 'xie', 'xian', 'ji', 'yin', 'za', 'yun', 'shao', 'le', 'peng', 'huang', 'ying', 'yun', 'peng', 'an', 'yin', 'xiang', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x98.php b/core/lib/Drupal/Component/Transliteration/data/x98.php index 8e1ff92..cb1ec6a 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x98.php +++ b/core/lib/Drupal/Component/Transliteration/data/x98.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'hu', 'ye', 'ding', 'qing', 'kui', 'xiang', 'shun', 'han', 'xu', 'yi', 'xu', 'e', 'song', 'kui', 'qi', 'hang', 0x10 => 'yu', 'wan', 'ban', 'dun', 'di', 'dan', 'pan', 'po', 'ling', 'che', 'jing', 'lei', 'he', 'qiao', 'e', 'e', 0x20 => 'wei', 'xie', 'kuo', 'shen', 'yi', 'shen', 'hai', 'dui', 'yu', 'ping', 'lei', 'fu', 'jia', 'tou', 'hui', 'kui', @@ -22,4 +22,4 @@ 0xD0 => 'zhan', 'biao', 'sa', 'ju', 'si', 'sou', 'yao', 'liu', 'piao', 'biao', 'biao', 'fei', 'fan', 'fei', 'fei', 'shi', 0xE0 => 'shi', 'can', 'ji', 'ding', 'si', 'tuo', 'zhan', 'sun', 'xiang', 'tun', 'ren', 'yu', 'juan', 'chi', 'yin', 'fan', 0xF0 => 'fan', 'sun', 'yin', 'tou', 'yi', 'zuo', 'bi', 'jie', 'tao', 'liu', 'ci', 'tie', 'si', 'bao', 'shi', 'duo', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x99.php b/core/lib/Drupal/Component/Transliteration/data/x99.php index 7e99ac0..6f6fb47 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x99.php +++ b/core/lib/Drupal/Component/Transliteration/data/x99.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'hai', 'ren', 'tian', 'jiao', 'jia', 'bing', 'yao', 'tong', 'ci', 'xiang', 'yang', 'juan', 'er', 'yan', 'le', 'xi', 0x10 => 'can', 'bo', 'nei', 'e', 'bu', 'jun', 'dou', 'su', 'yu', 'shi', 'yao', 'hun', 'guo', 'shi', 'jian', 'zhui', 0x20 => 'bing', 'xian', 'bu', 'ye', 'tan', 'fei', 'zhang', 'wei', 'guan', 'e', 'nuan', 'yun', 'hu', 'huang', 'tie', 'hui', @@ -22,4 +22,4 @@ 0xD0 => 'zhu', 'nu', 'ju', 'pi', 'zang', 'jia', 'ling', 'zhen', 'tai', 'fu', 'yang', 'shi', 'bi', 'tuo', 'tuo', 'si', 0xE0 => 'liu', 'ma', 'pian', 'tao', 'zhi', 'rong', 'teng', 'dong', 'xun', 'quan', 'shen', 'jiong', 'er', 'hai', 'bo', 'zhu', 0xF0 => 'yin', 'luo', 'zhou', 'dan', 'xie', 'liu', 'ju', 'song', 'qin', 'mang', 'lang', 'han', 'tu', 'xuan', 'tui', 'jun', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x9a.php b/core/lib/Drupal/Component/Transliteration/data/x9a.php index 3c85540..cd57659 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x9a.php +++ b/core/lib/Drupal/Component/Transliteration/data/x9a.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'e', 'cheng', 'xing', 'ai', 'lu', 'zhui', 'zhou', 'she', 'pian', 'kun', 'tao', 'lai', 'zong', 'ke', 'qi', 'qi', 0x10 => 'yan', 'fei', 'sao', 'yan', 'ge', 'yao', 'wu', 'pian', 'cong', 'pian', 'qian', 'fei', 'huang', 'qian', 'huo', 'yu', 0x20 => 'ti', 'quan', 'xia', 'zong', 'kui', 'rou', 'si', 'gua', 'tuo', 'gui', 'sou', 'qian', 'cheng', 'zhi', 'liu', 'peng', @@ -22,4 +22,4 @@ 0xD0 => 'xiao', 'du', 'zang', 'sui', 'ti', 'bin', 'kuan', 'lu', 'gao', 'gao', 'qiao', 'kao', 'qiao', 'lao', 'sao', 'biao', 0xE0 => 'kun', 'kun', 'di', 'fang', 'xiu', 'ran', 'mao', 'dan', 'kun', 'bin', 'fa', 'tiao', 'pi', 'zi', 'fa', 'ran', 0xF0 => 'ti', 'bao', 'bi', 'mao', 'fu', 'er', 'rong', 'qu', 'gong', 'xiu', 'kuo', 'ji', 'peng', 'zhua', 'shao', 'suo', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x9b.php b/core/lib/Drupal/Component/Transliteration/data/x9b.php index 9617f97..2cbbd7e 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x9b.php +++ b/core/lib/Drupal/Component/Transliteration/data/x9b.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ti', 'li', 'bin', 'zong', 'di', 'peng', 'song', 'zheng', 'quan', 'zong', 'shun', 'jian', 'tuo', 'hu', 'la', 'jiu', 0x10 => 'qi', 'lian', 'zhen', 'bin', 'peng', 'ma', 'san', 'man', 'man', 'seng', 'xu', 'lie', 'qian', 'qian', 'nang', 'huan', 0x20 => 'kuo', 'ning', 'bin', 'lie', 'rang', 'dou', 'dou', 'nao', 'hong', 'xi', 'dou', 'han', 'dou', 'dou', 'jiu', 'chang', @@ -22,4 +22,4 @@ 0xD0 => 'zou', 'xi', 'yong', 'ni', 'zi', 'qi', 'zheng', 'xiang', 'nei', 'chun', 'ji', 'diao', 'qie', 'gu', 'zhou', 'dong', 0xE0 => 'lai', 'fei', 'ni', 'yi', 'kun', 'lu', 'jiu', 'chang', 'jing', 'lun', 'ling', 'zou', 'li', 'meng', 'zong', 'zhi', 0xF0 => 'nian', 'hu', 'yu', 'di', 'shi', 'shen', 'hun', 'ti', 'hou', 'xing', 'zhu', 'la', 'zong', 'zei', 'bian', 'bian', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x9c.php b/core/lib/Drupal/Component/Transliteration/data/x9c.php index 76be43e..4ca423c 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x9c.php +++ b/core/lib/Drupal/Component/Transliteration/data/x9c.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'huan', 'quan', 'zei', 'wei', 'wei', 'yu', 'chun', 'rou', 'die', 'huang', 'lian', 'yan', 'qiu', 'qiu', 'jian', 'bi', 0x10 => 'e', 'yang', 'fu', 'sai', 'gan', 'xia', 'tuo', 'hu', 'shi', 'ruo', 'xuan', 'wen', 'qian', 'hao', 'wu', 'fang', 0x20 => 'sao', 'liu', 'ma', 'shi', 'shi', 'guan', 'zi', 'teng', 'ta', 'yao', 'e', 'yong', 'qian', 'qi', 'wen', 'ruo', @@ -22,4 +22,4 @@ 0xD0 => 'yao', 'pang', 'jian', 'le', 'biao', 'xue', 'bie', 'man', 'min', 'yong', 'wei', 'xi', 'gui', 'shan', 'lin', 'zun', 0xE0 => 'hu', 'gan', 'li', 'zhan', 'guan', 'niao', 'yi', 'fu', 'li', 'jiu', 'bu', 'yan', 'fu', 'diao', 'ji', 'feng', 0xF0 => 'ru', 'gan', 'shi', 'feng', 'ming', 'bao', 'yuan', 'zhi', 'hu', 'qin', 'fu', 'ban', 'wen', 'jian', 'shi', 'yu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x9d.php b/core/lib/Drupal/Component/Transliteration/data/x9d.php index 21e9977..d3b4d78 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x9d.php +++ b/core/lib/Drupal/Component/Transliteration/data/x9d.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'fou', 'yao', 'jue', 'jue', 'pi', 'huan', 'zhen', 'bao', 'yan', 'ya', 'zheng', 'fang', 'feng', 'wen', 'ou', 'dai', 0x10 => 'ge', 'ru', 'ling', 'mie', 'fu', 'tuo', 'min', 'li', 'bian', 'zhi', 'ge', 'yuan', 'ci', 'qu', 'xiao', 'chi', 0x20 => 'dan', 'ju', 'yao', 'gu', 'dong', 'yu', 'yang', 'rong', 'ya', 'tie', 'yu', 'tian', 'ying', 'dui', 'wu', 'er', @@ -22,4 +22,4 @@ 0xD0 => 'chen', 'ji', 'tuan', 'zhe', 'ao', 'yao', 'yi', 'ou', 'chi', 'zhi', 'liu', 'yong', 'lu', 'bi', 'shuang', 'zhuo', 0xE0 => 'yu', 'wu', 'jue', 'yin', 'ti', 'si', 'jiao', 'yi', 'hua', 'bi', 'ying', 'su', 'huang', 'fan', 'jiao', 'liao', 0xF0 => 'yan', 'gao', 'jiu', 'xian', 'xian', 'tu', 'mai', 'zun', 'yu', 'ying', 'lu', 'tuan', 'xian', 'xue', 'yi', 'pi', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x9e.php b/core/lib/Drupal/Component/Transliteration/data/x9e.php index b50dd0f..db7e7f0 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x9e.php +++ b/core/lib/Drupal/Component/Transliteration/data/x9e.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'chu', 'luo', 'xi', 'yi', 'ji', 'ze', 'yu', 'zhan', 'ye', 'yang', 'pi', 'ning', 'hu', 'mi', 'ying', 'meng', 0x10 => 'di', 'yue', 'yu', 'lei', 'bao', 'lu', 'he', 'long', 'shuang', 'yue', 'ying', 'guan', 'qu', 'li', 'luan', 'niao', 0x20 => 'jiu', 'ji', 'yuan', 'ming', 'shi', 'ou', 'ya', 'cang', 'bao', 'zhen', 'gu', 'dong', 'lu', 'ya', 'xiao', 'yang', @@ -22,4 +22,4 @@ 0xD0 => 'chi', 'hei', 'hei', 'yi', 'qian', 'dan', 'xi', 'tun', 'mo', 'mo', 'qian', 'dai', 'chu', 'you', 'dian', 'yi', 0xE0 => 'xia', 'yan', 'qu', 'mei', 'yan', 'qing', 'yue', 'li', 'dang', 'du', 'can', 'yan', 'yan', 'yan', 'dan', 'an', 0xF0 => 'zhen', 'dai', 'can', 'yi', 'mei', 'zhan', 'yan', 'du', 'lu', 'zhi', 'fen', 'fu', 'fu', 'mian', 'mian', 'yuan', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/x9f.php b/core/lib/Drupal/Component/Transliteration/data/x9f.php index 49f08e5..13ecd6e 100644 --- a/core/lib/Drupal/Component/Transliteration/data/x9f.php +++ b/core/lib/Drupal/Component/Transliteration/data/x9f.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'cu', 'qu', 'chao', 'wa', 'zhu', 'zhi', 'meng', 'ao', 'bie', 'tuo', 'bi', 'yuan', 'chao', 'tuo', 'ding', 'mi', 0x10 => 'nai', 'ding', 'zi', 'gu', 'gu', 'dong', 'fen', 'tao', 'yuan', 'pi', 'chang', 'gao', 'qi', 'yuan', 'tang', 'teng', 0x20 => 'shu', 'shu', 'fen', 'fei', 'wen', 'ba', 'diao', 'tuo', 'zhong', 'qu', 'sheng', 'shi', 'you', 'shi', 'ting', 'wu', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xa0.php b/core/lib/Drupal/Component/Transliteration/data/xa0.php index b7fee62..ca55187 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xa0.php +++ b/core/lib/Drupal/Component/Transliteration/data/xa0.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'it', 'ix', 'i', 'ip', 'iet', 'iex', 'ie', 'iep', 'at', 'ax', 'a', 'ap', 'uox', 'uo', 'uop', 'ot', 0x10 => 'ox', 'o', 'op', 'ex', 'e', 'wu', 'bit', 'bix', 'bi', 'bip', 'biet', 'biex', 'bie', 'biep', 'bat', 'bax', 0x20 => 'ba', 'bap', 'buox', 'buo', 'buop', 'bot', 'box', 'bo', 'bop', 'bex', 'be', 'bep', 'but', 'bux', 'bu', 'bup', @@ -22,4 +22,4 @@ 0xD0 => 'fip', 'fat', 'fax', 'fa', 'fap', 'fox', 'fo', 'fop', 'fut', 'fux', 'fu', 'fup', 'furx', 'fur', 'fyt', 'fyx', 0xE0 => 'fy', 'fyp', 'vit', 'vix', 'vi', 'vip', 'viet', 'viex', 'vie', 'viep', 'vat', 'vax', 'va', 'vap', 'vot', 'vox', 0xF0 => 'vo', 'vop', 'vex', 'vep', 'vut', 'vux', 'vu', 'vup', 'vurx', 'vur', 'vyt', 'vyx', 'vy', 'vyp', 'vyrx', 'vyr', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xa1.php b/core/lib/Drupal/Component/Transliteration/data/xa1.php index 66cc446..19ca96e 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xa1.php +++ b/core/lib/Drupal/Component/Transliteration/data/xa1.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'dit', 'dix', 'di', 'dip', 'diex', 'die', 'diep', 'dat', 'dax', 'da', 'dap', 'duox', 'duo', 'dot', 'dox', 'do', 0x10 => 'dop', 'dex', 'de', 'dep', 'dut', 'dux', 'du', 'dup', 'durx', 'dur', 'tit', 'tix', 'ti', 'tip', 'tiex', 'tie', 0x20 => 'tiep', 'tat', 'tax', 'ta', 'tap', 'tuot', 'tuox', 'tuo', 'tuop', 'tot', 'tox', 'to', 'top', 'tex', 'te', 'tep', @@ -22,4 +22,4 @@ 0xD0 => 'lu', 'lup', 'lurx', 'lur', 'lyt', 'lyx', 'ly', 'lyp', 'lyrx', 'lyr', 'git', 'gix', 'gi', 'gip', 'giet', 'giex', 0xE0 => 'gie', 'giep', 'gat', 'gax', 'ga', 'gap', 'guot', 'guox', 'guo', 'guop', 'got', 'gox', 'go', 'gop', 'get', 'gex', 0xF0 => 'ge', 'gep', 'gut', 'gux', 'gu', 'gup', 'gurx', 'gur', 'kit', 'kix', 'ki', 'kip', 'kiex', 'kie', 'kiep', 'kat', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xa2.php b/core/lib/Drupal/Component/Transliteration/data/xa2.php index 95d4c8c..0603d5f 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xa2.php +++ b/core/lib/Drupal/Component/Transliteration/data/xa2.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'kax', 'ka', 'kap', 'kuox', 'kuo', 'kuop', 'kot', 'kox', 'ko', 'kop', 'ket', 'kex', 'ke', 'kep', 'kut', 'kux', 0x10 => 'ku', 'kup', 'kurx', 'kur', 'ggit', 'ggix', 'ggi', 'ggiex', 'ggie', 'ggiep', 'ggat', 'ggax', 'gga', 'ggap', 'gguot', 'gguox', 0x20 => 'gguo', 'gguop', 'ggot', 'ggox', 'ggo', 'ggop', 'gget', 'ggex', 'gge', 'ggep', 'ggut', 'ggux', 'ggu', 'ggup', 'ggurx', 'ggur', @@ -22,4 +22,4 @@ 0xD0 => 'zzit', 'zzix', 'zzi', 'zzip', 'zziet', 'zziex', 'zzie', 'zziep', 'zzat', 'zzax', 'zza', 'zzap', 'zzox', 'zzo', 'zzop', 'zzex', 0xE0 => 'zze', 'zzep', 'zzux', 'zzu', 'zzup', 'zzurx', 'zzur', 'zzyt', 'zzyx', 'zzy', 'zzyp', 'zzyrx', 'zzyr', 'nzit', 'nzix', 'nzi', 0xF0 => 'nzip', 'nziex', 'nzie', 'nziep', 'nzat', 'nzax', 'nza', 'nzap', 'nzuox', 'nzuo', 'nzox', 'nzop', 'nzex', 'nze', 'nzux', 'nzu', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xa3.php b/core/lib/Drupal/Component/Transliteration/data/xa3.php index a63b281..207736f 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xa3.php +++ b/core/lib/Drupal/Component/Transliteration/data/xa3.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'nzup', 'nzurx', 'nzur', 'nzyt', 'nzyx', 'nzy', 'nzyp', 'nzyrx', 'nzyr', 'sit', 'six', 'si', 'sip', 'siex', 'sie', 'siep', 0x10 => 'sat', 'sax', 'sa', 'sap', 'suox', 'suo', 'suop', 'sot', 'sox', 'so', 'sop', 'sex', 'se', 'sep', 'sut', 'sux', 0x20 => 'su', 'sup', 'surx', 'sur', 'syt', 'syx', 'sy', 'syp', 'syrx', 'syr', 'ssit', 'ssix', 'ssi', 'ssip', 'ssiex', 'ssie', @@ -22,4 +22,4 @@ 0xD0 => 'rop', 'rex', 're', 'rep', 'rut', 'rux', 'ru', 'rup', 'rurx', 'rur', 'ryt', 'ryx', 'ry', 'ryp', 'ryrx', 'ryr', 0xE0 => 'jit', 'jix', 'ji', 'jip', 'jiet', 'jiex', 'jie', 'jiep', 'juot', 'juox', 'juo', 'juop', 'jot', 'jox', 'jo', 'jop', 0xF0 => 'jut', 'jux', 'ju', 'jup', 'jurx', 'jur', 'jyt', 'jyx', 'jy', 'jyp', 'jyrx', 'jyr', 'qit', 'qix', 'qi', 'qip', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xa4.php b/core/lib/Drupal/Component/Transliteration/data/xa4.php index 2210454..736b03c 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xa4.php +++ b/core/lib/Drupal/Component/Transliteration/data/xa4.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'qiet', 'qiex', 'qie', 'qiep', 'quot', 'quox', 'quo', 'quop', 'qot', 'qox', 'qo', 'qop', 'qut', 'qux', 'qu', 'qup', 0x10 => 'qurx', 'qur', 'qyt', 'qyx', 'qy', 'qyp', 'qyrx', 'qyr', 'jjit', 'jjix', 'jji', 'jjip', 'jjiet', 'jjiex', 'jjie', 'jjiep', 0x20 => 'jjuox', 'jjuo', 'jjuop', 'jjot', 'jjox', 'jjo', 'jjop', 'jjut', 'jjux', 'jju', 'jjup', 'jjurx', 'jjur', 'jjyt', 'jjyx', 'jjy', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xac.php b/core/lib/Drupal/Component/Transliteration/data/xac.php index 87c2d14..7ece9df 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xac.php +++ b/core/lib/Drupal/Component/Transliteration/data/xac.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ga', 'gag', 'gakk', 'gags', 'gan', 'ganj', 'ganh', 'gad', 'gal', 'galg', 'galm', 'galb', 'gals', 'galt', 'galp', 'galh', 0x10 => 'gam', 'gab', 'gabs', 'gas', 'gass', 'gang', 'gaj', 'gach', 'gak', 'gat', 'gap', 'gah', 'gae', 'gaeg', 'gaekk', 'gaegs', 0x20 => 'gaen', 'gaenj', 'gaenh', 'gaed', 'gael', 'gaelg', 'gaelm', 'gaelb', 'gaels', 'gaelt', 'gaelp', 'gaelh', 'gaem', 'gaeb', 'gaebs', 'gaes', @@ -22,4 +22,4 @@ 0xD0 => 'gyels', 'gyelt', 'gyelp', 'gyelh', 'gyem', 'gyeb', 'gyebs', 'gyes', 'gyess', 'gyeng', 'gyej', 'gyech', 'gyek', 'gyet', 'gyep', 'gyeh', 0xE0 => 'go', 'gog', 'gokk', 'gogs', 'gon', 'gonj', 'gonh', 'god', 'gol', 'golg', 'golm', 'golb', 'gols', 'golt', 'golp', 'golh', 0xF0 => 'gom', 'gob', 'gobs', 'gos', 'goss', 'gong', 'goj', 'goch', 'gok', 'got', 'gop', 'goh', 'gwa', 'gwag', 'gwakk', 'gwags', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xad.php b/core/lib/Drupal/Component/Transliteration/data/xad.php index 4e8eb27..8dd61de 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xad.php +++ b/core/lib/Drupal/Component/Transliteration/data/xad.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'gwan', 'gwanj', 'gwanh', 'gwad', 'gwal', 'gwalg', 'gwalm', 'gwalb', 'gwals', 'gwalt', 'gwalp', 'gwalh', 'gwam', 'gwab', 'gwabs', 'gwas', 0x10 => 'gwass', 'gwang', 'gwaj', 'gwach', 'gwak', 'gwat', 'gwap', 'gwah', 'gwae', 'gwaeg', 'gwaekk', 'gwaegs', 'gwaen', 'gwaenj', 'gwaenh', 'gwaed', 0x20 => 'gwael', 'gwaelg', 'gwaelm', 'gwaelb', 'gwaels', 'gwaelt', 'gwaelp', 'gwaelh', 'gwaem', 'gwaeb', 'gwaebs', 'gwaes', 'gwaess', 'gwaeng', 'gwaej', 'gwaech', @@ -22,4 +22,4 @@ 0xD0 => 'gwim', 'gwib', 'gwibs', 'gwis', 'gwiss', 'gwing', 'gwij', 'gwich', 'gwik', 'gwit', 'gwip', 'gwih', 'gyu', 'gyug', 'gyukk', 'gyugs', 0xE0 => 'gyun', 'gyunj', 'gyunh', 'gyud', 'gyul', 'gyulg', 'gyulm', 'gyulb', 'gyuls', 'gyult', 'gyulp', 'gyulh', 'gyum', 'gyub', 'gyubs', 'gyus', 0xF0 => 'gyuss', 'gyung', 'gyuj', 'gyuch', 'gyuk', 'gyut', 'gyup', 'gyuh', 'geu', 'geug', 'geukk', 'geugs', 'geun', 'geunj', 'geunh', 'geud', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xae.php b/core/lib/Drupal/Component/Transliteration/data/xae.php index 52f7f5c..1584a5c 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xae.php +++ b/core/lib/Drupal/Component/Transliteration/data/xae.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'geul', 'geulg', 'geulm', 'geulb', 'geuls', 'geult', 'geulp', 'geulh', 'geum', 'geub', 'geubs', 'geus', 'geuss', 'geung', 'geuj', 'geuch', 0x10 => 'geuk', 'geut', 'geup', 'geuh', 'gui', 'guig', 'guikk', 'guigs', 'guin', 'guinj', 'guinh', 'guid', 'guil', 'guilg', 'guilm', 'guilb', 0x20 => 'guils', 'guilt', 'guilp', 'guilh', 'guim', 'guib', 'guibs', 'guis', 'guiss', 'guing', 'guij', 'guich', 'guik', 'guit', 'guip', 'guih', @@ -22,4 +22,4 @@ 0xD0 => 'kkeoss', 'kkeong', 'kkeoj', 'kkeoch', 'kkeok', 'kkeot', 'kkeop', 'kkeoh', 'kke', 'kkeg', 'kkekk', 'kkegs', 'kken', 'kkenj', 'kkenh', 'kked', 0xE0 => 'kkel', 'kkelg', 'kkelm', 'kkelb', 'kkels', 'kkelt', 'kkelp', 'kkelh', 'kkem', 'kkeb', 'kkebs', 'kkes', 'kkess', 'kkeng', 'kkej', 'kkech', 0xF0 => 'kkek', 'kket', 'kkep', 'kkeh', 'kkyeo', 'kkyeog', 'kkyeokk', 'kkyeogs', 'kkyeon', 'kkyeonj', 'kkyeonh', 'kkyeod', 'kkyeol', 'kkyeolg', 'kkyeolm', 'kkyeolb', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xaf.php b/core/lib/Drupal/Component/Transliteration/data/xaf.php index e5f37fe..26c61c5 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xaf.php +++ b/core/lib/Drupal/Component/Transliteration/data/xaf.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'kkyeols', 'kkyeolt', 'kkyeolp', 'kkyeolh', 'kkyeom', 'kkyeob', 'kkyeobs', 'kkyeos', 'kkyeoss', 'kkyeong', 'kkyeoj', 'kkyeoch', 'kkyeok', 'kkyeot', 'kkyeop', 'kkyeoh', 0x10 => 'kkye', 'kkyeg', 'kkyekk', 'kkyegs', 'kkyen', 'kkyenj', 'kkyenh', 'kkyed', 'kkyel', 'kkyelg', 'kkyelm', 'kkyelb', 'kkyels', 'kkyelt', 'kkyelp', 'kkyelh', 0x20 => 'kkyem', 'kkyeb', 'kkyebs', 'kkyes', 'kkyess', 'kkyeng', 'kkyej', 'kkyech', 'kkyek', 'kkyet', 'kkyep', 'kkyeh', 'kko', 'kkog', 'kkokk', 'kkogs', @@ -22,4 +22,4 @@ 0xD0 => 'kkuk', 'kkut', 'kkup', 'kkuh', 'kkwo', 'kkwog', 'kkwokk', 'kkwogs', 'kkwon', 'kkwonj', 'kkwonh', 'kkwod', 'kkwol', 'kkwolg', 'kkwolm', 'kkwolb', 0xE0 => 'kkwols', 'kkwolt', 'kkwolp', 'kkwolh', 'kkwom', 'kkwob', 'kkwobs', 'kkwos', 'kkwoss', 'kkwong', 'kkwoj', 'kkwoch', 'kkwok', 'kkwot', 'kkwop', 'kkwoh', 0xF0 => 'kkwe', 'kkweg', 'kkwekk', 'kkwegs', 'kkwen', 'kkwenj', 'kkwenh', 'kkwed', 'kkwel', 'kkwelg', 'kkwelm', 'kkwelb', 'kkwels', 'kkwelt', 'kkwelp', 'kkwelh', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xb0.php b/core/lib/Drupal/Component/Transliteration/data/xb0.php index 96071fd..0ebe370 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xb0.php +++ b/core/lib/Drupal/Component/Transliteration/data/xb0.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'kkwem', 'kkweb', 'kkwebs', 'kkwes', 'kkwess', 'kkweng', 'kkwej', 'kkwech', 'kkwek', 'kkwet', 'kkwep', 'kkweh', 'kkwi', 'kkwig', 'kkwikk', 'kkwigs', 0x10 => 'kkwin', 'kkwinj', 'kkwinh', 'kkwid', 'kkwil', 'kkwilg', 'kkwilm', 'kkwilb', 'kkwils', 'kkwilt', 'kkwilp', 'kkwilh', 'kkwim', 'kkwib', 'kkwibs', 'kkwis', 0x20 => 'kkwiss', 'kkwing', 'kkwij', 'kkwich', 'kkwik', 'kkwit', 'kkwip', 'kkwih', 'kkyu', 'kkyug', 'kkyukk', 'kkyugs', 'kkyun', 'kkyunj', 'kkyunh', 'kkyud', @@ -22,4 +22,4 @@ 0xD0 => 'nya', 'nyag', 'nyakk', 'nyags', 'nyan', 'nyanj', 'nyanh', 'nyad', 'nyal', 'nyalg', 'nyalm', 'nyalb', 'nyals', 'nyalt', 'nyalp', 'nyalh', 0xE0 => 'nyam', 'nyab', 'nyabs', 'nyas', 'nyass', 'nyang', 'nyaj', 'nyach', 'nyak', 'nyat', 'nyap', 'nyah', 'nyae', 'nyaeg', 'nyaekk', 'nyaegs', 0xF0 => 'nyaen', 'nyaenj', 'nyaenh', 'nyaed', 'nyael', 'nyaelg', 'nyaelm', 'nyaelb', 'nyaels', 'nyaelt', 'nyaelp', 'nyaelh', 'nyaem', 'nyaeb', 'nyaebs', 'nyaes', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xb1.php b/core/lib/Drupal/Component/Transliteration/data/xb1.php index d90ecfc..2f4d010 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xb1.php +++ b/core/lib/Drupal/Component/Transliteration/data/xb1.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'nyaess', 'nyaeng', 'nyaej', 'nyaech', 'nyaek', 'nyaet', 'nyaep', 'nyaeh', 'neo', 'neog', 'neokk', 'neogs', 'neon', 'neonj', 'neonh', 'neod', 0x10 => 'neol', 'neolg', 'neolm', 'neolb', 'neols', 'neolt', 'neolp', 'neolh', 'neom', 'neob', 'neobs', 'neos', 'neoss', 'neong', 'neoj', 'neoch', 0x20 => 'neok', 'neot', 'neop', 'neoh', 'ne', 'neg', 'nekk', 'negs', 'nen', 'nenj', 'nenh', 'ned', 'nel', 'nelg', 'nelm', 'nelb', @@ -22,4 +22,4 @@ 0xD0 => 'noen', 'noenj', 'noenh', 'noed', 'noel', 'noelg', 'noelm', 'noelb', 'noels', 'noelt', 'noelp', 'noelh', 'noem', 'noeb', 'noebs', 'noes', 0xE0 => 'noess', 'noeng', 'noej', 'noech', 'noek', 'noet', 'noep', 'noeh', 'nyo', 'nyog', 'nyokk', 'nyogs', 'nyon', 'nyonj', 'nyonh', 'nyod', 0xF0 => 'nyol', 'nyolg', 'nyolm', 'nyolb', 'nyols', 'nyolt', 'nyolp', 'nyolh', 'nyom', 'nyob', 'nyobs', 'nyos', 'nyoss', 'nyong', 'nyoj', 'nyoch', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xb2.php b/core/lib/Drupal/Component/Transliteration/data/xb2.php index 1dced88..ef3617b 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xb2.php +++ b/core/lib/Drupal/Component/Transliteration/data/xb2.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'nyok', 'nyot', 'nyop', 'nyoh', 'nu', 'nug', 'nukk', 'nugs', 'nun', 'nunj', 'nunh', 'nud', 'nul', 'nulg', 'nulm', 'nulb', 0x10 => 'nuls', 'nult', 'nulp', 'nulh', 'num', 'nub', 'nubs', 'nus', 'nuss', 'nung', 'nuj', 'nuch', 'nuk', 'nut', 'nup', 'nuh', 0x20 => 'nwo', 'nwog', 'nwokk', 'nwogs', 'nwon', 'nwonj', 'nwonh', 'nwod', 'nwol', 'nwolg', 'nwolm', 'nwolb', 'nwols', 'nwolt', 'nwolp', 'nwolh', @@ -22,4 +22,4 @@ 0xD0 => 'nil', 'nilg', 'nilm', 'nilb', 'nils', 'nilt', 'nilp', 'nilh', 'nim', 'nib', 'nibs', 'nis', 'niss', 'ning', 'nij', 'nich', 0xE0 => 'nik', 'nit', 'nip', 'nih', 'da', 'dag', 'dakk', 'dags', 'dan', 'danj', 'danh', 'dad', 'dal', 'dalg', 'dalm', 'dalb', 0xF0 => 'dals', 'dalt', 'dalp', 'dalh', 'dam', 'dab', 'dabs', 'das', 'dass', 'dang', 'daj', 'dach', 'dak', 'dat', 'dap', 'dah', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xb3.php b/core/lib/Drupal/Component/Transliteration/data/xb3.php index 37a9a07..6b79807 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xb3.php +++ b/core/lib/Drupal/Component/Transliteration/data/xb3.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'dae', 'daeg', 'daekk', 'daegs', 'daen', 'daenj', 'daenh', 'daed', 'dael', 'daelg', 'daelm', 'daelb', 'daels', 'daelt', 'daelp', 'daelh', 0x10 => 'daem', 'daeb', 'daebs', 'daes', 'daess', 'daeng', 'daej', 'daech', 'daek', 'daet', 'daep', 'daeh', 'dya', 'dyag', 'dyakk', 'dyags', 0x20 => 'dyan', 'dyanj', 'dyanh', 'dyad', 'dyal', 'dyalg', 'dyalm', 'dyalb', 'dyals', 'dyalt', 'dyalp', 'dyalh', 'dyam', 'dyab', 'dyabs', 'dyas', @@ -22,4 +22,4 @@ 0xD0 => 'dols', 'dolt', 'dolp', 'dolh', 'dom', 'dob', 'dobs', 'dos', 'doss', 'dong', 'doj', 'doch', 'dok', 'dot', 'dop', 'doh', 0xE0 => 'dwa', 'dwag', 'dwakk', 'dwags', 'dwan', 'dwanj', 'dwanh', 'dwad', 'dwal', 'dwalg', 'dwalm', 'dwalb', 'dwals', 'dwalt', 'dwalp', 'dwalh', 0xF0 => 'dwam', 'dwab', 'dwabs', 'dwas', 'dwass', 'dwang', 'dwaj', 'dwach', 'dwak', 'dwat', 'dwap', 'dwah', 'dwae', 'dwaeg', 'dwaekk', 'dwaegs', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xb4.php b/core/lib/Drupal/Component/Transliteration/data/xb4.php index 2c46b3a..0ae19d4 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xb4.php +++ b/core/lib/Drupal/Component/Transliteration/data/xb4.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'dwaen', 'dwaenj', 'dwaenh', 'dwaed', 'dwael', 'dwaelg', 'dwaelm', 'dwaelb', 'dwaels', 'dwaelt', 'dwaelp', 'dwaelh', 'dwaem', 'dwaeb', 'dwaebs', 'dwaes', 0x10 => 'dwaess', 'dwaeng', 'dwaej', 'dwaech', 'dwaek', 'dwaet', 'dwaep', 'dwaeh', 'doe', 'doeg', 'doekk', 'doegs', 'doen', 'doenj', 'doenh', 'doed', 0x20 => 'doel', 'doelg', 'doelm', 'doelb', 'doels', 'doelt', 'doelp', 'doelh', 'doem', 'doeb', 'doebs', 'does', 'doess', 'doeng', 'doej', 'doech', @@ -22,4 +22,4 @@ 0xD0 => 'dyum', 'dyub', 'dyubs', 'dyus', 'dyuss', 'dyung', 'dyuj', 'dyuch', 'dyuk', 'dyut', 'dyup', 'dyuh', 'deu', 'deug', 'deukk', 'deugs', 0xE0 => 'deun', 'deunj', 'deunh', 'deud', 'deul', 'deulg', 'deulm', 'deulb', 'deuls', 'deult', 'deulp', 'deulh', 'deum', 'deub', 'deubs', 'deus', 0xF0 => 'deuss', 'deung', 'deuj', 'deuch', 'deuk', 'deut', 'deup', 'deuh', 'dui', 'duig', 'duikk', 'duigs', 'duin', 'duinj', 'duinh', 'duid', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xb5.php b/core/lib/Drupal/Component/Transliteration/data/xb5.php index ee61e54..22be8a0 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xb5.php +++ b/core/lib/Drupal/Component/Transliteration/data/xb5.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'duil', 'duilg', 'duilm', 'duilb', 'duils', 'duilt', 'duilp', 'duilh', 'duim', 'duib', 'duibs', 'duis', 'duiss', 'duing', 'duij', 'duich', 0x10 => 'duik', 'duit', 'duip', 'duih', 'di', 'dig', 'dikk', 'digs', 'din', 'dinj', 'dinh', 'did', 'dil', 'dilg', 'dilm', 'dilb', 0x20 => 'dils', 'dilt', 'dilp', 'dilh', 'dim', 'dib', 'dibs', 'dis', 'diss', 'ding', 'dij', 'dich', 'dik', 'dit', 'dip', 'dih', @@ -22,4 +22,4 @@ 0xD0 => 'ttess', 'tteng', 'ttej', 'ttech', 'ttek', 'ttet', 'ttep', 'tteh', 'ttyeo', 'ttyeog', 'ttyeokk', 'ttyeogs', 'ttyeon', 'ttyeonj', 'ttyeonh', 'ttyeod', 0xE0 => 'ttyeol', 'ttyeolg', 'ttyeolm', 'ttyeolb', 'ttyeols', 'ttyeolt', 'ttyeolp', 'ttyeolh', 'ttyeom', 'ttyeob', 'ttyeobs', 'ttyeos', 'ttyeoss', 'ttyeong', 'ttyeoj', 'ttyeoch', 0xF0 => 'ttyeok', 'ttyeot', 'ttyeop', 'ttyeoh', 'ttye', 'ttyeg', 'ttyekk', 'ttyegs', 'ttyen', 'ttyenj', 'ttyenh', 'ttyed', 'ttyel', 'ttyelg', 'ttyelm', 'ttyelb', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xb6.php b/core/lib/Drupal/Component/Transliteration/data/xb6.php index 5b209ee..9a40cdc 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xb6.php +++ b/core/lib/Drupal/Component/Transliteration/data/xb6.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ttyels', 'ttyelt', 'ttyelp', 'ttyelh', 'ttyem', 'ttyeb', 'ttyebs', 'ttyes', 'ttyess', 'ttyeng', 'ttyej', 'ttyech', 'ttyek', 'ttyet', 'ttyep', 'ttyeh', 0x10 => 'tto', 'ttog', 'ttokk', 'ttogs', 'tton', 'ttonj', 'ttonh', 'ttod', 'ttol', 'ttolg', 'ttolm', 'ttolb', 'ttols', 'ttolt', 'ttolp', 'ttolh', 0x20 => 'ttom', 'ttob', 'ttobs', 'ttos', 'ttoss', 'ttong', 'ttoj', 'ttoch', 'ttok', 'ttot', 'ttop', 'ttoh', 'ttwa', 'ttwag', 'ttwakk', 'ttwags', @@ -22,4 +22,4 @@ 0xD0 => 'ttwok', 'ttwot', 'ttwop', 'ttwoh', 'ttwe', 'ttweg', 'ttwekk', 'ttwegs', 'ttwen', 'ttwenj', 'ttwenh', 'ttwed', 'ttwel', 'ttwelg', 'ttwelm', 'ttwelb', 0xE0 => 'ttwels', 'ttwelt', 'ttwelp', 'ttwelh', 'ttwem', 'ttweb', 'ttwebs', 'ttwes', 'ttwess', 'ttweng', 'ttwej', 'ttwech', 'ttwek', 'ttwet', 'ttwep', 'ttweh', 0xF0 => 'ttwi', 'ttwig', 'ttwikk', 'ttwigs', 'ttwin', 'ttwinj', 'ttwinh', 'ttwid', 'ttwil', 'ttwilg', 'ttwilm', 'ttwilb', 'ttwils', 'ttwilt', 'ttwilp', 'ttwilh', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xb7.php b/core/lib/Drupal/Component/Transliteration/data/xb7.php index c19b876..419dbe1 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xb7.php +++ b/core/lib/Drupal/Component/Transliteration/data/xb7.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ttwim', 'ttwib', 'ttwibs', 'ttwis', 'ttwiss', 'ttwing', 'ttwij', 'ttwich', 'ttwik', 'ttwit', 'ttwip', 'ttwih', 'ttyu', 'ttyug', 'ttyukk', 'ttyugs', 0x10 => 'ttyun', 'ttyunj', 'ttyunh', 'ttyud', 'ttyul', 'ttyulg', 'ttyulm', 'ttyulb', 'ttyuls', 'ttyult', 'ttyulp', 'ttyulh', 'ttyum', 'ttyub', 'ttyubs', 'ttyus', 0x20 => 'ttyuss', 'ttyung', 'ttyuj', 'ttyuch', 'ttyuk', 'ttyut', 'ttyup', 'ttyuh', 'tteu', 'tteug', 'tteukk', 'tteugs', 'tteun', 'tteunj', 'tteunh', 'tteud', @@ -22,4 +22,4 @@ 0xD0 => 'lyae', 'lyaeg', 'lyaekk', 'lyaegs', 'lyaen', 'lyaenj', 'lyaenh', 'lyaed', 'lyael', 'lyaelg', 'lyaelm', 'lyaelb', 'lyaels', 'lyaelt', 'lyaelp', 'lyaelh', 0xE0 => 'lyaem', 'lyaeb', 'lyaebs', 'lyaes', 'lyaess', 'lyaeng', 'lyaej', 'lyaech', 'lyaek', 'lyaet', 'lyaep', 'lyaeh', 'leo', 'leog', 'leokk', 'leogs', 0xF0 => 'leon', 'leonj', 'leonh', 'leod', 'leol', 'leolg', 'leolm', 'leolb', 'leols', 'leolt', 'leolp', 'leolh', 'leom', 'leob', 'leobs', 'leos', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xb8.php b/core/lib/Drupal/Component/Transliteration/data/xb8.php index 3743ce2..0abd8a0 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xb8.php +++ b/core/lib/Drupal/Component/Transliteration/data/xb8.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'leoss', 'leong', 'leoj', 'leoch', 'leok', 'leot', 'leop', 'leoh', 'le', 'leg', 'lekk', 'legs', 'len', 'lenj', 'lenh', 'led', 0x10 => 'lel', 'lelg', 'lelm', 'lelb', 'lels', 'lelt', 'lelp', 'lelh', 'lem', 'leb', 'lebs', 'les', 'less', 'leng', 'lej', 'lech', 0x20 => 'lek', 'let', 'lep', 'leh', 'lyeo', 'lyeog', 'lyeokk', 'lyeogs', 'lyeon', 'lyeonj', 'lyeonh', 'lyeod', 'lyeol', 'lyeolg', 'lyeolm', 'lyeolb', @@ -22,4 +22,4 @@ 0xD0 => 'lyon', 'lyonj', 'lyonh', 'lyod', 'lyol', 'lyolg', 'lyolm', 'lyolb', 'lyols', 'lyolt', 'lyolp', 'lyolh', 'lyom', 'lyob', 'lyobs', 'lyos', 0xE0 => 'lyoss', 'lyong', 'lyoj', 'lyoch', 'lyok', 'lyot', 'lyop', 'lyoh', 'lu', 'lug', 'lukk', 'lugs', 'lun', 'lunj', 'lunh', 'lud', 0xF0 => 'lul', 'lulg', 'lulm', 'lulb', 'luls', 'lult', 'lulp', 'lulh', 'lum', 'lub', 'lubs', 'lus', 'luss', 'lung', 'luj', 'luch', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xb9.php b/core/lib/Drupal/Component/Transliteration/data/xb9.php index 0307106..9b5fcd1 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xb9.php +++ b/core/lib/Drupal/Component/Transliteration/data/xb9.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'luk', 'lut', 'lup', 'luh', 'lwo', 'lwog', 'lwokk', 'lwogs', 'lwon', 'lwonj', 'lwonh', 'lwod', 'lwol', 'lwolg', 'lwolm', 'lwolb', 0x10 => 'lwols', 'lwolt', 'lwolp', 'lwolh', 'lwom', 'lwob', 'lwobs', 'lwos', 'lwoss', 'lwong', 'lwoj', 'lwoch', 'lwok', 'lwot', 'lwop', 'lwoh', 0x20 => 'lwe', 'lweg', 'lwekk', 'lwegs', 'lwen', 'lwenj', 'lwenh', 'lwed', 'lwel', 'lwelg', 'lwelm', 'lwelb', 'lwels', 'lwelt', 'lwelp', 'lwelh', @@ -22,4 +22,4 @@ 0xD0 => 'mal', 'malg', 'malm', 'malb', 'mals', 'malt', 'malp', 'malh', 'mam', 'mab', 'mabs', 'mas', 'mass', 'mang', 'maj', 'mach', 0xE0 => 'mak', 'mat', 'map', 'mah', 'mae', 'maeg', 'maekk', 'maegs', 'maen', 'maenj', 'maenh', 'maed', 'mael', 'maelg', 'maelm', 'maelb', 0xF0 => 'maels', 'maelt', 'maelp', 'maelh', 'maem', 'maeb', 'maebs', 'maes', 'maess', 'maeng', 'maej', 'maech', 'maek', 'maet', 'maep', 'maeh', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xba.php b/core/lib/Drupal/Component/Transliteration/data/xba.php index 3087897..5a5448a 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xba.php +++ b/core/lib/Drupal/Component/Transliteration/data/xba.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'mya', 'myag', 'myakk', 'myags', 'myan', 'myanj', 'myanh', 'myad', 'myal', 'myalg', 'myalm', 'myalb', 'myals', 'myalt', 'myalp', 'myalh', 0x10 => 'myam', 'myab', 'myabs', 'myas', 'myass', 'myang', 'myaj', 'myach', 'myak', 'myat', 'myap', 'myah', 'myae', 'myaeg', 'myaekk', 'myaegs', 0x20 => 'myaen', 'myaenj', 'myaenh', 'myaed', 'myael', 'myaelg', 'myaelm', 'myaelb', 'myaels', 'myaelt', 'myaelp', 'myaelh', 'myaem', 'myaeb', 'myaebs', 'myaes', @@ -22,4 +22,4 @@ 0xD0 => 'mwals', 'mwalt', 'mwalp', 'mwalh', 'mwam', 'mwab', 'mwabs', 'mwas', 'mwass', 'mwang', 'mwaj', 'mwach', 'mwak', 'mwat', 'mwap', 'mwah', 0xE0 => 'mwae', 'mwaeg', 'mwaekk', 'mwaegs', 'mwaen', 'mwaenj', 'mwaenh', 'mwaed', 'mwael', 'mwaelg', 'mwaelm', 'mwaelb', 'mwaels', 'mwaelt', 'mwaelp', 'mwaelh', 0xF0 => 'mwaem', 'mwaeb', 'mwaebs', 'mwaes', 'mwaess', 'mwaeng', 'mwaej', 'mwaech', 'mwaek', 'mwaet', 'mwaep', 'mwaeh', 'moe', 'moeg', 'moekk', 'moegs', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xbb.php b/core/lib/Drupal/Component/Transliteration/data/xbb.php index 0f582fa..1b1ab3c 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xbb.php +++ b/core/lib/Drupal/Component/Transliteration/data/xbb.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'moen', 'moenj', 'moenh', 'moed', 'moel', 'moelg', 'moelm', 'moelb', 'moels', 'moelt', 'moelp', 'moelh', 'moem', 'moeb', 'moebs', 'moes', 0x10 => 'moess', 'moeng', 'moej', 'moech', 'moek', 'moet', 'moep', 'moeh', 'myo', 'myog', 'myokk', 'myogs', 'myon', 'myonj', 'myonh', 'myod', 0x20 => 'myol', 'myolg', 'myolm', 'myolb', 'myols', 'myolt', 'myolp', 'myolh', 'myom', 'myob', 'myobs', 'myos', 'myoss', 'myong', 'myoj', 'myoch', @@ -22,4 +22,4 @@ 0xD0 => 'meum', 'meub', 'meubs', 'meus', 'meuss', 'meung', 'meuj', 'meuch', 'meuk', 'meut', 'meup', 'meuh', 'mui', 'muig', 'muikk', 'muigs', 0xE0 => 'muin', 'muinj', 'muinh', 'muid', 'muil', 'muilg', 'muilm', 'muilb', 'muils', 'muilt', 'muilp', 'muilh', 'muim', 'muib', 'muibs', 'muis', 0xF0 => 'muiss', 'muing', 'muij', 'muich', 'muik', 'muit', 'muip', 'muih', 'mi', 'mig', 'mikk', 'migs', 'min', 'minj', 'minh', 'mid', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xbc.php b/core/lib/Drupal/Component/Transliteration/data/xbc.php index e145545..df91ce6 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xbc.php +++ b/core/lib/Drupal/Component/Transliteration/data/xbc.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'mil', 'milg', 'milm', 'milb', 'mils', 'milt', 'milp', 'milh', 'mim', 'mib', 'mibs', 'mis', 'miss', 'ming', 'mij', 'mich', 0x10 => 'mik', 'mit', 'mip', 'mih', 'ba', 'bag', 'bakk', 'bags', 'ban', 'banj', 'banh', 'bad', 'bal', 'balg', 'balm', 'balb', 0x20 => 'bals', 'balt', 'balp', 'balh', 'bam', 'bab', 'babs', 'bas', 'bass', 'bang', 'baj', 'bach', 'bak', 'bat', 'bap', 'bah', @@ -22,4 +22,4 @@ 0xD0 => 'byeoss', 'byeong', 'byeoj', 'byeoch', 'byeok', 'byeot', 'byeop', 'byeoh', 'bye', 'byeg', 'byekk', 'byegs', 'byen', 'byenj', 'byenh', 'byed', 0xE0 => 'byel', 'byelg', 'byelm', 'byelb', 'byels', 'byelt', 'byelp', 'byelh', 'byem', 'byeb', 'byebs', 'byes', 'byess', 'byeng', 'byej', 'byech', 0xF0 => 'byek', 'byet', 'byep', 'byeh', 'bo', 'bog', 'bokk', 'bogs', 'bon', 'bonj', 'bonh', 'bod', 'bol', 'bolg', 'bolm', 'bolb', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xbd.php b/core/lib/Drupal/Component/Transliteration/data/xbd.php index 539bb31..5cb779c 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xbd.php +++ b/core/lib/Drupal/Component/Transliteration/data/xbd.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'bols', 'bolt', 'bolp', 'bolh', 'bom', 'bob', 'bobs', 'bos', 'boss', 'bong', 'boj', 'boch', 'bok', 'bot', 'bop', 'boh', 0x10 => 'bwa', 'bwag', 'bwakk', 'bwags', 'bwan', 'bwanj', 'bwanh', 'bwad', 'bwal', 'bwalg', 'bwalm', 'bwalb', 'bwals', 'bwalt', 'bwalp', 'bwalh', 0x20 => 'bwam', 'bwab', 'bwabs', 'bwas', 'bwass', 'bwang', 'bwaj', 'bwach', 'bwak', 'bwat', 'bwap', 'bwah', 'bwae', 'bwaeg', 'bwaekk', 'bwaegs', @@ -22,4 +22,4 @@ 0xD0 => 'bwek', 'bwet', 'bwep', 'bweh', 'bwi', 'bwig', 'bwikk', 'bwigs', 'bwin', 'bwinj', 'bwinh', 'bwid', 'bwil', 'bwilg', 'bwilm', 'bwilb', 0xE0 => 'bwils', 'bwilt', 'bwilp', 'bwilh', 'bwim', 'bwib', 'bwibs', 'bwis', 'bwiss', 'bwing', 'bwij', 'bwich', 'bwik', 'bwit', 'bwip', 'bwih', 0xF0 => 'byu', 'byug', 'byukk', 'byugs', 'byun', 'byunj', 'byunh', 'byud', 'byul', 'byulg', 'byulm', 'byulb', 'byuls', 'byult', 'byulp', 'byulh', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xbe.php b/core/lib/Drupal/Component/Transliteration/data/xbe.php index 7d3bf6e..3800036 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xbe.php +++ b/core/lib/Drupal/Component/Transliteration/data/xbe.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'byum', 'byub', 'byubs', 'byus', 'byuss', 'byung', 'byuj', 'byuch', 'byuk', 'byut', 'byup', 'byuh', 'beu', 'beug', 'beukk', 'beugs', 0x10 => 'beun', 'beunj', 'beunh', 'beud', 'beul', 'beulg', 'beulm', 'beulb', 'beuls', 'beult', 'beulp', 'beulh', 'beum', 'beub', 'beubs', 'beus', 0x20 => 'beuss', 'beung', 'beuj', 'beuch', 'beuk', 'beut', 'beup', 'beuh', 'bui', 'buig', 'buikk', 'buigs', 'buin', 'buinj', 'buinh', 'buid', @@ -22,4 +22,4 @@ 0xD0 => 'ppeo', 'ppeog', 'ppeokk', 'ppeogs', 'ppeon', 'ppeonj', 'ppeonh', 'ppeod', 'ppeol', 'ppeolg', 'ppeolm', 'ppeolb', 'ppeols', 'ppeolt', 'ppeolp', 'ppeolh', 0xE0 => 'ppeom', 'ppeob', 'ppeobs', 'ppeos', 'ppeoss', 'ppeong', 'ppeoj', 'ppeoch', 'ppeok', 'ppeot', 'ppeop', 'ppeoh', 'ppe', 'ppeg', 'ppekk', 'ppegs', 0xF0 => 'ppen', 'ppenj', 'ppenh', 'pped', 'ppel', 'ppelg', 'ppelm', 'ppelb', 'ppels', 'ppelt', 'ppelp', 'ppelh', 'ppem', 'ppeb', 'ppebs', 'ppes', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xbf.php b/core/lib/Drupal/Component/Transliteration/data/xbf.php index 5681ed1..e355651 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xbf.php +++ b/core/lib/Drupal/Component/Transliteration/data/xbf.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ppess', 'ppeng', 'ppej', 'ppech', 'ppek', 'ppet', 'ppep', 'ppeh', 'ppyeo', 'ppyeog', 'ppyeokk', 'ppyeogs', 'ppyeon', 'ppyeonj', 'ppyeonh', 'ppyeod', 0x10 => 'ppyeol', 'ppyeolg', 'ppyeolm', 'ppyeolb', 'ppyeols', 'ppyeolt', 'ppyeolp', 'ppyeolh', 'ppyeom', 'ppyeob', 'ppyeobs', 'ppyeos', 'ppyeoss', 'ppyeong', 'ppyeoj', 'ppyeoch', 0x20 => 'ppyeok', 'ppyeot', 'ppyeop', 'ppyeoh', 'ppye', 'ppyeg', 'ppyekk', 'ppyegs', 'ppyen', 'ppyenj', 'ppyenh', 'ppyed', 'ppyel', 'ppyelg', 'ppyelm', 'ppyelb', @@ -22,4 +22,4 @@ 0xD0 => 'ppun', 'ppunj', 'ppunh', 'ppud', 'ppul', 'ppulg', 'ppulm', 'ppulb', 'ppuls', 'ppult', 'ppulp', 'ppulh', 'ppum', 'ppub', 'ppubs', 'ppus', 0xE0 => 'ppuss', 'ppung', 'ppuj', 'ppuch', 'ppuk', 'pput', 'ppup', 'ppuh', 'ppwo', 'ppwog', 'ppwokk', 'ppwogs', 'ppwon', 'ppwonj', 'ppwonh', 'ppwod', 0xF0 => 'ppwol', 'ppwolg', 'ppwolm', 'ppwolb', 'ppwols', 'ppwolt', 'ppwolp', 'ppwolh', 'ppwom', 'ppwob', 'ppwobs', 'ppwos', 'ppwoss', 'ppwong', 'ppwoj', 'ppwoch', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xc0.php b/core/lib/Drupal/Component/Transliteration/data/xc0.php index 89512d1..003544e 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xc0.php +++ b/core/lib/Drupal/Component/Transliteration/data/xc0.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ppwok', 'ppwot', 'ppwop', 'ppwoh', 'ppwe', 'ppweg', 'ppwekk', 'ppwegs', 'ppwen', 'ppwenj', 'ppwenh', 'ppwed', 'ppwel', 'ppwelg', 'ppwelm', 'ppwelb', 0x10 => 'ppwels', 'ppwelt', 'ppwelp', 'ppwelh', 'ppwem', 'ppweb', 'ppwebs', 'ppwes', 'ppwess', 'ppweng', 'ppwej', 'ppwech', 'ppwek', 'ppwet', 'ppwep', 'ppweh', 0x20 => 'ppwi', 'ppwig', 'ppwikk', 'ppwigs', 'ppwin', 'ppwinj', 'ppwinh', 'ppwid', 'ppwil', 'ppwilg', 'ppwilm', 'ppwilb', 'ppwils', 'ppwilt', 'ppwilp', 'ppwilh', @@ -22,4 +22,4 @@ 0xD0 => 'sael', 'saelg', 'saelm', 'saelb', 'saels', 'saelt', 'saelp', 'saelh', 'saem', 'saeb', 'saebs', 'saes', 'saess', 'saeng', 'saej', 'saech', 0xE0 => 'saek', 'saet', 'saep', 'saeh', 'sya', 'syag', 'syakk', 'syags', 'syan', 'syanj', 'syanh', 'syad', 'syal', 'syalg', 'syalm', 'syalb', 0xF0 => 'syals', 'syalt', 'syalp', 'syalh', 'syam', 'syab', 'syabs', 'syas', 'syass', 'syang', 'syaj', 'syach', 'syak', 'syat', 'syap', 'syah', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xc1.php b/core/lib/Drupal/Component/Transliteration/data/xc1.php index ae62f66..217d877 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xc1.php +++ b/core/lib/Drupal/Component/Transliteration/data/xc1.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'syae', 'syaeg', 'syaekk', 'syaegs', 'syaen', 'syaenj', 'syaenh', 'syaed', 'syael', 'syaelg', 'syaelm', 'syaelb', 'syaels', 'syaelt', 'syaelp', 'syaelh', 0x10 => 'syaem', 'syaeb', 'syaebs', 'syaes', 'syaess', 'syaeng', 'syaej', 'syaech', 'syaek', 'syaet', 'syaep', 'syaeh', 'seo', 'seog', 'seokk', 'seogs', 0x20 => 'seon', 'seonj', 'seonh', 'seod', 'seol', 'seolg', 'seolm', 'seolb', 'seols', 'seolt', 'seolp', 'seolh', 'seom', 'seob', 'seobs', 'seos', @@ -22,4 +22,4 @@ 0xD0 => 'swaels', 'swaelt', 'swaelp', 'swaelh', 'swaem', 'swaeb', 'swaebs', 'swaes', 'swaess', 'swaeng', 'swaej', 'swaech', 'swaek', 'swaet', 'swaep', 'swaeh', 0xE0 => 'soe', 'soeg', 'soekk', 'soegs', 'soen', 'soenj', 'soenh', 'soed', 'soel', 'soelg', 'soelm', 'soelb', 'soels', 'soelt', 'soelp', 'soelh', 0xF0 => 'soem', 'soeb', 'soebs', 'soes', 'soess', 'soeng', 'soej', 'soech', 'soek', 'soet', 'soep', 'soeh', 'syo', 'syog', 'syokk', 'syogs', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xc2.php b/core/lib/Drupal/Component/Transliteration/data/xc2.php index e540707..76a5738 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xc2.php +++ b/core/lib/Drupal/Component/Transliteration/data/xc2.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'syon', 'syonj', 'syonh', 'syod', 'syol', 'syolg', 'syolm', 'syolb', 'syols', 'syolt', 'syolp', 'syolh', 'syom', 'syob', 'syobs', 'syos', 0x10 => 'syoss', 'syong', 'syoj', 'syoch', 'syok', 'syot', 'syop', 'syoh', 'su', 'sug', 'sukk', 'sugs', 'sun', 'sunj', 'sunh', 'sud', 0x20 => 'sul', 'sulg', 'sulm', 'sulb', 'suls', 'sult', 'sulp', 'sulh', 'sum', 'sub', 'subs', 'sus', 'suss', 'sung', 'suj', 'such', @@ -22,4 +22,4 @@ 0xD0 => 'suim', 'suib', 'suibs', 'suis', 'suiss', 'suing', 'suij', 'suich', 'suik', 'suit', 'suip', 'suih', 'si', 'sig', 'sikk', 'sigs', 0xE0 => 'sin', 'sinj', 'sinh', 'sid', 'sil', 'silg', 'silm', 'silb', 'sils', 'silt', 'silp', 'silh', 'sim', 'sib', 'sibs', 'sis', 0xF0 => 'siss', 'sing', 'sij', 'sich', 'sik', 'sit', 'sip', 'sih', 'ssa', 'ssag', 'ssakk', 'ssags', 'ssan', 'ssanj', 'ssanh', 'ssad', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xc3.php b/core/lib/Drupal/Component/Transliteration/data/xc3.php index 4fd9755..24c8c24 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xc3.php +++ b/core/lib/Drupal/Component/Transliteration/data/xc3.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ssal', 'ssalg', 'ssalm', 'ssalb', 'ssals', 'ssalt', 'ssalp', 'ssalh', 'ssam', 'ssab', 'ssabs', 'ssas', 'ssass', 'ssang', 'ssaj', 'ssach', 0x10 => 'ssak', 'ssat', 'ssap', 'ssah', 'ssae', 'ssaeg', 'ssaekk', 'ssaegs', 'ssaen', 'ssaenj', 'ssaenh', 'ssaed', 'ssael', 'ssaelg', 'ssaelm', 'ssaelb', 0x20 => 'ssaels', 'ssaelt', 'ssaelp', 'ssaelh', 'ssaem', 'ssaeb', 'ssaebs', 'ssaes', 'ssaess', 'ssaeng', 'ssaej', 'ssaech', 'ssaek', 'ssaet', 'ssaep', 'ssaeh', @@ -22,4 +22,4 @@ 0xD0 => 'ssyess', 'ssyeng', 'ssyej', 'ssyech', 'ssyek', 'ssyet', 'ssyep', 'ssyeh', 'sso', 'ssog', 'ssokk', 'ssogs', 'sson', 'ssonj', 'ssonh', 'ssod', 0xE0 => 'ssol', 'ssolg', 'ssolm', 'ssolb', 'ssols', 'ssolt', 'ssolp', 'ssolh', 'ssom', 'ssob', 'ssobs', 'ssos', 'ssoss', 'ssong', 'ssoj', 'ssoch', 0xF0 => 'ssok', 'ssot', 'ssop', 'ssoh', 'sswa', 'sswag', 'sswakk', 'sswags', 'sswan', 'sswanj', 'sswanh', 'sswad', 'sswal', 'sswalg', 'sswalm', 'sswalb', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xc4.php b/core/lib/Drupal/Component/Transliteration/data/xc4.php index 0e9034f..5e0b970 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xc4.php +++ b/core/lib/Drupal/Component/Transliteration/data/xc4.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'sswals', 'sswalt', 'sswalp', 'sswalh', 'sswam', 'sswab', 'sswabs', 'sswas', 'sswass', 'sswang', 'sswaj', 'sswach', 'sswak', 'sswat', 'sswap', 'sswah', 0x10 => 'sswae', 'sswaeg', 'sswaekk', 'sswaegs', 'sswaen', 'sswaenj', 'sswaenh', 'sswaed', 'sswael', 'sswaelg', 'sswaelm', 'sswaelb', 'sswaels', 'sswaelt', 'sswaelp', 'sswaelh', 0x20 => 'sswaem', 'sswaeb', 'sswaebs', 'sswaes', 'sswaess', 'sswaeng', 'sswaej', 'sswaech', 'sswaek', 'sswaet', 'sswaep', 'sswaeh', 'ssoe', 'ssoeg', 'ssoekk', 'ssoegs', @@ -22,4 +22,4 @@ 0xD0 => 'sswik', 'sswit', 'sswip', 'sswih', 'ssyu', 'ssyug', 'ssyukk', 'ssyugs', 'ssyun', 'ssyunj', 'ssyunh', 'ssyud', 'ssyul', 'ssyulg', 'ssyulm', 'ssyulb', 0xE0 => 'ssyuls', 'ssyult', 'ssyulp', 'ssyulh', 'ssyum', 'ssyub', 'ssyubs', 'ssyus', 'ssyuss', 'ssyung', 'ssyuj', 'ssyuch', 'ssyuk', 'ssyut', 'ssyup', 'ssyuh', 0xF0 => 'sseu', 'sseug', 'sseukk', 'sseugs', 'sseun', 'sseunj', 'sseunh', 'sseud', 'sseul', 'sseulg', 'sseulm', 'sseulb', 'sseuls', 'sseult', 'sseulp', 'sseulh', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xc5.php b/core/lib/Drupal/Component/Transliteration/data/xc5.php index 21085ce..f679928 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xc5.php +++ b/core/lib/Drupal/Component/Transliteration/data/xc5.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'sseum', 'sseub', 'sseubs', 'sseus', 'sseuss', 'sseung', 'sseuj', 'sseuch', 'sseuk', 'sseut', 'sseup', 'sseuh', 'ssui', 'ssuig', 'ssuikk', 'ssuigs', 0x10 => 'ssuin', 'ssuinj', 'ssuinh', 'ssuid', 'ssuil', 'ssuilg', 'ssuilm', 'ssuilb', 'ssuils', 'ssuilt', 'ssuilp', 'ssuilh', 'ssuim', 'ssuib', 'ssuibs', 'ssuis', 0x20 => 'ssuiss', 'ssuing', 'ssuij', 'ssuich', 'ssuik', 'ssuit', 'ssuip', 'ssuih', 'ssi', 'ssig', 'ssikk', 'ssigs', 'ssin', 'ssinj', 'ssinh', 'ssid', @@ -22,4 +22,4 @@ 0xD0 => 'e', 'eg', 'ekk', 'egs', 'en', 'enj', 'enh', 'ed', 'el', 'elg', 'elm', 'elb', 'els', 'elt', 'elp', 'elh', 0xE0 => 'em', 'eb', 'ebs', 'es', 'ess', 'eng', 'ej', 'ech', 'ek', 'et', 'ep', 'eh', 'yeo', 'yeog', 'yeokk', 'yeogs', 0xF0 => 'yeon', 'yeonj', 'yeonh', 'yeod', 'yeol', 'yeolg', 'yeolm', 'yeolb', 'yeols', 'yeolt', 'yeolp', 'yeolh', 'yeom', 'yeob', 'yeobs', 'yeos', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xc6.php b/core/lib/Drupal/Component/Transliteration/data/xc6.php index 7cd53f2..fc2d896 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xc6.php +++ b/core/lib/Drupal/Component/Transliteration/data/xc6.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'yeoss', 'yeong', 'yeoj', 'yeoch', 'yeok', 'yeot', 'yeop', 'yeoh', 'ye', 'yeg', 'yekk', 'yegs', 'yen', 'yenj', 'yenh', 'yed', 0x10 => 'yel', 'yelg', 'yelm', 'yelb', 'yels', 'yelt', 'yelp', 'yelh', 'yem', 'yeb', 'yebs', 'yes', 'yess', 'yeng', 'yej', 'yech', 0x20 => 'yek', 'yet', 'yep', 'yeh', 'o', 'og', 'okk', 'ogs', 'on', 'onj', 'onh', 'od', 'ol', 'olg', 'olm', 'olb', @@ -22,4 +22,4 @@ 0xD0 => 'won', 'wonj', 'wonh', 'wod', 'wol', 'wolg', 'wolm', 'wolb', 'wols', 'wolt', 'wolp', 'wolh', 'wom', 'wob', 'wobs', 'wos', 0xE0 => 'woss', 'wong', 'woj', 'woch', 'wok', 'wot', 'wop', 'woh', 'we', 'weg', 'wekk', 'wegs', 'wen', 'wenj', 'wenh', 'wed', 0xF0 => 'wel', 'welg', 'welm', 'welb', 'wels', 'welt', 'welp', 'welh', 'wem', 'web', 'webs', 'wes', 'wess', 'weng', 'wej', 'wech', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xc7.php b/core/lib/Drupal/Component/Transliteration/data/xc7.php index f362ad4..405fd16 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xc7.php +++ b/core/lib/Drupal/Component/Transliteration/data/xc7.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'wek', 'wet', 'wep', 'weh', 'wi', 'wig', 'wikk', 'wigs', 'win', 'winj', 'winh', 'wid', 'wil', 'wilg', 'wilm', 'wilb', 0x10 => 'wils', 'wilt', 'wilp', 'wilh', 'wim', 'wib', 'wibs', 'wis', 'wiss', 'wing', 'wij', 'wich', 'wik', 'wit', 'wip', 'wih', 0x20 => 'yu', 'yug', 'yukk', 'yugs', 'yun', 'yunj', 'yunh', 'yud', 'yul', 'yulg', 'yulm', 'yulb', 'yuls', 'yult', 'yulp', 'yulh', @@ -22,4 +22,4 @@ 0xD0 => 'jyal', 'jyalg', 'jyalm', 'jyalb', 'jyals', 'jyalt', 'jyalp', 'jyalh', 'jyam', 'jyab', 'jyabs', 'jyas', 'jyass', 'jyang', 'jyaj', 'jyach', 0xE0 => 'jyak', 'jyat', 'jyap', 'jyah', 'jyae', 'jyaeg', 'jyaekk', 'jyaegs', 'jyaen', 'jyaenj', 'jyaenh', 'jyaed', 'jyael', 'jyaelg', 'jyaelm', 'jyaelb', 0xF0 => 'jyaels', 'jyaelt', 'jyaelp', 'jyaelh', 'jyaem', 'jyaeb', 'jyaebs', 'jyaes', 'jyaess', 'jyaeng', 'jyaej', 'jyaech', 'jyaek', 'jyaet', 'jyaep', 'jyaeh', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xc8.php b/core/lib/Drupal/Component/Transliteration/data/xc8.php index 656a070..952a139 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xc8.php +++ b/core/lib/Drupal/Component/Transliteration/data/xc8.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'jeo', 'jeog', 'jeokk', 'jeogs', 'jeon', 'jeonj', 'jeonh', 'jeod', 'jeol', 'jeolg', 'jeolm', 'jeolb', 'jeols', 'jeolt', 'jeolp', 'jeolh', 0x10 => 'jeom', 'jeob', 'jeobs', 'jeos', 'jeoss', 'jeong', 'jeoj', 'jeoch', 'jeok', 'jeot', 'jeop', 'jeoh', 'je', 'jeg', 'jekk', 'jegs', 0x20 => 'jen', 'jenj', 'jenh', 'jed', 'jel', 'jelg', 'jelm', 'jelb', 'jels', 'jelt', 'jelp', 'jelh', 'jem', 'jeb', 'jebs', 'jes', @@ -22,4 +22,4 @@ 0xD0 => 'joels', 'joelt', 'joelp', 'joelh', 'joem', 'joeb', 'joebs', 'joes', 'joess', 'joeng', 'joej', 'joech', 'joek', 'joet', 'joep', 'joeh', 0xE0 => 'jyo', 'jyog', 'jyokk', 'jyogs', 'jyon', 'jyonj', 'jyonh', 'jyod', 'jyol', 'jyolg', 'jyolm', 'jyolb', 'jyols', 'jyolt', 'jyolp', 'jyolh', 0xF0 => 'jyom', 'jyob', 'jyobs', 'jyos', 'jyoss', 'jyong', 'jyoj', 'jyoch', 'jyok', 'jyot', 'jyop', 'jyoh', 'ju', 'jug', 'jukk', 'jugs', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xc9.php b/core/lib/Drupal/Component/Transliteration/data/xc9.php index 5fd5eb5..0d990f7 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xc9.php +++ b/core/lib/Drupal/Component/Transliteration/data/xc9.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'jun', 'junj', 'junh', 'jud', 'jul', 'julg', 'julm', 'julb', 'juls', 'jult', 'julp', 'julh', 'jum', 'jub', 'jubs', 'jus', 0x10 => 'juss', 'jung', 'juj', 'juch', 'juk', 'jut', 'jup', 'juh', 'jwo', 'jwog', 'jwokk', 'jwogs', 'jwon', 'jwonj', 'jwonh', 'jwod', 0x20 => 'jwol', 'jwolg', 'jwolm', 'jwolb', 'jwols', 'jwolt', 'jwolp', 'jwolh', 'jwom', 'jwob', 'jwobs', 'jwos', 'jwoss', 'jwong', 'jwoj', 'jwoch', @@ -22,4 +22,4 @@ 0xD0 => 'jim', 'jib', 'jibs', 'jis', 'jiss', 'jing', 'jij', 'jich', 'jik', 'jit', 'jip', 'jih', 'jja', 'jjag', 'jjakk', 'jjags', 0xE0 => 'jjan', 'jjanj', 'jjanh', 'jjad', 'jjal', 'jjalg', 'jjalm', 'jjalb', 'jjals', 'jjalt', 'jjalp', 'jjalh', 'jjam', 'jjab', 'jjabs', 'jjas', 0xF0 => 'jjass', 'jjang', 'jjaj', 'jjach', 'jjak', 'jjat', 'jjap', 'jjah', 'jjae', 'jjaeg', 'jjaekk', 'jjaegs', 'jjaen', 'jjaenj', 'jjaenh', 'jjaed', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xca.php b/core/lib/Drupal/Component/Transliteration/data/xca.php index 7ebaa75..be314ec 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xca.php +++ b/core/lib/Drupal/Component/Transliteration/data/xca.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'jjael', 'jjaelg', 'jjaelm', 'jjaelb', 'jjaels', 'jjaelt', 'jjaelp', 'jjaelh', 'jjaem', 'jjaeb', 'jjaebs', 'jjaes', 'jjaess', 'jjaeng', 'jjaej', 'jjaech', 0x10 => 'jjaek', 'jjaet', 'jjaep', 'jjaeh', 'jjya', 'jjyag', 'jjyakk', 'jjyags', 'jjyan', 'jjyanj', 'jjyanh', 'jjyad', 'jjyal', 'jjyalg', 'jjyalm', 'jjyalb', 0x20 => 'jjyals', 'jjyalt', 'jjyalp', 'jjyalh', 'jjyam', 'jjyab', 'jjyabs', 'jjyas', 'jjyass', 'jjyang', 'jjyaj', 'jjyach', 'jjyak', 'jjyat', 'jjyap', 'jjyah', @@ -22,4 +22,4 @@ 0xD0 => 'jjoss', 'jjong', 'jjoj', 'jjoch', 'jjok', 'jjot', 'jjop', 'jjoh', 'jjwa', 'jjwag', 'jjwakk', 'jjwags', 'jjwan', 'jjwanj', 'jjwanh', 'jjwad', 0xE0 => 'jjwal', 'jjwalg', 'jjwalm', 'jjwalb', 'jjwals', 'jjwalt', 'jjwalp', 'jjwalh', 'jjwam', 'jjwab', 'jjwabs', 'jjwas', 'jjwass', 'jjwang', 'jjwaj', 'jjwach', 0xF0 => 'jjwak', 'jjwat', 'jjwap', 'jjwah', 'jjwae', 'jjwaeg', 'jjwaekk', 'jjwaegs', 'jjwaen', 'jjwaenj', 'jjwaenh', 'jjwaed', 'jjwael', 'jjwaelg', 'jjwaelm', 'jjwaelb', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xcb.php b/core/lib/Drupal/Component/Transliteration/data/xcb.php index cbd291a..c396fcd 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xcb.php +++ b/core/lib/Drupal/Component/Transliteration/data/xcb.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'jjwaels', 'jjwaelt', 'jjwaelp', 'jjwaelh', 'jjwaem', 'jjwaeb', 'jjwaebs', 'jjwaes', 'jjwaess', 'jjwaeng', 'jjwaej', 'jjwaech', 'jjwaek', 'jjwaet', 'jjwaep', 'jjwaeh', 0x10 => 'jjoe', 'jjoeg', 'jjoekk', 'jjoegs', 'jjoen', 'jjoenj', 'jjoenh', 'jjoed', 'jjoel', 'jjoelg', 'jjoelm', 'jjoelb', 'jjoels', 'jjoelt', 'jjoelp', 'jjoelh', 0x20 => 'jjoem', 'jjoeb', 'jjoebs', 'jjoes', 'jjoess', 'jjoeng', 'jjoej', 'jjoech', 'jjoek', 'jjoet', 'jjoep', 'jjoeh', 'jjyo', 'jjyog', 'jjyokk', 'jjyogs', @@ -22,4 +22,4 @@ 0xD0 => 'jjyuk', 'jjyut', 'jjyup', 'jjyuh', 'jjeu', 'jjeug', 'jjeukk', 'jjeugs', 'jjeun', 'jjeunj', 'jjeunh', 'jjeud', 'jjeul', 'jjeulg', 'jjeulm', 'jjeulb', 0xE0 => 'jjeuls', 'jjeult', 'jjeulp', 'jjeulh', 'jjeum', 'jjeub', 'jjeubs', 'jjeus', 'jjeuss', 'jjeung', 'jjeuj', 'jjeuch', 'jjeuk', 'jjeut', 'jjeup', 'jjeuh', 0xF0 => 'jjui', 'jjuig', 'jjuikk', 'jjuigs', 'jjuin', 'jjuinj', 'jjuinh', 'jjuid', 'jjuil', 'jjuilg', 'jjuilm', 'jjuilb', 'jjuils', 'jjuilt', 'jjuilp', 'jjuilh', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xcc.php b/core/lib/Drupal/Component/Transliteration/data/xcc.php index d543b26..4dc25f2 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xcc.php +++ b/core/lib/Drupal/Component/Transliteration/data/xcc.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'jjuim', 'jjuib', 'jjuibs', 'jjuis', 'jjuiss', 'jjuing', 'jjuij', 'jjuich', 'jjuik', 'jjuit', 'jjuip', 'jjuih', 'jji', 'jjig', 'jjikk', 'jjigs', 0x10 => 'jjin', 'jjinj', 'jjinh', 'jjid', 'jjil', 'jjilg', 'jjilm', 'jjilb', 'jjils', 'jjilt', 'jjilp', 'jjilh', 'jjim', 'jjib', 'jjibs', 'jjis', 0x20 => 'jjiss', 'jjing', 'jjij', 'jjich', 'jjik', 'jjit', 'jjip', 'jjih', 'cha', 'chag', 'chakk', 'chags', 'chan', 'chanj', 'chanh', 'chad', @@ -22,4 +22,4 @@ 0xD0 => 'chyeo', 'chyeog', 'chyeokk', 'chyeogs', 'chyeon', 'chyeonj', 'chyeonh', 'chyeod', 'chyeol', 'chyeolg', 'chyeolm', 'chyeolb', 'chyeols', 'chyeolt', 'chyeolp', 'chyeolh', 0xE0 => 'chyeom', 'chyeob', 'chyeobs', 'chyeos', 'chyeoss', 'chyeong', 'chyeoj', 'chyeoch', 'chyeok', 'chyeot', 'chyeop', 'chyeoh', 'chye', 'chyeg', 'chyekk', 'chyegs', 0xF0 => 'chyen', 'chyenj', 'chyenh', 'chyed', 'chyel', 'chyelg', 'chyelm', 'chyelb', 'chyels', 'chyelt', 'chyelp', 'chyelh', 'chyem', 'chyeb', 'chyebs', 'chyes', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xcd.php b/core/lib/Drupal/Component/Transliteration/data/xcd.php index 6f730e5..21f2ed7 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xcd.php +++ b/core/lib/Drupal/Component/Transliteration/data/xcd.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'chyess', 'chyeng', 'chyej', 'chyech', 'chyek', 'chyet', 'chyep', 'chyeh', 'cho', 'chog', 'chokk', 'chogs', 'chon', 'chonj', 'chonh', 'chod', 0x10 => 'chol', 'cholg', 'cholm', 'cholb', 'chols', 'cholt', 'cholp', 'cholh', 'chom', 'chob', 'chobs', 'chos', 'choss', 'chong', 'choj', 'choch', 0x20 => 'chok', 'chot', 'chop', 'choh', 'chwa', 'chwag', 'chwakk', 'chwags', 'chwan', 'chwanj', 'chwanh', 'chwad', 'chwal', 'chwalg', 'chwalm', 'chwalb', @@ -22,4 +22,4 @@ 0xD0 => 'chwen', 'chwenj', 'chwenh', 'chwed', 'chwel', 'chwelg', 'chwelm', 'chwelb', 'chwels', 'chwelt', 'chwelp', 'chwelh', 'chwem', 'chweb', 'chwebs', 'chwes', 0xE0 => 'chwess', 'chweng', 'chwej', 'chwech', 'chwek', 'chwet', 'chwep', 'chweh', 'chwi', 'chwig', 'chwikk', 'chwigs', 'chwin', 'chwinj', 'chwinh', 'chwid', 0xF0 => 'chwil', 'chwilg', 'chwilm', 'chwilb', 'chwils', 'chwilt', 'chwilp', 'chwilh', 'chwim', 'chwib', 'chwibs', 'chwis', 'chwiss', 'chwing', 'chwij', 'chwich', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xce.php b/core/lib/Drupal/Component/Transliteration/data/xce.php index 099354e..08dff78 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xce.php +++ b/core/lib/Drupal/Component/Transliteration/data/xce.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'chwik', 'chwit', 'chwip', 'chwih', 'chyu', 'chyug', 'chyukk', 'chyugs', 'chyun', 'chyunj', 'chyunh', 'chyud', 'chyul', 'chyulg', 'chyulm', 'chyulb', 0x10 => 'chyuls', 'chyult', 'chyulp', 'chyulh', 'chyum', 'chyub', 'chyubs', 'chyus', 'chyuss', 'chyung', 'chyuj', 'chyuch', 'chyuk', 'chyut', 'chyup', 'chyuh', 0x20 => 'cheu', 'cheug', 'cheukk', 'cheugs', 'cheun', 'cheunj', 'cheunh', 'cheud', 'cheul', 'cheulg', 'cheulm', 'cheulb', 'cheuls', 'cheult', 'cheulp', 'cheulh', @@ -22,4 +22,4 @@ 0xD0 => 'kyael', 'kyaelg', 'kyaelm', 'kyaelb', 'kyaels', 'kyaelt', 'kyaelp', 'kyaelh', 'kyaem', 'kyaeb', 'kyaebs', 'kyaes', 'kyaess', 'kyaeng', 'kyaej', 'kyaech', 0xE0 => 'kyaek', 'kyaet', 'kyaep', 'kyaeh', 'keo', 'keog', 'keokk', 'keogs', 'keon', 'keonj', 'keonh', 'keod', 'keol', 'keolg', 'keolm', 'keolb', 0xF0 => 'keols', 'keolt', 'keolp', 'keolh', 'keom', 'keob', 'keobs', 'keos', 'keoss', 'keong', 'keoj', 'keoch', 'keok', 'keot', 'keop', 'keoh', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xcf.php b/core/lib/Drupal/Component/Transliteration/data/xcf.php index 434113f..2a0a946 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xcf.php +++ b/core/lib/Drupal/Component/Transliteration/data/xcf.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ke', 'keg', 'kekk', 'kegs', 'ken', 'kenj', 'kenh', 'ked', 'kel', 'kelg', 'kelm', 'kelb', 'kels', 'kelt', 'kelp', 'kelh', 0x10 => 'kem', 'keb', 'kebs', 'kes', 'kess', 'keng', 'kej', 'kech', 'kek', 'ket', 'kep', 'keh', 'kyeo', 'kyeog', 'kyeokk', 'kyeogs', 0x20 => 'kyeon', 'kyeonj', 'kyeonh', 'kyeod', 'kyeol', 'kyeolg', 'kyeolm', 'kyeolb', 'kyeols', 'kyeolt', 'kyeolp', 'kyeolh', 'kyeom', 'kyeob', 'kyeobs', 'kyeos', @@ -22,4 +22,4 @@ 0xD0 => 'kyols', 'kyolt', 'kyolp', 'kyolh', 'kyom', 'kyob', 'kyobs', 'kyos', 'kyoss', 'kyong', 'kyoj', 'kyoch', 'kyok', 'kyot', 'kyop', 'kyoh', 0xE0 => 'ku', 'kug', 'kukk', 'kugs', 'kun', 'kunj', 'kunh', 'kud', 'kul', 'kulg', 'kulm', 'kulb', 'kuls', 'kult', 'kulp', 'kulh', 0xF0 => 'kum', 'kub', 'kubs', 'kus', 'kuss', 'kung', 'kuj', 'kuch', 'kuk', 'kut', 'kup', 'kuh', 'kwo', 'kwog', 'kwokk', 'kwogs', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xd0.php b/core/lib/Drupal/Component/Transliteration/data/xd0.php index 848b49c..3c94c68 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xd0.php +++ b/core/lib/Drupal/Component/Transliteration/data/xd0.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'kwon', 'kwonj', 'kwonh', 'kwod', 'kwol', 'kwolg', 'kwolm', 'kwolb', 'kwols', 'kwolt', 'kwolp', 'kwolh', 'kwom', 'kwob', 'kwobs', 'kwos', 0x10 => 'kwoss', 'kwong', 'kwoj', 'kwoch', 'kwok', 'kwot', 'kwop', 'kwoh', 'kwe', 'kweg', 'kwekk', 'kwegs', 'kwen', 'kwenj', 'kwenh', 'kwed', 0x20 => 'kwel', 'kwelg', 'kwelm', 'kwelb', 'kwels', 'kwelt', 'kwelp', 'kwelh', 'kwem', 'kweb', 'kwebs', 'kwes', 'kwess', 'kweng', 'kwej', 'kwech', @@ -22,4 +22,4 @@ 0xD0 => 'tam', 'tab', 'tabs', 'tas', 'tass', 'tang', 'taj', 'tach', 'tak', 'tat', 'tap', 'tah', 'tae', 'taeg', 'taekk', 'taegs', 0xE0 => 'taen', 'taenj', 'taenh', 'taed', 'tael', 'taelg', 'taelm', 'taelb', 'taels', 'taelt', 'taelp', 'taelh', 'taem', 'taeb', 'taebs', 'taes', 0xF0 => 'taess', 'taeng', 'taej', 'taech', 'taek', 'taet', 'taep', 'taeh', 'tya', 'tyag', 'tyakk', 'tyags', 'tyan', 'tyanj', 'tyanh', 'tyad', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xd1.php b/core/lib/Drupal/Component/Transliteration/data/xd1.php index c6504f4..418f207 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xd1.php +++ b/core/lib/Drupal/Component/Transliteration/data/xd1.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'tyal', 'tyalg', 'tyalm', 'tyalb', 'tyals', 'tyalt', 'tyalp', 'tyalh', 'tyam', 'tyab', 'tyabs', 'tyas', 'tyass', 'tyang', 'tyaj', 'tyach', 0x10 => 'tyak', 'tyat', 'tyap', 'tyah', 'tyae', 'tyaeg', 'tyaekk', 'tyaegs', 'tyaen', 'tyaenj', 'tyaenh', 'tyaed', 'tyael', 'tyaelg', 'tyaelm', 'tyaelb', 0x20 => 'tyaels', 'tyaelt', 'tyaelp', 'tyaelh', 'tyaem', 'tyaeb', 'tyaebs', 'tyaes', 'tyaess', 'tyaeng', 'tyaej', 'tyaech', 'tyaek', 'tyaet', 'tyaep', 'tyaeh', @@ -22,4 +22,4 @@ 0xD0 => 'twass', 'twang', 'twaj', 'twach', 'twak', 'twat', 'twap', 'twah', 'twae', 'twaeg', 'twaekk', 'twaegs', 'twaen', 'twaenj', 'twaenh', 'twaed', 0xE0 => 'twael', 'twaelg', 'twaelm', 'twaelb', 'twaels', 'twaelt', 'twaelp', 'twaelh', 'twaem', 'twaeb', 'twaebs', 'twaes', 'twaess', 'twaeng', 'twaej', 'twaech', 0xF0 => 'twaek', 'twaet', 'twaep', 'twaeh', 'toe', 'toeg', 'toekk', 'toegs', 'toen', 'toenj', 'toenh', 'toed', 'toel', 'toelg', 'toelm', 'toelb', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xd2.php b/core/lib/Drupal/Component/Transliteration/data/xd2.php index 741c229..d749276 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xd2.php +++ b/core/lib/Drupal/Component/Transliteration/data/xd2.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'toels', 'toelt', 'toelp', 'toelh', 'toem', 'toeb', 'toebs', 'toes', 'toess', 'toeng', 'toej', 'toech', 'toek', 'toet', 'toep', 'toeh', 0x10 => 'tyo', 'tyog', 'tyokk', 'tyogs', 'tyon', 'tyonj', 'tyonh', 'tyod', 'tyol', 'tyolg', 'tyolm', 'tyolb', 'tyols', 'tyolt', 'tyolp', 'tyolh', 0x20 => 'tyom', 'tyob', 'tyobs', 'tyos', 'tyoss', 'tyong', 'tyoj', 'tyoch', 'tyok', 'tyot', 'tyop', 'tyoh', 'tu', 'tug', 'tukk', 'tugs', @@ -22,4 +22,4 @@ 0xD0 => 'teuk', 'teut', 'teup', 'teuh', 'tui', 'tuig', 'tuikk', 'tuigs', 'tuin', 'tuinj', 'tuinh', 'tuid', 'tuil', 'tuilg', 'tuilm', 'tuilb', 0xE0 => 'tuils', 'tuilt', 'tuilp', 'tuilh', 'tuim', 'tuib', 'tuibs', 'tuis', 'tuiss', 'tuing', 'tuij', 'tuich', 'tuik', 'tuit', 'tuip', 'tuih', 0xF0 => 'ti', 'tig', 'tikk', 'tigs', 'tin', 'tinj', 'tinh', 'tid', 'til', 'tilg', 'tilm', 'tilb', 'tils', 'tilt', 'tilp', 'tilh', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xd3.php b/core/lib/Drupal/Component/Transliteration/data/xd3.php index 54aab18..d56ee58 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xd3.php +++ b/core/lib/Drupal/Component/Transliteration/data/xd3.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'tim', 'tib', 'tibs', 'tis', 'tiss', 'ting', 'tij', 'tich', 'tik', 'tit', 'tip', 'tih', 'pa', 'pag', 'pakk', 'pags', 0x10 => 'pan', 'panj', 'panh', 'pad', 'pal', 'palg', 'palm', 'palb', 'pals', 'palt', 'palp', 'palh', 'pam', 'pab', 'pabs', 'pas', 0x20 => 'pass', 'pang', 'paj', 'pach', 'pak', 'pat', 'pap', 'pah', 'pae', 'paeg', 'paekk', 'paegs', 'paen', 'paenj', 'paenh', 'paed', @@ -22,4 +22,4 @@ 0xD0 => 'pye', 'pyeg', 'pyekk', 'pyegs', 'pyen', 'pyenj', 'pyenh', 'pyed', 'pyel', 'pyelg', 'pyelm', 'pyelb', 'pyels', 'pyelt', 'pyelp', 'pyelh', 0xE0 => 'pyem', 'pyeb', 'pyebs', 'pyes', 'pyess', 'pyeng', 'pyej', 'pyech', 'pyek', 'pyet', 'pyep', 'pyeh', 'po', 'pog', 'pokk', 'pogs', 0xF0 => 'pon', 'ponj', 'ponh', 'pod', 'pol', 'polg', 'polm', 'polb', 'pols', 'polt', 'polp', 'polh', 'pom', 'pob', 'pobs', 'pos', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xd4.php b/core/lib/Drupal/Component/Transliteration/data/xd4.php index 0df6410..dcbf3ec 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xd4.php +++ b/core/lib/Drupal/Component/Transliteration/data/xd4.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'poss', 'pong', 'poj', 'poch', 'pok', 'pot', 'pop', 'poh', 'pwa', 'pwag', 'pwakk', 'pwags', 'pwan', 'pwanj', 'pwanh', 'pwad', 0x10 => 'pwal', 'pwalg', 'pwalm', 'pwalb', 'pwals', 'pwalt', 'pwalp', 'pwalh', 'pwam', 'pwab', 'pwabs', 'pwas', 'pwass', 'pwang', 'pwaj', 'pwach', 0x20 => 'pwak', 'pwat', 'pwap', 'pwah', 'pwae', 'pwaeg', 'pwaekk', 'pwaegs', 'pwaen', 'pwaenj', 'pwaenh', 'pwaed', 'pwael', 'pwaelg', 'pwaelm', 'pwaelb', @@ -22,4 +22,4 @@ 0xD0 => 'pwin', 'pwinj', 'pwinh', 'pwid', 'pwil', 'pwilg', 'pwilm', 'pwilb', 'pwils', 'pwilt', 'pwilp', 'pwilh', 'pwim', 'pwib', 'pwibs', 'pwis', 0xE0 => 'pwiss', 'pwing', 'pwij', 'pwich', 'pwik', 'pwit', 'pwip', 'pwih', 'pyu', 'pyug', 'pyukk', 'pyugs', 'pyun', 'pyunj', 'pyunh', 'pyud', 0xF0 => 'pyul', 'pyulg', 'pyulm', 'pyulb', 'pyuls', 'pyult', 'pyulp', 'pyulh', 'pyum', 'pyub', 'pyubs', 'pyus', 'pyuss', 'pyung', 'pyuj', 'pyuch', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xd5.php b/core/lib/Drupal/Component/Transliteration/data/xd5.php index 2dbeada..0b3efb1 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xd5.php +++ b/core/lib/Drupal/Component/Transliteration/data/xd5.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'pyuk', 'pyut', 'pyup', 'pyuh', 'peu', 'peug', 'peukk', 'peugs', 'peun', 'peunj', 'peunh', 'peud', 'peul', 'peulg', 'peulm', 'peulb', 0x10 => 'peuls', 'peult', 'peulp', 'peulh', 'peum', 'peub', 'peubs', 'peus', 'peuss', 'peung', 'peuj', 'peuch', 'peuk', 'peut', 'peup', 'peuh', 0x20 => 'pui', 'puig', 'puikk', 'puigs', 'puin', 'puinj', 'puinh', 'puid', 'puil', 'puilg', 'puilm', 'puilb', 'puils', 'puilt', 'puilp', 'puilh', @@ -22,4 +22,4 @@ 0xD0 => 'heol', 'heolg', 'heolm', 'heolb', 'heols', 'heolt', 'heolp', 'heolh', 'heom', 'heob', 'heobs', 'heos', 'heoss', 'heong', 'heoj', 'heoch', 0xE0 => 'heok', 'heot', 'heop', 'heoh', 'he', 'heg', 'hekk', 'hegs', 'hen', 'henj', 'henh', 'hed', 'hel', 'helg', 'helm', 'helb', 0xF0 => 'hels', 'helt', 'help', 'helh', 'hem', 'heb', 'hebs', 'hes', 'hess', 'heng', 'hej', 'hech', 'hek', 'het', 'hep', 'heh', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xd6.php b/core/lib/Drupal/Component/Transliteration/data/xd6.php index e86914f..ae1dcf7 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xd6.php +++ b/core/lib/Drupal/Component/Transliteration/data/xd6.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'hyeo', 'hyeog', 'hyeokk', 'hyeogs', 'hyeon', 'hyeonj', 'hyeonh', 'hyeod', 'hyeol', 'hyeolg', 'hyeolm', 'hyeolb', 'hyeols', 'hyeolt', 'hyeolp', 'hyeolh', 0x10 => 'hyeom', 'hyeob', 'hyeobs', 'hyeos', 'hyeoss', 'hyeong', 'hyeoj', 'hyeoch', 'hyeok', 'hyeot', 'hyeop', 'hyeoh', 'hye', 'hyeg', 'hyekk', 'hyegs', 0x20 => 'hyen', 'hyenj', 'hyenh', 'hyed', 'hyel', 'hyelg', 'hyelm', 'hyelb', 'hyels', 'hyelt', 'hyelp', 'hyelh', 'hyem', 'hyeb', 'hyebs', 'hyes', @@ -22,4 +22,4 @@ 0xD0 => 'huls', 'hult', 'hulp', 'hulh', 'hum', 'hub', 'hubs', 'hus', 'huss', 'hung', 'huj', 'huch', 'huk', 'hut', 'hup', 'huh', 0xE0 => 'hwo', 'hwog', 'hwokk', 'hwogs', 'hwon', 'hwonj', 'hwonh', 'hwod', 'hwol', 'hwolg', 'hwolm', 'hwolb', 'hwols', 'hwolt', 'hwolp', 'hwolh', 0xF0 => 'hwom', 'hwob', 'hwobs', 'hwos', 'hwoss', 'hwong', 'hwoj', 'hwoch', 'hwok', 'hwot', 'hwop', 'hwoh', 'hwe', 'hweg', 'hwekk', 'hwegs', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xd7.php b/core/lib/Drupal/Component/Transliteration/data/xd7.php index af74c89..c0f75b5 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xd7.php +++ b/core/lib/Drupal/Component/Transliteration/data/xd7.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'hwen', 'hwenj', 'hwenh', 'hwed', 'hwel', 'hwelg', 'hwelm', 'hwelb', 'hwels', 'hwelt', 'hwelp', 'hwelh', 'hwem', 'hweb', 'hwebs', 'hwes', 0x10 => 'hwess', 'hweng', 'hwej', 'hwech', 'hwek', 'hwet', 'hwep', 'hweh', 'hwi', 'hwig', 'hwikk', 'hwigs', 'hwin', 'hwinj', 'hwinh', 'hwid', 0x20 => 'hwil', 'hwilg', 'hwilm', 'hwilb', 'hwils', 'hwilt', 'hwilp', 'hwilh', 'hwim', 'hwib', 'hwibs', 'hwis', 'hwiss', 'hwing', 'hwij', 'hwich', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xf9.php b/core/lib/Drupal/Component/Transliteration/data/xf9.php index efc8499..29eaa3b 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xf9.php +++ b/core/lib/Drupal/Component/Transliteration/data/xf9.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'qi', 'geng', 'che', 'jia', 'hua', 'chuan', 'ju', 'gui', 'gui', 'qi', 'jin', 'la', 'nai', 'lan', 'lai', 'luo', 0x10 => 'luo', 'luo', 'luo', 'luo', 'le', 'luo', 'lao', 'luo', 'luo', 'lao', 'luo', 'luan', 'luan', 'lan', 'lan', 'lan', 0x20 => 'luan', 'lan', 'lan', 'lan', 'lan', 'la', 'la', 'la', 'lang', 'lang', 'lang', 'lang', 'lang', 'lai', 'leng', 'lao', @@ -22,4 +22,4 @@ 0xD0 => 'lei', 'liu', 'lu', 'lu', 'lun', 'lun', 'lun', 'lun', 'lu', 'li', 'li', 'lu', 'long', 'li', 'li', 'lu', 0xE0 => 'yi', 'li', 'li', 'ni', 'li', 'li', 'li', 'li', 'li', 'li', 'li', 'ni', 'ni', 'lin', 'lin', 'lin', 0xF0 => 'lin', 'lin', 'lin', 'lin', 'lin', 'lin', 'lin', 'li', 'li', 'li', 'zhuang', 'zhi', 'shi', 'shen', 'cha', 'ci', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xfa.php b/core/lib/Drupal/Component/Transliteration/data/xfa.php index 7ba4ae8..d5b92f6 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xfa.php +++ b/core/lib/Drupal/Component/Transliteration/data/xfa.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'qie', 'du', 'ta', 'tang', 'zhai', 'dong', 'bao', 'fu', 'xing', 'jiang', 'jian', 'kuo', 'wu', 'hu', NULL, NULL, 0x10 => 'zhong', NULL, 'qing', NULL, NULL, 'xi', 'zhu', 'yi', 'li', 'shen', 'xiang', 'fu', 'jing', 'jing', 'yu', NULL, 0x20 => 'qiu', NULL, 'zhu', NULL, NULL, 'yi', 'dou', NULL, NULL, NULL, 'fan', 'si', 'guan', 'he', NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, 'he', 'xie', 'jie', NULL, 'qian', 'beng', 'e', 'pang', NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xfb.php b/core/lib/Drupal/Component/Transliteration/data/xfb.php index 7dd47ae..aa734cd 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xfb.php +++ b/core/lib/Drupal/Component/Transliteration/data/xfb.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x10 => NULL, NULL, NULL, 'mn', 'me', 'mi', 'vn', 'mkh', NULL, NULL, NULL, NULL, NULL, 'y', '', 'yy', 0x20 => '`', '', 'd', 'h', 'k', 'l', 'm', 'r', 't', '+', 's', 's', 's', 's', 'a', 'a', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, 'ng', 'ng', 'ng', 'ng', '', '', '', '', '', '', '', 'v', 'v', 0xE0 => '', '', '', '', '', '', '', '', 'y', 'y', 'ya', 'ya', '', '', 'yw', 'yw', 0xF0 => '', '', '', '', '', '', '', '', '', 'yy', 'yy', 'yy', 'y', 'y', 'y', 'y', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xfc.php b/core/lib/Drupal/Component/Transliteration/data/xfc.php index 959ef1e..aac2f66 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xfc.php +++ b/core/lib/Drupal/Component/Transliteration/data/xfc.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'yj', 'yh', 'ym', 'yy', 'yy', 'bj', 'bh', 'bkh', 'bm', 'by', 'by', 'tj', 'th', 'tkh', 'tm', 'ty', 0x10 => 'ty', 'thj', 'thm', 'thy', 'thy', 'jh', 'jm', 'hj', 'hm', 'khj', 'khh', 'khm', 'sj', 'sh', 'skh', 'sm', 0x20 => 'sh', 'sm', 'dj', 'dh', 'dkh', 'dm', 'th', 'tm', 'zm', '', '', 'ghj', 'ghm', 'fj', 'fh', 'fkh', @@ -22,4 +22,4 @@ 0xD0 => 'mkh', 'mm', 'nj', 'nh', 'nkh', 'nm', 'nh', 'hj', 'hm', 'h', 'yj', 'yh', 'ykh', 'ym', 'yh', 'ym', 0xE0 => 'yh', 'bm', 'bh', 'tm', 'th', 'thm', 'thh', 'sm', 'sh', 'shm', 'shh', 'kl', 'km', 'lm', 'nm', 'nh', 0xF0 => 'ym', 'yh', 'a', 'u', 'i', 'ty', 'ty', '', '', 'ghy', 'ghy', 'sy', 'sy', 'shy', 'shy', 'hy', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xfd.php b/core/lib/Drupal/Component/Transliteration/data/xfd.php index 26372c4..a970732 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xfd.php +++ b/core/lib/Drupal/Component/Transliteration/data/xfd.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => 'hy', 'jy', 'jy', 'khy', 'khy', 'sy', 'sy', 'dy', 'dy', 'shj', 'shh', 'shkh', 'shm', 'shr', 'sr', 'sr', 0x10 => 'dr', 'ty', 'ty', '', '', 'ghy', 'ghy', 'sy', 'sy', 'shy', 'shy', 'hy', 'hy', 'jy', 'jy', 'khy', 0x20 => 'khy', 'sy', 'sy', 'dy', 'dy', 'shj', 'shh', 'shkh', 'shm', 'shr', 'sr', 'sr', 'dr', 'shj', 'shh', 'shkh', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xE0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0xF0 => '', '', 'allh', 'akbr', 'mhmd', '', 'rswl', '', 'wslm', 'sly', '', 'jl jlalh', 'ryal', NULL, NULL, NULL, -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xfe.php b/core/lib/Drupal/Component/Transliteration/data/xfe.php index c53867b..d054020 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xfe.php +++ b/core/lib/Drupal/Component/Transliteration/data/xfe.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0x10 => ',', ',', '.', ':', ';', '!', '?', NULL, NULL, '...', NULL, NULL, NULL, NULL, NULL, NULL, 0x20 => '', '', '', '~', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -22,4 +22,4 @@ 0xD0 => 'gh', 'f', 'f', 'f', 'f', 'q', 'q', 'q', 'q', 'k', 'k', 'k', 'k', 'l', 'l', 'l', 0xE0 => 'l', 'm', 'm', 'm', 'm', 'n', 'n', 'n', 'n', 'h', 'h', 'h', 'h', 'w', 'w', 'y', 0xF0 => 'y', 'y', 'y', 'y', 'y', 'la', 'la', 'la', 'la', 'la', 'la', 'la', 'la', NULL, NULL, '', -); +]; diff --git a/core/lib/Drupal/Component/Transliteration/data/xff.php b/core/lib/Drupal/Component/Transliteration/data/xff.php index 8085298..3f669bd 100644 --- a/core/lib/Drupal/Component/Transliteration/data/xff.php +++ b/core/lib/Drupal/Component/Transliteration/data/xff.php @@ -5,7 +5,7 @@ * Generic transliteration data for the PhpTransliteration class. */ -$base = array( +$base = [ 0x00 => NULL, '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', 0x10 => '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', 0x20 => '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', @@ -22,4 +22,4 @@ 0xD0 => NULL, NULL, 'yo', 'u', 'wo', 'we', 'wi', 'yu', NULL, NULL, 'eu', 'ui', 'i', NULL, NULL, NULL, 0xE0 => '/C', 'PS', '!', '-', '|', 'Y=', 'W=', NULL, '|', '-', '|', '-', '|', '#', 'O', NULL, 0xF0 => NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '{', '|', '}', '', '', '', '', -); +]; diff --git a/core/lib/Drupal/Component/Utility/ArgumentsResolver.php b/core/lib/Drupal/Component/Utility/ArgumentsResolver.php index e04cc35..0bd53b2 100644 --- a/core/lib/Drupal/Component/Utility/ArgumentsResolver.php +++ b/core/lib/Drupal/Component/Utility/ArgumentsResolver.php @@ -49,7 +49,7 @@ public function __construct(array $scalars, array $objects, array $wildcards) { * {@inheritdoc} */ public function getArguments(callable $callable) { - $arguments = array(); + $arguments = []; foreach ($this->getReflector($callable)->getParameters() as $parameter) { $arguments[] = $this->getArgument($parameter); } diff --git a/core/lib/Drupal/Component/Utility/Color.php b/core/lib/Drupal/Component/Utility/Color.php index d53261c..aa296e9 100644 --- a/core/lib/Drupal/Component/Utility/Color.php +++ b/core/lib/Drupal/Component/Utility/Color.php @@ -56,11 +56,11 @@ public static function hexToRgb($hex) { $c = hexdec($hex); - return array( + return [ 'red' => $c >> 16 & 0xFF, 'green' => $c >> 8 & 0xFF, 'blue' => $c & 0xFF, - ); + ]; } /** diff --git a/core/lib/Drupal/Component/Utility/DiffArray.php b/core/lib/Drupal/Component/Utility/DiffArray.php index 719049e..825648e 100644 --- a/core/lib/Drupal/Component/Utility/DiffArray.php +++ b/core/lib/Drupal/Component/Utility/DiffArray.php @@ -25,7 +25,7 @@ class DiffArray { * in array2. */ public static function diffAssocRecursive(array $array1, array $array2) { - $difference = array(); + $difference = []; foreach ($array1 as $key => $value) { if (is_array($value)) { diff --git a/core/lib/Drupal/Component/Utility/Html.php b/core/lib/Drupal/Component/Utility/Html.php index 5456cfa..75bb62f 100644 --- a/core/lib/Drupal/Component/Utility/Html.php +++ b/core/lib/Drupal/Component/Utility/Html.php @@ -14,7 +14,7 @@ class Html { * * @var array */ - protected static $classes = array(); + protected static $classes = []; /** * An array of the initial IDs used in one request. @@ -89,13 +89,13 @@ public static function getClass($class) { * @return string * The cleaned identifier. */ - public static function cleanCssIdentifier($identifier, array $filter = array( + public static function cleanCssIdentifier($identifier, array $filter = [ ' ' => '-', '_' => '-', '/' => '-', '[' => '-', ']' => '', - )) { + ]) { // We could also use strtr() here but its much slower than str_replace(). In // order to keep '__' to stay '__' we first replace it with a different // placeholder after checking that it is not defined as a filter. @@ -120,10 +120,10 @@ public static function cleanCssIdentifier($identifier, array $filter = array( // We strip out any character not in the above list. $identifier = preg_replace('/[^\x{002D}\x{0030}-\x{0039}\x{0041}-\x{005A}\x{005F}\x{0061}-\x{007A}\x{00A1}-\x{FFFF}]/u', '', $identifier); // Identifiers cannot start with a digit, two hyphens, or a hyphen followed by a digit. - $identifier = preg_replace(array( + $identifier = preg_replace([ '/^[0-9]/', '/^(-[0-9])|^(--)/' - ), array('_', '__'), $identifier); + ], ['_', '__'], $identifier); return $identifier; } @@ -176,7 +176,7 @@ public static function getUniqueId($id) { // @todo Remove all that code once we switch over to random IDs only, // see https://www.drupal.org/node/1090592. if (!isset(static::$seenIdsInit)) { - static::$seenIdsInit = array(); + static::$seenIdsInit = []; } if (!isset(static::$seenIds)) { static::$seenIds = static::$seenIdsInit; @@ -279,7 +279,7 @@ public static function load($html) { // PHP's \DOMDocument serialization adds extra whitespace when the markup // of the wrapping document contains newlines, so ensure we remove all // newlines before injecting the actual HTML body to be processed. - $document = strtr($document, array("\n" => '', '!html' => $html)); + $document = strtr($document, ["\n" => '', '!html' => $html]); $dom = new \DOMDocument(); // Ignore warnings during HTML soup loading. diff --git a/core/lib/Drupal/Component/Utility/NestedArray.php b/core/lib/Drupal/Component/Utility/NestedArray.php index 0b7cf4f..c11d6a6 100644 --- a/core/lib/Drupal/Component/Utility/NestedArray.php +++ b/core/lib/Drupal/Component/Utility/NestedArray.php @@ -150,7 +150,7 @@ public static function setValue(array &$array, array $parents, $value, $force = // PHP auto-creates container arrays and NULL entries without error if $ref // is NULL, but throws an error if $ref is set, but not an array. if ($force && isset($ref) && !is_array($ref)) { - $ref = array(); + $ref = []; } $ref = &$ref[$parent]; } @@ -322,7 +322,7 @@ public static function mergeDeep() { * @see NestedArray::mergeDeep() */ public static function mergeDeepArray(array $arrays, $preserve_integer_keys = FALSE) { - $result = array(); + $result = []; foreach ($arrays as $array) { foreach ($array as $key => $value) { // Renumber integer keys as array_merge_recursive() does unless @@ -333,7 +333,7 @@ public static function mergeDeepArray(array $arrays, $preserve_integer_keys = FA } // Recurse when both values are arrays. elseif (isset($result[$key]) && is_array($result[$key]) && is_array($value)) { - $result[$key] = self::mergeDeepArray(array($result[$key], $value), $preserve_integer_keys); + $result[$key] = self::mergeDeepArray([$result[$key], $value], $preserve_integer_keys); } // Otherwise, use the latter value, overriding any previous value. else { diff --git a/core/lib/Drupal/Component/Utility/Random.php b/core/lib/Drupal/Component/Utility/Random.php index 3a00839..e158b9d 100644 --- a/core/lib/Drupal/Component/Utility/Random.php +++ b/core/lib/Drupal/Component/Utility/Random.php @@ -24,14 +24,14 @@ class Random { * * @var array */ - protected $strings = array(); + protected $strings = []; /** * A list of unique names generated by name(). * * @var array */ - protected $names = array(); + protected $names = []; /** * Generates a random string of ASCII characters of codes 32 to 126. @@ -141,9 +141,9 @@ public function name($length = 8, $unique = FALSE) { public function word($length) { mt_srand((double) microtime() * 1000000); - $vowels = array("a", "e", "i", "o", "u"); - $cons = array("b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr", - "cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl", "sh"); + $vowels = ["a", "e", "i", "o", "u"]; + $cons = ["b", "c", "d", "g", "h", "j", "k", "l", "m", "n", "p", "r", "s", "t", "u", "v", "w", "tr", + "cr", "br", "fr", "th", "dr", "ch", "ph", "wr", "st", "sp", "sw", "pr", "sl", "cl", "sh"]; $num_vowels = count($vowels); $num_cons = count($cons); @@ -190,7 +190,7 @@ public function object($size = 4) { * Nonsense latin words which form sentence(s). */ public function sentences($min_word_count, $capitalize = FALSE) { - $dictionary = array("abbas", "abdo", "abico", "abigo", "abluo", "accumsan", + $dictionary = ["abbas", "abdo", "abico", "abigo", "abluo", "accumsan", "acsi", "ad", "adipiscing", "aliquam", "aliquip", "amet", "antehabeo", "appellatio", "aptent", "at", "augue", "autem", "bene", "blandit", "brevitas", "caecus", "camur", "capto", "causa", "cogo", "comis", @@ -219,7 +219,7 @@ public function sentences($min_word_count, $capitalize = FALSE) { "utrum", "uxor", "valde", "valetudo", "validus", "vel", "velit", "veniam", "venio", "vereor", "vero", "verto", "vicis", "vindico", "virtus", "voco", "volutpat", "vulpes", "vulputate", "wisi", "ymo", - "zelus"); + "zelus"]; $dictionary_flipped = array_flip($dictionary); $greeking = ''; diff --git a/core/lib/Drupal/Component/Utility/Tags.php b/core/lib/Drupal/Component/Utility/Tags.php index 3f8ed13..ac0ce60 100644 --- a/core/lib/Drupal/Component/Utility/Tags.php +++ b/core/lib/Drupal/Component/Utility/Tags.php @@ -25,7 +25,7 @@ public static function explode($tags) { preg_match_all($regexp, $tags, $matches); $typed_tags = array_unique($matches[1]); - $tags = array(); + $tags = []; foreach ($typed_tags as $tag) { // If a user has escaped a term (to demonstrate that it is a group, // or includes a comma or quote character), we remove the escape @@ -65,7 +65,7 @@ public static function encode($tag) { * The imploded string. */ public static function implode($tags) { - $encoded_tags = array(); + $encoded_tags = []; foreach ($tags as $tag) { $encoded_tags[] = self::encode($tag); } diff --git a/core/lib/Drupal/Component/Utility/Timer.php b/core/lib/Drupal/Component/Utility/Timer.php index 959eeb3..b8dc026 100644 --- a/core/lib/Drupal/Component/Utility/Timer.php +++ b/core/lib/Drupal/Component/Utility/Timer.php @@ -9,7 +9,7 @@ */ class Timer { - static protected $timers = array(); + static protected $timers = []; /** * Starts the timer with the specified name. diff --git a/core/lib/Drupal/Component/Utility/Unicode.php b/core/lib/Drupal/Component/Utility/Unicode.php index f6b4668..98db804 100644 --- a/core/lib/Drupal/Component/Utility/Unicode.php +++ b/core/lib/Drupal/Component/Utility/Unicode.php @@ -125,7 +125,7 @@ public static function getStatus() { * The new status of multibyte support. */ public static function setStatus($status) { - if (!in_array($status, array(static::STATUS_SINGLEBYTE, static::STATUS_MULTIBYTE, static::STATUS_ERROR))) { + if (!in_array($status, [static::STATUS_SINGLEBYTE, static::STATUS_MULTIBYTE, static::STATUS_ERROR])) { throw new \InvalidArgumentException('Invalid status value for unicode support.'); } static::$status = $status; @@ -189,7 +189,7 @@ public static function check() { * The name of the encoding, or FALSE if no byte order mark was present. */ public static function encodingFromBOM($data) { - static $bomMap = array( + static $bomMap = [ "\xEF\xBB\xBF" => 'UTF-8', "\xFE\xFF" => 'UTF-16BE', "\xFF\xFE" => 'UTF-16LE', @@ -200,7 +200,7 @@ public static function encodingFromBOM($data) { "\x2B\x2F\x76\x2B" => 'UTF-7', "\x2B\x2F\x76\x2F" => 'UTF-7', "\x2B\x2F\x76\x38\x2D" => 'UTF-7', - ); + ]; foreach ($bomMap as $bom => $encoding) { if (strpos($data, $bom) === 0) { @@ -542,7 +542,7 @@ public static function truncate($string, $max_length, $wordsafe = FALSE, $add_el } if ($wordsafe) { - $matches = array(); + $matches = []; // Find the last word boundary, if there is one within $min_wordsafe_length // to $max_length characters. preg_match() is always greedy, so it will // find the longest string possible. diff --git a/core/lib/Drupal/Component/Utility/UrlHelper.php b/core/lib/Drupal/Component/Utility/UrlHelper.php index 1395d81..04c217b 100644 --- a/core/lib/Drupal/Component/Utility/UrlHelper.php +++ b/core/lib/Drupal/Component/Utility/UrlHelper.php @@ -14,7 +14,7 @@ class UrlHelper { * * @var array */ - protected static $allowedProtocols = array('http', 'https'); + protected static $allowedProtocols = ['http', 'https']; /** * Parses an array into a valid, rawurlencoded query string. @@ -43,7 +43,7 @@ class UrlHelper { * @ingroup php_wrappers */ public static function buildQuery(array $query, $parent = '') { - $params = array(); + $params = []; foreach ($query as $key => $value) { $key = ($parent ? $parent . '[' . rawurlencode($key) . ']' : rawurlencode($key)); @@ -79,7 +79,7 @@ public static function buildQuery(array $query, $parent = '') { * @return * An array containing query parameters. */ - public static function filterQueryParameters(array $query, array $exclude = array(), $parent = '') { + public static function filterQueryParameters(array $query, array $exclude = [], $parent = '') { // If $exclude is empty, there is nothing to filter. if (empty($exclude)) { return $query; @@ -88,7 +88,7 @@ public static function filterQueryParameters(array $query, array $exclude = arra $exclude = array_flip($exclude); } - $params = array(); + $params = []; foreach ($query as $key => $value) { $string_key = ($parent ? $parent . '[' . $key . ']' : $key); if (isset($exclude[$string_key])) { @@ -134,11 +134,11 @@ public static function filterQueryParameters(array $query, array $exclude = arra * @ingroup php_wrappers */ public static function parse($url) { - $options = array( + $options = [ 'path' => NULL, - 'query' => array(), + 'query' => [], 'fragment' => '', - ); + ]; // External URLs: not using parse_url() here, so we do not have to rebuild // the scheme, host, and path without having any use for it. @@ -294,7 +294,7 @@ public static function getAllowedProtocols() { * @param array $protocols * An array of protocols, for example http, https and irc. */ - public static function setAllowedProtocols(array $protocols = array()) { + public static function setAllowedProtocols(array $protocols = []) { static::$allowedProtocols = $protocols; } diff --git a/core/lib/Drupal/Component/Utility/UserAgent.php b/core/lib/Drupal/Component/Utility/UserAgent.php index 2fc67d6..c80c44e 100644 --- a/core/lib/Drupal/Component/Utility/UserAgent.php +++ b/core/lib/Drupal/Component/Utility/UserAgent.php @@ -36,7 +36,7 @@ class UserAgent { * The selected language code or FALSE if no valid language can be * identified. */ - public static function getBestMatchingLangcode($http_accept_language, $langcodes, $mappings = array()) { + public static function getBestMatchingLangcode($http_accept_language, $langcodes, $mappings = []) { // The Accept-Language header contains information about the language // preferences configured in the user's user agent / operating system. // RFC 2616 (section 14.4) defines the Accept-Language header as follows: @@ -44,7 +44,7 @@ public static function getBestMatchingLangcode($http_accept_language, $langcodes // 1#( language-range [ ";" "q" "=" qvalue ] ) // language-range = ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) | "*" ) // Samples: "hu, en-us;q=0.66, en;q=0.33", "hu,en-us;q=0.5" - $ua_langcodes = array(); + $ua_langcodes = []; if (preg_match_all('@(?<=[, ]|^)([a-zA-Z-]+|\*)(?:;q=([0-9.]+))?(?:$|\s*,\s*)@', trim($http_accept_language), $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { if ($mappings) { diff --git a/core/lib/Drupal/Component/Utility/Variable.php b/core/lib/Drupal/Component/Utility/Variable.php index 5a83079..c6c6935 100644 --- a/core/lib/Drupal/Component/Utility/Variable.php +++ b/core/lib/Drupal/Component/Utility/Variable.php @@ -43,7 +43,7 @@ public static function export($var, $prefix = '') { // If the string contains a line break or a single quote, use the // double quote export mode. Encode backslash, dollar symbols, and // double quotes and transform some common control characters. - $var = str_replace(array('\\', '$', '"', "\n", "\r", "\t"), array('\\\\', '\$', '\"', '\n', '\r', '\t'), $var); + $var = str_replace(['\\', '$', '"', "\n", "\r", "\t"], ['\\\\', '\$', '\"', '\n', '\r', '\t'], $var); $output = '"' . $var . '"'; } else { diff --git a/core/lib/Drupal/Component/Utility/Xss.php b/core/lib/Drupal/Component/Utility/Xss.php index ab8be78..6770edc 100644 --- a/core/lib/Drupal/Component/Utility/Xss.php +++ b/core/lib/Drupal/Component/Utility/Xss.php @@ -16,7 +16,7 @@ class Xss { * * @see \Drupal\Component\Utility\Xss::filterAdmin() */ - protected static $adminTags = array('a', 'abbr', 'acronym', 'address', 'article', 'aside', 'b', 'bdi', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'command', 'dd', 'del', 'details', 'dfn', 'div', 'dl', 'dt', 'em', 'figcaption', 'figure', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'mark', 'menu', 'meter', 'nav', 'ol', 'output', 'p', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'small', 'span', 'strong', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', 'tr', 'tt', 'u', 'ul', 'var', 'wbr'); + protected static $adminTags = ['a', 'abbr', 'acronym', 'address', 'article', 'aside', 'b', 'bdi', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'command', 'dd', 'del', 'details', 'dfn', 'div', 'dl', 'dt', 'em', 'figcaption', 'figure', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'mark', 'menu', 'meter', 'nav', 'ol', 'output', 'p', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'small', 'span', 'strong', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', 'tr', 'tt', 'u', 'ul', 'var', 'wbr']; /** * The default list of HTML tags allowed by filter(). @@ -25,7 +25,7 @@ class Xss { * * @see \Drupal\Component\Utility\Xss::filter() */ - protected static $htmlTags = array('a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd'); + protected static $htmlTags = ['a', 'em', 'strong', 'cite', 'blockquote', 'code', 'ul', 'ol', 'li', 'dl', 'dt', 'dd']; /** * Filters HTML to prevent cross-site-scripting (XSS) vulnerabilities. @@ -196,7 +196,7 @@ protected static function split($string, $html_tags, $class) { * Cleaned up version of the HTML attributes. */ protected static function attributes($attributes) { - $attributes_array = array(); + $attributes_array = []; $mode = 0; $attribute_name = ''; $skip = FALSE; @@ -221,10 +221,10 @@ protected static function attributes($attributes) { // such attributes. // @see \Drupal\Component\Utility\UrlHelper::filterBadProtocol() // @see http://www.w3.org/TR/html4/index/attributes.html - $skip_protocol_filtering = substr($attribute_name, 0, 5) === 'data-' || in_array($attribute_name, array( + $skip_protocol_filtering = substr($attribute_name, 0, 5) === 'data-' || in_array($attribute_name, [ 'title', 'alt', - )); + ]); $working = $mode = 1; $attributes = preg_replace('/^[-a-zA-Z][-a-zA-Z0-9]*/', '', $attributes); diff --git a/core/lib/Drupal/Core/Access/AccessManager.php b/core/lib/Drupal/Core/Access/AccessManager.php index 95e7721..b7b7c0b 100644 --- a/core/lib/Drupal/Core/Access/AccessManager.php +++ b/core/lib/Drupal/Core/Access/AccessManager.php @@ -78,7 +78,7 @@ public function __construct(RouteProviderInterface $route_provider, ParamConvert /** * {@inheritdoc} */ - public function checkNamedRoute($route_name, array $parameters = array(), AccountInterface $account = NULL, $return_as_object = FALSE) { + public function checkNamedRoute($route_name, array $parameters = [], AccountInterface $account = NULL, $return_as_object = FALSE) { try { $route = $this->routeProvider->getRouteByName($route_name, $parameters); @@ -120,7 +120,7 @@ public function check(RouteMatchInterface $route_match, AccountInterface $accoun $account = $this->currentUser; } $route = $route_match->getRouteObject(); - $checks = $route->getOption('_access_checks') ?: array(); + $checks = $route->getOption('_access_checks') ?: []; // Filter out checks which require the incoming request. if (!isset($request)) { diff --git a/core/lib/Drupal/Core/Access/AccessManagerInterface.php b/core/lib/Drupal/Core/Access/AccessManagerInterface.php index fc2a0e8..bbb1ec9 100644 --- a/core/lib/Drupal/Core/Access/AccessManagerInterface.php +++ b/core/lib/Drupal/Core/Access/AccessManagerInterface.php @@ -33,7 +33,7 @@ * returned, i.e. TRUE means access is explicitly allowed, FALSE means * access is either explicitly forbidden or "no opinion". */ - public function checkNamedRoute($route_name, array $parameters = array(), AccountInterface $account = NULL, $return_as_object = FALSE); + public function checkNamedRoute($route_name, array $parameters = [], AccountInterface $account = NULL, $return_as_object = FALSE); /** * Execute access checks against the incoming request. diff --git a/core/lib/Drupal/Core/Access/AccessResult.php b/core/lib/Drupal/Core/Access/AccessResult.php index f67b9f5..24e0a20 100644 --- a/core/lib/Drupal/Core/Access/AccessResult.php +++ b/core/lib/Drupal/Core/Access/AccessResult.php @@ -237,7 +237,7 @@ public function setCacheMaxAge($max_age) { * @return $this */ public function cachePerPermissions() { - $this->addCacheContexts(array('user.permissions')); + $this->addCacheContexts(['user.permissions']); return $this; } @@ -247,7 +247,7 @@ public function cachePerPermissions() { * @return $this */ public function cachePerUser() { - $this->addCacheContexts(array('user')); + $this->addCacheContexts(['user']); return $this; } diff --git a/core/lib/Drupal/Core/Access/CheckProvider.php b/core/lib/Drupal/Core/Access/CheckProvider.php index c68cf38..d6ba1cf 100644 --- a/core/lib/Drupal/Core/Access/CheckProvider.php +++ b/core/lib/Drupal/Core/Access/CheckProvider.php @@ -20,7 +20,7 @@ class CheckProvider implements CheckProviderInterface, ContainerAwareInterface { * * @var array */ - protected $checkIds = array(); + protected $checkIds = []; /** * Array of access check objects keyed by service id. @@ -34,12 +34,12 @@ class CheckProvider implements CheckProviderInterface, ContainerAwareInterface { * * @var array */ - protected $checkMethods = array(); + protected $checkMethods = []; /** * Array of access checks which only will be run on the incoming request. */ - protected $checksNeedsRequest = array(); + protected $checksNeedsRequest = []; /** * An array to map static requirement keys to service IDs. @@ -58,7 +58,7 @@ class CheckProvider implements CheckProviderInterface, ContainerAwareInterface { /** * {@inheritdoc} */ - public function addCheckService($service_id, $service_method, array $applies_checks = array(), $needs_incoming_request = FALSE) { + public function addCheckService($service_id, $service_method, array $applies_checks = [], $needs_incoming_request = FALSE) { $this->checkIds[] = $service_id; $this->checkMethods[$service_id] = $service_method; if ($needs_incoming_request) { @@ -102,7 +102,7 @@ public function loadCheck($service_id) { if (!($check instanceof AccessInterface)) { throw new AccessException('All access checks must implement AccessInterface.'); } - if (!is_callable(array($check, $this->checkMethods[$service_id]))) { + if (!is_callable([$check, $this->checkMethods[$service_id]])) { throw new AccessException(sprintf('Access check method %s in service %s must be callable.', $this->checkMethods[$service_id], $service_id)); } @@ -122,7 +122,7 @@ public function loadCheck($service_id) { * route. */ protected function applies(Route $route) { - $checks = array(); + $checks = []; // Iterate through map requirements from appliesTo() on access checkers. // Only iterate through all checkIds if this is not used. @@ -151,7 +151,7 @@ protected function loadDynamicRequirementMap() { } // Set them here, so we can use the isset() check above. - $this->dynamicRequirementMap = array(); + $this->dynamicRequirementMap = []; foreach ($this->checkIds as $service_id) { if (empty($this->checks[$service_id])) { diff --git a/core/lib/Drupal/Core/Access/CheckProviderInterface.php b/core/lib/Drupal/Core/Access/CheckProviderInterface.php index bb0dd4a..a94a92c 100644 --- a/core/lib/Drupal/Core/Access/CheckProviderInterface.php +++ b/core/lib/Drupal/Core/Access/CheckProviderInterface.php @@ -37,7 +37,7 @@ public function setChecks(RouteCollection $routes); * @param bool $needs_incoming_request * (optional) True if access-check method only acts on an incoming request. */ - public function addCheckService($service_id, $service_method, array $applies_checks = array(), $needs_incoming_request = FALSE); + public function addCheckService($service_id, $service_method, array $applies_checks = [], $needs_incoming_request = FALSE); /** * Lazy-loads access check services. diff --git a/core/lib/Drupal/Core/Access/CsrfRequestHeaderAccessCheck.php b/core/lib/Drupal/Core/Access/CsrfRequestHeaderAccessCheck.php index 53f326d..c12192d 100644 --- a/core/lib/Drupal/Core/Access/CsrfRequestHeaderAccessCheck.php +++ b/core/lib/Drupal/Core/Access/CsrfRequestHeaderAccessCheck.php @@ -64,7 +64,7 @@ public function applies(Route $route) { $methods = explode('|', $requirements['_method']); // CSRF protection only applies to write operations, so we can filter // out any routes that require reading methods only. - $write_methods = array_diff($methods, array('GET', 'HEAD', 'OPTIONS', 'TRACE')); + $write_methods = array_diff($methods, ['GET', 'HEAD', 'OPTIONS', 'TRACE']); if (empty($write_methods)) { return FALSE; } @@ -93,7 +93,7 @@ public function access(Request $request, AccountInterface $account) { // 1. this is a write operation // 2. the user was successfully authenticated and // 3. the request comes with a session cookie. - if (!in_array($method, array('GET', 'HEAD', 'OPTIONS', 'TRACE')) + if (!in_array($method, ['GET', 'HEAD', 'OPTIONS', 'TRACE']) && $account->isAuthenticated() && $this->sessionConfiguration->hasSession($request) ) { diff --git a/core/lib/Drupal/Core/Action/ConfigurableActionBase.php b/core/lib/Drupal/Core/Action/ConfigurableActionBase.php index 6c19540..cde7d56 100644 --- a/core/lib/Drupal/Core/Action/ConfigurableActionBase.php +++ b/core/lib/Drupal/Core/Action/ConfigurableActionBase.php @@ -24,7 +24,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition * {@inheritdoc} */ public function defaultConfiguration() { - return array(); + return []; } /** @@ -51,7 +51,7 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form * {@inheritdoc} */ public function calculateDependencies() { - return array(); + return []; } } diff --git a/core/lib/Drupal/Core/Ajax/AddCssCommand.php b/core/lib/Drupal/Core/Ajax/AddCssCommand.php index fbb5ce4..80ee17a 100644 --- a/core/lib/Drupal/Core/Ajax/AddCssCommand.php +++ b/core/lib/Drupal/Core/Ajax/AddCssCommand.php @@ -39,10 +39,10 @@ public function __construct($styles) { */ public function render() { - return array( + return [ 'command' => 'add_css', 'data' => $this->styles, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/AfterCommand.php b/core/lib/Drupal/Core/Ajax/AfterCommand.php index 05060a6..41e232d 100644 --- a/core/lib/Drupal/Core/Ajax/AfterCommand.php +++ b/core/lib/Drupal/Core/Ajax/AfterCommand.php @@ -23,13 +23,13 @@ class AfterCommand extends InsertCommand { */ public function render() { - return array( + return [ 'command' => 'insert', 'method' => 'after', 'selector' => $this->selector, 'data' => $this->getRenderedContent(), 'settings' => $this->settings, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponse.php b/core/lib/Drupal/Core/Ajax/AjaxResponse.php index 4b12578..4d1c123 100644 --- a/core/lib/Drupal/Core/Ajax/AjaxResponse.php +++ b/core/lib/Drupal/Core/Ajax/AjaxResponse.php @@ -21,7 +21,7 @@ class AjaxResponse extends JsonResponse implements AttachmentsInterface { * * @var array */ - protected $commands = array(); + protected $commands = []; /** * Add an AJAX command to the response. diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php index 45aa45e..ee5208b 100644 --- a/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php @@ -167,7 +167,7 @@ protected function buildAttachmentsCommands(AjaxResponse $response, Request $req } // Prepend commands to add the assets, preserving their relative order. - $resource_commands = array(); + $resource_commands = []; if ($css_assets) { $css_render_array = $this->cssCollectionRenderer->render($css_assets); $resource_commands[] = new AddCssCommand($this->renderer->renderPlain($css_render_array)); diff --git a/core/lib/Drupal/Core/Ajax/AlertCommand.php b/core/lib/Drupal/Core/Ajax/AlertCommand.php index 46388d0..360036f 100644 --- a/core/lib/Drupal/Core/Ajax/AlertCommand.php +++ b/core/lib/Drupal/Core/Ajax/AlertCommand.php @@ -31,10 +31,10 @@ public function __construct($text) { */ public function render() { - return array( + return [ 'command' => 'alert', 'text' => $this->text, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/AppendCommand.php b/core/lib/Drupal/Core/Ajax/AppendCommand.php index e183091..34c751d 100644 --- a/core/lib/Drupal/Core/Ajax/AppendCommand.php +++ b/core/lib/Drupal/Core/Ajax/AppendCommand.php @@ -23,13 +23,13 @@ class AppendCommand extends InsertCommand { */ public function render() { - return array( + return [ 'command' => 'insert', 'method' => 'append', 'selector' => $this->selector, 'data' => $this->getRenderedContent(), 'settings' => $this->settings, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/BaseCommand.php b/core/lib/Drupal/Core/Ajax/BaseCommand.php index f150657..eeb36cf 100644 --- a/core/lib/Drupal/Core/Ajax/BaseCommand.php +++ b/core/lib/Drupal/Core/Ajax/BaseCommand.php @@ -38,10 +38,10 @@ public function __construct($command, $data) { * {@inheritdoc} */ public function render() { - return array( + return [ 'command' => $this->command, 'data' => $this->data, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/BeforeCommand.php b/core/lib/Drupal/Core/Ajax/BeforeCommand.php index 04290e0..8de47c8 100644 --- a/core/lib/Drupal/Core/Ajax/BeforeCommand.php +++ b/core/lib/Drupal/Core/Ajax/BeforeCommand.php @@ -23,13 +23,13 @@ class BeforeCommand extends InsertCommand { */ public function render() { - return array( + return [ 'command' => 'insert', 'method' => 'before', 'selector' => $this->selector, 'data' => $this->getRenderedContent(), 'settings' => $this->settings, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/ChangedCommand.php b/core/lib/Drupal/Core/Ajax/ChangedCommand.php index b128cfc..0027d7c 100644 --- a/core/lib/Drupal/Core/Ajax/ChangedCommand.php +++ b/core/lib/Drupal/Core/Ajax/ChangedCommand.php @@ -50,11 +50,11 @@ public function __construct($selector, $asterisk = '') { */ public function render() { - return array( + return [ 'command' => 'changed', 'selector' => $this->selector, 'asterisk' => $this->asterisk, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/CloseDialogCommand.php b/core/lib/Drupal/Core/Ajax/CloseDialogCommand.php index fa58208..1feeb0c 100644 --- a/core/lib/Drupal/Core/Ajax/CloseDialogCommand.php +++ b/core/lib/Drupal/Core/Ajax/CloseDialogCommand.php @@ -40,11 +40,11 @@ public function __construct($selector = NULL, $persist = FALSE) { * {@inheritdoc} */ public function render() { - return array( + return [ 'command' => 'closeDialog', 'selector' => $this->selector, 'persist' => $this->persist, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/CssCommand.php b/core/lib/Drupal/Core/Ajax/CssCommand.php index b12cc09..016c813 100644 --- a/core/lib/Drupal/Core/Ajax/CssCommand.php +++ b/core/lib/Drupal/Core/Ajax/CssCommand.php @@ -32,7 +32,7 @@ class CssCommand implements CommandInterface { * * @var array */ - protected $css = array(); + protected $css = []; /** * Constructs a CssCommand object. @@ -42,7 +42,7 @@ class CssCommand implements CommandInterface { * @param array $css * An array of CSS property/value pairs to set. */ - public function __construct($selector, array $css = array()) { + public function __construct($selector, array $css = []) { $this->selector = $selector; $this->css = $css; } @@ -67,11 +67,11 @@ public function setProperty($property, $value) { */ public function render() { - return array( + return [ 'command' => 'css', 'selector' => $this->selector, 'argument' => $this->css, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/DataCommand.php b/core/lib/Drupal/Core/Ajax/DataCommand.php index 92b87bd..a1bee21 100644 --- a/core/lib/Drupal/Core/Ajax/DataCommand.php +++ b/core/lib/Drupal/Core/Ajax/DataCommand.php @@ -62,12 +62,12 @@ public function __construct($selector, $name, $value) { */ public function render() { - return array( + return [ 'command' => 'data', 'selector' => $this->selector, 'name' => $this->name, 'value' => $this->value, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/HtmlCommand.php b/core/lib/Drupal/Core/Ajax/HtmlCommand.php index 39635c3..e39f08f 100644 --- a/core/lib/Drupal/Core/Ajax/HtmlCommand.php +++ b/core/lib/Drupal/Core/Ajax/HtmlCommand.php @@ -23,13 +23,13 @@ class HtmlCommand extends InsertCommand { */ public function render() { - return array( + return [ 'command' => 'insert', 'method' => 'html', 'selector' => $this->selector, 'data' => $this->getRenderedContent(), 'settings' => $this->settings, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/InsertCommand.php b/core/lib/Drupal/Core/Ajax/InsertCommand.php index 00cb616..1813e50 100644 --- a/core/lib/Drupal/Core/Ajax/InsertCommand.php +++ b/core/lib/Drupal/Core/Ajax/InsertCommand.php @@ -66,13 +66,13 @@ public function __construct($selector, $content, array $settings = NULL) { */ public function render() { - return array( + return [ 'command' => 'insert', 'method' => NULL, 'selector' => $this->selector, 'data' => $this->getRenderedContent(), 'settings' => $this->settings, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/InvokeCommand.php b/core/lib/Drupal/Core/Ajax/InvokeCommand.php index 4195888..46e37ff 100644 --- a/core/lib/Drupal/Core/Ajax/InvokeCommand.php +++ b/core/lib/Drupal/Core/Ajax/InvokeCommand.php @@ -51,7 +51,7 @@ class InvokeCommand implements CommandInterface { * @param array $arguments * An optional array of arguments to pass to the method. */ - public function __construct($selector, $method, array $arguments = array()) { + public function __construct($selector, $method, array $arguments = []) { $this->selector = $selector; $this->method = $method; $this->arguments = $arguments; @@ -62,12 +62,12 @@ public function __construct($selector, $method, array $arguments = array()) { */ public function render() { - return array( + return [ 'command' => 'invoke', 'selector' => $this->selector, 'method' => $this->method, 'args' => $this->arguments, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php b/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php index 5c5be4c..b9dacaf 100644 --- a/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php +++ b/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php @@ -68,8 +68,8 @@ class OpenDialogCommand implements CommandInterface, CommandWithAttachedAssetsIn * on the content of the dialog. If left empty, the settings will be * populated automatically from the current request. */ - public function __construct($selector, $title, $content, array $dialog_options = array(), $settings = NULL) { - $dialog_options += array('title' => $title); + public function __construct($selector, $title, $content, array $dialog_options = [], $settings = NULL) { + $dialog_options += ['title' => $title]; $this->selector = $selector; $this->content = $content; $this->dialogOptions = $dialog_options; @@ -125,13 +125,13 @@ public function setDialogTitle($title) { public function render() { // For consistency ensure the modal option is set to TRUE or FALSE. $this->dialogOptions['modal'] = isset($this->dialogOptions['modal']) && $this->dialogOptions['modal']; - return array( + return [ 'command' => 'openDialog', 'selector' => $this->selector, 'settings' => $this->settings, 'data' => $this->getRenderedContent(), 'dialogOptions' => $this->dialogOptions, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/OpenModalDialogCommand.php b/core/lib/Drupal/Core/Ajax/OpenModalDialogCommand.php index edb4fe3..53d6e82 100644 --- a/core/lib/Drupal/Core/Ajax/OpenModalDialogCommand.php +++ b/core/lib/Drupal/Core/Ajax/OpenModalDialogCommand.php @@ -29,7 +29,7 @@ class OpenModalDialogCommand extends OpenDialogCommand { * on the content of the dialog. If left empty, the settings will be * populated automatically from the current request. */ - public function __construct($title, $content, array $dialog_options = array(), $settings = NULL) { + public function __construct($title, $content, array $dialog_options = [], $settings = NULL) { $dialog_options['modal'] = TRUE; parent::__construct('#drupal-modal', $title, $content, $dialog_options, $settings); } diff --git a/core/lib/Drupal/Core/Ajax/PrependCommand.php b/core/lib/Drupal/Core/Ajax/PrependCommand.php index 5e41bae..e3902b8 100644 --- a/core/lib/Drupal/Core/Ajax/PrependCommand.php +++ b/core/lib/Drupal/Core/Ajax/PrependCommand.php @@ -23,13 +23,13 @@ class PrependCommand extends InsertCommand { */ public function render() { - return array( + return [ 'command' => 'insert', 'method' => 'prepend', 'selector' => $this->selector, 'data' => $this->getRenderedContent(), 'settings' => $this->settings, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/RedirectCommand.php b/core/lib/Drupal/Core/Ajax/RedirectCommand.php index 7dbf26e..572c62f 100644 --- a/core/lib/Drupal/Core/Ajax/RedirectCommand.php +++ b/core/lib/Drupal/Core/Ajax/RedirectCommand.php @@ -31,10 +31,10 @@ public function __construct($url) { * Implements \Drupal\Core\Ajax\CommandInterface:render(). */ public function render() { - return array( + return [ 'command' => 'redirect', 'url' => $this->url, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/RemoveCommand.php b/core/lib/Drupal/Core/Ajax/RemoveCommand.php index c52211d..d7f86dd 100644 --- a/core/lib/Drupal/Core/Ajax/RemoveCommand.php +++ b/core/lib/Drupal/Core/Ajax/RemoveCommand.php @@ -38,10 +38,10 @@ public function __construct($selector) { * Implements Drupal\Core\Ajax\CommandInterface:render(). */ public function render() { - return array( + return [ 'command' => 'remove', 'selector' => $this->selector, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/ReplaceCommand.php b/core/lib/Drupal/Core/Ajax/ReplaceCommand.php index 8ccb7c1..25927b7 100644 --- a/core/lib/Drupal/Core/Ajax/ReplaceCommand.php +++ b/core/lib/Drupal/Core/Ajax/ReplaceCommand.php @@ -24,13 +24,13 @@ class ReplaceCommand extends InsertCommand { */ public function render() { - return array( + return [ 'command' => 'insert', 'method' => 'replaceWith', 'selector' => $this->selector, 'data' => $this->getRenderedContent(), 'settings' => $this->settings, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/RestripeCommand.php b/core/lib/Drupal/Core/Ajax/RestripeCommand.php index 331e1bf..33b7e25 100644 --- a/core/lib/Drupal/Core/Ajax/RestripeCommand.php +++ b/core/lib/Drupal/Core/Ajax/RestripeCommand.php @@ -40,10 +40,10 @@ public function __construct($selector) { */ public function render() { - return array( + return [ 'command' => 'restripe', 'selector' => $this->selector, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/SetDialogOptionCommand.php b/core/lib/Drupal/Core/Ajax/SetDialogOptionCommand.php index 9e7836b..f24f97c 100644 --- a/core/lib/Drupal/Core/Ajax/SetDialogOptionCommand.php +++ b/core/lib/Drupal/Core/Ajax/SetDialogOptionCommand.php @@ -52,12 +52,12 @@ public function __construct($selector, $option_name, $option_value) { * {@inheritdoc} */ public function render() { - return array( + return [ 'command' => 'setDialogOption', 'selector' => $this->selector, 'optionName' => $this->optionName, 'optionValue' => $this->optionValue, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Ajax/SettingsCommand.php b/core/lib/Drupal/Core/Ajax/SettingsCommand.php index 154ab9c..ca41720 100644 --- a/core/lib/Drupal/Core/Ajax/SettingsCommand.php +++ b/core/lib/Drupal/Core/Ajax/SettingsCommand.php @@ -54,11 +54,11 @@ public function __construct(array $settings, $merge = FALSE) { */ public function render() { - return array( + return [ 'command' => 'settings', 'settings' => $this->settings, 'merge' => $this->merge, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Annotation/ContextDefinition.php b/core/lib/Drupal/Core/Annotation/ContextDefinition.php index abe14e5..0ff61e6 100644 --- a/core/lib/Drupal/Core/Annotation/ContextDefinition.php +++ b/core/lib/Drupal/Core/Annotation/ContextDefinition.php @@ -99,11 +99,11 @@ class ContextDefinition extends Plugin { * ContextDefinitionInterface implementing class. */ public function __construct(array $values) { - $values += array( + $values += [ 'required' => TRUE, 'multiple' => FALSE, 'default_value' => NULL, - ); + ]; // Annotation classes extract data from passed annotation classes directly // used in the classes they pass to. foreach (['label', 'description'] as $key) { diff --git a/core/lib/Drupal/Core/Annotation/Translation.php b/core/lib/Drupal/Core/Annotation/Translation.php index 4fcfb9e..90fe5e0 100644 --- a/core/lib/Drupal/Core/Annotation/Translation.php +++ b/core/lib/Drupal/Core/Annotation/Translation.php @@ -74,12 +74,12 @@ class Translation extends AnnotationBase { */ public function __construct(array $values) { $string = $values['value']; - $arguments = isset($values['arguments']) ? $values['arguments'] : array(); - $options = array(); + $arguments = isset($values['arguments']) ? $values['arguments'] : []; + $options = []; if (!empty($values['context'])) { - $options = array( + $options = [ 'context' => $values['context'], - ); + ]; } $this->translation = new TranslatableMarkup($string, $arguments, $options); } diff --git a/core/lib/Drupal/Core/Archiver/ArchiverInterface.php b/core/lib/Drupal/Core/Archiver/ArchiverInterface.php index 38c62cb..2e63536 100644 --- a/core/lib/Drupal/Core/Archiver/ArchiverInterface.php +++ b/core/lib/Drupal/Core/Archiver/ArchiverInterface.php @@ -47,7 +47,7 @@ public function remove($path); * @return \Drupal\Core\Archiver\ArchiverInterface * The called object. */ - public function extract($path, array $files = array()); + public function extract($path, array $files = []); /** * Lists all files in the archive. diff --git a/core/lib/Drupal/Core/Archiver/ArchiverManager.php b/core/lib/Drupal/Core/Archiver/ArchiverManager.php index ee2dad5..7cd11f9 100644 --- a/core/lib/Drupal/Core/Archiver/ArchiverManager.php +++ b/core/lib/Drupal/Core/Archiver/ArchiverManager.php @@ -36,7 +36,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac /** * {@inheritdoc} */ - public function createInstance($plugin_id, array $configuration = array()) { + public function createInstance($plugin_id, array $configuration = []) { $plugin_definition = $this->getDefinition($plugin_id); $plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition, 'Drupal\Core\Archiver\ArchiverInterface'); return new $plugin_class($configuration['filepath']); diff --git a/core/lib/Drupal/Core/Archiver/Tar.php b/core/lib/Drupal/Core/Archiver/Tar.php index 33f4de6..3b33ddd 100644 --- a/core/lib/Drupal/Core/Archiver/Tar.php +++ b/core/lib/Drupal/Core/Archiver/Tar.php @@ -52,7 +52,7 @@ public function remove($file_path) { /** * {@inheritdoc} */ - public function extract($path, array $files = array()) { + public function extract($path, array $files = []) { if ($files) { $this->tar->extractList($files, $path); } @@ -67,7 +67,7 @@ public function extract($path, array $files = array()) { * {@inheritdoc} */ public function listContents() { - $files = array(); + $files = []; foreach ($this->tar->listContent() as $file_data) { $files[] = $file_data['filename']; } diff --git a/core/lib/Drupal/Core/Archiver/Zip.php b/core/lib/Drupal/Core/Archiver/Zip.php index 640bcde..fd769c1 100644 --- a/core/lib/Drupal/Core/Archiver/Zip.php +++ b/core/lib/Drupal/Core/Archiver/Zip.php @@ -29,7 +29,7 @@ class Zip implements ArchiverInterface { public function __construct($file_path) { $this->zip = new \ZipArchive(); if ($this->zip->open($file_path) !== TRUE) { - throw new ArchiverException(t('Cannot open %file_path', array('%file_path' => $file_path))); + throw new ArchiverException(t('Cannot open %file_path', ['%file_path' => $file_path])); } } @@ -54,7 +54,7 @@ public function remove($file_path) { /** * {@inheritdoc} */ - public function extract($path, array $files = array()) { + public function extract($path, array $files = []) { if ($files) { $this->zip->extractTo($path, $files); } @@ -69,7 +69,7 @@ public function extract($path, array $files = array()) { * {@inheritdoc} */ public function listContents() { - $files = array(); + $files = []; for ($i = 0; $i < $this->zip->numFiles; $i++) { $files[] = $this->zip->getNameIndex($i); } diff --git a/core/lib/Drupal/Core/Asset/CssCollectionGrouper.php b/core/lib/Drupal/Core/Asset/CssCollectionGrouper.php index 2c4122d..4dedfa6 100644 --- a/core/lib/Drupal/Core/Asset/CssCollectionGrouper.php +++ b/core/lib/Drupal/Core/Asset/CssCollectionGrouper.php @@ -20,7 +20,7 @@ class CssCollectionGrouper implements AssetCollectionGrouperInterface { * type, media, and browsers, if needed to accommodate other items in between. */ public function group(array $css_assets) { - $groups = array(); + $groups = []; // If a group can contain multiple items, we track the information that must // be the same for each item in the group, so that when we iterate the next // item, we can determine if it can be put into the current group, or if a @@ -52,7 +52,7 @@ public function group(array $css_assets) { // Group file items if their 'preprocess' flag is TRUE. // Help ensure maximum reuse of aggregate files by only grouping // together items that share the same 'group' value. - $group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['media'], $item['browsers']) : FALSE; + $group_keys = $item['preprocess'] ? [$item['type'], $item['group'], $item['media'], $item['browsers']] : FALSE; break; case 'external': @@ -71,7 +71,7 @@ public function group(array $css_assets) { // the group. $groups[$i] = $item; unset($groups[$i]['data'], $groups[$i]['weight'], $groups[$i]['basename']); - $groups[$i]['items'] = array(); + $groups[$i]['items'] = []; $current_group_keys = $group_keys ? $group_keys : NULL; } diff --git a/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php b/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php index 9beddd1..b9b3933 100644 --- a/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php +++ b/core/lib/Drupal/Core/Asset/CssCollectionOptimizer.php @@ -80,8 +80,8 @@ public function optimize(array $css_assets) { // Drupal contrib can override this default CSS aggregator to keep the same // grouping, optimizing and dumping, but change the strategy that is used to // determine when the aggregate should be rebuilt (e.g. mtime, HTTPS …). - $map = $this->state->get('drupal_css_cache_files') ?: array(); - $css_assets = array(); + $map = $this->state->get('drupal_css_cache_files') ?: []; + $css_assets = []; foreach ($css_groups as $order => $css_group) { // We have to return a single asset, not a group of assets. It is now up // to one of the pieces of code in the switch statement below to set the @@ -155,7 +155,7 @@ public function optimize(array $css_assets) { * A hash to uniquely identify the given group of CSS assets. */ protected function generateHash(array $css_group) { - $css_data = array(); + $css_data = []; foreach ($css_group['items'] as $css_file) { $css_data[] = $css_file['data']; } @@ -181,7 +181,7 @@ public function deleteAll() { file_unmanaged_delete($uri); } }; - file_scan_directory('public://css', '/.*/', array('callback' => $delete_stale)); + file_scan_directory('public://css', '/.*/', ['callback' => $delete_stale]); } } diff --git a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php index 869abe3..95ea3ad 100644 --- a/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php +++ b/core/lib/Drupal/Core/Asset/CssCollectionRenderer.php @@ -74,7 +74,7 @@ public function __construct(StateInterface $state) { * {@inheritdoc} */ public function render(array $css_assets) { - $elements = array(); + $elements = []; // A dummy query-string is added to filenames, to gain control over // browser-caching. The string changes on every update or full cache @@ -83,22 +83,22 @@ public function render(array $css_assets) { $query_string = $this->state->get('system.css_js_query_string') ?: '0'; // Defaults for LINK and STYLE elements. - $link_element_defaults = array( + $link_element_defaults = [ '#type' => 'html_tag', '#tag' => 'link', - '#attributes' => array( + '#attributes' => [ 'rel' => 'stylesheet', - ), - ); - $style_element_defaults = array( + ], + ]; + $style_element_defaults = [ '#type' => 'html_tag', '#tag' => 'style', - ); + ]; // For filthy IE hack. $current_ie_group_keys = NULL; $get_ie_group_key = function ($css_asset) { - return array($css_asset['type'], $css_asset['preprocess'], $css_asset['group'], $css_asset['media'], $css_asset['browsers']); + return [$css_asset['type'], $css_asset['preprocess'], $css_asset['group'], $css_asset['media'], $css_asset['browsers']]; }; // Loop through all CSS assets, by key, to allow for the special IE @@ -151,7 +151,7 @@ public function render(array $css_assets) { // The file CSS asset can be aggregated, but hasn't been: combine // multiple items into as few STYLE tags as possible. else { - $import = array(); + $import = []; // Start with the current CSS asset, iterate over subsequent CSS // assets and find which ones have the same 'type', 'group', // 'preprocess', 'media' and 'browsers' properties. diff --git a/core/lib/Drupal/Core/Asset/CssOptimizer.php b/core/lib/Drupal/Core/Asset/CssOptimizer.php index 87575e0..74a9ead 100644 --- a/core/lib/Drupal/Core/Asset/CssOptimizer.php +++ b/core/lib/Drupal/Core/Asset/CssOptimizer.php @@ -61,7 +61,7 @@ protected function processFile($css_asset) { $this->rewriteFileURIBasePath = $css_base_path . '/'; // Anchor all paths in the CSS with its base URL, ignoring external and absolute paths. - return preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', array($this, 'rewriteFileURI'), $contents); + return preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', [$this, 'rewriteFileURI'], $contents); } /** @@ -228,7 +228,7 @@ protected function processCss($contents, $optimize = FALSE) { // Replaces @import commands with the actual stylesheet content. // This happens recursively but omits external files. - $contents = preg_replace_callback('/@import\s*(?:url\(\s*)?[\'"]?(?![a-z]+:)(?!\/\/)([^\'"\()]+)[\'"]?\s*\)?\s*;/', array($this, 'loadNestedFile'), $contents); + $contents = preg_replace_callback('/@import\s*(?:url\(\s*)?[\'"]?(?![a-z]+:)(?!\/\/)([^\'"\()]+)[\'"]?\s*\)?\s*;/', [$this, 'loadNestedFile'], $contents); return $contents; } diff --git a/core/lib/Drupal/Core/Asset/JsCollectionGrouper.php b/core/lib/Drupal/Core/Asset/JsCollectionGrouper.php index 710e3c0..9d29c40 100644 --- a/core/lib/Drupal/Core/Asset/JsCollectionGrouper.php +++ b/core/lib/Drupal/Core/Asset/JsCollectionGrouper.php @@ -19,7 +19,7 @@ class JsCollectionGrouper implements AssetCollectionGrouperInterface { * type and browsers, if needed to accommodate other items in between. */ public function group(array $js_assets) { - $groups = array(); + $groups = []; // If a group can contain multiple items, we track the information that must // be the same for each item in the group, so that when we iterate the next // item, we can determine if it can be put into the current group, or if a @@ -38,7 +38,7 @@ public function group(array $js_assets) { // Group file items if their 'preprocess' flag is TRUE. // Help ensure maximum reuse of aggregate files by only grouping // together items that share the same 'group' value. - $group_keys = $item['preprocess'] ? array($item['type'], $item['group'], $item['browsers']) : FALSE; + $group_keys = $item['preprocess'] ? [$item['type'], $item['group'], $item['browsers']] : FALSE; break; case 'external': @@ -56,7 +56,7 @@ public function group(array $js_assets) { // unique to the item and should not be carried over to the group. $groups[$index] = $item; unset($groups[$index]['data'], $groups[$index]['weight']); - $groups[$index]['items'] = array(); + $groups[$index]['items'] = []; $current_group_keys = $group_keys ? $group_keys : NULL; } diff --git a/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php b/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php index aef10bf..d08a48a 100644 --- a/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php +++ b/core/lib/Drupal/Core/Asset/JsCollectionOptimizer.php @@ -81,8 +81,8 @@ public function optimize(array $js_assets) { // Drupal contrib can override this default JS aggregator to keep the same // grouping, optimizing and dumping, but change the strategy that is used to // determine when the aggregate should be rebuilt (e.g. mtime, HTTPS …). - $map = $this->state->get('system.js_cache_files') ?: array(); - $js_assets = array(); + $map = $this->state->get('system.js_cache_files') ?: []; + $js_assets = []; foreach ($js_groups as $order => $js_group) { // We have to return a single asset, not a group of assets. It is now up // to one of the pieces of code in the switch statement below to set the @@ -159,7 +159,7 @@ public function optimize(array $js_assets) { * A hash to uniquely identify the given group of JavaScript assets. */ protected function generateHash(array $js_group) { - $js_data = array(); + $js_data = []; foreach ($js_group['items'] as $js_file) { $js_data[] = $js_file['data']; } @@ -184,7 +184,7 @@ public function deleteAll() { file_unmanaged_delete($uri); } }; - file_scan_directory('public://js', '/.*/', array('callback' => $delete_stale)); + file_scan_directory('public://js', '/.*/', ['callback' => $delete_stale]); } } diff --git a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php index c5f0a2b..966e73b 100644 --- a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php +++ b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php @@ -37,7 +37,7 @@ public function __construct(StateInterface $state) { * logic for grouping and aggregating files. */ public function render(array $js_assets) { - $elements = array(); + $elements = []; // A dummy query-string is added to filenames, to gain control over // browser-caching. The string changes on every update or full cache @@ -47,11 +47,11 @@ public function render(array $js_assets) { $default_query_string = $this->state->get('system.css_js_query_string') ?: '0'; // Defaults for each SCRIPT element. - $element_defaults = array( + $element_defaults = [ '#type' => 'html_tag', '#tag' => 'script', '#value' => '', - ); + ]; // Loop through all JS assets. foreach ($js_assets as $js_asset) { @@ -62,12 +62,12 @@ public function render(array $js_assets) { // Element properties that depend on item type. switch ($js_asset['type']) { case 'setting': - $element['#attributes'] = array( + $element['#attributes'] = [ // This type attribute prevents this from being parsed as an // inline script. 'type' => 'application/json', 'data-drupal-selector' => 'drupal-settings-json', - ); + ]; $element['#value'] = Json::encode($js_asset['data']); break; diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php index 799ee07..b4c716d 100644 --- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php +++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php @@ -69,7 +69,7 @@ public function __construct($root, ModuleHandlerInterface $module_handler, Theme * Thrown when a js file defines a positive weight. */ public function buildByExtension($extension) { - $libraries = array(); + $libraries = []; if ($extension === 'core') { $path = 'core'; @@ -92,7 +92,7 @@ public function buildByExtension($extension) { if (!isset($library['js']) && !isset($library['css']) && !isset($library['drupalSettings'])) { throw new IncompleteLibraryDefinitionException(sprintf("Incomplete library definition for definition '%s' in extension '%s'", $id, $extension)); } - $library += array('dependencies' => array(), 'js' => array(), 'css' => array()); + $library += ['dependencies' => [], 'js' => [], 'css' => []]; if (isset($library['header']) && !is_bool($library['header'])) { throw new \LogicException(sprintf("The 'header' key in the library definition '%s' in extension '%s' is invalid: it must be a boolean.", $id, $extension)); @@ -116,14 +116,14 @@ public function buildByExtension($extension) { // Assign Drupal's license to libraries that don't have license info. if (!isset($library['license'])) { - $library['license'] = array( + $library['license'] = [ 'name' => 'GNU-GPL-2.0-or-later', 'url' => 'https://www.drupal.org/licensing/faq', 'gpl-compatible' => TRUE, - ); + ]; } - foreach (array('js', 'css') as $type) { + foreach (['js', 'css'] as $type) { // Prepare (flatten) the SMACSS-categorized definitions. // @todo After Asset(ic) changes, retain the definitions as-is and // properly resolve dependencies for all (css) libraries per category, @@ -145,7 +145,7 @@ public function buildByExtension($extension) { unset($library[$type][$source]); // Allow to omit the options hashmap in YAML declarations. if (!is_array($options)) { - $options = array(); + $options = []; } if ($type == 'js' && isset($options['weight']) && $options['weight'] > 0) { throw new \UnexpectedValueException("The $extension/$id library defines a positive weight for '$source'. Only negative weights are allowed (but should be avoided). Instead of a positive weight, specify accurate dependencies for this library."); diff --git a/core/lib/Drupal/Core/Batch/BatchStorage.php b/core/lib/Drupal/Core/Batch/BatchStorage.php index 789703c..82f5b65 100644 --- a/core/lib/Drupal/Core/Batch/BatchStorage.php +++ b/core/lib/Drupal/Core/Batch/BatchStorage.php @@ -58,10 +58,10 @@ public function load($id) { // Ensure that a session is started before using the CSRF token generator. $this->session->start(); try { - $batch = $this->connection->query("SELECT batch FROM {batch} WHERE bid = :bid AND token = :token", array( + $batch = $this->connection->query("SELECT batch FROM {batch} WHERE bid = :bid AND token = :token", [ ':bid' => $id, ':token' => $this->csrfToken->get($id), - ))->fetchField(); + ])->fetchField(); } catch (\Exception $e) { $this->catchException($e); @@ -93,7 +93,7 @@ public function delete($id) { public function update(array $batch) { try { $this->connection->update('batch') - ->fields(array('batch' => serialize($batch))) + ->fields(['batch' => serialize($batch)]) ->condition('bid', $batch['id']) ->execute(); } @@ -150,12 +150,12 @@ public function create(array $batch) { */ protected function doCreate(array $batch) { $this->connection->insert('batch') - ->fields(array( + ->fields([ 'bid' => $batch['id'], 'timestamp' => REQUEST_TIME, 'token' => $this->csrfToken->get($batch['id']), 'batch' => serialize($batch), - )) + ]) ->execute(); } diff --git a/core/lib/Drupal/Core/Block/BlockBase.php b/core/lib/Drupal/Core/Block/BlockBase.php index bcc3954..84c11c5 100644 --- a/core/lib/Drupal/Core/Block/BlockBase.php +++ b/core/lib/Drupal/Core/Block/BlockBase.php @@ -81,19 +81,19 @@ public function setConfiguration(array $configuration) { * An associative array with the default configuration. */ protected function baseConfigurationDefaults() { - return array( + return [ 'id' => $this->getPluginId(), 'label' => '', 'provider' => $this->pluginDefinition['provider'], 'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE, - ); + ]; } /** * {@inheritdoc} */ public function defaultConfiguration() { - return array(); + return []; } /** @@ -107,7 +107,7 @@ public function setConfigurationValue($key, $value) { * {@inheritdoc} */ public function calculateDependencies() { - return array(); + return []; } /** @@ -150,29 +150,29 @@ protected function blockAccess(AccountInterface $account) { */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { $definition = $this->getPluginDefinition(); - $form['provider'] = array( + $form['provider'] = [ '#type' => 'value', '#value' => $definition['provider'], - ); + ]; - $form['admin_label'] = array( + $form['admin_label'] = [ '#type' => 'item', '#title' => $this->t('Block description'), '#plain_text' => $definition['admin_label'], - ); - $form['label'] = array( + ]; + $form['label'] = [ '#type' => 'textfield', '#title' => $this->t('Title'), '#maxlength' => 255, '#default_value' => $this->label(), '#required' => TRUE, - ); - $form['label_display'] = array( + ]; + $form['label_display'] = [ '#type' => 'checkbox', '#title' => $this->t('Display title'), '#default_value' => ($this->configuration['label_display'] === BlockInterface::BLOCK_LABEL_VISIBLE), '#return_value' => BlockInterface::BLOCK_LABEL_VISIBLE, - ); + ]; // Add context mapping UI form elements. $contexts = $form_state->getTemporaryValue('gathered_contexts') ?: []; @@ -186,7 +186,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Block/BlockManager.php b/core/lib/Drupal/Core/Block/BlockManager.php index 3c88bdc..a837340 100644 --- a/core/lib/Drupal/Core/Block/BlockManager.php +++ b/core/lib/Drupal/Core/Block/BlockManager.php @@ -74,7 +74,7 @@ public function getGroupedDefinitions(array $definitions = NULL) { /** * {@inheritdoc} */ - public function getFallbackPluginId($plugin_id, array $configuration = array()) { + public function getFallbackPluginId($plugin_id, array $configuration = []) { return 'broken'; } diff --git a/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php b/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php index bb651cc..f418a5e 100644 --- a/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php +++ b/core/lib/Drupal/Core/Breadcrumb/BreadcrumbManager.php @@ -29,7 +29,7 @@ class BreadcrumbManager implements ChainBreadcrumbBuilderInterface { * * @var array */ - protected $builders = array(); + protected $builders = []; /** * Holds the array of breadcrumb builders sorted by priority. @@ -71,7 +71,7 @@ public function applies(RouteMatchInterface $route_match) { */ public function build(RouteMatchInterface $route_match) { $breadcrumb = new Breadcrumb(); - $context = array('builder' => NULL); + $context = ['builder' => NULL]; // Call the build method of registered breadcrumb builders, // until one of them returns an array. foreach ($this->getSortedBuilders() as $builder) { @@ -107,7 +107,7 @@ protected function getSortedBuilders() { // Sort the builders according to priority. krsort($this->builders); // Merge nested builders from $this->builders into $this->sortedBuilders. - $this->sortedBuilders = array(); + $this->sortedBuilders = []; foreach ($this->builders as $builders) { $this->sortedBuilders = array_merge($this->sortedBuilders, $builders); } diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php index 5338a74..d7847ff 100644 --- a/core/lib/Drupal/Core/Cache/ApcuBackend.php +++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php @@ -80,13 +80,13 @@ public function get($cid, $allow_invalid = FALSE) { */ public function getMultiple(&$cids, $allow_invalid = FALSE) { // Translate the requested cache item IDs to APCu keys. - $map = array(); + $map = []; foreach ($cids as $cid) { $map[$this->getApcuKey($cid)] = $cid; } $result = apcu_fetch(array_keys($map)); - $cache = array(); + $cache = []; if ($result) { foreach ($result as $key => $item) { $item = $this->prepareItem($item, $allow_invalid); @@ -140,7 +140,7 @@ protected function prepareItem($cache, $allow_invalid) { return FALSE; } - $cache->tags = $cache->tags ? explode(' ', $cache->tags) : array(); + $cache->tags = $cache->tags ? explode(' ', $cache->tags) : []; // Check expire time. $cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME; @@ -160,7 +160,7 @@ protected function prepareItem($cache, $allow_invalid) { /** * {@inheritdoc} */ - public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = array()) { + public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANENT, array $tags = []) { assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.'); $tags = array_unique($tags); $cache = new \stdClass(); @@ -180,9 +180,9 @@ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANEN /** * {@inheritdoc} */ - public function setMultiple(array $items = array()) { + public function setMultiple(array $items = []) { foreach ($items as $cid => $item) { - $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : array()); + $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : []); } } @@ -197,7 +197,7 @@ public function delete($cid) { * {@inheritdoc} */ public function deleteMultiple(array $cids) { - apcu_delete(array_map(array($this, 'getApcuKey'), $cids)); + apcu_delete(array_map([$this, 'getApcuKey'], $cids)); } /** @@ -225,7 +225,7 @@ public function removeBin() { * {@inheritdoc} */ public function invalidate($cid) { - $this->invalidateMultiple(array($cid)); + $this->invalidateMultiple([$cid]); } /** diff --git a/core/lib/Drupal/Core/Cache/BackendChain.php b/core/lib/Drupal/Core/Cache/BackendChain.php index 851978b..a8cef19 100644 --- a/core/lib/Drupal/Core/Cache/BackendChain.php +++ b/core/lib/Drupal/Core/Cache/BackendChain.php @@ -26,7 +26,7 @@ class BackendChain implements CacheBackendInterface, CacheTagsInvalidatorInterfa * * @var array */ - protected $backends = array(); + protected $backends = []; /** * Constructs a DatabaseBackend object. @@ -91,7 +91,7 @@ public function get($cid, $allow_invalid = FALSE) { * {@inheritdoc} */ public function getMultiple(&$cids, $allow_invalid = FALSE) { - $return = array(); + $return = []; foreach ($this->backends as $index => $backend) { $items = $backend->getMultiple($cids, $allow_invalid); @@ -121,7 +121,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) { /** * {@inheritdoc} */ - public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) { + public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) { foreach ($this->backends as $backend) { $backend->set($cid, $data, $expire, $tags); } diff --git a/core/lib/Drupal/Core/Cache/Cache.php b/core/lib/Drupal/Core/Cache/Cache.php index 2d0c220..9b7c2f8 100644 --- a/core/lib/Drupal/Core/Cache/Cache.php +++ b/core/lib/Drupal/Core/Cache/Cache.php @@ -152,7 +152,7 @@ public static function invalidateTags(array $tags) { * An array of cache backend objects keyed by cache bins. */ public static function getBins() { - $bins = array(); + $bins = []; $container = \Drupal::getContainer(); foreach ($container->getParameter('cache_bins') as $service_id => $bin) { $bins[$bin] = $container->get($service_id); @@ -178,7 +178,7 @@ public static function getBins() { */ public static function keyFromQuery(SelectInterface $query) { $query->preExecute(); - $keys = array((string) $query, $query->getArguments()); + $keys = [(string) $query, $query->getArguments()]; return hash('sha256', serialize($keys)); } diff --git a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php index 68c5b5a..a8ce888 100644 --- a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php @@ -96,7 +96,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE); * @see \Drupal\Core\Cache\CacheBackendInterface::get() * @see \Drupal\Core\Cache\CacheBackendInterface::getMultiple() */ - public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()); + public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []); /** * Store multiple items in the persistent cache. diff --git a/core/lib/Drupal/Core/Cache/CacheCollector.php b/core/lib/Drupal/Core/Cache/CacheCollector.php index 2db4608..acbbf00 100644 --- a/core/lib/Drupal/Core/Cache/CacheCollector.php +++ b/core/lib/Drupal/Core/Cache/CacheCollector.php @@ -56,21 +56,21 @@ * * @var array */ - protected $keysToPersist = array(); + protected $keysToPersist = []; /** * An array of keys to remove from the cache on service termination. * * @var array */ - protected $keysToRemove = array(); + protected $keysToRemove = []; /** * Storage for the data itself. * * @var array */ - protected $storage = array(); + protected $storage = []; /** * Stores the cache creation time. @@ -110,7 +110,7 @@ * @param array $tags * (optional) The tags to specify for the cache item. */ - public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, array $tags = array()) { + public function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, array $tags = []) { assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache tags must be strings.'); $this->cid = $cid; $this->cache = $cache; @@ -216,7 +216,7 @@ protected function persist($key, $persist = TRUE) { * TRUE. */ protected function updateCache($lock = TRUE) { - $data = array(); + $data = []; foreach ($this->keysToPersist as $offset => $persist) { if ($persist) { $data[$offset] = $this->storage[$offset]; @@ -256,8 +256,8 @@ protected function updateCache($lock = TRUE) { } } - $this->keysToPersist = array(); - $this->keysToRemove = array(); + $this->keysToPersist = []; + $this->keysToRemove = []; } /** @@ -288,9 +288,9 @@ protected function normalizeLockName($cid) { * {@inheritdoc} */ public function reset() { - $this->storage = array(); - $this->keysToPersist = array(); - $this->keysToRemove = array(); + $this->storage = []; + $this->keysToPersist = []; + $this->keysToRemove = []; $this->cacheLoaded = FALSE; } diff --git a/core/lib/Drupal/Core/Cache/CacheFactory.php b/core/lib/Drupal/Core/Cache/CacheFactory.php index d9b39e4..d029cc1 100644 --- a/core/lib/Drupal/Core/Cache/CacheFactory.php +++ b/core/lib/Drupal/Core/Cache/CacheFactory.php @@ -42,7 +42,7 @@ class CacheFactory implements CacheFactoryInterface, ContainerAwareInterface { * (optional) A mapping of bin to backend service name. Mappings in * $settings take precedence over this. */ - public function __construct(Settings $settings, array $default_bin_backends = array()) { + public function __construct(Settings $settings, array $default_bin_backends = []) { $this->settings = $settings; $this->defaultBinBackends = $default_bin_backends; } diff --git a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php index cfc64f2..ceb8f49 100644 --- a/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php +++ b/core/lib/Drupal/Core/Cache/CacheTagsInvalidator.php @@ -16,7 +16,7 @@ class CacheTagsInvalidator implements CacheTagsInvalidatorInterface { * * @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface[] */ - protected $invalidators = array(); + protected $invalidators = []; /** * {@inheritdoc} @@ -66,7 +66,7 @@ public function addInvalidator(CacheTagsInvalidatorInterface $invalidator) { * interface, keyed by their cache bin. */ protected function getInvalidatorCacheBins() { - $bins = array(); + $bins = []; foreach ($this->container->getParameter('cache_bins') as $service_id => $bin) { $service = $this->container->get($service_id); if ($service instanceof CacheTagsInvalidatorInterface) { diff --git a/core/lib/Drupal/Core/Cache/ChainedFastBackend.php b/core/lib/Drupal/Core/Cache/ChainedFastBackend.php index 5c0750d..5351cfb 100644 --- a/core/lib/Drupal/Core/Cache/ChainedFastBackend.php +++ b/core/lib/Drupal/Core/Cache/ChainedFastBackend.php @@ -107,7 +107,7 @@ public function __construct(CacheBackendInterface $consistent_backend, CacheBack * {@inheritdoc} */ public function get($cid, $allow_invalid = FALSE) { - $cids = array($cid); + $cids = [$cid]; $cache = $this->getMultiple($cids, $allow_invalid); return reset($cache); } @@ -117,7 +117,7 @@ public function get($cid, $allow_invalid = FALSE) { */ public function getMultiple(&$cids, $allow_invalid = FALSE) { $cids_copy = $cids; - $cache = array(); + $cache = []; // If we can determine the time at which the last write to the consistent // backend occurred (we might not be able to if it has been recently @@ -150,7 +150,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) { } catch (\Exception $e) { $cids = $cids_copy; - $items = array(); + $items = []; } // Even if items were successfully fetched from the fast backend, they @@ -184,7 +184,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) { /** * {@inheritdoc} */ - public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) { + public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) { $this->consistentBackend->set($cid, $data, $expire, $tags); $this->markAsOutdated(); // Don't write the cache tags to the fast backend as any cache tag @@ -210,7 +210,7 @@ public function setMultiple(array $items) { * {@inheritdoc} */ public function delete($cid) { - $this->consistentBackend->deleteMultiple(array($cid)); + $this->consistentBackend->deleteMultiple([$cid]); $this->markAsOutdated(); } @@ -234,7 +234,7 @@ public function deleteAll() { * {@inheritdoc} */ public function invalidate($cid) { - $this->invalidateMultiple(array($cid)); + $this->invalidateMultiple([$cid]); } /** diff --git a/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php b/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php index 00dc9b5..e4da328 100644 --- a/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php +++ b/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php @@ -43,7 +43,7 @@ class ChainedFastBackendFactory implements CacheFactoryInterface { public function __construct(Settings $settings = NULL, $consistent_service_name = NULL, $fast_service_name = NULL) { // Default the consistent backend to the site's default backend. if (!isset($consistent_service_name)) { - $cache_settings = isset($settings) ? $settings->get('cache') : array(); + $cache_settings = isset($settings) ? $settings->get('cache') : []; $consistent_service_name = isset($cache_settings['default']) ? $cache_settings['default'] : 'cache.backend.database'; } diff --git a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php index 0e89fb9..9a555f8 100644 --- a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php +++ b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php @@ -71,7 +71,7 @@ public function getAll() { * An array of available cache contexts and corresponding labels. */ public function getLabels($include_calculated_cache_contexts = FALSE) { - $with_labels = array(); + $with_labels = []; foreach ($this->contexts as $context) { $service = $this->getService($context); if (!$include_calculated_cache_contexts && $service instanceof CalculatedCacheContextInterface) { diff --git a/core/lib/Drupal/Core/Cache/Context/LanguagesCacheContext.php b/core/lib/Drupal/Core/Cache/Context/LanguagesCacheContext.php index a13b763..952dc14 100644 --- a/core/lib/Drupal/Core/Cache/Context/LanguagesCacheContext.php +++ b/core/lib/Drupal/Core/Cache/Context/LanguagesCacheContext.php @@ -50,7 +50,7 @@ public static function getLabel() { */ public function getContext($type = NULL) { if ($type === NULL) { - $context_parts = array(); + $context_parts = []; if ($this->languageManager->isMultilingual()) { foreach ($this->languageManager->getLanguageTypes() as $type) { $context_parts[] = $this->languageManager->getCurrentLanguage($type)->getId(); diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index a96d183..d53c51c 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -59,7 +59,7 @@ public function __construct(Connection $connection, CacheTagsChecksumInterface $ * {@inheritdoc} */ public function get($cid, $allow_invalid = FALSE) { - $cids = array($cid); + $cids = [$cid]; $cache = $this->getMultiple($cids, $allow_invalid); return reset($cache); } @@ -68,7 +68,7 @@ public function get($cid, $allow_invalid = FALSE) { * {@inheritdoc} */ public function getMultiple(&$cids, $allow_invalid = FALSE) { - $cid_mapping = array(); + $cid_mapping = []; foreach ($cids as $cid) { $cid_mapping[$this->normalizeCid($cid)] = $cid; } @@ -79,14 +79,14 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) { // is used here only due to the performance overhead we would incur // otherwise. When serving an uncached page, the overhead of using // ::select() is a much smaller proportion of the request. - $result = array(); + $result = []; try { - $result = $this->connection->query('SELECT cid, data, created, expire, serialized, tags, checksum FROM {' . $this->connection->escapeTable($this->bin) . '} WHERE cid IN ( :cids[] ) ORDER BY cid', array(':cids[]' => array_keys($cid_mapping))); + $result = $this->connection->query('SELECT cid, data, created, expire, serialized, tags, checksum FROM {' . $this->connection->escapeTable($this->bin) . '} WHERE cid IN ( :cids[] ) ORDER BY cid', [':cids[]' => array_keys($cid_mapping)]); } catch (\Exception $e) { // Nothing to do. } - $cache = array(); + $cache = []; foreach ($result as $item) { // Map the cache ID back to the original. $item->cid = $cid_mapping[$item->cid]; @@ -119,7 +119,7 @@ protected function prepareItem($cache, $allow_invalid) { return FALSE; } - $cache->tags = $cache->tags ? explode(' ', $cache->tags) : array(); + $cache->tags = $cache->tags ? explode(' ', $cache->tags) : []; // Check expire time. $cache->valid = $cache->expire == Cache::PERMANENT || $cache->expire >= REQUEST_TIME; @@ -144,7 +144,7 @@ protected function prepareItem($cache, $allow_invalid) { /** * {@inheritdoc} */ - public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) { + public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) { $this->setMultiple([ $cid => [ 'data' => $data, @@ -186,26 +186,26 @@ public function setMultiple(array $items) { * @see \Drupal\Core\Cache\CacheBackendInterface::setMultiple() */ protected function doSetMultiple(array $items) { - $values = array(); + $values = []; foreach ($items as $cid => $item) { - $item += array( + $item += [ 'expire' => CacheBackendInterface::CACHE_PERMANENT, - 'tags' => array(), - ); + 'tags' => [], + ]; assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($item[\'tags\'])', 'Cache Tags must be strings.'); $item['tags'] = array_unique($item['tags']); // Sort the cache tags so that they are stored consistently in the DB. sort($item['tags']); - $fields = array( + $fields = [ 'cid' => $this->normalizeCid($cid), 'expire' => $item['expire'], 'created' => round(microtime(TRUE), 3), 'tags' => implode(' ', $item['tags']), 'checksum' => $this->checksumProvider->getCurrentChecksum($item['tags']), - ); + ]; if (!is_string($item['data'])) { $fields['data'] = serialize($item['data']); @@ -223,7 +223,7 @@ protected function doSetMultiple(array $items) { $query = $this->connection ->upsert($this->bin) ->key('cid') - ->fields(array('cid', 'expire', 'created', 'tags', 'checksum', 'data', 'serialized')); + ->fields(['cid', 'expire', 'created', 'tags', 'checksum', 'data', 'serialized']); foreach ($values as $fields) { // Only pass the values since the order of $fields matches the order of // the insert fields. This is a performance optimization to avoid @@ -238,14 +238,14 @@ protected function doSetMultiple(array $items) { * {@inheritdoc} */ public function delete($cid) { - $this->deleteMultiple(array($cid)); + $this->deleteMultiple([$cid]); } /** * {@inheritdoc} */ public function deleteMultiple(array $cids) { - $cids = array_values(array_map(array($this, 'normalizeCid'), $cids)); + $cids = array_values(array_map([$this, 'normalizeCid'], $cids)); try { // Delete in chunks when a large array is passed. foreach (array_chunk($cids, 1000) as $cids_chunk) { @@ -285,19 +285,19 @@ public function deleteAll() { * {@inheritdoc} */ public function invalidate($cid) { - $this->invalidateMultiple(array($cid)); + $this->invalidateMultiple([$cid]); } /** * {@inheritdoc} */ public function invalidateMultiple(array $cids) { - $cids = array_values(array_map(array($this, 'normalizeCid'), $cids)); + $cids = array_values(array_map([$this, 'normalizeCid'], $cids)); try { // Update in chunks when a large array is passed. foreach (array_chunk($cids, 1000) as $cids_chunk) { $this->connection->update($this->bin) - ->fields(array('expire' => REQUEST_TIME - 1)) + ->fields(['expire' => REQUEST_TIME - 1]) ->condition('cid', $cids_chunk, 'IN') ->execute(); } @@ -313,7 +313,7 @@ public function invalidateMultiple(array $cids) { public function invalidateAll() { try { $this->connection->update($this->bin) - ->fields(array('expire' => REQUEST_TIME - 1)) + ->fields(['expire' => REQUEST_TIME - 1]) ->execute(); } catch (\Exception $e) { @@ -419,62 +419,62 @@ protected function normalizeCid($cid) { * Defines the schema for the {cache_*} bin tables. */ public function schemaDefinition() { - $schema = array( + $schema = [ 'description' => 'Storage for the cache API.', - 'fields' => array( - 'cid' => array( + 'fields' => [ + 'cid' => [ 'description' => 'Primary Key: Unique cache ID.', 'type' => 'varchar_ascii', 'length' => 255, 'not null' => TRUE, 'default' => '', 'binary' => TRUE, - ), - 'data' => array( + ], + 'data' => [ 'description' => 'A collection of data to cache.', 'type' => 'blob', 'not null' => FALSE, 'size' => 'big', - ), - 'expire' => array( + ], + 'expire' => [ 'description' => 'A Unix timestamp indicating when the cache entry should expire, or ' . Cache::PERMANENT . ' for never.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, - ), - 'created' => array( + ], + 'created' => [ 'description' => 'A timestamp with millisecond precision indicating when the cache entry was created.', 'type' => 'numeric', 'precision' => 14, 'scale' => 3, 'not null' => TRUE, 'default' => 0, - ), - 'serialized' => array( + ], + 'serialized' => [ 'description' => 'A flag to indicate whether content is serialized (1) or not (0).', 'type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0, - ), - 'tags' => array( + ], + 'tags' => [ 'description' => 'Space-separated list of cache tags for this entry.', 'type' => 'text', 'size' => 'big', 'not null' => FALSE, - ), - 'checksum' => array( + ], + 'checksum' => [ 'description' => 'The tag invalidation checksum when this entry was saved.', 'type' => 'varchar_ascii', 'length' => 255, 'not null' => TRUE, - ), - ), - 'indexes' => array( - 'expire' => array('expire'), - ), - 'primary key' => array('cid'), - ); + ], + ], + 'indexes' => [ + 'expire' => ['expire'], + ], + 'primary key' => ['cid'], + ]; return $schema; } diff --git a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php index a133d88..450b441 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php +++ b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php @@ -22,7 +22,7 @@ class DatabaseCacheTagsChecksum implements CacheTagsChecksumInterface, CacheTags * * @var array */ - protected $tagCache = array(); + protected $tagCache = []; /** * A list of tags that have already been invalidated in this request. @@ -31,7 +31,7 @@ class DatabaseCacheTagsChecksum implements CacheTagsChecksumInterface, CacheTags * * @var array */ - protected $invalidatedTags = array(); + protected $invalidatedTags = []; /** * Constructs a DatabaseCacheTagsChecksum object. @@ -56,7 +56,7 @@ public function invalidateTags(array $tags) { $this->invalidatedTags[$tag] = TRUE; unset($this->tagCache[$tag]); $this->connection->merge('cachetags') - ->insertFields(array('invalidations' => 1)) + ->insertFields(['invalidations' => 1]) ->expression('invalidations', 'invalidations + 1') ->key('tag', $tag) ->execute(); @@ -107,9 +107,9 @@ protected function calculateChecksum(array $tags) { $query_tags = array_diff($tags, array_keys($this->tagCache)); if ($query_tags) { - $db_tags = array(); + $db_tags = []; try { - $db_tags = $this->connection->query('SELECT tag, invalidations FROM {cachetags} WHERE tag IN ( :tags[] )', array(':tags[]' => $query_tags)) + $db_tags = $this->connection->query('SELECT tag, invalidations FROM {cachetags} WHERE tag IN ( :tags[] )', [':tags[]' => $query_tags]) ->fetchAllKeyed(); $this->tagCache += $db_tags; } @@ -134,8 +134,8 @@ protected function calculateChecksum(array $tags) { * {@inheritdoc} */ public function reset() { - $this->tagCache = array(); - $this->invalidatedTags = array(); + $this->tagCache = []; + $this->invalidatedTags = []; } /** @@ -165,25 +165,25 @@ protected function ensureTableExists() { * Defines the schema for the {cachetags} table. */ public function schemaDefinition() { - $schema = array( + $schema = [ 'description' => 'Cache table for tracking cache tag invalidations.', - 'fields' => array( - 'tag' => array( + 'fields' => [ + 'tag' => [ 'description' => 'Namespace-prefixed tag string.', 'type' => 'varchar_ascii', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), - 'invalidations' => array( + ], + 'invalidations' => [ 'description' => 'Number incremented when the tag is invalidated.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, - ), - ), - 'primary key' => array('tag'), - ); + ], + ], + 'primary key' => ['tag'], + ]; return $schema; } diff --git a/core/lib/Drupal/Core/Cache/ListCacheBinsPass.php b/core/lib/Drupal/Core/Cache/ListCacheBinsPass.php index 27886ac..32bac09 100644 --- a/core/lib/Drupal/Core/Cache/ListCacheBinsPass.php +++ b/core/lib/Drupal/Core/Cache/ListCacheBinsPass.php @@ -16,8 +16,8 @@ class ListCacheBinsPass implements CompilerPassInterface { * Collects the cache bins into the cache_bins parameter. */ public function process(ContainerBuilder $container) { - $cache_bins = array(); - $cache_default_bin_backends = array(); + $cache_bins = []; + $cache_default_bin_backends = []; foreach ($container->findTaggedServiceIds('cache.bin') as $id => $attributes) { $bin = substr($id, strpos($id, '.') + 1); $cache_bins[$id] = $bin; diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php index c517fb4..9fe4db1 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -17,7 +17,7 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf /** * Array to store cache objects. */ - protected $cache = array(); + protected $cache = []; /** * {@inheritdoc} @@ -35,7 +35,7 @@ public function get($cid, $allow_invalid = FALSE) { * {@inheritdoc} */ public function getMultiple(&$cids, $allow_invalid = FALSE) { - $ret = array(); + $ret = []; $items = array_intersect_key($this->cache, array_flip($cids)); @@ -92,26 +92,26 @@ protected function prepareItem($cache, $allow_invalid) { /** * {@inheritdoc} */ - public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) { + public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) { assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.'); $tags = array_unique($tags); // Sort the cache tags so that they are stored consistently in the database. sort($tags); - $this->cache[$cid] = (object) array( + $this->cache[$cid] = (object) [ 'cid' => $cid, 'data' => serialize($data), 'created' => $this->getRequestTime(), 'expire' => $expire, 'tags' => $tags, - ); + ]; } /** * {@inheritdoc} */ - public function setMultiple(array $items = array()) { + public function setMultiple(array $items = []) { foreach ($items as $cid => $item) { - $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : array()); + $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : []); } } @@ -133,7 +133,7 @@ public function deleteMultiple(array $cids) { * {@inheritdoc} */ public function deleteAll() { - $this->cache = array(); + $this->cache = []; } /** diff --git a/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php b/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php index 4457e59..680f850 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackendFactory.php @@ -9,7 +9,7 @@ class MemoryBackendFactory implements CacheFactoryInterface { * * @var \Drupal\Core\Cache\MemoryBackend[] */ - protected $bins = array(); + protected $bins = []; /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php b/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php index 5ec490c..63d2007 100644 --- a/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php @@ -17,7 +17,7 @@ class MemoryCounterBackend extends MemoryBackend { * * @var array */ - protected $counter = array(); + protected $counter = []; /** * {@inheritdoc} @@ -30,7 +30,7 @@ public function get($cid, $allow_invalid = FALSE) { /** * {@inheritdoc} */ - public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) { + public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) { $this->increaseCounter(__FUNCTION__, $cid); parent::set($cid, $data, $expire, $tags); } @@ -76,7 +76,7 @@ public function getCounter($method = NULL, $cid = NULL) { return isset($this->counter[$method][$cid]) ? $this->counter[$method][$cid] : 0; } elseif ($method) { - return isset($this->counter[$method]) ? $this->counter[$method] : array(); + return isset($this->counter[$method]) ? $this->counter[$method] : []; } else { return $this->counter; @@ -87,7 +87,7 @@ public function getCounter($method = NULL, $cid = NULL) { * Resets the call counter. */ public function resetCounter() { - $this->counter = array(); + $this->counter = []; } } diff --git a/core/lib/Drupal/Core/Cache/NullBackend.php b/core/lib/Drupal/Core/Cache/NullBackend.php index fec549f..b0077a5 100644 --- a/core/lib/Drupal/Core/Cache/NullBackend.php +++ b/core/lib/Drupal/Core/Cache/NullBackend.php @@ -36,18 +36,18 @@ public function get($cid, $allow_invalid = FALSE) { * {@inheritdoc} */ public function getMultiple(&$cids, $allow_invalid = FALSE) { - return array(); + return []; } /** * {@inheritdoc} */ - public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) {} + public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) {} /** * {@inheritdoc} */ - public function setMultiple(array $items = array()) {} + public function setMultiple(array $items = []) {} /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/Cache/PhpBackend.php b/core/lib/Drupal/Core/Cache/PhpBackend.php index 38f9b9b..2404493 100644 --- a/core/lib/Drupal/Core/Cache/PhpBackend.php +++ b/core/lib/Drupal/Core/Cache/PhpBackend.php @@ -28,7 +28,7 @@ class PhpBackend implements CacheBackendInterface { /** * Array to store cache objects. */ - protected $cache = array(); + protected $cache = []; /** * The cache tags checksum provider. @@ -83,7 +83,7 @@ protected function getByHash($cidhash, $allow_invalid = FALSE) { */ public function setMultiple(array $items) { foreach ($items as $cid => $item) { - $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : array()); + $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : []); } } @@ -91,7 +91,7 @@ public function setMultiple(array $items) { * {@inheritdoc} */ public function getMultiple(&$cids, $allow_invalid = FALSE) { - $ret = array(); + $ret = []; foreach ($cids as $cid) { if ($item = $this->get($cid, $allow_invalid)) { @@ -142,16 +142,16 @@ protected function prepareItem($cache, $allow_invalid) { /** * {@inheritdoc} */ - public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) { + public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) { assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.'); - $item = (object) array( + $item = (object) [ 'cid' => $cid, 'data' => $data, 'created' => round(microtime(TRUE), 3), 'expire' => $expire, 'tags' => array_unique($tags), 'checksum' => $this->checksumProvider->getCurrentChecksum($tags), - ); + ]; $this->writeItem($this->normalizeCid($cid), $item); } @@ -226,7 +226,7 @@ public function garbageCollection() { * {@inheritdoc} */ public function removeBin() { - $this->cache = array(); + $this->cache = []; $this->storage()->deleteAll(); } diff --git a/core/lib/Drupal/Core/Composer/Composer.php b/core/lib/Drupal/Core/Composer/Composer.php index 51a4917..e44c493 100644 --- a/core/lib/Drupal/Core/Composer/Composer.php +++ b/core/lib/Drupal/Core/Composer/Composer.php @@ -82,22 +82,22 @@ public static function preAutoloadDump(Event $event) { // Check for our packages, and then optimize them if they're present. if ($repository->findPackage('symfony/http-foundation', $constraint)) { $autoload = $package->getAutoload(); - $autoload['classmap'] = array_merge($autoload['classmap'], array( + $autoload['classmap'] = array_merge($autoload['classmap'], [ 'vendor/symfony/http-foundation/Request.php', 'vendor/symfony/http-foundation/ParameterBag.php', 'vendor/symfony/http-foundation/FileBag.php', 'vendor/symfony/http-foundation/ServerBag.php', 'vendor/symfony/http-foundation/HeaderBag.php', - )); + ]); $package->setAutoload($autoload); } if ($repository->findPackage('symfony/http-kernel', $constraint)) { $autoload = $package->getAutoload(); - $autoload['classmap'] = array_merge($autoload['classmap'], array( + $autoload['classmap'] = array_merge($autoload['classmap'], [ 'vendor/symfony/http-kernel/HttpKernel.php', 'vendor/symfony/http-kernel/HttpKernelInterface.php', 'vendor/symfony/http-kernel/TerminableInterface.php', - )); + ]); $package->setAutoload($autoload); } } diff --git a/core/lib/Drupal/Core/Condition/Annotation/Condition.php b/core/lib/Drupal/Core/Condition/Annotation/Condition.php index 0959ef7..b6686cf 100644 --- a/core/lib/Drupal/Core/Condition/Annotation/Condition.php +++ b/core/lib/Drupal/Core/Condition/Annotation/Condition.php @@ -55,7 +55,7 @@ class Condition extends Plugin { * * @var \Drupal\Core\Annotation\ContextDefinition[] */ - public $context = array(); + public $context = []; /** * The category under which the condition should listed in the UI. diff --git a/core/lib/Drupal/Core/Condition/ConditionManager.php b/core/lib/Drupal/Core/Condition/ConditionManager.php index bbe6fe7..2c6b61b 100644 --- a/core/lib/Drupal/Core/Condition/ConditionManager.php +++ b/core/lib/Drupal/Core/Condition/ConditionManager.php @@ -46,7 +46,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac /** * {@inheritdoc} */ - public function createInstance($plugin_id, array $configuration = array()) { + public function createInstance($plugin_id, array $configuration = []) { $plugin = $this->getFactory()->createInstance($plugin_id, $configuration); // If we receive any context values via config set it into the plugin. diff --git a/core/lib/Drupal/Core/Condition/ConditionPluginBase.php b/core/lib/Drupal/Core/Condition/ConditionPluginBase.php index aaa7ee8..b5134fb 100644 --- a/core/lib/Drupal/Core/Condition/ConditionPluginBase.php +++ b/core/lib/Drupal/Core/Condition/ConditionPluginBase.php @@ -53,11 +53,11 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta } $contexts = $form_state->getTemporaryValue('gathered_contexts') ?: []; $form['context_mapping'] = $this->addContextAssignmentElement($this, $contexts); - $form['negate'] = array( + $form['negate'] = [ '#type' => 'checkbox', '#title' => $this->t('Negate the condition'), '#default_value' => $this->configuration['negate'], - ); + ]; return $form; } @@ -88,9 +88,9 @@ public function execute() { * {@inheritdoc} */ public function getConfiguration() { - return array( + return [ 'id' => $this->getPluginId(), - ) + $this->configuration; + ] + $this->configuration; } /** @@ -105,16 +105,16 @@ public function setConfiguration(array $configuration) { * {@inheritdoc} */ public function defaultConfiguration() { - return array( + return [ 'negate' => FALSE, - ); + ]; } /** * {@inheritdoc} */ public function calculateDependencies() { - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Condition/ConditionPluginCollection.php b/core/lib/Drupal/Core/Condition/ConditionPluginCollection.php index 5801ac1..4d6dd70 100644 --- a/core/lib/Drupal/Core/Condition/ConditionPluginCollection.php +++ b/core/lib/Drupal/Core/Condition/ConditionPluginCollection.php @@ -15,7 +15,7 @@ class ConditionPluginCollection extends DefaultLazyPluginCollection { * * @var \Drupal\Component\Plugin\Context\ContextInterface[] */ - protected $conditionContexts = array(); + protected $conditionContexts = []; /** * {@inheritdoc} @@ -33,7 +33,7 @@ public function getConfiguration() { $configuration = parent::getConfiguration(); // Remove configuration if it matches the defaults. foreach ($configuration as $instance_id => $instance_config) { - $default_config = array(); + $default_config = []; $default_config['id'] = $instance_id; $default_config += $this->get($instance_id)->defaultConfiguration(); // In order to determine if a plugin is configured, we must compare it to diff --git a/core/lib/Drupal/Core/Config/CachedStorage.php b/core/lib/Drupal/Core/Config/CachedStorage.php index 363fcd0..7286fbc 100644 --- a/core/lib/Drupal/Core/Config/CachedStorage.php +++ b/core/lib/Drupal/Core/Config/CachedStorage.php @@ -34,7 +34,7 @@ class CachedStorage implements StorageInterface, StorageCacheInterface { * * @var array */ - protected $findByPrefixCache = array(); + protected $findByPrefixCache = []; /** * Constructs a new CachedStorage. @@ -80,7 +80,7 @@ public function read($name) { * {@inheritdoc} */ public function readMultiple(array $names) { - $data_to_return = array(); + $data_to_return = []; $cache_keys_map = $this->getCacheKeys($names); $cache_keys = array_values($cache_keys_map); @@ -95,11 +95,11 @@ public function readMultiple(array $names) { $list = $this->storage->readMultiple($names_to_get); // Cache configuration objects that were loaded from the storage, cache // missing configuration objects as an explicit FALSE. - $items = array(); + $items = []; foreach ($names_to_get as $name) { $data = isset($list[$name]) ? $list[$name] : FALSE; $data_to_return[$name] = $data; - $items[$cache_keys_map[$name]] = array('data' => $data); + $items[$cache_keys_map[$name]] = ['data' => $data]; } $this->cache->setMultiple($items); @@ -125,7 +125,7 @@ public function write($name, array $data) { // While not all written data is read back, setting the cache instead of // just deleting it avoids cache rebuild stampedes. $this->cache->set($this->getCacheKey($name), $data); - $this->findByPrefixCache = array(); + $this->findByPrefixCache = []; return TRUE; } return FALSE; @@ -139,7 +139,7 @@ public function delete($name) { // rebuilding the cache before the storage is gone. if ($this->storage->delete($name)) { $this->cache->delete($this->getCacheKey($name)); - $this->findByPrefixCache = array(); + $this->findByPrefixCache = []; return TRUE; } return FALSE; @@ -154,7 +154,7 @@ public function rename($name, $new_name) { if ($this->storage->rename($name, $new_name)) { $this->cache->delete($this->getCacheKey($name)); $this->cache->delete($this->getCacheKey($new_name)); - $this->findByPrefixCache = array(); + $this->findByPrefixCache = []; return TRUE; } return FALSE; @@ -227,7 +227,7 @@ public function deleteAll($prefix = '') { * Clears the static list cache. */ public function resetListCache() { - $this->findByPrefixCache = array(); + $this->findByPrefixCache = []; } /** diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index 0128c66..584feb7 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -155,10 +155,10 @@ public function setModuleOverride(array $data) { protected function setOverriddenData() { $this->overriddenData = $this->data; if (isset($this->moduleOverrides) && is_array($this->moduleOverrides)) { - $this->overriddenData = NestedArray::mergeDeepArray(array($this->overriddenData, $this->moduleOverrides), TRUE); + $this->overriddenData = NestedArray::mergeDeepArray([$this->overriddenData, $this->moduleOverrides], TRUE); } if (isset($this->settingsOverrides) && is_array($this->settingsOverrides)) { - $this->overriddenData = NestedArray::mergeDeepArray(array($this->overriddenData, $this->settingsOverrides), TRUE); + $this->overriddenData = NestedArray::mergeDeepArray([$this->overriddenData, $this->settingsOverrides], TRUE); } return $this; } @@ -239,7 +239,7 @@ public function save($has_trusted_data = FALSE) { * The configuration object. */ public function delete() { - $this->data = array(); + $this->data = []; $this->storage->delete($this->name); Cache::invalidateTags($this->getCacheTags()); $this->isNew = TRUE; @@ -281,10 +281,10 @@ public function getOriginal($key = '', $apply_overrides = TRUE) { if ($apply_overrides) { // Apply overrides. if (isset($this->moduleOverrides) && is_array($this->moduleOverrides)) { - $original_data = NestedArray::mergeDeepArray(array($original_data, $this->moduleOverrides), TRUE); + $original_data = NestedArray::mergeDeepArray([$original_data, $this->moduleOverrides], TRUE); } if (isset($this->settingsOverrides) && is_array($this->settingsOverrides)) { - $original_data = NestedArray::mergeDeepArray(array($original_data, $this->settingsOverrides), TRUE); + $original_data = NestedArray::mergeDeepArray([$original_data, $this->settingsOverrides], TRUE); } } diff --git a/core/lib/Drupal/Core/Config/ConfigBase.php b/core/lib/Drupal/Core/Config/ConfigBase.php index 6dfa962..596ed92 100644 --- a/core/lib/Drupal/Core/Config/ConfigBase.php +++ b/core/lib/Drupal/Core/Config/ConfigBase.php @@ -40,7 +40,7 @@ * * @var array */ - protected $data = array(); + protected $data = []; /** * The maximum length of a configuration object name. @@ -247,7 +247,7 @@ public function clear($key) { */ public function merge(array $data_to_merge) { // Preserve integer keys so that configuration keys are not changed. - $this->setData(NestedArray::mergeDeepArray(array($this->data, $data_to_merge), TRUE)); + $this->setData(NestedArray::mergeDeepArray([$this->data, $data_to_merge], TRUE)); return $this; } diff --git a/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php b/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php index ca526cd..f1a8fb9 100644 --- a/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php +++ b/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php @@ -17,7 +17,7 @@ class ConfigCollectionInfo extends Event { * * @var array */ - protected $collections = array(); + protected $collections = []; /** * Adds a collection to the list of possible collections. diff --git a/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php index 1189a4a..d91bec9 100644 --- a/core/lib/Drupal/Core/Config/ConfigFactory.php +++ b/core/lib/Drupal/Core/Config/ConfigFactory.php @@ -43,7 +43,7 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface * * @var \Drupal\Core\Config\Config[] */ - protected $cache = array(); + protected $cache = []; /** * The typed config manager. @@ -57,7 +57,7 @@ class ConfigFactory implements ConfigFactoryInterface, EventSubscriberInterface * * @var \Drupal\Core\Config\ConfigFactoryOverrideInterface[] */ - protected $configFactoryOverrides = array(); + protected $configFactoryOverrides = []; /** * Constructs the Config factory. @@ -101,7 +101,7 @@ public function get($name) { * A configuration object. */ protected function doGet($name, $immutable = TRUE) { - if ($config = $this->doLoadMultiple(array($name), $immutable)) { + if ($config = $this->doLoadMultiple([$name], $immutable)) { return $config[$name]; } else { @@ -111,7 +111,7 @@ protected function doGet($name, $immutable = TRUE) { if ($immutable) { // Get and apply any overrides. - $overrides = $this->loadOverrides(array($name)); + $overrides = $this->loadOverrides([$name]); if (isset($overrides[$name])) { $config->setModuleOverride($overrides[$name]); } @@ -148,7 +148,7 @@ public function loadMultiple(array $names) { * List of successfully loaded configuration objects, keyed by name. */ protected function doLoadMultiple(array $names, $immutable = TRUE) { - $list = array(); + $list = []; foreach ($names as $key => $name) { $cache_key = $this->getConfigCacheKey($name, $immutable); @@ -161,7 +161,7 @@ protected function doLoadMultiple(array $names, $immutable = TRUE) { // Pre-load remaining configuration files. if (!empty($names)) { // Initialise override information. - $module_overrides = array(); + $module_overrides = []; $storage_data = $this->storage->readMultiple($names); if ($immutable && !empty($storage_data)) { @@ -202,11 +202,11 @@ protected function doLoadMultiple(array $names, $immutable = TRUE) { * An array of overrides keyed by the configuration object name. */ protected function loadOverrides(array $names) { - $overrides = array(); + $overrides = []; foreach ($this->configFactoryOverrides as $override) { // Existing overrides take precedence since these will have been added // by events with a higher priority. - $overrides = NestedArray::mergeDeepArray(array($override->loadOverrides($names), $overrides), TRUE); + $overrides = NestedArray::mergeDeepArray([$override->loadOverrides($names), $overrides], TRUE); } return $overrides; } @@ -236,7 +236,7 @@ public function reset($name = NULL) { } } else { - $this->cache = array(); + $this->cache = []; } // Clear the static list cache if supported by the storage. @@ -317,7 +317,7 @@ protected function getConfigCacheKeys($name) { * {@inheritdoc} */ public function clearStaticCache() { - $this->cache = array(); + $this->cache = []; return $this; } @@ -366,8 +366,8 @@ public function onConfigDelete(ConfigCrudEvent $event) { * {@inheritdoc} */ static function getSubscribedEvents() { - $events[ConfigEvents::SAVE][] = array('onConfigSave', 255); - $events[ConfigEvents::DELETE][] = array('onConfigDelete', 255); + $events[ConfigEvents::SAVE][] = ['onConfigSave', 255]; + $events[ConfigEvents::DELETE][] = ['onConfigDelete', 255]; return $events; } diff --git a/core/lib/Drupal/Core/Config/ConfigFactoryOverrideBase.php b/core/lib/Drupal/Core/Config/ConfigFactoryOverrideBase.php index 79eb294..3ca1602 100644 --- a/core/lib/Drupal/Core/Config/ConfigFactoryOverrideBase.php +++ b/core/lib/Drupal/Core/Config/ConfigFactoryOverrideBase.php @@ -45,10 +45,10 @@ * {@inheritdoc} */ static function getSubscribedEvents() { - $events[ConfigEvents::COLLECTION_INFO][] = array('addCollections'); - $events[ConfigEvents::SAVE][] = array('onConfigSave', 20); - $events[ConfigEvents::DELETE][] = array('onConfigDelete', 20); - $events[ConfigEvents::RENAME][] = array('onConfigRename', 20); + $events[ConfigEvents::COLLECTION_INFO][] = ['addCollections']; + $events[ConfigEvents::SAVE][] = ['onConfigSave', 20]; + $events[ConfigEvents::DELETE][] = ['onConfigDelete', 20]; + $events[ConfigEvents::RENAME][] = ['onConfigRename', 20]; return $events; } diff --git a/core/lib/Drupal/Core/Config/ConfigImportValidateEventSubscriberBase.php b/core/lib/Drupal/Core/Config/ConfigImportValidateEventSubscriberBase.php index 4f172a3..ca49645 100644 --- a/core/lib/Drupal/Core/Config/ConfigImportValidateEventSubscriberBase.php +++ b/core/lib/Drupal/Core/Config/ConfigImportValidateEventSubscriberBase.php @@ -23,7 +23,7 @@ * {@inheritdoc} */ static function getSubscribedEvents() { - $events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidate', 20); + $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidate', 20]; return $events; } diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index 25071b0..7d48a4a 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -135,7 +135,7 @@ class ConfigImporter { * * @var array */ - protected $errors = array(); + protected $errors = []; /** * The total number of extensions to process. @@ -253,16 +253,16 @@ public function reset() { * An empty list of extensions to process. */ protected function getEmptyExtensionsProcessedList() { - return array( - 'module' => array( - 'install' => array(), - 'uninstall' => array(), - ), - 'theme' => array( - 'install' => array(), - 'uninstall' => array(), - ), - ); + return [ + 'module' => [ + 'install' => [], + 'uninstall' => [], + ], + 'theme' => [ + 'install' => [], + 'uninstall' => [], + ], + ]; } /** @@ -273,7 +273,7 @@ protected function getEmptyExtensionsProcessedList() { */ public function hasUnprocessedConfigurationChanges() { foreach ($this->storageComparer->getAllCollectionNames() as $collection) { - foreach (array('delete', 'create', 'rename', 'update') as $op) { + foreach (['delete', 'create', 'rename', 'update'] as $op) { if (count($this->getUnprocessedConfiguration($op, $collection))) { return TRUE; } @@ -440,10 +440,10 @@ public function getExtensionChangelist($type, $op = NULL) { */ protected function getUnprocessedExtensions($type) { $changelist = $this->getExtensionChangelist($type); - return array( + return [ 'install' => array_diff($changelist['install'], $this->processedExtensions[$type]['install']), 'uninstall' => array_diff($changelist['uninstall'], $this->processedExtensions[$type]['uninstall']), - ); + ]; } /** @@ -459,7 +459,7 @@ public function import() { $sync_steps = $this->initialize(); foreach ($sync_steps as $step) { - $context = array(); + $context = []; do { $this->doSyncStep($step, $context); } while ($context['finished'] < 1); @@ -489,7 +489,7 @@ public function doSyncStep($sync_step, &$context) { } elseif (is_callable($sync_step)) { \Drupal::service('config.installer')->setSyncing(TRUE); - call_user_func_array($sync_step, array(&$context, $this)); + call_user_func_array($sync_step, [&$context, $this]); } else { throw new \InvalidArgumentException('Invalid configuration synchronization step'); @@ -517,13 +517,13 @@ public function initialize() { throw new ConfigImporterException(sprintf('%s is already importing', static::LOCK_NAME)); } - $sync_steps = array(); + $sync_steps = []; $modules = $this->getUnprocessedExtensions('module'); - foreach (array('install', 'uninstall') as $op) { + foreach (['install', 'uninstall'] as $op) { $this->totalExtensionsToProcess += count($modules[$op]); } $themes = $this->getUnprocessedExtensions('theme'); - foreach (array('install', 'uninstall') as $op) { + foreach (['install', 'uninstall'] as $op) { $this->totalExtensionsToProcess += count($themes[$op]); } @@ -549,7 +549,7 @@ protected function processExtensions(&$context) { $operation = $this->getNextExtensionOperation(); if (!empty($operation)) { $this->processExtension($operation['type'], $operation['op'], $operation['name']); - $context['message'] = t('Synchronizing extensions: @op @name.', array('@op' => $operation['op'], '@name' => $operation['name'])); + $context['message'] = t('Synchronizing extensions: @op @name.', ['@op' => $operation['op'], '@name' => $operation['name']]); $processed_count = count($this->processedExtensions['module']['install']) + count($this->processedExtensions['module']['uninstall']); $processed_count += count($this->processedExtensions['theme']['uninstall']) + count($this->processedExtensions['theme']['install']); $context['finished'] = $processed_count / $this->totalExtensionsToProcess; @@ -573,7 +573,7 @@ protected function processConfigurations(&$context) { if ($this->totalConfigurationToProcess == 0) { $this->storageComparer->reset(); foreach ($this->storageComparer->getAllCollectionNames() as $collection) { - foreach (array('delete', 'create', 'rename', 'update') as $op) { + foreach (['delete', 'create', 'rename', 'update'] as $op) { $this->totalConfigurationToProcess += count($this->getUnprocessedConfiguration($op, $collection)); } } @@ -584,14 +584,14 @@ protected function processConfigurations(&$context) { $this->processConfiguration($operation['collection'], $operation['op'], $operation['name']); } if ($operation['collection'] == StorageInterface::DEFAULT_COLLECTION) { - $context['message'] = $this->t('Synchronizing configuration: @op @name.', array('@op' => $operation['op'], '@name' => $operation['name'])); + $context['message'] = $this->t('Synchronizing configuration: @op @name.', ['@op' => $operation['op'], '@name' => $operation['name']]); } else { - $context['message'] = $this->t('Synchronizing configuration: @op @name in @collection.', array('@op' => $operation['op'], '@name' => $operation['name'], '@collection' => $operation['collection'])); + $context['message'] = $this->t('Synchronizing configuration: @op @name in @collection.', ['@op' => $operation['op'], '@name' => $operation['name'], '@collection' => $operation['collection']]); } $processed_count = 0; foreach ($this->storageComparer->getAllCollectionNames() as $collection) { - foreach (array('delete', 'create', 'rename', 'update') as $op) { + foreach (['delete', 'create', 'rename', 'update'] as $op) { $processed_count += count($this->processedConfiguration[$collection][$op]); } } @@ -657,15 +657,15 @@ protected function finish(&$context) { * on. If there is nothing left to do returns FALSE; */ protected function getNextExtensionOperation() { - foreach (array('module', 'theme') as $type) { - foreach (array('install', 'uninstall') as $op) { + foreach (['module', 'theme'] as $type) { + foreach (['install', 'uninstall'] as $op) { $unprocessed = $this->getUnprocessedExtensions($type); if (!empty($unprocessed[$op])) { - return array( + return [ 'op' => $op, 'type' => $type, 'name' => array_shift($unprocessed[$op]), - ); + ]; } } } @@ -683,14 +683,14 @@ protected function getNextConfigurationOperation() { // The order configuration operations is processed is important. Deletes // have to come first so that recreates can work. foreach ($this->storageComparer->getAllCollectionNames() as $collection) { - foreach (array('delete', 'create', 'rename', 'update') as $op) { + foreach (['delete', 'create', 'rename', 'update'] as $op) { $config_names = $this->getUnprocessedConfiguration($op, $collection); if (!empty($config_names)) { - return array( + return [ 'op' => $op, 'name' => array_shift($config_names), 'collection' => $collection, - ); + ]; } } } @@ -716,11 +716,11 @@ public function validate() { $old_entity_type_id = $this->configManager->getEntityTypeIdByName($names['old_name']); $new_entity_type_id = $this->configManager->getEntityTypeIdByName($names['new_name']); if ($old_entity_type_id != $new_entity_type_id) { - $this->logError($this->t('Entity type mismatch on rename. @old_type not equal to @new_type for existing configuration @old_name and staged configuration @new_name.', array('@old_type' => $old_entity_type_id, '@new_type' => $new_entity_type_id, '@old_name' => $names['old_name'], '@new_name' => $names['new_name']))); + $this->logError($this->t('Entity type mismatch on rename. @old_type not equal to @new_type for existing configuration @old_name and staged configuration @new_name.', ['@old_type' => $old_entity_type_id, '@new_type' => $new_entity_type_id, '@old_name' => $names['old_name'], '@new_name' => $names['new_name']])); } // Has to be a configuration entity. if (!$old_entity_type_id) { - $this->logError($this->t('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', array('@old_name' => $names['old_name'], '@new_name' => $names['new_name']))); + $this->logError($this->t('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', ['@old_name' => $names['old_name'], '@new_name' => $names['new_name']])); } } $this->eventDispatcher->dispatch(ConfigEvents::IMPORT_VALIDATE, new ConfigImporterEvent($this)); @@ -760,7 +760,7 @@ protected function processConfiguration($collection, $op, $name) { } } catch (\Exception $e) { - $this->logError($this->t('Unexpected error during import with operation @op for @name: @message', array('@op' => $op, '@name' => $name, '@message' => $e->getMessage()))); + $this->logError($this->t('Unexpected error during import with operation @op for @name: @message', ['@op' => $op, '@name' => $name, '@message' => $e->getMessage()])); // Error for that operation was logged, mark it as processed so that // the import can continue. $this->setProcessedConfiguration($collection, $op, $name); @@ -783,7 +783,7 @@ protected function processExtension($type, $op, $name) { \Drupal::service('config.installer') ->setSourceStorage($this->storageComparer->getSourceStorage()); if ($type == 'module') { - $this->moduleInstaller->$op(array($name), FALSE); + $this->moduleInstaller->$op([$name], FALSE); // Installing a module can cause a kernel boot therefore reinject all the // services. $this->reInjectMe(); @@ -803,7 +803,7 @@ protected function processExtension($type, $op, $name) { $this->configManager->getConfigFactory()->reset('system.theme'); $this->processedSystemTheme = TRUE; } - $this->themeHandler->$op(array($name)); + $this->themeHandler->$op([$name]); } $this->setProcessedExtension($type, $op, $name); @@ -863,11 +863,11 @@ protected function checkOp($collection, $op, $name) { $entity_type = $this->configManager->getEntityManager()->getDefinition($entity_type_id); $entity = $entity_storage->load($entity_storage->getIDFromConfigName($name, $entity_type->getConfigPrefix())); $entity->delete(); - $this->logError($this->t('Deleted and replaced configuration entity "@name"', array('@name' => $name))); + $this->logError($this->t('Deleted and replaced configuration entity "@name"', ['@name' => $name])); } else { $this->storageComparer->getTargetStorage($collection)->delete($name); - $this->logError($this->t('Deleted and replaced configuration "@name"', array('@name' => $name))); + $this->logError($this->t('Deleted and replaced configuration "@name"', ['@name' => $name])); } return TRUE; } @@ -875,7 +875,7 @@ protected function checkOp($collection, $op, $name) { case 'update': if (!$target_exists) { - $this->logError($this->t('Update target "@name" is missing.', array('@name' => $name))); + $this->logError($this->t('Update target "@name" is missing.', ['@name' => $name])); // Mark as processed so that the synchronization continues. Once the // the current synchronization is complete it will show up as a // create. @@ -912,7 +912,7 @@ protected function importConfig($collection, $op, $name) { } else { $data = $this->storageComparer->getSourceStorage($collection)->read($name); - $config->setData($data ? $data : array()); + $config->setData($data ? $data : []); $config->save(); } $this->setProcessedConfiguration($collection, $op, $name); @@ -1037,7 +1037,7 @@ public function alreadyImporting() { * keep the services used by the importer in sync. */ protected function reInjectMe() { - $this->_serviceIds = array(); + $this->_serviceIds = []; $vars = get_object_vars($this); foreach ($vars as $key => $value) { if (is_object($value) && isset($value->_serviceId)) { diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php index 97c3688..826312c 100644 --- a/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -416,7 +416,7 @@ public function isSyncing() { * collection. */ protected function findPreExistingConfiguration(StorageInterface $storage) { - $existing_configuration = array(); + $existing_configuration = []; // Gather information about all the supported collections. $collection_info = $this->configManager->getConfigCollectionInfo(); diff --git a/core/lib/Drupal/Core/Config/ConfigManager.php b/core/lib/Drupal/Core/Config/ConfigManager.php index f00fcd4..ad71261 100644 --- a/core/lib/Drupal/Core/Config/ConfigManager.php +++ b/core/lib/Drupal/Core/Config/ConfigManager.php @@ -148,17 +148,17 @@ public function diff(StorageInterface $source_storage, StorageInterface $target_ $target_data = explode("\n", Yaml::encode($target_storage->read($target_name))); // Check for new or removed files. - if ($source_data === array('false')) { + if ($source_data === ['false']) { // Added file. // Cast the result of t() to a string, as the diff engine doesn't know // about objects. - $source_data = array((string) $this->t('File added')); + $source_data = [(string) $this->t('File added')]; } - if ($target_data === array('false')) { + if ($target_data === ['false']) { // Deleted file. // Cast the result of t() to a string, as the diff engine doesn't know // about objects. - $target_data = array((string) $this->t('File removed')); + $target_data = [(string) $this->t('File removed')]; } return new Diff($source_data, $target_data); @@ -251,7 +251,7 @@ public function findConfigEntityDependents($type, array $names, ConfigDependency if (!$dependency_manager) { $dependency_manager = $this->getConfigDependencyManager(); } - $dependencies = array(); + $dependencies = []; foreach ($names as $name) { $dependencies = array_merge($dependencies, $dependency_manager->getDependentEntities($type, $name)); } @@ -263,7 +263,7 @@ public function findConfigEntityDependents($type, array $names, ConfigDependency */ public function findConfigEntityDependentsAsEntities($type, array $names, ConfigDependencyManager $dependency_manager = NULL) { $dependencies = $this->findConfigEntityDependents($type, $names, $dependency_manager); - $entities = array(); + $entities = []; $definitions = $this->entityManager->getDefinitions(); foreach ($dependencies as $config_name => $dependency) { // Group by entity type to efficient load entities using @@ -278,7 +278,7 @@ public function findConfigEntityDependentsAsEntities($type, array $names, Config $entities[$entity_type_id][] = $id; } } - $entities_to_return = array(); + $entities_to_return = []; foreach ($entities as $entity_type_id => $entities_to_load) { $storage = $this->entityManager->getStorage($entity_type_id); // Remove the keys since there are potential ID clashes from different @@ -403,12 +403,12 @@ protected function callOnDependencyRemoval(ConfigEntityInterface $entity, array return FALSE; } - $affected_dependencies = array( - 'config' => array(), - 'content' => array(), - 'module' => array(), - 'theme' => array(), - ); + $affected_dependencies = [ + 'config' => [], + 'content' => [], + 'module' => [], + 'theme' => [], + ]; // Work out if any of the entity's dependencies are going to be affected. if (isset($entity_dependencies[$type])) { @@ -457,8 +457,8 @@ protected function callOnDependencyRemoval(ConfigEntityInterface $entity, array * {@inheritdoc} */ public function findMissingContentDependencies() { - $content_dependencies = array(); - $missing_dependencies = array(); + $content_dependencies = []; + $missing_dependencies = []; foreach ($this->activeStorage->readMultiple($this->activeStorage->listAll()) as $config_data) { if (isset($config_data['dependencies']['content'])) { $content_dependencies = array_merge($content_dependencies, $config_data['dependencies']['content']); @@ -471,11 +471,11 @@ public function findMissingContentDependencies() { // Format of the dependency is entity_type:bundle:uuid. list($entity_type, $bundle, $uuid) = explode(':', $content_dependency, 3); if (!$this->entityManager->loadEntityByUuid($entity_type, $uuid)) { - $missing_dependencies[$uuid] = array( + $missing_dependencies[$uuid] = [ 'entity_type' => $entity_type, 'bundle' => $bundle, 'uuid' => $uuid, - ); + ]; } } return $missing_dependencies; diff --git a/core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php b/core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php index a8a42c5..6f1efc9 100644 --- a/core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php +++ b/core/lib/Drupal/Core/Config/ConfigModuleOverridesEvent.php @@ -43,7 +43,7 @@ class ConfigModuleOverridesEvent extends Event { public function __construct(array $names, LanguageInterface $language = NULL) { $this->names = $names; $this->language = $language; - $this->overrides = array(); + $this->overrides = []; } /** @@ -91,7 +91,7 @@ public function setOverride($name, array $values) { if (isset($this->overrides[$name])) { // Existing overrides take precedence since these will have been added // by events with a higher priority. - $this->overrides[$name] = NestedArray::mergeDeepArray(array($values, $this->overrides[$name]), TRUE); + $this->overrides[$name] = NestedArray::mergeDeepArray([$values, $this->overrides[$name]], TRUE); } else { $this->overrides[$name] = $values; diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php index 4e0c184..1368dff 100644 --- a/core/lib/Drupal/Core/Config/DatabaseStorage.php +++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php @@ -32,7 +32,7 @@ class DatabaseStorage implements StorageInterface { * * @var array */ - protected $options = array(); + protected $options = []; /** * The storage collection. @@ -54,7 +54,7 @@ class DatabaseStorage implements StorageInterface { * (optional) The collection to store configuration in. Defaults to the * default collection. */ - public function __construct(Connection $connection, $table, array $options = array(), $collection = StorageInterface::DEFAULT_COLLECTION) { + public function __construct(Connection $connection, $table, array $options = [], $collection = StorageInterface::DEFAULT_COLLECTION) { $this->connection = $connection; $this->table = $table; $this->options = $options; @@ -66,10 +66,10 @@ public function __construct(Connection $connection, $table, array $options = arr */ public function exists($name) { try { - return (bool) $this->connection->queryRange('SELECT 1 FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :name', 0, 1, array( + return (bool) $this->connection->queryRange('SELECT 1 FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :name', 0, 1, [ ':collection' => $this->collection, ':name' => $name, - ), $this->options)->fetchField(); + ], $this->options)->fetchField(); } catch (\Exception $e) { // If we attempt a read without actually having the database or the table @@ -84,7 +84,7 @@ public function exists($name) { public function read($name) { $data = FALSE; try { - $raw = $this->connection->query('SELECT data FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :name', array(':collection' => $this->collection, ':name' => $name), $this->options)->fetchField(); + $raw = $this->connection->query('SELECT data FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :name', [':collection' => $this->collection, ':name' => $name], $this->options)->fetchField(); if ($raw !== FALSE) { $data = $this->decode($raw); } @@ -100,9 +100,9 @@ public function read($name) { * {@inheritdoc} */ public function readMultiple(array $names) { - $list = array(); + $list = []; try { - $list = $this->connection->query('SELECT name, data FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name IN ( :names[] )', array(':collection' => $this->collection, ':names[]' => $names), $this->options)->fetchAllKeyed(); + $list = $this->connection->query('SELECT name, data FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name IN ( :names[] )', [':collection' => $this->collection, ':names[]' => $names], $this->options)->fetchAllKeyed(); foreach ($list as &$data) { $data = $this->decode($data); } @@ -143,10 +143,10 @@ public function write($name, array $data) { * @return bool */ protected function doWrite($name, $data) { - $options = array('return' => Database::RETURN_AFFECTED) + $this->options; + $options = ['return' => Database::RETURN_AFFECTED] + $this->options; return (bool) $this->connection->merge($this->table, $options) - ->keys(array('collection', 'name'), array($this->collection, $name)) - ->fields(array('data' => $data)) + ->keys(['collection', 'name'], [$this->collection, $name]) + ->fields(['data' => $data]) ->execute(); } @@ -182,32 +182,32 @@ protected function ensureTableExists() { * Defines the schema for the configuration table. */ protected static function schemaDefinition() { - $schema = array( + $schema = [ 'description' => 'The base table for configuration data.', - 'fields' => array( - 'collection' => array( + 'fields' => [ + 'collection' => [ 'description' => 'Primary Key: Config object collection.', 'type' => 'varchar_ascii', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), - 'name' => array( + ], + 'name' => [ 'description' => 'Primary Key: Config object name.', 'type' => 'varchar_ascii', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), - 'data' => array( + ], + 'data' => [ 'description' => 'A serialized configuration object data.', 'type' => 'blob', 'not null' => FALSE, 'size' => 'big', - ), - ), - 'primary key' => array('collection', 'name'), - ); + ], + ], + 'primary key' => ['collection', 'name'], + ]; return $schema; } @@ -219,7 +219,7 @@ protected static function schemaDefinition() { * @todo Ignore replica targets for data manipulation operations. */ public function delete($name) { - $options = array('return' => Database::RETURN_AFFECTED) + $this->options; + $options = ['return' => Database::RETURN_AFFECTED] + $this->options; return (bool) $this->connection->delete($this->table, $options) ->condition('collection', $this->collection) ->condition('name', $name) @@ -233,9 +233,9 @@ public function delete($name) { * @throws PDOException */ public function rename($name, $new_name) { - $options = array('return' => Database::RETURN_AFFECTED) + $this->options; + $options = ['return' => Database::RETURN_AFFECTED] + $this->options; return (bool) $this->connection->update($this->table, $options) - ->fields(array('name' => $new_name)) + ->fields(['name' => $new_name]) ->condition('name', $name) ->condition('collection', $this->collection) ->execute(); @@ -266,14 +266,14 @@ public function decode($raw) { public function listAll($prefix = '') { try { $query = $this->connection->select($this->table); - $query->fields($this->table, array('name')); + $query->fields($this->table, ['name']); $query->condition('collection', $this->collection, '='); $query->condition('name', $prefix . '%', 'LIKE'); $query->orderBy('collection')->orderBy('name'); return $query->execute()->fetchCol(); } catch (\Exception $e) { - return array(); + return []; } } @@ -282,7 +282,7 @@ public function listAll($prefix = '') { */ public function deleteAll($prefix = '') { try { - $options = array('return' => Database::RETURN_AFFECTED) + $this->options; + $options = ['return' => Database::RETURN_AFFECTED] + $this->options; return (bool) $this->connection->delete($this->table, $options) ->condition('name', $prefix . '%', 'LIKE') ->condition('collection', $this->collection) @@ -317,12 +317,12 @@ public function getCollectionName() { */ public function getAllCollectionNames() { try { - return $this->connection->query('SELECT DISTINCT collection FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection <> :collection ORDER by collection', array( - ':collection' => StorageInterface::DEFAULT_COLLECTION) + return $this->connection->query('SELECT DISTINCT collection FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection <> :collection ORDER by collection', [ + ':collection' => StorageInterface::DEFAULT_COLLECTION] )->fetchCol(); } catch (\Exception $e) { - return array(); + return []; } } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyDeleteFormTrait.php b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyDeleteFormTrait.php index 44c02e3..2ec87dd 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyDeleteFormTrait.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyDeleteFormTrait.php @@ -17,7 +17,7 @@ * * Provided by \Drupal\Core\StringTranslation\StringTranslationTrait. */ - abstract protected function t($string, array $args = array(), array $options = array()); + abstract protected function t($string, array $args = [], array $options = []); /** * Adds form elements to list affected configuration entities. @@ -41,15 +41,15 @@ protected function addDependencyListsToForm(array &$form, $type, array $names, ConfigManagerInterface $config_manager, EntityManagerInterface $entity_manager) { // Get the dependent entities. $dependent_entities = $config_manager->getConfigEntitiesToChangeOnDependencyRemoval($type, $names); - $entity_types = array(); + $entity_types = []; - $form['entity_updates'] = array( + $form['entity_updates'] = [ '#type' => 'details', '#title' => $this->t('Configuration updates'), '#description' => $this->t('The listed configuration will be updated.'), '#open' => TRUE, '#access' => FALSE, - ); + ]; foreach ($dependent_entities['update'] as $entity) { /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */ @@ -59,11 +59,11 @@ protected function addDependencyListsToForm(array &$form, $type, array $names, C // Store the ID and label to sort the entity types and entities later. $label = $entity_type->getLabel(); $entity_types[$entity_type_id] = $label; - $form['entity_updates'][$entity_type_id] = array( + $form['entity_updates'][$entity_type_id] = [ '#theme' => 'item_list', '#title' => $label, - '#items' => array(), - ); + '#items' => [], + ]; } $form['entity_updates'][$entity_type_id]['#items'][$entity->id()] = $entity->label() ?: $entity->id(); } @@ -81,13 +81,13 @@ protected function addDependencyListsToForm(array &$form, $type, array $names, C } } - $form['entity_deletes'] = array( + $form['entity_deletes'] = [ '#type' => 'details', '#title' => $this->t('Configuration deletions'), '#description' => $this->t('The listed configuration will be deleted.'), '#open' => TRUE, '#access' => FALSE, - ); + ]; foreach ($dependent_entities['delete'] as $entity) { $entity_type_id = $entity->getEntityTypeId(); @@ -96,11 +96,11 @@ protected function addDependencyListsToForm(array &$form, $type, array $names, C // Store the ID and label to sort the entity types and entities later. $label = $entity_type->getLabel(); $entity_types[$entity_type_id] = $label; - $form['entity_deletes'][$entity_type_id] = array( + $form['entity_deletes'][$entity_type_id] = [ '#theme' => 'item_list', '#title' => $label, - '#items' => array(), - ); + '#items' => [], + ]; } $form['entity_deletes'][$entity_type_id]['#items'][$entity->id()] = $entity->label() ?: $entity->id(); } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php index ef522ad..9dc02c0 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php @@ -126,7 +126,7 @@ class ConfigDependencyManager { * * @var \Drupal\Core\Config\Entity\ConfigEntityDependency[] */ - protected $data = array(); + protected $data = []; /** * The directed acyclic graph. @@ -150,9 +150,9 @@ class ConfigDependencyManager { * An array of config entity dependency objects that are dependent. */ public function getDependentEntities($type, $name) { - $dependent_entities = array(); + $dependent_entities = []; - $entities_to_check = array(); + $entities_to_check = []; if ($type == 'config') { $entities_to_check[] = $name; } @@ -174,7 +174,7 @@ public function getDependentEntities($type, $name) { // always after field storages. This is because field storages need to be // created before a field. $graph = $this->getGraph(); - uasort($graph, array($this, 'sortGraph')); + uasort($graph, [$this, 'sortGraph']); return array_replace(array_intersect_key($graph, $dependencies), $dependencies); } @@ -189,7 +189,7 @@ public function sortAll() { $graph = $this->getGraph(); // Sort by weight and alphabetically. The most dependent entities // are last and entities with the same weight are alphabetically ordered. - uasort($graph, array($this, 'sortGraphByWeight')); + uasort($graph, [$this, 'sortGraphByWeight']); // Use array_intersect_key() to exclude modules and themes from the list. return array_keys(array_intersect_key($graph, $this->data)); } @@ -248,7 +248,7 @@ public static function sortGraph(array $a, array $b) { * supplied entities to check. */ protected function createGraphConfigEntityDependencies($entities_to_check) { - $dependent_entities = array(); + $dependent_entities = []; $graph = $this->getGraph(); foreach ($entities_to_check as $entity) { @@ -271,7 +271,7 @@ protected function createGraphConfigEntityDependencies($entities_to_check) { */ protected function getGraph() { if (!isset($this->graph)) { - $graph = array(); + $graph = []; foreach ($this->data as $entity) { $graph_key = $entity->getConfigDependencyName(); if (!isset($graph[$graph_key])) { diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 08e7e19..90bb702 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -86,7 +86,7 @@ * * @var array */ - protected $third_party_settings = array(); + protected $third_party_settings = []; /** * Information maintained by Drupal core about configuration. @@ -263,7 +263,7 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) * {@inheritdoc} */ public function toArray() { - $properties = array(); + $properties = []; /** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type */ $entity_type = $this->getEntityType(); @@ -411,7 +411,7 @@ public function urlInfo($rel = 'edit-form', array $options = []) { /** * {@inheritdoc} */ - public function url($rel = 'edit-form', $options = array()) { + public function url($rel = 'edit-form', $options = []) { // Do not remove this override: the default value of $rel is different. return parent::url($rel, $options); } @@ -551,7 +551,7 @@ public function getThirdPartySetting($module, $key, $default = NULL) { * {@inheritdoc} */ public function getThirdPartySettings($module) { - return isset($this->third_party_settings[$module]) ? $this->third_party_settings[$module] : array(); + return isset($this->third_party_settings[$module]) ? $this->third_party_settings[$module] : []; } /** diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php index dc17e05..59128d8 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php @@ -109,7 +109,7 @@ protected function loadDisplays($entity_type_id) { $storage = $this->entityManager()->getStorage($entity_type_id); return $storage->loadMultiple($ids); } - return array(); + return []; } } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php index 1b9a80e..d92b55b 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityDependency.php @@ -57,7 +57,7 @@ public function __construct($name, $values = []) { * The list of dependencies of the supplied type. */ public function getDependencies($type) { - $dependencies = array(); + $dependencies = []; if (isset($this->dependencies[$type])) { $dependencies = $this->dependencies[$type]; } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php index acd9d03..38b7fa8 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php @@ -21,7 +21,7 @@ public function load() { // Sort the entities using the entity class's sort() method. // See \Drupal\Core\Config\Entity\ConfigEntityBase::sort(). - uasort($entities, array($this->entityType->getClass(), 'sort')); + uasort($entities, [$this->entityType->getClass(), 'sort']); return $entities; } @@ -34,18 +34,18 @@ public function getDefaultOperations(EntityInterface $entity) { if ($this->entityType->hasKey('status')) { if (!$entity->status() && $entity->hasLinkTemplate('enable')) { - $operations['enable'] = array( + $operations['enable'] = [ 'title' => t('Enable'), 'weight' => -10, 'url' => $entity->urlInfo('enable'), - ); + ]; } elseif ($entity->hasLinkTemplate('disable')) { - $operations['disable'] = array( + $operations['disable'] = [ 'title' => t('Disable'), 'weight' => 40, 'url' => $entity->urlInfo('disable'), - ); + ]; } } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php index 3834dae..11b66fc 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php @@ -84,7 +84,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora * @var array * @see \Drupal\Core\Config\ConfigFactoryInterface::getCacheKeys(). */ - protected $entities = array(); + protected $entities = []; /** * Determines if the underlying configuration is retrieved override free. @@ -170,7 +170,7 @@ protected function doLoadMultiple(array $ids = NULL) { $names = $this->configFactory->listAll($prefix); } else { - $names = array(); + $names = []; foreach ($ids as $id) { // Add the prefix to the ID to serve as the configuration object name. $names[] = $prefix . $id; @@ -220,7 +220,7 @@ protected function doLoadMultiple(array $ids = NULL) { */ protected function doCreate(array $values) { // Set default language to current language if not provided. - $values += array($this->langcodeKey => $this->languageManager->getCurrentLanguage()->getId()); + $values += [$this->langcodeKey => $this->languageManager->getCurrentLanguage()->getId()]; $entity = new $this->entityClass($values, $this->entityTypeId); return $entity; @@ -282,7 +282,7 @@ protected function doSave($id, EntityInterface $entity) { // Update the entity with the values stored in configuration. It is possible // that configuration schema has casted some of the values. if (!$entity->hasTrustedData()) { - $data = $this->mapFromStorageRecords(array($config->get())); + $data = $this->mapFromStorageRecords([$config->get()]); $updated_entity = current($data); foreach (array_keys($config->get()) as $property) { @@ -326,7 +326,7 @@ protected function has($id, EntityInterface $entity) { * Array of entities from the entity cache. */ protected function getFromStaticCache(array $ids) { - $entities = array(); + $entities = []; // Load any available entities from the internal cache. if ($this->entityType->isStaticallyCacheable() && !empty($this->entities)) { $config_overrides_key = $this->overrideFree ? '' : implode(':', $this->configFactory->getCacheKeys()); @@ -366,9 +366,9 @@ protected function setStaticCache(array $entities) { */ protected function invokeHook($hook, EntityInterface $entity) { // Invoke the hook. - $this->moduleHandler->invokeAll($this->entityTypeId . '_' . $hook, array($entity)); + $this->moduleHandler->invokeAll($this->entityTypeId . '_' . $hook, [$entity]); // Invoke the respective entity-level hook. - $this->moduleHandler->invokeAll('entity_' . $hook, array($entity, $this->entityTypeId)); + $this->moduleHandler->invokeAll('entity_' . $hook, [$entity, $this->entityTypeId]); } /** @@ -449,7 +449,7 @@ protected function _doCreateFromStorageRecord(array $values, $is_syncing = FALSE if ($this->uuidKey && $this->uuidService && !isset($values[$this->uuidKey])) { $values[$this->uuidKey] = $this->uuidService->generate(); } - $data = $this->mapFromStorageRecords(array($values)); + $data = $this->mapFromStorageRecords([$values]); $entity = current($data); $entity->original = clone $entity; $entity->setSyncing($is_syncing); @@ -469,7 +469,7 @@ protected function _doCreateFromStorageRecord(array $values, $is_syncing = FALSE public function updateFromStorageRecord(ConfigEntityInterface $entity, array $values) { $entity->original = clone $entity; - $data = $this->mapFromStorageRecords(array($values)); + $data = $this->mapFromStorageRecords([$values]); $updated_entity = current($data); foreach (array_keys($values) as $property) { diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php index 1a36427..11c9ff1 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php @@ -64,9 +64,9 @@ public function __construct($definition) { // Always add a default 'uuid' key. $this->entity_keys['uuid'] = 'uuid'; $this->entity_keys['langcode'] = 'langcode'; - $this->handlers += array( + $this->handlers += [ 'storage' => 'Drupal\Core\Config\Entity\ConfigEntityStorage', - ); + ]; $this->lookup_keys[] = 'uuid'; } diff --git a/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php b/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php index dc0ac92..97e6ea5 100644 --- a/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php +++ b/core/lib/Drupal/Core/Config/Entity/DraggableListBuilder.php @@ -25,7 +25,7 @@ * * @var \Drupal\Core\Entity\EntityInterface[] */ - protected $entities = array(); + protected $entities = []; /** * Name of the entity's weight field or FALSE if no field is provided. @@ -57,7 +57,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter * {@inheritdoc} */ public function buildHeader() { - $header = array(); + $header = []; if (!empty($this->weightKey)) { $header['weight'] = t('Weight'); } @@ -68,19 +68,19 @@ public function buildHeader() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row = array(); + $row = []; if (!empty($this->weightKey)) { // Override default values to markup elements. $row['#attributes']['class'][] = 'draggable'; $row['#weight'] = $entity->get($this->weightKey); // Add weight column. - $row['weight'] = array( + $row['weight'] = [ '#type' => 'weight', - '#title' => t('Weight for @title', array('@title' => $entity->label())), + '#title' => t('Weight for @title', ['@title' => $entity->label()]), '#title_display' => 'invisible', '#default_value' => $entity->get($this->weightKey), - '#attributes' => array('class' => array('weight')), - ); + '#attributes' => ['class' => ['weight']], + ]; } return $row + parent::buildRow($entity); } @@ -99,18 +99,18 @@ public function render() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $form[$this->entitiesKey] = array( + $form[$this->entitiesKey] = [ '#type' => 'table', '#header' => $this->buildHeader(), - '#empty' => t('There is no @label yet.', array('@label' => $this->entityType->getLabel())), - '#tabledrag' => array( - array( + '#empty' => t('There is no @label yet.', ['@label' => $this->entityType->getLabel()]), + '#tabledrag' => [ + [ 'action' => 'order', 'relationship' => 'sibling', 'group' => 'weight', - ), - ), - ); + ], + ], + ]; $this->entities = $this->load(); $delta = 10; @@ -124,7 +124,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { foreach ($this->entities as $entity) { $row = $this->buildRow($entity); if (isset($row['label'])) { - $row['label'] = array('#markup' => $row['label']); + $row['label'] = ['#markup' => $row['label']]; } if (isset($row['weight'])) { $row['weight']['#delta'] = $delta; @@ -133,11 +133,11 @@ public function buildForm(array $form, FormStateInterface $form_state) { } $form['actions']['#type'] = 'actions'; - $form['actions']['submit'] = array( + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => t('Save'), '#button_type' => 'primary', - ); + ]; return $form; } diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Condition.php b/core/lib/Drupal/Core/Config/Entity/Query/Condition.php index c7e993d..6764d01 100644 --- a/core/lib/Drupal/Core/Config/Entity/Query/Condition.php +++ b/core/lib/Drupal/Core/Config/Entity/Query/Condition.php @@ -19,8 +19,8 @@ class Condition extends ConditionBase { */ public function compile($configs) { $and = strtoupper($this->conjunction) == 'AND'; - $single_conditions = array(); - $condition_groups = array(); + $single_conditions = []; + $condition_groups = []; foreach ($this->conditions as $condition) { if ($condition['field'] instanceof ConditionInterface) { $condition_groups[] = $condition; @@ -41,7 +41,7 @@ public function compile($configs) { $single_conditions[] = $condition; } } - $return = array(); + $return = []; if ($single_conditions) { foreach ($configs as $config_name => $config) { foreach ($single_conditions as $condition) { @@ -110,7 +110,7 @@ public function notExists($field, $langcode = NULL) { * @return bool * TRUE when the condition matched to the data else FALSE. */ - protected function matchArray(array $condition, array $data, array $needs_matching, array $parents = array()) { + protected function matchArray(array $condition, array $data, array $needs_matching, array $parents = []) { $parent = array_shift($needs_matching); if ($parent === '*') { $candidates = array_keys($data); @@ -120,7 +120,7 @@ protected function matchArray(array $condition, array $data, array $needs_matchi if (!isset($data[$parent])) { $data[$parent] = NULL; } - $candidates = array($parent); + $candidates = [$parent]; } foreach ($candidates as $key) { if ($needs_matching) { diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Query.php b/core/lib/Drupal/Core/Config/Entity/Query/Query.php index eee073f..e75b98a 100644 --- a/core/lib/Drupal/Core/Config/Entity/Query/Query.php +++ b/core/lib/Drupal/Core/Config/Entity/Query/Query.php @@ -141,7 +141,7 @@ protected function loadRecords() { elseif (in_array($condition['field'], $lookup_keys)) { // If we don't find anything then there are no matches. No point in // listing anything. - $names = array(); + $names = []; $keys = (array) $condition['value']; $keys = array_map(function ($value) use ($condition) { return $condition['field'] . ':' . $value; @@ -208,7 +208,7 @@ protected function loadRecords() { } // Load the corresponding records. - $records = array(); + $records = []; foreach ($this->configFactory->loadMultiple($names) as $config) { $records[substr($config->getName(), $prefix_length)] = $config->get(); } diff --git a/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php b/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php index 4396a39..5667ab2 100644 --- a/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php +++ b/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php @@ -163,7 +163,7 @@ protected function getKeys(Config $config, $key, $get_method, ConfigEntityTypeIn $values = (array) $this->getValues($config, $parts[0], $get_method, $parts); - $output = array(); + $output = []; // Flatten the array to a single dimension and add the key to all the // values. array_walk_recursive($values, function ($current) use (&$output, $key) { @@ -250,8 +250,8 @@ public function onConfigDelete(ConfigCrudEvent $event) { * {@inheritdoc} */ static function getSubscribedEvents() { - $events[ConfigEvents::SAVE][] = array('onConfigSave', 128); - $events[ConfigEvents::DELETE][] = array('onConfigDelete', 128); + $events[ConfigEvents::SAVE][] = ['onConfigSave', 128]; + $events[ConfigEvents::DELETE][] = ['onConfigDelete', 128]; return $events; } diff --git a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php index 14e80dd..f435379 100644 --- a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php +++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php @@ -74,7 +74,7 @@ public function createCollection($collection) { */ protected function getAllFolders() { if (!isset($this->folders)) { - $this->folders = array(); + $this->folders = []; $this->folders += $this->getCoreNames(); $install_profile = Settings::get('install_profile'); @@ -95,7 +95,7 @@ protected function getAllFolders() { drupal_get_filename('profile', $profile, $profile_list[$profile]->getPathname()); } $module_list_scan = $listing->scan('module'); - $module_list = array(); + $module_list = []; foreach (array_keys($modules) as $module) { if (isset($module_list_scan[$module])) { $module_list[$module] = $module_list_scan[$module]; @@ -122,7 +122,7 @@ protected function getAllFolders() { $profile_list = $listing->scan('profile'); } if (isset($profile_list[$profile])) { - $profile_folders = $this->getComponentNames(array($profile_list[$profile])); + $profile_folders = $this->getComponentNames([$profile_list[$profile]]); $this->folders = $profile_folders + $this->folders; } } diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php index 4904576..84d23d3 100644 --- a/core/lib/Drupal/Core/Config/FileStorage.php +++ b/core/lib/Drupal/Core/Config/FileStorage.php @@ -125,7 +125,7 @@ public function read($name) { * {@inheritdoc} */ public function readMultiple(array $names) { - $list = array(); + $list = []; foreach ($names as $name) { if ($data = $this->read($name)) { $list[$name] = $data; @@ -217,7 +217,7 @@ public function decode($raw) { public function listAll($prefix = '') { $dir = $this->getCollectionDirectory(); if (!is_dir($dir)) { - return array(); + return []; } $extension = '.' . static::getFileExtension(); @@ -227,7 +227,7 @@ public function listAll($prefix = '') { // @see https://github.com/mikey179/vfsStream/issues/2 $files = scandir($dir); - $names = array(); + $names = []; $pattern = '/^' . preg_quote($prefix, '/') . '.*' . preg_quote($extension, '/') . '$/'; foreach ($files as $file) { if ($file[0] !== '.' && preg_match($pattern, $file)) { @@ -311,7 +311,7 @@ public function getAllCollectionNames() { * A list of collection names contained within the provided directory. */ protected function getAllCollectionNamesHelper($directory) { - $collections = array(); + $collections = []; $pattern = '/\.' . preg_quote($this->getFileExtension(), '/') . '$/'; foreach (new \DirectoryIterator($directory) as $fileinfo) { if ($fileinfo->isDir() && !$fileinfo->isDot()) { diff --git a/core/lib/Drupal/Core/Config/Importer/FinalMissingContentSubscriber.php b/core/lib/Drupal/Core/Config/Importer/FinalMissingContentSubscriber.php index 9def6df..3dca3fb 100644 --- a/core/lib/Drupal/Core/Config/Importer/FinalMissingContentSubscriber.php +++ b/core/lib/Drupal/Core/Config/Importer/FinalMissingContentSubscriber.php @@ -33,7 +33,7 @@ public function onMissingContent(MissingContentEvent $event) { public static function getSubscribedEvents() { // This should always be the final event as it will mark all content // dependencies as resolved. - $events[ConfigEvents::IMPORT_MISSING_CONTENT][] = array('onMissingContent', -1024); + $events[ConfigEvents::IMPORT_MISSING_CONTENT][] = ['onMissingContent', -1024]; return $events; } diff --git a/core/lib/Drupal/Core/Config/InstallStorage.php b/core/lib/Drupal/Core/Config/InstallStorage.php index bd9bf30..9fea3df 100644 --- a/core/lib/Drupal/Core/Config/InstallStorage.php +++ b/core/lib/Drupal/Core/Config/InstallStorage.php @@ -131,7 +131,7 @@ public function listAll($prefix = '') { return $names; } else { - $return = array(); + $return = []; foreach ($names as $index => $name) { if (strpos($name, $prefix) === 0 ) { $return[$index] = $names[$index]; @@ -149,7 +149,7 @@ public function listAll($prefix = '') { */ protected function getAllFolders() { if (!isset($this->folders)) { - $this->folders = array(); + $this->folders = []; $this->folders += $this->getCoreNames(); // Perform an ExtensionDiscovery scan as we cannot use drupal_get_path() // yet because the system module may not yet be enabled during install. @@ -163,7 +163,7 @@ protected function getAllFolders() { // during the module scan. // @todo Remove as part of https://www.drupal.org/node/2186491 drupal_get_filename('profile', $profile, $profile_list[$profile]->getPathname()); - $this->folders += $this->getComponentNames(array($profile_list[$profile])); + $this->folders += $this->getComponentNames([$profile_list[$profile]]); } } // @todo Remove as part of https://www.drupal.org/node/2186491 @@ -185,7 +185,7 @@ protected function getAllFolders() { public function getComponentNames(array $list) { $extension = '.' . $this->getFileExtension(); $pattern = '/' . preg_quote($extension, '/') . '$/'; - $folders = array(); + $folders = []; foreach ($list as $extension_object) { // We don't have to use ExtensionDiscovery here because our list of // extensions was already obtained through an ExtensionDiscovery scan. @@ -216,7 +216,7 @@ public function getComponentNames(array $list) { public function getCoreNames() { $extension = '.' . $this->getFileExtension(); $pattern = '/' . preg_quote($extension, '/') . '$/'; - $folders = array(); + $folders = []; $directory = $this->getCoreFolder(); if (is_dir($directory)) { // glob() directly calls into libc glob(), which is not aware of PHP diff --git a/core/lib/Drupal/Core/Config/NullStorage.php b/core/lib/Drupal/Core/Config/NullStorage.php index 7966033..0dd1473 100644 --- a/core/lib/Drupal/Core/Config/NullStorage.php +++ b/core/lib/Drupal/Core/Config/NullStorage.php @@ -29,14 +29,14 @@ public function exists($name) { * {@inheritdoc} */ public function read($name) { - return array(); + return []; } /** * {@inheritdoc} */ public function readMultiple(array $names) { - return array(); + return []; } /** @@ -78,7 +78,7 @@ public function decode($raw) { * {@inheritdoc} */ public function listAll($prefix = '') { - return array(); + return []; } /** @@ -99,7 +99,7 @@ public function createCollection($collection) { * {@inheritdoc} */ public function getAllCollectionNames() { - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Config/PreExistingConfigException.php b/core/lib/Drupal/Core/Config/PreExistingConfigException.php index 4c19dfa..57f54b2 100644 --- a/core/lib/Drupal/Core/Config/PreExistingConfigException.php +++ b/core/lib/Drupal/Core/Config/PreExistingConfigException.php @@ -57,10 +57,10 @@ public function getExtension() { */ public static function create($extension, array $config_objects) { $message = SafeMarkup::format('Configuration objects (@config_names) provided by @extension already exist in active configuration', - array( + [ '@config_names' => implode(', ', static::flattenConfigObjects($config_objects)), '@extension' => $extension - ) + ] ); $e = new static($message); $e->configObjects = $config_objects; @@ -80,7 +80,7 @@ public static function create($extension, array $config_objects) { * collection. */ public static function flattenConfigObjects(array $config_objects) { - $flat_config_objects = array(); + $flat_config_objects = []; foreach ($config_objects as $collection => $config_names) { $config_names = array_map(function ($config_name) use ($collection) { if ($collection != StorageInterface::DEFAULT_COLLECTION) { diff --git a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php index 7fc6cc5..c507655 100644 --- a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php +++ b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php @@ -19,7 +19,7 @@ * Array of valid configuration data keys. */ protected function getAllKeys() { - return is_array($this->value) ? array_keys($this->value) : array(); + return is_array($this->value) ? array_keys($this->value) : []; } /** @@ -29,7 +29,7 @@ protected function getAllKeys() { * An array of elements contained in this element. */ protected function parse() { - $elements = array(); + $elements = []; foreach ($this->getAllKeys() as $key) { $value = isset($this->value[$key]) ? $this->value[$key] : NULL; $definition = $this->getElementDefinition($key); @@ -96,7 +96,7 @@ public function isEmpty() { * {@inheritdoc} */ public function toArray() { - return isset($this->value) ? $this->value : array(); + return isset($this->value) ? $this->value : []; } /** diff --git a/core/lib/Drupal/Core/Config/Schema/ConfigSchemaDiscovery.php b/core/lib/Drupal/Core/Config/Schema/ConfigSchemaDiscovery.php index f74cc91..b086c62 100644 --- a/core/lib/Drupal/Core/Config/Schema/ConfigSchemaDiscovery.php +++ b/core/lib/Drupal/Core/Config/Schema/ConfigSchemaDiscovery.php @@ -34,7 +34,7 @@ function __construct(StorageInterface $schema_storage) { * {@inheritdoc} */ public function getDefinitions() { - $definitions = array(); + $definitions = []; foreach ($this->schemaStorage->readMultiple($this->schemaStorage->listAll()) as $schema) { foreach ($schema as $type => $definition) { $definitions[$type] = $definition; diff --git a/core/lib/Drupal/Core/Config/Schema/Mapping.php b/core/lib/Drupal/Core/Config/Schema/Mapping.php index 2f4b58f..220a350 100644 --- a/core/lib/Drupal/Core/Config/Schema/Mapping.php +++ b/core/lib/Drupal/Core/Config/Schema/Mapping.php @@ -22,7 +22,7 @@ class Mapping extends ArrayElement { */ protected function getElementDefinition($key) { $value = isset($this->value[$key]) ? $this->value[$key] : NULL; - $definition = isset($this->definition['mapping'][$key]) ? $this->definition['mapping'][$key] : array(); + $definition = isset($this->definition['mapping'][$key]) ? $this->definition['mapping'][$key] : []; return $this->buildDataDefinition($definition, $value, $key); } diff --git a/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php b/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php index 972eda4..9230281 100644 --- a/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php +++ b/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php @@ -58,7 +58,7 @@ public function checkConfigSchema(TypedConfigManagerInterface $typed_config, $co $definition = $typed_config->getDefinition($config_name); $data_definition = $typed_config->buildDataDefinition($definition, $config_data); $this->schema = $typed_config->create($data_definition, $config_data); - $errors = array(); + $errors = []; foreach ($config_data as $key => $value) { $errors = array_merge($errors, $this->checkValue($key, $value)); } @@ -83,12 +83,12 @@ protected function checkValue($key, $value) { $error_key = $this->configName . ':' . $key; $element = $this->schema->get($key); if ($element instanceof Undefined) { - return array($error_key => 'missing schema'); + return [$error_key => 'missing schema']; } // Do not check value if it is defined to be ignored. if ($element && $element instanceof Ignore) { - return array(); + return []; } if ($element && is_scalar($value) || $value === NULL) { @@ -110,11 +110,11 @@ protected function checkValue($key, $value) { } $class = get_class($element); if (!$success) { - return array($error_key => "variable type is $type but applied schema class is $class"); + return [$error_key => "variable type is $type but applied schema class is $class"]; } } else { - $errors = array(); + $errors = []; if (!$element instanceof TraversableTypedDataInterface) { $errors[$error_key] = 'non-scalar value but not defined as an array (such as mapping or sequence)'; } @@ -131,7 +131,7 @@ protected function checkValue($key, $value) { return $errors; } // No errors found. - return array(); + return []; } } diff --git a/core/lib/Drupal/Core/Config/Schema/Sequence.php b/core/lib/Drupal/Core/Config/Schema/Sequence.php index e03427e..ce8dc1b 100644 --- a/core/lib/Drupal/Core/Config/Schema/Sequence.php +++ b/core/lib/Drupal/Core/Config/Schema/Sequence.php @@ -19,7 +19,7 @@ class Sequence extends ArrayElement { protected function getElementDefinition($key) { $value = isset($this->value[$key]) ? $this->value[$key] : NULL; // @todo: Remove BC layer for sequence with hyphen in front. https://www.drupal.org/node/2444979 - $definition = array(); + $definition = []; if (isset($this->definition['sequence'][0])) { $definition = $this->definition['sequence'][0]; } diff --git a/core/lib/Drupal/Core/Config/StorableConfigBase.php b/core/lib/Drupal/Core/Config/StorableConfigBase.php index 40a25ef..4b227c9 100644 --- a/core/lib/Drupal/Core/Config/StorableConfigBase.php +++ b/core/lib/Drupal/Core/Config/StorableConfigBase.php @@ -55,7 +55,7 @@ * * @var array */ - protected $originalData = array(); + protected $originalData = []; /** * Saves the configuration object. diff --git a/core/lib/Drupal/Core/Config/StorageComparer.php b/core/lib/Drupal/Core/Config/StorageComparer.php index bf071de..55aeebc 100644 --- a/core/lib/Drupal/Core/Config/StorageComparer.php +++ b/core/lib/Drupal/Core/Config/StorageComparer.php @@ -63,7 +63,7 @@ class StorageComparer implements StorageComparerInterface { * * @var array */ - protected $sourceNames = array(); + protected $sourceNames = []; /** * Sorted list of all the configuration object names in the target storage. @@ -72,7 +72,7 @@ class StorageComparer implements StorageComparerInterface { * * @var array */ - protected $targetNames = array(); + protected $targetNames = []; /** * A memory cache backend to statically cache source configuration data. @@ -149,12 +149,12 @@ public function getTargetStorage($collection = StorageInterface::DEFAULT_COLLECT * {@inheritdoc} */ public function getEmptyChangelist() { - return array( - 'create' => array(), - 'update' => array(), - 'delete' => array(), - 'rename' => array(), - ); + return [ + 'create' => [], + 'update' => [], + 'delete' => [], + 'rename' => [], + ]; } /** @@ -254,7 +254,7 @@ protected function addChangelistCreate($collection) { * The storage collection to operate on. */ protected function addChangelistUpdate($collection) { - $recreates = array(); + $recreates = []; foreach (array_intersect($this->sourceNames[$collection], $this->targetNames[$collection]) as $name) { $source_data = $this->getSourceStorage($collection)->read($name); $target_data = $this->getTargetStorage($collection)->read($name); @@ -266,7 +266,7 @@ protected function addChangelistUpdate($collection) { $recreates[] = $name; } else { - $this->addChangeList($collection, 'update', array($name)); + $this->addChangeList($collection, 'update', [$name]); } } } @@ -298,7 +298,7 @@ protected function addChangelistRename($collection) { return; } - $create_uuids = array(); + $create_uuids = []; foreach ($this->sourceNames[$collection] as $name) { $data = $this->getSourceStorage($collection)->read($name); if (isset($data['uuid']) && in_array($name, $create_list)) { @@ -309,7 +309,7 @@ protected function addChangelistRename($collection) { return; } - $renames = array(); + $renames = []; // Renames should be ordered so that dependencies are renamed last. This // ensures that if there is logic in the configuration entity class to keep @@ -357,15 +357,15 @@ protected function removeFromChangelist($collection, $op, $name) { public function moveRenameToUpdate($rename, $collection = StorageInterface::DEFAULT_COLLECTION) { $names = $this->extractRenameNames($rename); $this->removeFromChangelist($collection, 'rename', $rename); - $this->addChangeList($collection, 'update', array($names['new_name']), $this->sourceNames[$collection]); + $this->addChangeList($collection, 'update', [$names['new_name']], $this->sourceNames[$collection]); } /** * {@inheritdoc} */ public function reset() { - $this->changelist = array(StorageInterface::DEFAULT_COLLECTION => $this->getEmptyChangelist()); - $this->sourceNames = $this->targetNames = array(); + $this->changelist = [StorageInterface::DEFAULT_COLLECTION => $this->getEmptyChangelist()]; + $this->sourceNames = $this->targetNames = []; // Reset the static configuration data caches. $this->sourceCacheStorage->deleteAll(); $this->targetCacheStorage->deleteAll(); @@ -377,7 +377,7 @@ public function reset() { */ public function hasChanges() { foreach ($this->getAllCollectionNames() as $collection) { - foreach (array('delete', 'create', 'update', 'rename') as $op) { + foreach (['delete', 'create', 'update', 'rename'] as $op) { if (!empty($this->changelist[$collection][$op])) { return TRUE; } @@ -442,10 +442,10 @@ protected function createRenameName($name1, $name2) { */ public function extractRenameNames($name) { $names = explode('::', $name, 2); - return array( + return [ 'old_name' => $names[0], 'new_name' => $names[1], - ); + ]; } /** diff --git a/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php index e863b35..96caa84b 100644 --- a/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php +++ b/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php @@ -36,14 +36,14 @@ class ConfigSchemaChecker implements EventSubscriberInterface { * * @var array */ - protected $checked = array(); + protected $checked = []; /** * An array of config object names that are excluded from schema checking. * * @var string[] */ - protected $exclude = array(); + protected $exclude = []; /** * Constructs the ConfigSchemaChecker object. @@ -53,7 +53,7 @@ class ConfigSchemaChecker implements EventSubscriberInterface { * @param string[] $exclude * An array of config object names that are excluded from schema checking. */ - public function __construct(TypedConfigManagerInterface $typed_manager, array $exclude = array()) { + public function __construct(TypedConfigManagerInterface $typed_manager, array $exclude = []) { $this->typedManager = $typed_manager; $this->exclude = $exclude; } @@ -88,7 +88,7 @@ public function onConfigSave(ConfigCrudEvent $event) { elseif (is_array($errors)) { $text_errors = []; foreach ($errors as $key => $error) { - $text_errors[] = SafeMarkup::format('@key @error', array('@key' => $key, '@error' => $error)); + $text_errors[] = SafeMarkup::format('@key @error', ['@key' => $key, '@error' => $error]); } throw new SchemaIncompleteException("Schema errors for $name with the following errors: " . implode(', ', $text_errors)); } @@ -99,7 +99,7 @@ public function onConfigSave(ConfigCrudEvent $event) { * {@inheritdoc} */ public static function getSubscribedEvents() { - $events[ConfigEvents::SAVE][] = array('onConfigSave', 255); + $events[ConfigEvents::SAVE][] = ['onConfigSave', 255]; return $events; } diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php index 8e3ea45..f9c7dce 100644 --- a/core/lib/Drupal/Core/Config/TypedConfigManager.php +++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php @@ -79,13 +79,13 @@ public function get($name) { */ public function buildDataDefinition(array $definition, $value, $name = NULL, $parent = NULL) { // Add default values for data type and replace variables. - $definition += array('type' => 'undefined'); + $definition += ['type' => 'undefined']; $replace = []; $type = $definition['type']; if (strpos($type, ']')) { // Replace variable names in definition. - $replace = is_array($value) ? $value : array(); + $replace = is_array($value) ? $value : []; if (isset($parent)) { $replace['%parent'] = $parent; } @@ -161,7 +161,7 @@ protected function getDefinitionWithReplacements($base_plugin_id, array $replace $merge = $this->getDefinition($definition['type'], $exception_on_invalid); // Preserve integer keys on merge, so sequence item types can override // parent settings as opposed to adding unused second, third, etc. items. - $definition = NestedArray::mergeDeepArray(array($merge, $definition), TRUE); + $definition = NestedArray::mergeDeepArray([$merge, $definition], TRUE); // Replace dynamic portions of the definition type. if (!empty($replacements) && strpos($definition['type'], ']')) { @@ -176,10 +176,10 @@ protected function getDefinitionWithReplacements($base_plugin_id, array $replace $this->definitions[$type] = $definition; } // Add type and default definition class. - $definition += array( + $definition += [ 'definition_class' => '\Drupal\Core\TypedData\DataDefinition', 'type' => $type, - ); + ]; return $definition; } @@ -265,7 +265,7 @@ protected function getFallbackName($name) { protected function replaceName($name, $data) { if (preg_match_all("/\[(.*)\]/U", $name, $matches)) { // Build our list of '[value]' => replacement. - $replace = array(); + $replace = []; foreach (array_combine($matches[0], $matches[1]) as $key => $value) { $replace[$key] = $this->replaceVariable($value, $data); } diff --git a/core/lib/Drupal/Core/Config/UnmetDependenciesException.php b/core/lib/Drupal/Core/Config/UnmetDependenciesException.php index c74513c..026fbc0 100644 --- a/core/lib/Drupal/Core/Config/UnmetDependenciesException.php +++ b/core/lib/Drupal/Core/Config/UnmetDependenciesException.php @@ -76,10 +76,10 @@ public function getTranslatedMessage(TranslationInterface $string_translation, $ */ public static function create($extension, array $config_objects) { $message = SafeMarkup::format('Configuration objects (@config_names) provided by @extension have unmet dependencies', - array( + [ '@config_names' => implode(', ', $config_objects), '@extension' => $extension - ) + ] ); $e = new static($message); $e->configObjects = $config_objects; diff --git a/core/lib/Drupal/Core/Controller/ControllerResolver.php b/core/lib/Drupal/Core/Controller/ControllerResolver.php index 3a1d868..c16a087 100644 --- a/core/lib/Drupal/Core/Controller/ControllerResolver.php +++ b/core/lib/Drupal/Core/Controller/ControllerResolver.php @@ -122,7 +122,7 @@ protected function createController($controller) { $controller = $this->classResolver->getInstanceFromDefinition($class_or_service); - return array($controller, $method); + return [$controller, $method]; } /** @@ -131,7 +131,7 @@ protected function createController($controller) { protected function doGetArguments(Request $request, $controller, array $parameters) { $attributes = $request->attributes->all(); $raw_parameters = $request->attributes->has('_raw_variables') ? $request->attributes->get('_raw_variables') : []; - $arguments = array(); + $arguments = []; foreach ($parameters as $param) { if (array_key_exists($param->name, $attributes)) { $arguments[] = $attributes[$param->name]; diff --git a/core/lib/Drupal/Core/Controller/TitleResolver.php b/core/lib/Drupal/Core/Controller/TitleResolver.php index e5e5fce..954835d 100644 --- a/core/lib/Drupal/Core/Controller/TitleResolver.php +++ b/core/lib/Drupal/Core/Controller/TitleResolver.php @@ -47,11 +47,11 @@ public function getTitle(Request $request, Route $route) { $route_title = call_user_func_array($callable, $arguments); } elseif ($title = $route->getDefault('_title')) { - $options = array(); + $options = []; if ($context = $route->getDefault('_title_context')) { $options['context'] = $context; } - $args = array(); + $args = []; if (($raw_parameters = $request->attributes->get('_raw_variables'))) { foreach ($raw_parameters->all() as $key => $value) { $args['@' . $key] = $value; diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index 791bf7a..cd47523 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -50,14 +50,14 @@ * * @var array */ - protected $transactionLayers = array(); + protected $transactionLayers = []; /** * Index of what driver-specific class to use for various operations. * * @var array */ - protected $driverClasses = array(); + protected $driverClasses = []; /** * The name of the Statement class for this connection. @@ -101,7 +101,7 @@ * * @var array */ - protected $connectionOptions = array(); + protected $connectionOptions = []; /** * The schema object for this connection. @@ -117,21 +117,21 @@ * * @var array */ - protected $prefixes = array(); + protected $prefixes = []; /** * List of search values for use in prefixTables(). * * @var array */ - protected $prefixSearch = array(); + protected $prefixSearch = []; /** * List of replacement values for use in prefixTables(). * * @var array */ - protected $prefixReplace = array(); + protected $prefixReplace = []; /** * List of un-prefixed table names, keyed by prefixed table names. @@ -157,7 +157,7 @@ public function __construct(\PDO $connection, array $connection_options) { // Set a Statement class, unless the driver opted out. if (!empty($this->statementClass)) { - $connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this))); + $connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, [$this->statementClass, [$this]]); } $this->connection = $connection; @@ -173,7 +173,7 @@ public function __construct(\PDO $connection, array $connection_options) { * @return \PDO * A \PDO object. */ - public static function open(array &$connection_options = array()) { } + public static function open(array &$connection_options = []) { } /** * Destroys this Connection object. @@ -188,7 +188,7 @@ public function destroy() { // The Statement class attribute only accepts a new value that presents a // proper callable, so we reset it to PDOStatement. if (!empty($this->statementClass)) { - $this->connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array())); + $this->connection->setAttribute(\PDO::ATTR_STATEMENT_CLASS, ['PDOStatement', []]); } $this->schema = NULL; } @@ -245,13 +245,13 @@ public function destroy() { * An array of default query options. */ protected function defaultOptions() { - return array( + return [ 'target' => 'default', 'fetch' => \PDO::FETCH_OBJ, 'return' => Database::RETURN_STATEMENT, 'throw_exception' => TRUE, 'allow_delimiter_in_query' => FALSE, - ); + ]; } /** @@ -279,16 +279,16 @@ public function getConnectionOptions() { */ protected function setPrefix($prefix) { if (is_array($prefix)) { - $this->prefixes = $prefix + array('default' => ''); + $this->prefixes = $prefix + ['default' => '']; } else { - $this->prefixes = array('default' => $prefix); + $this->prefixes = ['default' => $prefix]; } // Set up variables for use in prefixTables(). Replace table-specific // prefixes first. - $this->prefixSearch = array(); - $this->prefixReplace = array(); + $this->prefixSearch = []; + $this->prefixReplace = []; foreach ($this->prefixes as $key => $val) { if ($key != 'default') { $this->prefixSearch[] = '{' . $key . '}'; @@ -582,7 +582,7 @@ protected function filterComment($comment = '') { * * @see \Drupal\Core\Database\Connection::defaultOptions() */ - public function query($query, array $args = array(), $options = array()) { + public function query($query, array $args = [], $options = []) { // Use default values if not already set. $options += $this->defaultOptions(); @@ -656,7 +656,7 @@ public function query($query, array $args = array(), $options = array()) { * @throws \Drupal\Core\Database\DatabaseExceptionWrapper * @throws \Drupal\Core\Database\IntegrityConstraintViolationException */ - protected function handleQueryException(\PDOException $e, $query, array $args = array(), $options = array()) { + protected function handleQueryException(\PDOException $e, $query, array $args = [], $options = []) { if ($options['throw_exception']) { // Wrap the exception in another exception, because PHP does not allow // overriding Exception::getMessage(). Its message is the extra database @@ -718,7 +718,7 @@ protected function expandArguments(&$query, &$args) { } // Handle expansion of arrays. $key_name = str_replace('[]', '__', $key); - $new_keys = array(); + $new_keys = []; // We require placeholders to have trailing brackets if the developer // intends them to be expanded to an array to make the intent explicit. foreach (array_values($data) as $i => $value) { @@ -782,7 +782,7 @@ public function getDriverClass($class) { * * @see \Drupal\Core\Database\Query\Select */ - public function select($table, $alias = NULL, array $options = array()) { + public function select($table, $alias = NULL, array $options = []) { $class = $this->getDriverClass('Select'); return new $class($table, $alias, $this, $options); } @@ -800,7 +800,7 @@ public function select($table, $alias = NULL, array $options = array()) { * * @see \Drupal\Core\Database\Query\Insert */ - public function insert($table, array $options = array()) { + public function insert($table, array $options = []) { $class = $this->getDriverClass('Insert'); return new $class($this, $table, $options); } @@ -818,7 +818,7 @@ public function insert($table, array $options = array()) { * * @see \Drupal\Core\Database\Query\Merge */ - public function merge($table, array $options = array()) { + public function merge($table, array $options = []) { $class = $this->getDriverClass('Merge'); return new $class($this, $table, $options); } @@ -836,7 +836,7 @@ public function merge($table, array $options = array()) { * * @see \Drupal\Core\Database\Query\Upsert */ - public function upsert($table, array $options = array()) { + public function upsert($table, array $options = []) { $class = $this->getDriverClass('Upsert'); return new $class($this, $table, $options); } @@ -854,7 +854,7 @@ public function upsert($table, array $options = array()) { * * @see \Drupal\Core\Database\Query\Update */ - public function update($table, array $options = array()) { + public function update($table, array $options = []) { $class = $this->getDriverClass('Update'); return new $class($this, $table, $options); } @@ -872,7 +872,7 @@ public function update($table, array $options = array()) { * * @see \Drupal\Core\Database\Query\Delete */ - public function delete($table, array $options = array()) { + public function delete($table, array $options = []) { $class = $this->getDriverClass('Delete'); return new $class($this, $table, $options); } @@ -890,7 +890,7 @@ public function delete($table, array $options = array()) { * * @see \Drupal\Core\Database\Query\Truncate */ - public function truncate($table, array $options = array()) { + public function truncate($table, array $options = []) { $class = $this->getDriverClass('Truncate'); return new $class($this, $table, $options); } @@ -1211,7 +1211,7 @@ protected function popCommittableTransactions() { * A database query result resource, or NULL if the query was not executed * correctly. */ - abstract public function queryRange($query, $from, $count, array $args = array(), array $options = array()); + abstract public function queryRange($query, $from, $count, array $args = [], array $options = []); /** * Generates a temporary table name. @@ -1248,7 +1248,7 @@ protected function generateTemporaryTableName() { * @return string * The name of the temporary table. */ - abstract function queryTemporary($query, array $args = array(), array $options = array()); + abstract function queryTemporary($query, array $args = [], array $options = []); /** * Returns the type of database driver. @@ -1395,7 +1395,7 @@ public function commit() { * * @see \PDO::prepare() */ - public function prepare($statement, array $driver_options = array()) { + public function prepare($statement, array $driver_options = []) { return $this->connection->prepare($statement, $driver_options); } diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php index 8fe1c45..dd19018 100644 --- a/core/lib/Drupal/Core/Database/Database.php +++ b/core/lib/Drupal/Core/Database/Database.php @@ -40,21 +40,21 @@ * * @var array */ - static protected $connections = array(); + static protected $connections = []; /** * A processed copy of the database connection information from settings.php. * * @var array */ - static protected $databaseInfo = array(); + static protected $databaseInfo = []; /** * A list of key/target credentials to simply ignore. * * @var array */ - static protected $ignoreTargets = array(); + static protected $ignoreTargets = []; /** * The key of the currently active database connection. @@ -75,7 +75,7 @@ * * @var array */ - static protected $logs = array(); + static protected $logs = []; /** * Starts logging a given logging key on the specified connection. @@ -214,15 +214,15 @@ // Parse the prefix information. if (!isset($info['prefix'])) { // Default to an empty prefix. - $info['prefix'] = array( + $info['prefix'] = [ 'default' => '', - ); + ]; } elseif (!is_array($info['prefix'])) { // Transform the flat form into an array form. - $info['prefix'] = array( + $info['prefix'] = [ 'default' => $info['prefix'], - ); + ]; } return $info; } @@ -459,11 +459,11 @@ public static function convertDbUrlToConnectionInfo($url, $root) { if (!isset($info['scheme'], $info['host'], $info['path'])) { throw new \InvalidArgumentException('Minimum requirement: driver://host/database'); } - $info += array( + $info += [ 'user' => '', 'pass' => '', 'fragment' => '', - ); + ]; // A SQLite database path with two leading slashes indicates a system path. // Otherwise the path is relative to the Drupal root. @@ -474,13 +474,13 @@ public static function convertDbUrlToConnectionInfo($url, $root) { $info['path'] = $root . '/' . $info['path']; } - $database = array( + $database = [ 'driver' => $info['scheme'], 'username' => $info['user'], 'password' => $info['pass'], 'host' => $info['host'], 'database' => $info['path'], - ); + ]; if (isset($info['port'])) { $database['port'] = $info['port']; } diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php index df51067..ec42523 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php @@ -61,7 +61,7 @@ class Connection extends DatabaseConnection { /** * Constructs a Connection object. */ - public function __construct(\PDO $connection, array $connection_options = array()) { + public function __construct(\PDO $connection, array $connection_options = []) { parent::__construct($connection, $connection_options); // This driver defaults to transaction support, except if explicitly passed FALSE. @@ -76,7 +76,7 @@ public function __construct(\PDO $connection, array $connection_options = array( /** * {@inheritdoc} */ - public function query($query, array $args = array(), $options = array()) { + public function query($query, array $args = [], $options = []) { try { return parent::query($query, $args, $options); } @@ -95,7 +95,7 @@ public function query($query, array $args = array(), $options = array()) { /** * {@inheritdoc} */ - public static function open(array &$connection_options = array()) { + public static function open(array &$connection_options = []) { if (isset($connection_options['_dsn_utf8_fallback']) && $connection_options['_dsn_utf8_fallback'] === TRUE) { // Only used during the installer version check, as a fallback from utf8mb4. $charset = 'utf8'; @@ -119,10 +119,10 @@ public static function open(array &$connection_options = array()) { $dsn .= ';dbname=' . $connection_options['database']; } // Allow PDO options to be overridden. - $connection_options += array( - 'pdo' => array(), - ); - $connection_options['pdo'] += array( + $connection_options += [ + 'pdo' => [], + ]; + $connection_options['pdo'] += [ \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, // So we don't have to mess around with cursors and unbuffered queries by default. \PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE, @@ -132,7 +132,7 @@ public static function open(array &$connection_options = array()) { \PDO::MYSQL_ATTR_FOUND_ROWS => TRUE, // Because MySQL's prepared statements skip the query cache, because it's dumb. \PDO::ATTR_EMULATE_PREPARES => TRUE, - ); + ]; if (defined('\PDO::MYSQL_ATTR_MULTI_STATEMENTS')) { // An added connection option in PHP 5.5.21 to optionally limit SQL to a // single statement like mysqli. @@ -159,12 +159,12 @@ public static function open(array &$connection_options = array()) { // https://www.drupal.org/node/344575 for further discussion. Also, as MySQL // 5.5 changed the meaning of TRADITIONAL we need to spell out the modes one // by one. - $connection_options += array( - 'init_commands' => array(), - ); - $connection_options['init_commands'] += array( + $connection_options += [ + 'init_commands' => [], + ]; + $connection_options['init_commands'] += [ 'sql_mode' => "SET sql_mode = 'ANSI,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,ONLY_FULL_GROUP_BY'", - ); + ]; // Execute initial commands. foreach ($connection_options['init_commands'] as $sql) { $pdo->exec($sql); @@ -195,11 +195,11 @@ public function __destruct() { } } - public function queryRange($query, $from, $count, array $args = array(), array $options = array()) { + public function queryRange($query, $from, $count, array $args = [], array $options = []) { return $this->query($query . ' LIMIT ' . (int) $from . ', ' . (int) $count, $args, $options); } - public function queryTemporary($query, array $args = array(), array $options = array()) { + public function queryTemporary($query, array $args = [], array $options = []) { $tablename = $this->generateTemporaryTableName(); $this->query('CREATE TEMPORARY TABLE {' . $tablename . '} Engine=MEMORY ' . $query, $args, $options); return $tablename; @@ -241,7 +241,7 @@ public function mapConditionOperator($operator) { } public function nextId($existing_id = 0) { - $new_id = $this->query('INSERT INTO {sequences} () VALUES ()', array(), array('return' => Database::RETURN_INSERT_ID)); + $new_id = $this->query('INSERT INTO {sequences} () VALUES ()', [], ['return' => Database::RETURN_INSERT_ID]); // This should only happen after an import or similar event. if ($existing_id >= $new_id) { // If we INSERT a value manually into the sequences table, on the next @@ -251,8 +251,8 @@ public function nextId($existing_id = 0) { // other than duplicate keys. Instead, we use INSERT ... ON DUPLICATE KEY // UPDATE in such a way that the UPDATE does not do anything. This way, // duplicate keys do not generate errors but everything else does. - $this->query('INSERT INTO {sequences} (value) VALUES (:value) ON DUPLICATE KEY UPDATE value = value', array(':value' => $existing_id)); - $new_id = $this->query('INSERT INTO {sequences} () VALUES ()', array(), array('return' => Database::RETURN_INSERT_ID)); + $this->query('INSERT INTO {sequences} (value) VALUES (:value) ON DUPLICATE KEY UPDATE value = value', [':value' => $existing_id]); + $new_id = $this->query('INSERT INTO {sequences} () VALUES ()', [], ['return' => Database::RETURN_INSERT_ID]); } $this->needsCleanup = TRUE; return $new_id; @@ -270,7 +270,7 @@ public function nextIdDelete() { try { $max_id = $this->query('SELECT MAX(value) FROM {sequences}')->fetchField(); // We know we are using MySQL here, no need for the slower db_delete(). - $this->query('DELETE FROM {sequences} WHERE value < :value', array(':value' => $max_id)); + $this->query('DELETE FROM {sequences} WHERE value < :value', [':value' => $max_id]); } // During testing, this function is called from shutdown with the // simpletest prefix stored in $this->connection, and those tables are gone @@ -316,7 +316,7 @@ protected function popCommittableTransactions() { if ($e->getPrevious()->errorInfo[1] == '1305') { // If one SAVEPOINT was released automatically, then all were. // Therefore, clean the transaction stack. - $this->transactionLayers = array(); + $this->transactionLayers = []; // We also have to explain to PDO that the transaction stack has // been cleaned-up. $this->connection->commit(); diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php b/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php index 213eb83..8b7c602e 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php @@ -18,7 +18,7 @@ public function execute() { // pass it back, as any remaining options are irrelevant. if (empty($this->fromQuery)) { $max_placeholder = 0; - $values = array(); + $values = []; foreach ($this->insertValues as $insert_values) { foreach ($insert_values as $value) { $values[':db_insert_placeholder_' . $max_placeholder++] = $value; @@ -32,7 +32,7 @@ public function execute() { $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(); + $this->insertValues = []; return $last_insert_id; } diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php index 40a589c..b19af64 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php @@ -33,10 +33,10 @@ class Tasks extends InstallTasks { * Constructs a \Drupal\Core\Database\Driver\mysql\Install\Tasks object. */ public function __construct() { - $this->tasks[] = array( - 'arguments' => array(), + $this->tasks[] = [ + 'arguments' => [], 'function' => 'ensureInnoDbAvailable', - ); + ]; } /** @@ -67,7 +67,7 @@ protected function connect() { catch (\Exception $e) { // Detect utf8mb4 incompability. if ($e->getCode() == Connection::UNSUPPORTED_CHARSET || ($e->getCode() == Connection::SQLSTATE_SYNTAX_ERROR && $e->errorInfo[1] == Connection::UNKNOWN_CHARSET)) { - $this->fail(t('Your MySQL server and PHP MySQL driver must support utf8mb4 character encoding. Make sure to use a database system that supports this (such as MySQL/MariaDB/Percona 5.5.3 and up), and that the utf8mb4 character set is compiled in. See the MySQL documentation for more information.', array(':documentation' => 'https://dev.mysql.com/doc/refman/5.0/en/cannot-initialize-character-set.html'))); + $this->fail(t('Your MySQL server and PHP MySQL driver must support utf8mb4 character encoding. Make sure to use a database system that supports this (such as MySQL/MariaDB/Percona 5.5.3 and up), and that the utf8mb4 character set is compiled in. See the MySQL documentation for more information.', [':documentation' => 'https://dev.mysql.com/doc/refman/5.0/en/cannot-initialize-character-set.html'])); $info = Database::getConnectionInfo(); $info_copy = $info; // Set a flag to fall back to utf8. Note: this flag should only be @@ -112,13 +112,13 @@ protected function connect() { catch (DatabaseNotFoundException $e) { // Still no dice; probably a permission issue. Raise the error to the // installer. - $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage()))); + $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', ['%database' => $database, '%error' => $e->getMessage()])); } } else { // Database connection failed for some other reason than the database // not existing. - $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.', array('%error' => $e->getMessage()))); + $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.', ['%error' => $e->getMessage()])); return FALSE; } } @@ -159,13 +159,13 @@ protected function checkEngineVersion() { // The mysqlnd driver supports utf8mb4 starting at version 5.0.9. $version = preg_replace('/^\D+([\d.]+).*/', '$1', $version); if (version_compare($version, self::MYSQLND_MINIMUM_VERSION, '<')) { - $this->fail(t("The MySQLnd driver version %version is less than the minimum required version. Upgrade to MySQLnd version %mysqlnd_minimum_version or up, or alternatively switch mysql drivers to libmysqlclient version %libmysqlclient_minimum_version or up.", array('%version' => $version, '%mysqlnd_minimum_version' => self::MYSQLND_MINIMUM_VERSION, '%libmysqlclient_minimum_version' => self::LIBMYSQLCLIENT_MINIMUM_VERSION))); + $this->fail(t("The MySQLnd driver version %version is less than the minimum required version. Upgrade to MySQLnd version %mysqlnd_minimum_version or up, or alternatively switch mysql drivers to libmysqlclient version %libmysqlclient_minimum_version or up.", ['%version' => $version, '%mysqlnd_minimum_version' => self::MYSQLND_MINIMUM_VERSION, '%libmysqlclient_minimum_version' => self::LIBMYSQLCLIENT_MINIMUM_VERSION])); } } else { // The libmysqlclient driver supports utf8mb4 starting at version 5.5.3. if (version_compare($version, self::LIBMYSQLCLIENT_MINIMUM_VERSION, '<')) { - $this->fail(t("The libmysqlclient driver version %version is less than the minimum required version. Upgrade to libmysqlclient version %libmysqlclient_minimum_version or up, or alternatively switch mysql drivers to MySQLnd version %mysqlnd_minimum_version or up.", array('%version' => $version, '%libmysqlclient_minimum_version' => self::LIBMYSQLCLIENT_MINIMUM_VERSION, '%mysqlnd_minimum_version' => self::MYSQLND_MINIMUM_VERSION))); + $this->fail(t("The libmysqlclient driver version %version is less than the minimum required version. Upgrade to libmysqlclient version %libmysqlclient_minimum_version or up, or alternatively switch mysql drivers to MySQLnd version %mysqlnd_minimum_version or up.", ['%version' => $version, '%libmysqlclient_minimum_version' => self::LIBMYSQLCLIENT_MINIMUM_VERSION, '%mysqlnd_minimum_version' => self::MYSQLND_MINIMUM_VERSION])); } } } diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php index 6fd999e..65689d0 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php @@ -33,14 +33,14 @@ class Schema extends DatabaseSchema { * @var array * List of MySQL string types. */ - protected $mysqlStringTypes = array( + protected $mysqlStringTypes = [ 'VARCHAR', 'CHAR', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'TEXT', - ); + ]; /** * Get information about the table and database name from the prefix. @@ -49,7 +49,7 @@ class Schema extends DatabaseSchema { * A keyed array with information about the database, table name and prefix. */ protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) { - $info = array('prefix' => $this->connection->tablePrefix($table)); + $info = ['prefix' => $this->connection->tablePrefix($table)]; if ($add_prefix) { $table = $info['prefix'] . $table; } @@ -95,10 +95,10 @@ protected function createTableSql($name, $table) { $info = $this->connection->getConnectionOptions(); // Provide defaults if needed. - $table += array( + $table += [ 'mysql_engine' => 'InnoDB', 'mysql_character_set' => 'utf8mb4', - ); + ]; $sql = "CREATE TABLE {" . $name . "} (\n"; @@ -130,7 +130,7 @@ protected function createTableSql($name, $table) { $sql .= ' COMMENT ' . $this->prepareComment($table['description'], self::COMMENT_MAX_TABLE); } - return array($sql); + return [$sql]; } /** @@ -231,7 +231,7 @@ public function getFieldTypeMap() { // it much easier for modules (such as schema.module) to map // database types back into schema types. // $map does not use drupal_static as its value never changes. - static $map = array( + static $map = [ 'varchar_ascii:normal' => 'VARCHAR', 'varchar:normal' => 'VARCHAR', @@ -265,12 +265,12 @@ public function getFieldTypeMap() { 'blob:big' => 'LONGBLOB', 'blob:normal' => 'BLOB', - ); + ]; return $map; } protected function createKeysSql($spec) { - $keys = array(); + $keys = []; if (!empty($spec['primary key'])) { $keys[] = 'PRIMARY KEY (' . $this->createKeySql($spec['primary key']) . ')'; @@ -349,12 +349,12 @@ protected function shortenIndex(&$index) { } } else { - $index = array($index, 191); + $index = [$index, 191]; } } protected function createKeySql($fields) { - $return = array(); + $return = []; foreach ($fields as $field) { if (is_array($field)) { $return[] = '`' . $field[0] . '`(' . $field[1] . ')'; @@ -368,10 +368,10 @@ protected function createKeySql($fields) { public function renameTable($table, $new_name) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", array('@table' => $table, '@table_new' => $new_name))); + throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", ['@table' => $table, '@table_new' => $new_name])); } if ($this->tableExists($new_name)) { - throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", array('@table' => $table, '@table_new' => $new_name))); + throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", ['@table' => $table, '@table_new' => $new_name])); } $info = $this->getPrefixInfo($new_name); @@ -387,12 +387,12 @@ public function dropTable($table) { return TRUE; } - public function addField($table, $field, $spec, $keys_new = array()) { + public function addField($table, $field, $spec, $keys_new = []) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", array('@field' => $field, '@table' => $table))); + throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", ['@field' => $field, '@table' => $table])); } if ($this->fieldExists($table, $field)) { - throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", array('@field' => $field, '@table' => $table))); + throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", ['@field' => $field, '@table' => $table])); } $fixnull = FALSE; @@ -408,7 +408,7 @@ public function addField($table, $field, $spec, $keys_new = array()) { $this->connection->query($query); if (isset($spec['initial'])) { $this->connection->update($table) - ->fields(array($field => $spec['initial'])) + ->fields([$field => $spec['initial']]) ->execute(); } if (isset($spec['initial_from_field'])) { @@ -433,7 +433,7 @@ public function dropField($table, $field) { public function fieldSetDefault($table, $field, $default) { if (!$this->fieldExists($table, $field)) { - throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field))); + throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field])); } $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` SET DEFAULT ' . $this->escapeDefaultValue($default)); @@ -441,7 +441,7 @@ public function fieldSetDefault($table, $field, $default) { public function fieldSetNoDefault($table, $field) { if (!$this->fieldExists($table, $field)) { - throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field))); + throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field])); } $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` DROP DEFAULT'); @@ -456,10 +456,10 @@ public function indexExists($table, $name) { public function addPrimaryKey($table, $fields) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", array('@table' => $table))); + throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", ['@table' => $table])); } if ($this->indexExists($table, 'PRIMARY')) { - throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", array('@table' => $table))); + throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", ['@table' => $table])); } $this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createKeySql($fields) . ')'); @@ -476,10 +476,10 @@ public function dropPrimaryKey($table) { public function addUniqueKey($table, $name, $fields) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name))); + throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name])); } if ($this->indexExists($table, $name)) { - throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", array('@table' => $table, '@name' => $name))); + throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", ['@table' => $table, '@name' => $name])); } $this->connection->query('ALTER TABLE {' . $table . '} ADD UNIQUE KEY `' . $name . '` (' . $this->createKeySql($fields) . ')'); @@ -499,10 +499,10 @@ public function dropUniqueKey($table, $name) { */ public function addIndex($table, $name, $fields, array $spec) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name))); + throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name])); } if ($this->indexExists($table, $name)) { - throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", array('@table' => $table, '@name' => $name))); + throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", ['@table' => $table, '@name' => $name])); } $spec['indexes'][$name] = $fields; @@ -520,12 +520,12 @@ public function dropIndex($table, $name) { return TRUE; } - public function changeField($table, $field, $field_new, $spec, $keys_new = array()) { + public function changeField($table, $field, $field_new, $spec, $keys_new = []) { if (!$this->fieldExists($table, $field)) { - throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", array('@table' => $table, '@name' => $field))); + throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", ['@table' => $table, '@name' => $field])); } if (($field != $field_new) && $this->fieldExists($table, $field_new)) { - throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", array('@table' => $table, '@name' => $field, '@name_new' => $field_new))); + throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", ['@table' => $table, '@name' => $field, '@name_new' => $field_new])); } $sql = 'ALTER TABLE {' . $table . '} CHANGE `' . $field . '` ' . $this->createFieldSql($field_new, $this->processField($spec)); @@ -542,7 +542,7 @@ public function prepareComment($comment, $length = NULL) { $comment = Unicode::truncate($this->connection->prefixTables($comment), $length, TRUE, TRUE); } // Remove semicolons to avoid triggering multi-statement check. - $comment = strtr($comment, array(';' => '.')); + $comment = strtr($comment, [';' => '.']); return $this->connection->quote($comment); } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php index 8049796..aae2d09 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php @@ -74,7 +74,7 @@ public function __construct(\PDO $connection, array $connection_options) { /** * {@inheritdoc} */ - public static function open(array &$connection_options = array()) { + public static function open(array &$connection_options = []) { // Default to TCP connection on port 5432. if (empty($connection_options['port'])) { $connection_options['port'] = 5432; @@ -98,10 +98,10 @@ public static function open(array &$connection_options = array()) { $dsn = 'pgsql:host=' . $connection_options['host'] . ' dbname=' . $connection_options['database'] . ' port=' . $connection_options['port']; // Allow PDO options to be overridden. - $connection_options += array( - 'pdo' => array(), - ); - $connection_options['pdo'] += array( + $connection_options += [ + 'pdo' => [], + ]; + $connection_options['pdo'] += [ \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, // Prepared statements are most effective for performance when queries // are recycled (used several times). However, if they are not re-used, @@ -112,7 +112,7 @@ public static function open(array &$connection_options = array()) { \PDO::ATTR_EMULATE_PREPARES => TRUE, // Convert numeric values to strings when fetching. \PDO::ATTR_STRINGIFY_FETCHES => TRUE, - ); + ]; $pdo = new \PDO($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']); return $pdo; @@ -121,7 +121,7 @@ public static function open(array &$connection_options = array()) { /** * {@inheritdoc} */ - public function query($query, array $args = array(), $options = array()) { + public function query($query, array $args = [], $options = []) { $options += $this->defaultOptions(); // The PDO PostgreSQL driver has a bug which doesn't type cast booleans @@ -178,11 +178,11 @@ public function prepareQuery($query) { return parent::prepareQuery(preg_replace('/ ([^ ]+) +(I*LIKE|NOT +I*LIKE) /i', ' ${1}::text ${2} ', $query)); } - public function queryRange($query, $from, $count, array $args = array(), array $options = array()) { + public function queryRange($query, $from, $count, array $args = [], array $options = []) { return $this->query($query . ' LIMIT ' . (int) $count . ' OFFSET ' . (int) $from, $args, $options); } - public function queryTemporary($query, array $args = array(), array $options = array()) { + public function queryTemporary($query, array $args = [], array $options = []) { $tablename = $this->generateTemporaryTableName(); $this->query('CREATE TEMPORARY TABLE {' . $tablename . '} AS ' . $query, $args, $options); return $tablename; @@ -300,14 +300,14 @@ public function createDatabase($database) { } public function mapConditionOperator($operator) { - static $specials = array( + static $specials = [ // In PostgreSQL, 'LIKE' is case-sensitive. For case-insensitive LIKE // statements, we need to use ILIKE instead. - 'LIKE' => array('operator' => 'ILIKE'), - 'LIKE BINARY' => array('operator' => 'LIKE'), - 'NOT LIKE' => array('operator' => 'NOT ILIKE'), - 'REGEXP' => array('operator' => '~*'), - ); + 'LIKE' => ['operator' => 'ILIKE'], + 'LIKE BINARY' => ['operator' => 'LIKE'], + 'NOT LIKE' => ['operator' => 'NOT ILIKE'], + 'REGEXP' => ['operator' => '~*'], + ]; return isset($specials[$operator]) ? $specials[$operator] : NULL; } @@ -416,7 +416,7 @@ public function rollbackSavepoint($savepoint_name = 'mimic_implicit_commit') { /** * {@inheritdoc} */ - public function upsert($table, array $options = array()) { + public function upsert($table, array $options = []) { // Use the (faster) native Upsert implementation for PostgreSQL >= 9.5. if (version_compare($this->version(), '9.5', '>=')) { $class = $this->getDriverClass('NativeUpsert'); diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php index 6b9be78..45c7a47 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php @@ -26,7 +26,7 @@ public function execute() { $table_information = $this->connection->schema()->queryTableInformation($this->table); $max_placeholder = 0; - $blobs = array(); + $blobs = []; $blob_count = 0; foreach ($this->insertValues as $insert_values) { foreach ($this->insertFields as $idx => $field) { @@ -66,7 +66,7 @@ public function execute() { // used twice. However, trying to insert a value into a serial // column should only be done in very rare cases and is not thread // safe by definition. - $this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", array(':serial_value' => (int)$serial_value)); + $this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", [':serial_value' => (int)$serial_value]); } } } @@ -103,10 +103,10 @@ public function execute() { try { // Only use the returned last_insert_id if it is not already set. if (!empty($last_insert_id)) { - $this->connection->query($stmt, array(), $options); + $this->connection->query($stmt, [], $options); } else { - $last_insert_id = $this->connection->query($stmt, array(), $options); + $last_insert_id = $this->connection->query($stmt, [], $options); } $this->connection->releaseSavepoint(); } @@ -116,7 +116,7 @@ public function execute() { } // Re-initialize the values array so that we can re-use this query. - $this->insertValues = array(); + $this->insertValues = []; return $last_insert_id; } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php index 95ff527..329b420 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php @@ -21,22 +21,22 @@ class Tasks extends InstallTasks { * Constructs a \Drupal\Core\Database\Driver\pgsql\Install\Tasks object. */ public function __construct() { - $this->tasks[] = array( + $this->tasks[] = [ 'function' => 'checkEncoding', - 'arguments' => array(), - ); - $this->tasks[] = array( + 'arguments' => [], + ]; + $this->tasks[] = [ 'function' => 'checkBinaryOutput', - 'arguments' => array(), - ); - $this->tasks[] = array( + 'arguments' => [], + ]; + $this->tasks[] = [ 'function' => 'checkStandardConformingStrings', - 'arguments' => array(), - ); - $this->tasks[] = array( + 'arguments' => [], + ]; + $this->tasks[] = [ 'function' => 'initializeDatabase', - 'arguments' => array(), - ); + 'arguments' => [], + ]; } /** @@ -95,13 +95,13 @@ protected function connect() { catch (DatabaseNotFoundException $e) { // Still no dice; probably a permission issue. Raise the error to the // installer. - $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage()))); + $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', ['%database' => $database, '%error' => $e->getMessage()])); } } else { // Database connection failed for some other reason than the database // not existing. - $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.', array('%error' => $e->getMessage()))); + $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.', ['%error' => $e->getMessage()])); return FALSE; } } @@ -117,10 +117,10 @@ protected function checkEncoding() { $this->pass(t('Database is encoded in UTF-8')); } else { - $this->fail(t('The %driver database must use %encoding encoding to work with Drupal. Recreate the database with %encoding encoding. See INSTALL.pgsql.txt for more details.', array( + $this->fail(t('The %driver database must use %encoding encoding to work with Drupal. Recreate the database with %encoding encoding. See INSTALL.pgsql.txt for more details.', [ '%encoding' => 'UTF8', '%driver' => $this->name(), - ))); + ])); } } catch (\Exception $e) { @@ -162,12 +162,12 @@ function checkBinaryOutput() { // Recheck, if it fails, finally just rely on the end user to do the // right thing. if (!$this->checkBinaryOutputSuccess()) { - $replacements = array( + $replacements = [ '%setting' => 'bytea_output', '%current_value' => 'hex', '%needed_value' => 'escape', '@query' => $query, - ); + ]; $this->fail(t("The %setting setting is currently set to '%current_value', but needs to be '%needed_value'. Change this by running the following query: @query", $replacements)); } } @@ -215,12 +215,12 @@ public function checkStandardConformingStrings() { // Recheck, if it fails, finally just rely on the end user to do the // right thing. if (!$this->checkStandardConformingStringsSuccess()) { - $replacements = array( + $replacements = [ '%setting' => 'standard_conforming_strings', '%current_value' => 'off', '%needed_value' => 'on', '@query' => $query, - ); + ]; $this->fail(t("The %setting setting is currently set to '%current_value', but needs to be '%needed_value'. Change this by running the following query: @query", $replacements)); } } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/NativeUpsert.php b/core/lib/Drupal/Core/Database/Driver/pgsql/NativeUpsert.php index 23c0264..8cb2ce7 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/NativeUpsert.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/NativeUpsert.php @@ -60,7 +60,7 @@ public function execute() { // used twice. However, trying to insert a value into a serial // column should only be done in very rare cases and is not thread // safe by definition. - $this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", array(':serial_value' => (int)$serial_value)); + $this->connection->query("SELECT setval('" . $table_information->sequences[$index] . "', GREATEST(MAX(" . $serial_field . "), :serial_value)) FROM {" . $this->table . "}", [':serial_value' => (int)$serial_value]); } } } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php index c0775c9..2ccf22b 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php @@ -26,7 +26,7 @@ class Schema extends DatabaseSchema { * @see DatabaseConnection_pgsql->queryTableInformation() * @var array */ - protected $tableInformation = array(); + protected $tableInformation = []; /** * The maximum allowed length for index, primary key and constraint names. @@ -104,16 +104,16 @@ public function queryTableInformation($table) { if (!isset($this->tableInformation[$key])) { // Split the key into schema and table for querying. list($schema, $table_name) = explode('.', $key); - $table_information = (object) array( - 'blob_fields' => array(), - 'sequences' => array(), - ); + $table_information = (object) [ + 'blob_fields' => [], + 'sequences' => [], + ]; // Don't use {} around information_schema.columns table. $this->connection->addSavepoint(); try { // Check if the table information exists in the PostgreSQL metadata. - $table_information_exists = (bool) $this->connection->query("SELECT 1 FROM pg_class WHERE relname = :table", array(':table' => $table_name))->fetchField(); + $table_information_exists = (bool) $this->connection->query("SELECT 1 FROM pg_class WHERE relname = :table", [':table' => $table_name])->fetchField(); // If the table information does not yet exist in the PostgreSQL // metadata, then return the default table information here, so that it @@ -123,11 +123,11 @@ public function queryTableInformation($table) { return $table_information; } else { - $result = $this->connection->query("SELECT column_name, data_type, column_default FROM information_schema.columns WHERE table_schema = :schema AND table_name = :table AND (data_type = 'bytea' OR (numeric_precision IS NOT NULL AND column_default LIKE :default))", array( + $result = $this->connection->query("SELECT column_name, data_type, column_default FROM information_schema.columns WHERE table_schema = :schema AND table_name = :table AND (data_type = 'bytea' OR (numeric_precision IS NOT NULL AND column_default LIKE :default))", [ ':schema' => $schema, ':table' => $table_name, ':default' => '%nextval%', - )); + ]); } } catch (\Exception $e) { @@ -190,11 +190,11 @@ public function queryFieldInformation($table, $field) { $this->connection->addSavepoint(); try { - $checks = $this->connection->query("SELECT conname FROM pg_class cl INNER JOIN pg_constraint co ON co.conrelid = cl.oid INNER JOIN pg_attribute attr ON attr.attrelid = cl.oid AND attr.attnum = ANY (co.conkey) INNER JOIN pg_namespace ns ON cl.relnamespace = ns.oid WHERE co.contype = 'c' AND ns.nspname = :schema AND cl.relname = :table AND attr.attname = :column", array( + $checks = $this->connection->query("SELECT conname FROM pg_class cl INNER JOIN pg_constraint co ON co.conrelid = cl.oid INNER JOIN pg_attribute attr ON attr.attrelid = cl.oid AND attr.attnum = ANY (co.conkey) INNER JOIN pg_namespace ns ON cl.relnamespace = ns.oid WHERE co.contype = 'c' AND ns.nspname = :schema AND cl.relname = :table AND attr.attname = :column", [ ':schema' => $schema, ':table' => $table_name, ':column' => $field, - )); + ]); } catch (\Exception $e) { $this->connection->rollbackSavepoint(); @@ -219,12 +219,12 @@ public function queryFieldInformation($table, $field) { * An array of SQL statements to create the table. */ protected function createTableSql($name, $table) { - $sql_fields = array(); + $sql_fields = []; foreach ($table['fields'] as $field_name => $field) { $sql_fields[] = $this->createFieldSql($field_name, $this->processField($field)); } - $sql_keys = array(); + $sql_keys = []; if (isset($table['primary key']) && is_array($table['primary key'])) { $sql_keys[] = 'CONSTRAINT ' . $this->ensureIdentifiersLength($name, '', 'pkey') . ' PRIMARY KEY (' . $this->createPrimaryKeySql($table['primary key']) . ')'; } @@ -284,7 +284,7 @@ protected function createFieldSql($name, $spec) { unset($spec['not null']); } - if (in_array($spec['pgsql_type'], array('varchar', 'character')) && isset($spec['length'])) { + if (in_array($spec['pgsql_type'], ['varchar', 'character']) && isset($spec['length'])) { $sql .= '(' . $spec['length'] . ')'; } elseif (isset($spec['precision']) && isset($spec['scale'])) { @@ -366,7 +366,7 @@ function getFieldTypeMap() { // it much easier for modules (such as schema.module) to map // database types back into schema types. // $map does not use drupal_static as its value never changes. - static $map = array( + static $map = [ 'varchar_ascii:normal' => 'varchar', 'varchar:normal' => 'varchar', @@ -400,12 +400,12 @@ function getFieldTypeMap() { 'serial:medium' => 'serial', 'serial:big' => 'bigserial', 'serial:normal' => 'serial', - ); + ]; return $map; } protected function _createKeySql($fields) { - $return = array(); + $return = []; foreach ($fields as $field) { if (is_array($field)) { $return[] = 'substr(' . $field[0] . ', 1, ' . $field[1] . ')'; @@ -425,7 +425,7 @@ protected function _createKeySql($fields) { * key length defined in the schema is ignored. */ protected function createPrimaryKeySql($fields) { - $return = array(); + $return = []; foreach ($fields as $field) { if (is_array($field)) { $return[] = '"' . $field[0] . '"'; @@ -443,24 +443,24 @@ protected function createPrimaryKeySql($fields) { public function tableExists($table) { $prefixInfo = $this->getPrefixInfo($table, TRUE); - return (bool) $this->connection->query("SELECT 1 FROM pg_tables WHERE schemaname = :schema AND tablename = :table", array(':schema' => $prefixInfo['schema'], ':table' => $prefixInfo['table']))->fetchField(); + return (bool) $this->connection->query("SELECT 1 FROM pg_tables WHERE schemaname = :schema AND tablename = :table", [':schema' => $prefixInfo['schema'], ':table' => $prefixInfo['table']])->fetchField(); } function renameTable($table, $new_name) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", array('@table' => $table, '@table_new' => $new_name))); + throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", ['@table' => $table, '@table_new' => $new_name])); } if ($this->tableExists($new_name)) { - throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", array('@table' => $table, '@table_new' => $new_name))); + throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", ['@table' => $table, '@table_new' => $new_name])); } // Get the schema and tablename for the old table. $old_full_name = $this->connection->prefixTables('{' . $table . '}'); - list($old_schema, $old_table_name) = strpos($old_full_name, '.') ? explode('.', $old_full_name) : array('public', $old_full_name); + list($old_schema, $old_table_name) = strpos($old_full_name, '.') ? explode('.', $old_full_name) : ['public', $old_full_name]; // Index names and constraint names are global in PostgreSQL, so we need to // rename them when renaming the table. - $indexes = $this->connection->query('SELECT indexname FROM pg_indexes WHERE schemaname = :schema AND tablename = :table', array(':schema' => $old_schema, ':table' => $old_table_name)); + $indexes = $this->connection->query('SELECT indexname FROM pg_indexes WHERE schemaname = :schema AND tablename = :table', [':schema' => $old_schema, ':table' => $old_table_name]); foreach ($indexes as $index) { // Get the index type by suffix, e.g. idx/key/pkey @@ -510,12 +510,12 @@ public function dropTable($table) { return TRUE; } - public function addField($table, $field, $spec, $new_keys = array()) { + public function addField($table, $field, $spec, $new_keys = []) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", array('@field' => $field, '@table' => $table))); + throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", ['@field' => $field, '@table' => $table])); } if ($this->fieldExists($table, $field)) { - throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", array('@field' => $field, '@table' => $table))); + throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", ['@field' => $field, '@table' => $table])); } $fixnull = FALSE; @@ -528,7 +528,7 @@ public function addField($table, $field, $spec, $new_keys = array()) { $this->connection->query($query); if (isset($spec['initial'])) { $this->connection->update($table) - ->fields(array($field => $spec['initial'])) + ->fields([$field => $spec['initial']]) ->execute(); } if (isset($spec['initial_from_field'])) { @@ -561,7 +561,7 @@ public function dropField($table, $field) { public function fieldSetDefault($table, $field, $default) { if (!$this->fieldExists($table, $field)) { - throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field))); + throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field])); } $default = $this->escapeDefaultValue($default); @@ -571,7 +571,7 @@ public function fieldSetDefault($table, $field, $default) { public function fieldSetNoDefault($table, $field) { if (!$this->fieldExists($table, $field)) { - throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field))); + throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field])); } $this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN "' . $field . '" DROP DEFAULT'); @@ -619,10 +619,10 @@ public function constraintExists($table, $name) { public function addPrimaryKey($table, $fields) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", array('@table' => $table))); + throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", ['@table' => $table])); } if ($this->constraintExists($table, 'pkey')) { - throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", array('@table' => $table))); + throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", ['@table' => $table])); } $this->connection->query('ALTER TABLE {' . $table . '} ADD CONSTRAINT ' . $this->ensureIdentifiersLength($table, '', 'pkey') . ' PRIMARY KEY (' . $this->createPrimaryKeySql($fields) . ')'); @@ -641,10 +641,10 @@ public function dropPrimaryKey($table) { function addUniqueKey($table, $name, $fields) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name))); + throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name])); } if ($this->constraintExists($table, $name . '__key')) { - throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", array('@table' => $table, '@name' => $name))); + throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", ['@table' => $table, '@name' => $name])); } $this->connection->query('ALTER TABLE {' . $table . '} ADD CONSTRAINT ' . $this->ensureIdentifiersLength($table, $name, 'key') . ' UNIQUE (' . implode(',', $fields) . ')'); @@ -666,10 +666,10 @@ public function dropUniqueKey($table, $name) { */ public function addIndex($table, $name, $fields, array $spec) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name))); + throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name])); } if ($this->indexExists($table, $name)) { - throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", array('@table' => $table, '@name' => $name))); + throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", ['@table' => $table, '@name' => $name])); } $this->connection->query($this->_createIndexSql($table, $name, $fields)); @@ -686,12 +686,12 @@ public function dropIndex($table, $name) { return TRUE; } - public function changeField($table, $field, $field_new, $spec, $new_keys = array()) { + public function changeField($table, $field, $field_new, $spec, $new_keys = []) { if (!$this->fieldExists($table, $field)) { - throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", array('@table' => $table, '@name' => $field))); + throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", ['@table' => $table, '@name' => $field])); } if (($field != $field_new) && $this->fieldExists($table, $field_new)) { - throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", array('@table' => $table, '@name' => $field, '@name_new' => $field_new))); + throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", ['@table' => $table, '@name' => $field, '@name_new' => $field_new])); } $spec = $this->processField($spec); @@ -699,14 +699,14 @@ public function changeField($table, $field, $field_new, $spec, $new_keys = array // Type 'serial' is known to PostgreSQL, but only during table creation, // not when altering. Because of that, we create it here as an 'int'. After // we create it we manually re-apply the sequence. - if (in_array($spec['pgsql_type'], array('serial', 'bigserial'))) { + if (in_array($spec['pgsql_type'], ['serial', 'bigserial'])) { $field_def = 'int'; } else { $field_def = $spec['pgsql_type']; } - if (in_array($spec['pgsql_type'], array('varchar', 'character', 'text')) && isset($spec['length'])) { + if (in_array($spec['pgsql_type'], ['varchar', 'character', 'text']) && isset($spec['length'])) { $field_def .= '(' . $spec['length'] . ')'; } elseif (isset($spec['precision']) && isset($spec['scale'])) { @@ -757,7 +757,7 @@ public function changeField($table, $field, $field_new, $spec, $new_keys = array $this->connection->query('ALTER TABLE {' . $table . '} ALTER "' . $field . '" ' . $nullaction); } - if (in_array($spec['pgsql_type'], array('serial', 'bigserial'))) { + if (in_array($spec['pgsql_type'], ['serial', 'bigserial'])) { // Type "serial" is known to PostgreSQL, but *only* during table creation, // not when altering. Because of that, the sequence needs to be created // and initialized by hand. @@ -827,10 +827,10 @@ public function getComment($table, $column = NULL) { $info = $this->getPrefixInfo($table); // Don't use {} around pg_class, pg_attribute tables. if (isset($column)) { - return $this->connection->query('SELECT col_description(oid, attnum) FROM pg_class, pg_attribute WHERE attrelid = oid AND relname = ? AND attname = ?', array($info['table'], $column))->fetchField(); + return $this->connection->query('SELECT col_description(oid, attnum) FROM pg_class, pg_attribute WHERE attrelid = oid AND relname = ? AND attname = ?', [$info['table'], $column])->fetchField(); } else { - return $this->connection->query('SELECT obj_description(oid, ?) FROM pg_class WHERE relname = ?', array('pg_class', $info['table']))->fetchField(); + return $this->connection->query('SELECT obj_description(oid, ?) FROM pg_class WHERE relname = ?', ['pg_class', $info['table']])->fetchField(); } } @@ -847,7 +847,7 @@ public function getComment($table, $column = NULL) { protected function hashBase64($data) { $hash = base64_encode(hash('sha256', $data, TRUE)); // Modify the hash so it's safe to use in PostgreSQL identifiers. - return strtr($hash, array('+' => '_', '/' => '_', '=' => '')); + return strtr($hash, ['+' => '_', '/' => '_', '=' => '']); } } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php index 3214b33..e76cb0f 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php @@ -114,7 +114,7 @@ public function orderBy($field, $direction = 'ASC') { /** * {@inheritdoc} */ - public function addExpression($expression, $alias = NULL, $arguments = array()) { + public function addExpression($expression, $alias = NULL, $arguments = []) { if (empty($alias)) { $alias = 'expression'; } @@ -127,11 +127,11 @@ public function addExpression($expression, $alias = NULL, $arguments = array()) } $alias = $alias_candidate; - $this->expressions[$alias] = array( + $this->expressions[$alias] = [ 'expression' => $expression, 'alias' => $this->connection->escapeAlias($alias_candidate), 'arguments' => $arguments, - ); + ]; return $alias; } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php index f631952..e937f6c 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php @@ -13,7 +13,7 @@ class Update extends QueryUpdate { public function execute() { $max_placeholder = 0; - $blobs = array(); + $blobs = []; $blob_count = 0; // Because we filter $fields the same way here and in __toString(), the @@ -75,7 +75,7 @@ public function execute() { $this->connection->addSavepoint(); try { - $result = $this->connection->query($stmt, array(), $options); + $result = $this->connection->query($stmt, [], $options); $this->connection->releaseSavepoint(); return $result; } diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php index 9dd4fc2..bd75807 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php @@ -18,9 +18,9 @@ public function execute() { } // Default options for upsert queries. - $this->queryOptions += array( + $this->queryOptions += [ 'throw_exception' => TRUE, - ); + ]; // Default fields are always placed first for consistency. $insert_fields = array_merge($this->defaultFields, $this->insertFields); @@ -66,7 +66,7 @@ public function execute() { } // Re-initialize the values array so that we can re-use this query. - $this->insertValues = array(); + $this->insertValues = []; // Transaction commits here where $transaction looses scope. diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php index 23dd261..48c2ecf 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php @@ -29,7 +29,7 @@ class Connection extends DatabaseConnection { * * @var array */ - protected $attachedDatabases = array(); + protected $attachedDatabases = []; /** * Whether or not a table has been dropped this request: the destructor will @@ -70,10 +70,10 @@ public function __construct(\PDO $connection, array $connection_options) { // In memory database use ':memory:' as database name. According to // http://www.sqlite.org/inmemorydb.html it will open a unique // database so attaching it twice is not a problem. - $this->query('ATTACH DATABASE :database AS :prefix', array(':database' => $connection_options['database'], ':prefix' => $prefix)); + $this->query('ATTACH DATABASE :database AS :prefix', [':database' => $connection_options['database'], ':prefix' => $prefix]); } else { - $this->query('ATTACH DATABASE :database AS :prefix', array(':database' => $connection_options['database'] . '-' . $prefix, ':prefix' => $prefix)); + $this->query('ATTACH DATABASE :database AS :prefix', [':database' => $connection_options['database'] . '-' . $prefix, ':prefix' => $prefix]); } } @@ -89,50 +89,50 @@ public function __construct(\PDO $connection, array $connection_options) { /** * {@inheritdoc} */ - public static function open(array &$connection_options = array()) { + public static function open(array &$connection_options = []) { // Allow PDO options to be overridden. - $connection_options += array( - 'pdo' => array(), - ); - $connection_options['pdo'] += array( + $connection_options += [ + 'pdo' => [], + ]; + $connection_options['pdo'] += [ \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, // Convert numeric values to strings when fetching. \PDO::ATTR_STRINGIFY_FETCHES => TRUE, - ); + ]; $pdo = new \PDO('sqlite:' . $connection_options['database'], '', '', $connection_options['pdo']); // Create functions needed by SQLite. - $pdo->sqliteCreateFunction('if', array(__CLASS__, 'sqlFunctionIf')); - $pdo->sqliteCreateFunction('greatest', array(__CLASS__, 'sqlFunctionGreatest')); + $pdo->sqliteCreateFunction('if', [__CLASS__, 'sqlFunctionIf']); + $pdo->sqliteCreateFunction('greatest', [__CLASS__, 'sqlFunctionGreatest']); $pdo->sqliteCreateFunction('pow', 'pow', 2); $pdo->sqliteCreateFunction('exp', 'exp', 1); $pdo->sqliteCreateFunction('length', 'strlen', 1); $pdo->sqliteCreateFunction('md5', 'md5', 1); - $pdo->sqliteCreateFunction('concat', array(__CLASS__, 'sqlFunctionConcat')); - $pdo->sqliteCreateFunction('concat_ws', array(__CLASS__, 'sqlFunctionConcatWs')); - $pdo->sqliteCreateFunction('substring', array(__CLASS__, 'sqlFunctionSubstring'), 3); - $pdo->sqliteCreateFunction('substring_index', array(__CLASS__, 'sqlFunctionSubstringIndex'), 3); - $pdo->sqliteCreateFunction('rand', array(__CLASS__, 'sqlFunctionRand')); - $pdo->sqliteCreateFunction('regexp', array(__CLASS__, 'sqlFunctionRegexp')); + $pdo->sqliteCreateFunction('concat', [__CLASS__, 'sqlFunctionConcat']); + $pdo->sqliteCreateFunction('concat_ws', [__CLASS__, 'sqlFunctionConcatWs']); + $pdo->sqliteCreateFunction('substring', [__CLASS__, 'sqlFunctionSubstring'], 3); + $pdo->sqliteCreateFunction('substring_index', [__CLASS__, 'sqlFunctionSubstringIndex'], 3); + $pdo->sqliteCreateFunction('rand', [__CLASS__, 'sqlFunctionRand']); + $pdo->sqliteCreateFunction('regexp', [__CLASS__, 'sqlFunctionRegexp']); // SQLite does not support the LIKE BINARY operator, so we overload the // non-standard GLOB operator for case-sensitive matching. Another option // would have been to override another non-standard operator, MATCH, but // that does not support the NOT keyword prefix. - $pdo->sqliteCreateFunction('glob', array(__CLASS__, 'sqlFunctionLikeBinary')); + $pdo->sqliteCreateFunction('glob', [__CLASS__, 'sqlFunctionLikeBinary']); // Create a user-space case-insensitive collation with UTF-8 support. - $pdo->sqliteCreateCollation('NOCASE_UTF8', array('Drupal\Component\Utility\Unicode', 'strcasecmp')); + $pdo->sqliteCreateCollation('NOCASE_UTF8', ['Drupal\Component\Utility\Unicode', 'strcasecmp']); // Set SQLite init_commands if not already defined. Enable the Write-Ahead // Logging (WAL) for SQLite. See https://www.drupal.org/node/2348137 and // https://www.sqlite.org/wal.html. - $connection_options += array( - 'init_commands' => array(), - ); - $connection_options['init_commands'] += array( + $connection_options += [ + 'init_commands' => [], + ]; + $connection_options['init_commands'] += [ 'wal' => "PRAGMA journal_mode=WAL", - ); + ]; // Execute sqlite init_commands. if (isset($connection_options['init_commands'])) { @@ -155,7 +155,7 @@ public function __destruct() { foreach ($this->attachedDatabases as $prefix) { // Check if the database is now empty, ignore the internal SQLite tables. try { - $count = $this->query('SELECT COUNT(*) FROM ' . $prefix . '.sqlite_master WHERE type = :type AND name NOT LIKE :pattern', array(':type' => 'table', ':pattern' => 'sqlite_%'))->fetchField(); + $count = $this->query('SELECT COUNT(*) FROM ' . $prefix . '.sqlite_master WHERE type = :type AND name NOT LIKE :pattern', [':type' => 'table', ':pattern' => 'sqlite_%'])->fetchField(); // We can prune the database file if it doesn't have any tables. if ($count == 0) { @@ -301,21 +301,21 @@ public static function sqlFunctionLikeBinary($pattern, $subject) { // Replace the SQL LIKE wildcard meta-characters with the equivalent regular // expression meta-characters and escape the delimiter that will be used for // matching. - $pattern = str_replace(array('%', '_'), array('.*?', '.'), preg_quote($pattern, '/')); + $pattern = str_replace(['%', '_'], ['.*?', '.'], preg_quote($pattern, '/')); return preg_match('/^' . $pattern . '$/', $subject); } /** * {@inheritdoc} */ - public function prepare($statement, array $driver_options = array()) { + public function prepare($statement, array $driver_options = []) { return new Statement($this->connection, $this, $statement, $driver_options); } /** * {@inheritdoc} */ - protected function handleQueryException(\PDOException $e, $query, array $args = array(), $options = array()) { + protected function handleQueryException(\PDOException $e, $query, array $args = [], $options = []) { // The database schema might be changed by another process in between the // time that the statement was prepared and the time the statement was run // (e.g. usually happens when running tests). In this case, we need to @@ -329,11 +329,11 @@ protected function handleQueryException(\PDOException $e, $query, array $args = parent::handleQueryException($e, $query, $args, $options); } - public function queryRange($query, $from, $count, array $args = array(), array $options = array()) { + public function queryRange($query, $from, $count, array $args = [], array $options = []) { return $this->query($query . ' LIMIT ' . (int) $from . ', ' . (int) $count, $args, $options); } - public function queryTemporary($query, array $args = array(), array $options = array()) { + public function queryTemporary($query, array $args = [], array $options = []) { // Generate a new temporary table name and protect it from prefixing. // SQLite requires that temporary tables to be non-qualified. $tablename = $this->generateTemporaryTableName(); @@ -371,12 +371,12 @@ public function createDatabase($database) { public function mapConditionOperator($operator) { // We don't want to override any of the defaults. - static $specials = array( - 'LIKE' => array('postfix' => " ESCAPE '\\'"), - 'NOT LIKE' => array('postfix' => " ESCAPE '\\'"), - 'LIKE BINARY' => array('postfix' => " ESCAPE '\\'", 'operator' => 'GLOB'), - 'NOT LIKE BINARY' => array('postfix' => " ESCAPE '\\'", 'operator' => 'NOT GLOB'), - ); + static $specials = [ + 'LIKE' => ['postfix' => " ESCAPE '\\'"], + 'NOT LIKE' => ['postfix' => " ESCAPE '\\'"], + 'LIKE BINARY' => ['postfix' => " ESCAPE '\\'", 'operator' => 'GLOB'], + 'NOT LIKE BINARY' => ['postfix' => " ESCAPE '\\'", 'operator' => 'NOT GLOB'], + ]; return isset($specials[$operator]) ? $specials[$operator] : NULL; } @@ -397,13 +397,13 @@ public function nextId($existing_id = 0) { // wait until this transaction commits. Also, the return value needs to be // set to RETURN_AFFECTED as if it were a real update() query otherwise it // is not possible to get the row count properly. - $affected = $this->query('UPDATE {sequences} SET value = GREATEST(value, :existing_id) + 1', array( + $affected = $this->query('UPDATE {sequences} SET value = GREATEST(value, :existing_id) + 1', [ ':existing_id' => $existing_id, - ), array('return' => Database::RETURN_AFFECTED)); + ], ['return' => Database::RETURN_AFFECTED]); if (!$affected) { - $this->query('INSERT INTO {sequences} (value) VALUES (:existing_id + 1)', array( + $this->query('INSERT INTO {sequences} (value) VALUES (:existing_id + 1)', [ ':existing_id' => $existing_id, - )); + ]); } // The transaction gets committed when the transaction object gets destroyed // because it gets out of scope. diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php index 506e655..0c4fdb6 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php @@ -21,7 +21,7 @@ public function execute() { return parent::execute(); } else { - return $this->connection->query('INSERT INTO {' . $this->table . '} DEFAULT VALUES', array(), $this->queryOptions); + return $this->connection->query('INSERT INTO {' . $this->table . '} DEFAULT VALUES', [], $this->queryOptions); } } @@ -30,7 +30,7 @@ public function __toString() { $comments = $this->connection->makeComment($this->comments); // Produce as many generic placeholders as necessary. - $placeholders = array(); + $placeholders = []; if (!empty($this->insertFields)) { $placeholders = array_fill(0, count($this->insertFields), '?'); } diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php index f56b26c..b0ea188 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php @@ -42,7 +42,7 @@ public function getFormOptions(array $database) { // Make the text more accurate for SQLite. $form['database']['#title'] = t('Database file'); - $form['database']['#description'] = t('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', array('@drupal' => drupal_install_profile_distribution_name())); + $form['database']['#description'] = t('The absolute path to the file where @drupal data will be stored. This must be writable by the web server and should exist outside of the web root.', ['@drupal' => drupal_install_profile_distribution_name()]); $default_database = \Drupal::service('site.path') . '/files/.ht.sqlite'; $form['database']['#default_value'] = empty($database['database']) ? $default_database : $database['database']; return $form; @@ -91,13 +91,13 @@ protected function connect() { catch (DatabaseNotFoundException $e) { // Still no dice; probably a permission issue. Raise the error to the // installer. - $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', array('%database' => $database, '%error' => $e->getMessage()))); + $this->fail(t('Database %database not found. The server reports the following message when attempting to create the database: %error.', ['%database' => $database, '%error' => $e->getMessage()])); } } else { // Database connection failed for some other reason than the database // not existing. - $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.', array('%error' => $e->getMessage()))); + $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.', ['%error' => $e->getMessage()])); return FALSE; } } diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php index 4b954ed..385b8d3 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php @@ -26,7 +26,7 @@ public function tableExists($table) { $info = $this->getPrefixInfo($table); // Don't use {} around sqlite_master table. - return (bool) $this->connection->query('SELECT 1 FROM ' . $info['schema'] . '.sqlite_master WHERE type = :type AND name = :name', array(':type' => 'table', ':name' => $info['table']))->fetchField(); + return (bool) $this->connection->query('SELECT 1 FROM ' . $info['schema'] . '.sqlite_master WHERE type = :type AND name = :name', [':type' => 'table', ':name' => $info['table']])->fetchField(); } public function fieldExists($table, $column) { @@ -45,7 +45,7 @@ public function fieldExists($table, $column) { * An array of SQL statements to create the table. */ public function createTableSql($name, $table) { - $sql = array(); + $sql = []; $sql[] = "CREATE TABLE {" . $name . "} (\n" . $this->createColumnsSql($name, $table) . "\n)\n"; return array_merge($sql, $this->createIndexSql($name, $table)); } @@ -54,7 +54,7 @@ public function createTableSql($name, $table) { * Build the SQL expression for indexes. */ protected function createIndexSql($tablename, $schema) { - $sql = array(); + $sql = []; $info = $this->getPrefixInfo($tablename); if (!empty($schema['unique keys'])) { foreach ($schema['unique keys'] as $key => $fields) { @@ -73,7 +73,7 @@ protected function createIndexSql($tablename, $schema) { * Build the SQL expression for creating columns. */ protected function createColumnsSql($tablename, $schema) { - $sql_array = array(); + $sql_array = []; // Add the SQL statement for each field. foreach ($schema['fields'] as $name => $field) { @@ -97,7 +97,7 @@ protected function createColumnsSql($tablename, $schema) { * Build the SQL expression for keys. */ protected function createKeySql($fields) { - $return = array(); + $return = []; foreach ($fields as $field) { if (is_array($field)) { $return[] = $field[0]; @@ -163,7 +163,7 @@ protected function createFieldSql($name, $spec) { else { $sql = $name . ' ' . $spec['sqlite_type']; - if (in_array($spec['sqlite_type'], array('VARCHAR', 'TEXT'))) { + if (in_array($spec['sqlite_type'], ['VARCHAR', 'TEXT'])) { if (isset($spec['length'])) { $sql .= '(' . $spec['length'] . ')'; } @@ -209,7 +209,7 @@ public function getFieldTypeMap() { // it much easier for modules (such as schema.module) to map // database types back into schema types. // $map does not use drupal_static as its value never changes. - static $map = array( + static $map = [ 'varchar_ascii:normal' => 'VARCHAR', 'varchar:normal' => 'VARCHAR', @@ -243,16 +243,16 @@ public function getFieldTypeMap() { 'blob:big' => 'BLOB', 'blob:normal' => 'BLOB', - ); + ]; return $map; } public function renameTable($table, $new_name) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", array('@table' => $table, '@table_new' => $new_name))); + throw new SchemaObjectDoesNotExistException(t("Cannot rename @table to @table_new: table @table doesn't exist.", ['@table' => $table, '@table_new' => $new_name])); } if ($this->tableExists($new_name)) { - throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", array('@table' => $table, '@table_new' => $new_name))); + throw new SchemaObjectExistsException(t("Cannot rename @table to @table_new: table @table_new already exists.", ['@table' => $table, '@table_new' => $new_name])); } $schema = $this->introspectSchema($table); @@ -293,12 +293,12 @@ public function dropTable($table) { return TRUE; } - public function addField($table, $field, $specification, $keys_new = array()) { + public function addField($table, $field, $specification, $keys_new = []) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", array('@field' => $field, '@table' => $table))); + throw new SchemaObjectDoesNotExistException(t("Cannot add field @table.@field: table doesn't exist.", ['@field' => $field, '@table' => $table])); } if ($this->fieldExists($table, $field)) { - throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", array('@field' => $field, '@table' => $table))); + throw new SchemaObjectExistsException(t("Cannot add field @table.@field: field already exists.", ['@field' => $field, '@table' => $table])); } // SQLite doesn't have a full-featured ALTER TABLE statement. It only @@ -313,7 +313,7 @@ public function addField($table, $field, $specification, $keys_new = array()) { // Apply the initial value if set. if (isset($specification['initial'])) { $this->connection->update($table) - ->fields(array($field => $specification['initial'])) + ->fields([$field => $specification['initial']]) ->execute(); } if (isset($specification['initial_from_field'])) { @@ -332,20 +332,20 @@ public function addField($table, $field, $specification, $keys_new = array()) { $new_schema['fields'][$field] = $specification; // Build the mapping between the old fields and the new fields. - $mapping = array(); + $mapping = []; if (isset($specification['initial'])) { // If we have a initial value, copy it over. - $mapping[$field] = array( + $mapping[$field] = [ 'expression' => ':newfieldinitial', - 'arguments' => array(':newfieldinitial' => $specification['initial']), - ); + 'arguments' => [':newfieldinitial' => $specification['initial']], + ]; } elseif (isset($specification['initial_from_field'])) { // If we have a initial value, copy it over. - $mapping[$field] = array( + $mapping[$field] = [ 'expression' => $specification['initial_from_field'], 'arguments' => [], - ); + ]; } else { // Else use the default of the field. @@ -380,7 +380,7 @@ public function addField($table, $field, $specification, $keys_new = array()) { * - an associative array with two keys 'expression' and 'arguments', * that will be used as an expression field. */ - protected function alterTable($table, $old_schema, $new_schema, array $mapping = array()) { + protected function alterTable($table, $old_schema, $new_schema, array $mapping = []) { $i = 0; do { $new_table = $table . '_' . $i++; @@ -441,12 +441,12 @@ protected function alterTable($table, $old_schema, $new_schema, array $mapping = */ protected function introspectSchema($table) { $mapped_fields = array_flip($this->getFieldTypeMap()); - $schema = array( - 'fields' => array(), - 'primary key' => array(), - 'unique keys' => array(), - 'indexes' => array(), - ); + $schema = [ + 'fields' => [], + 'primary key' => [], + 'unique keys' => [], + 'indexes' => [], + ]; $info = $this->getPrefixInfo($table); $result = $this->connection->query('PRAGMA ' . $info['schema'] . '.table_info(' . $info['table'] . ')'); @@ -461,12 +461,12 @@ protected function introspectSchema($table) { } if (isset($mapped_fields[$type])) { list($type, $size) = explode(':', $mapped_fields[$type]); - $schema['fields'][$row->name] = array( + $schema['fields'][$row->name] = [ 'type' => $type, 'size' => $size, 'not null' => !empty($row->notnull), 'default' => trim($row->dflt_value, "'"), - ); + ]; if ($length) { $schema['fields'][$row->name]['length'] = $length; } @@ -478,14 +478,14 @@ protected function introspectSchema($table) { throw new \Exception("Unable to parse the column type " . $row->type); } } - $indexes = array(); + $indexes = []; $result = $this->connection->query('PRAGMA ' . $info['schema'] . '.index_list(' . $info['table'] . ')'); foreach ($result as $row) { if (strpos($row->name, 'sqlite_autoindex_') !== 0) { - $indexes[] = array( + $indexes[] = [ 'schema_key' => $row->unique ? 'unique keys' : 'indexes', 'name' => $row->name, - ); + ]; } } foreach ($indexes as $index) { @@ -531,12 +531,12 @@ public function dropField($table, $field) { return TRUE; } - public function changeField($table, $field, $field_new, $spec, $keys_new = array()) { + public function changeField($table, $field, $field_new, $spec, $keys_new = []) { if (!$this->fieldExists($table, $field)) { - throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", array('@table' => $table, '@name' => $field))); + throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field @table.@name: field doesn't exist.", ['@table' => $table, '@name' => $field])); } if (($field != $field_new) && $this->fieldExists($table, $field_new)) { - throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", array('@table' => $table, '@name' => $field, '@name_new' => $field_new))); + throw new SchemaObjectExistsException(t("Cannot rename field @table.@name to @name_new: target field already exists.", ['@table' => $table, '@name' => $field, '@name_new' => $field_new])); } $old_schema = $this->introspectSchema($table); @@ -547,7 +547,7 @@ public function changeField($table, $field, $field_new, $spec, $keys_new = array $mapping[$field_new] = $field; } else { - $mapping = array(); + $mapping = []; } // Remove the previous definition and swap in the new one. @@ -556,7 +556,7 @@ public function changeField($table, $field, $field_new, $spec, $keys_new = array // Map the former indexes to the new column name. $new_schema['primary key'] = $this->mapKeyDefinition($new_schema['primary key'], $mapping); - foreach (array('unique keys', 'indexes') as $k) { + foreach (['unique keys', 'indexes'] as $k) { foreach ($new_schema[$k] as &$key_definition) { $key_definition = $this->mapKeyDefinition($key_definition, $mapping); } @@ -566,7 +566,7 @@ public function changeField($table, $field, $field_new, $spec, $keys_new = array if (isset($keys_new['primary key'])) { $new_schema['primary key'] = $keys_new['primary key']; } - foreach (array('unique keys', 'indexes') as $k) { + foreach (['unique keys', 'indexes'] as $k) { if (!empty($keys_new[$k])) { $new_schema[$k] = $keys_new[$k] + $new_schema[$k]; } @@ -601,10 +601,10 @@ protected function mapKeyDefinition(array $key_definition, array $mapping) { */ public function addIndex($table, $name, $fields, array $spec) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name))); + throw new SchemaObjectDoesNotExistException(t("Cannot add index @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name])); } if ($this->indexExists($table, $name)) { - throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", array('@table' => $table, '@name' => $name))); + throw new SchemaObjectExistsException(t("Cannot add index @name to table @table: index already exists.", ['@table' => $table, '@name' => $name])); } $schema['indexes'][$name] = $fields; @@ -633,10 +633,10 @@ public function dropIndex($table, $name) { public function addUniqueKey($table, $name, $fields) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", array('@table' => $table, '@name' => $name))); + throw new SchemaObjectDoesNotExistException(t("Cannot add unique key @name to table @table: table doesn't exist.", ['@table' => $table, '@name' => $name])); } if ($this->indexExists($table, $name)) { - throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", array('@table' => $table, '@name' => $name))); + throw new SchemaObjectExistsException(t("Cannot add unique key @name to table @table: unique key already exists.", ['@table' => $table, '@name' => $name])); } $schema['unique keys'][$name] = $fields; @@ -659,14 +659,14 @@ public function dropUniqueKey($table, $name) { public function addPrimaryKey($table, $fields) { if (!$this->tableExists($table)) { - throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", array('@table' => $table))); + throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table @table: table doesn't exist.", ['@table' => $table])); } $old_schema = $this->introspectSchema($table); $new_schema = $old_schema; if (!empty($new_schema['primary key'])) { - throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", array('@table' => $table))); + throw new SchemaObjectExistsException(t("Cannot add primary key to table @table: primary key already exists.", ['@table' => $table])); } $new_schema['primary key'] = $fields; @@ -688,7 +688,7 @@ public function dropPrimaryKey($table) { public function fieldSetDefault($table, $field, $default) { if (!$this->fieldExists($table, $field)) { - throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field))); + throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field])); } $old_schema = $this->introspectSchema($table); @@ -700,7 +700,7 @@ public function fieldSetDefault($table, $field, $default) { public function fieldSetNoDefault($table, $field) { if (!$this->fieldExists($table, $field)) { - throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", array('@table' => $table, '@field' => $field))); + throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field @table.@field: field doesn't exist.", ['@table' => $table, '@field' => $field])); } $old_schema = $this->introspectSchema($table); @@ -726,11 +726,11 @@ public function findTables($table_expression) { // Can't use query placeholders for the schema because the query would // have to be :prefixsqlite_master, which does not work. We also need to // ignore the internal SQLite tables. - $result = $this->connection->query("SELECT name FROM " . $schema . ".sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", array( + $result = $this->connection->query("SELECT name FROM " . $schema . ".sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", [ ':type' => 'table', ':table_name' => $table_expression, ':pattern' => 'sqlite_%', - )); + ]); $tables += $result->fetchAllKeyed(0, 0); } diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php index adc537c..5610d07 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php @@ -26,13 +26,13 @@ class Statement extends StatementPrefetch implements StatementInterface { * * See http://bugs.php.net/bug.php?id=45259 for more details. */ - protected function getStatement($query, &$args = array()) { + protected function getStatement($query, &$args = []) { if (count($args)) { // Check if $args is a simple numeric array. if (range(0, count($args) - 1) === array_keys($args)) { // In that case, we have unnamed placeholders. $count = 0; - $new_args = array(); + $new_args = []; foreach ($args as $value) { if (is_float($value) || is_int($value)) { if (is_float($value)) { @@ -85,7 +85,7 @@ protected function getStatement($query, &$args = array()) { /** * {@inheritdoc} */ - public function execute($args = array(), $options = array()) { + public function execute($args = [], $options = []) { try { $return = parent::execute($args, $options); } @@ -103,7 +103,7 @@ public function execute($args = array(), $options = array()) { // In some weird cases, SQLite will prefix some column names by the name // of the table. We post-process the data, by renaming the column names // using the same convention as MySQL and PostgreSQL. - $rename_columns = array(); + $rename_columns = []; foreach ($this->columnNames as $k => $column) { // In some SQLite versions, SELECT DISTINCT(field) will return "(field)" // instead of "field". diff --git a/core/lib/Drupal/Core/Database/Install/Tasks.php b/core/lib/Drupal/Core/Database/Install/Tasks.php index 2819615..a2ea41b 100644 --- a/core/lib/Drupal/Core/Database/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Install/Tasks.php @@ -26,58 +26,58 @@ * Each value of the tasks array is an associative array defining the function * to call (optional) and any arguments to be passed to the function. */ - protected $tasks = array( - array( + protected $tasks = [ + [ 'function' => 'checkEngineVersion', - 'arguments' => array(), - ), - array( - 'arguments' => array( + 'arguments' => [], + ], + [ + 'arguments' => [ 'CREATE TABLE {drupal_install_test} (id int NULL)', 'Drupal can use CREATE TABLE database commands.', 'Failed to CREATE a test table on your database server with the command %query. The server reports the following message: %error.

Are you sure the configured username has the necessary permissions to create tables in the database?

', TRUE, - ), - ), - array( - 'arguments' => array( + ], + ], + [ + 'arguments' => [ 'INSERT INTO {drupal_install_test} (id) VALUES (1)', 'Drupal can use INSERT database commands.', 'Failed to INSERT a value into a test table on your database server. We tried inserting a value with the command %query and the server reported the following error: %error.', - ), - ), - array( - 'arguments' => array( + ], + ], + [ + 'arguments' => [ 'UPDATE {drupal_install_test} SET id = 2', 'Drupal can use UPDATE database commands.', 'Failed to UPDATE a value in a test table on your database server. We tried updating a value with the command %query and the server reported the following error: %error.', - ), - ), - array( - 'arguments' => array( + ], + ], + [ + 'arguments' => [ 'DELETE FROM {drupal_install_test}', 'Drupal can use DELETE database commands.', 'Failed to DELETE a value from a test table on your database server. We tried deleting a value with the command %query and the server reported the following error: %error.', - ), - ), - array( - 'arguments' => array( + ], + ], + [ + 'arguments' => [ 'DROP TABLE {drupal_install_test}', 'Drupal can use DROP TABLE database commands.', 'Failed to DROP a test table from your database server. We tried dropping a table with the command %query and the server reported the following error %error.', - ), - ), - ); + ], + ], + ]; /** * Results from tasks. * * @var array */ - protected $results = array( - 'fail' => array(), - 'pass' => array(), - ); + protected $results = [ + 'fail' => [], + 'pass' => [], + ]; /** * Ensure the PDO driver is supported by the version of PHP in use. @@ -138,12 +138,12 @@ public function runTasks() { } if (method_exists($this, $task['function'])) { // Returning false is fatal. No other tasks can run. - if (FALSE === call_user_func_array(array($this, $task['function']), $task['arguments'])) { + if (FALSE === call_user_func_array([$this, $task['function']], $task['arguments'])) { break; } } else { - $this->fail(t("Failed to run all tasks against the database server. The task %task wasn't found.", array('%task' => $task['function']))); + $this->fail(t("Failed to run all tasks against the database server. The task %task wasn't found.", ['%task' => $task['function']])); } } } @@ -162,7 +162,7 @@ protected function connect() { $this->pass('Drupal can CONNECT to the database ok.'); } catch (\Exception $e) { - $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.', array('%error' => $e->getMessage()))); + $this->fail(t('Failed to connect to your database server. The server reports the following message: %error.', ['%error' => $e->getMessage()])); return FALSE; } return TRUE; @@ -177,7 +177,7 @@ protected function runTestQuery($query, $pass, $fail, $fatal = FALSE) { $this->pass(t($pass)); } catch (\Exception $e) { - $this->fail(t($fail, array('%query' => $query, '%error' => $e->getMessage(), '%name' => $this->name()))); + $this->fail(t($fail, ['%query' => $query, '%error' => $e->getMessage(), '%name' => $this->name()])); return !$fatal; } } @@ -188,7 +188,7 @@ protected function runTestQuery($query, $pass, $fail, $fatal = FALSE) { protected function checkEngineVersion() { // Ensure that the database server has the right version. if ($this->minimumVersion() && version_compare(Database::getConnection()->version(), $this->minimumVersion(), '<')) { - $this->fail(t("The database server version %version is less than the minimum required version %minimum_version.", array('%version' => Database::getConnection()->version(), '%minimum_version' => $this->minimumVersion()))); + $this->fail(t("The database server version %version is less than the minimum required version %minimum_version.", ['%version' => Database::getConnection()->version(), '%minimum_version' => $this->minimumVersion()])); } } @@ -202,58 +202,58 @@ protected function checkEngineVersion() { * The options form array. */ public function getFormOptions(array $database) { - $form['database'] = array( + $form['database'] = [ '#type' => 'textfield', '#title' => t('Database name'), '#default_value' => empty($database['database']) ? '' : $database['database'], '#size' => 45, '#required' => TRUE, - '#states' => array( - 'required' => array( - ':input[name=driver]' => array('value' => $this->pdoDriver), - ), - ), - ); + '#states' => [ + 'required' => [ + ':input[name=driver]' => ['value' => $this->pdoDriver], + ], + ], + ]; - $form['username'] = array( + $form['username'] = [ '#type' => 'textfield', '#title' => t('Database username'), '#default_value' => empty($database['username']) ? '' : $database['username'], '#size' => 45, '#required' => TRUE, - '#states' => array( - 'required' => array( - ':input[name=driver]' => array('value' => $this->pdoDriver), - ), - ), - ); + '#states' => [ + 'required' => [ + ':input[name=driver]' => ['value' => $this->pdoDriver], + ], + ], + ]; - $form['password'] = array( + $form['password'] = [ '#type' => 'password', '#title' => t('Database password'), '#default_value' => empty($database['password']) ? '' : $database['password'], '#required' => FALSE, '#size' => 45, - ); + ]; - $form['advanced_options'] = array( + $form['advanced_options'] = [ '#type' => 'details', '#title' => t('Advanced options'), '#weight' => 10, - ); + ]; $profile = drupal_get_profile(); $db_prefix = ($profile == 'standard') ? 'drupal_' : $profile . '_'; - $form['advanced_options']['prefix'] = array( + $form['advanced_options']['prefix'] = [ '#type' => 'textfield', '#title' => t('Table name prefix'), '#default_value' => empty($database['prefix']) ? '' : $database['prefix'], '#size' => 45, - '#description' => t('If more than one application will be sharing this database, a unique table name prefix – such as %prefix – will prevent collisions.', array('%prefix' => $db_prefix)), + '#description' => t('If more than one application will be sharing this database, a unique table name prefix – such as %prefix – will prevent collisions.', ['%prefix' => $db_prefix]), '#weight' => 10, - ); + ]; - $form['advanced_options']['host'] = array( + $form['advanced_options']['host'] = [ '#type' => 'textfield', '#title' => t('Host'), '#default_value' => empty($database['host']) ? 'localhost' : $database['host'], @@ -261,15 +261,15 @@ public function getFormOptions(array $database) { // Hostnames can be 255 characters long. '#maxlength' => 255, '#required' => TRUE, - ); + ]; - $form['advanced_options']['port'] = array( + $form['advanced_options']['port'] = [ '#type' => 'number', '#title' => t('Port number'), '#default_value' => empty($database['port']) ? '' : $database['port'], '#min' => 0, '#max' => 65535, - ); + ]; return $form; } @@ -287,11 +287,11 @@ public function getFormOptions(array $database) { * An array of driver configuration errors, keyed by form element name. */ public function validateDatabaseSettings($database) { - $errors = array(); + $errors = []; // Verify the table prefix. if (!empty($database['prefix']) && is_string($database['prefix']) && !preg_match('/^[A-Za-z0-9_.]+$/', $database['prefix'])) { - $errors[$database['driver'] . '][prefix'] = t('The database table prefix you have entered, %prefix, is invalid. The table prefix can only contain alphanumeric characters, periods, or underscores.', array('%prefix' => $database['prefix'])); + $errors[$database['driver'] . '][prefix'] = t('The database table prefix you have entered, %prefix, is invalid. The table prefix can only contain alphanumeric characters, periods, or underscores.', ['%prefix' => $database['prefix']]); } return $errors; diff --git a/core/lib/Drupal/Core/Database/Log.php b/core/lib/Drupal/Core/Database/Log.php index 76c39db..bf142c2 100644 --- a/core/lib/Drupal/Core/Database/Log.php +++ b/core/lib/Drupal/Core/Database/Log.php @@ -29,7 +29,7 @@ class Log { * * @var array */ - protected $queryLog = array(); + protected $queryLog = []; /** * The connection key for which this object is logging. @@ -86,7 +86,7 @@ public function get($logging_key) { * The logging key to empty. */ public function clear($logging_key) { - $this->queryLog[$logging_key] = array(); + $this->queryLog[$logging_key] = []; } /** @@ -111,13 +111,13 @@ public function end($logging_key) { */ public function log(StatementInterface $statement, $args, $time) { foreach (array_keys($this->queryLog) as $key) { - $this->queryLog[$key][] = array( + $this->queryLog[$key][] = [ 'query' => $statement->getQueryString(), 'args' => $args, 'target' => $statement->dbh->getTarget(), 'caller' => $this->findCaller(), 'time' => $time, - ); + ]; } } @@ -151,15 +151,15 @@ public function findCaller() { $stack[$i]['class'] = ''; } if (strpos($stack[$i]['class'], __NAMESPACE__) === FALSE && strpos($stack[$i + 1]['function'], 'db_') === FALSE && !empty($stack[$i]['file'])) { - $stack[$i] += array('file' => '?', 'line' => '?', 'args' => array()); - return array( + $stack[$i] += ['file' => '?', 'line' => '?', 'args' => []]; + return [ 'file' => $stack[$i]['file'], 'line' => $stack[$i]['line'], 'function' => $stack[$i + 1]['function'], 'class' => isset($stack[$i + 1]['class']) ? $stack[$i + 1]['class'] : NULL, 'type' => isset($stack[$i + 1]['type']) ? $stack[$i + 1]['type'] : NULL, 'args' => $stack[$i + 1]['args'], - ); + ]; } } } diff --git a/core/lib/Drupal/Core/Database/Query/Condition.php b/core/lib/Drupal/Core/Database/Query/Condition.php index ad7397e..effab67 100644 --- a/core/lib/Drupal/Core/Database/Query/Condition.php +++ b/core/lib/Drupal/Core/Database/Query/Condition.php @@ -15,14 +15,14 @@ class Condition implements ConditionInterface, \Countable { * * @var array */ - protected $conditions = array(); + protected $conditions = []; /** * Array of arguments. * * @var array */ - protected $arguments = array(); + protected $arguments = []; /** * Whether the conditions have been changed. @@ -71,11 +71,11 @@ public function condition($field, $value = NULL, $operator = '=') { throw new InvalidQueryException(sprintf("Query condition '%s %s ()' cannot be empty.", $field, $operator)); } - $this->conditions[] = array( + $this->conditions[] = [ 'field' => $field, 'value' => $value, 'operator' => $operator, - ); + ]; $this->changed = TRUE; @@ -85,12 +85,12 @@ public function condition($field, $value = NULL, $operator = '=') { /** * {@inheritdoc} */ - public function where($snippet, $args = array()) { - $this->conditions[] = array( + public function where($snippet, $args = []) { + $this->conditions[] = [ 'field' => $snippet, 'value' => $args, 'operator' => NULL, - ); + ]; $this->changed = TRUE; return $this; @@ -151,8 +151,8 @@ public function compile(Connection $connection, PlaceholderInterface $queryPlace if ($this->changed || isset($this->queryPlaceholderIdentifier) && ($this->queryPlaceholderIdentifier != $queryPlaceholder->uniqueIdentifier())) { $this->queryPlaceholderIdentifier = $queryPlaceholder->uniqueIdentifier(); - $condition_fragments = array(); - $arguments = array(); + $condition_fragments = []; + $arguments = []; $conditions = $this->conditions; $conjunction = $conditions['#conjunction']; @@ -176,13 +176,13 @@ public function compile(Connection $connection, PlaceholderInterface $queryPlace else { // For simplicity, we treat all operators as the same data structure. // In the typical degenerate case, this won't get changed. - $operator_defaults = array( + $operator_defaults = [ 'prefix' => '', 'postfix' => '', 'delimiter' => '', 'operator' => $condition['operator'], 'use_value' => TRUE, - ); + ]; // Remove potentially dangerous characters. // If something passed in an invalid character stop early, so we // don't rely on a broken SQL statement when we would just replace @@ -208,7 +208,7 @@ public function compile(Connection $connection, PlaceholderInterface $queryPlace } $operator += $operator_defaults; - $placeholders = array(); + $placeholders = []; if ($condition['value'] instanceof SelectInterface) { $condition['value']->compile($connection, $queryPlaceholder); $placeholders[] = (string) $condition['value']; @@ -221,7 +221,7 @@ public function compile(Connection $connection, PlaceholderInterface $queryPlace // array. If not, it is a scalar. For simplicity, we first convert // up to an array so that we can build the placeholders in the same way. elseif (!$operator['delimiter'] && !is_array($condition['value'])) { - $condition['value'] = array($condition['value']); + $condition['value'] = [$condition['value']]; } if ($operator['use_value']) { foreach ($condition['value'] as $value) { @@ -298,25 +298,25 @@ function __clone() { */ protected function mapConditionOperator($operator) { // $specials does not use drupal_static as its value never changes. - static $specials = array( - 'BETWEEN' => array('delimiter' => ' AND '), - 'NOT BETWEEN' => array('delimiter' => ' AND '), - 'IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'), - 'NOT IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'), - 'EXISTS' => array('prefix' => ' (', 'postfix' => ')'), - 'NOT EXISTS' => array('prefix' => ' (', 'postfix' => ')'), - 'IS NULL' => array('use_value' => FALSE), - 'IS NOT NULL' => array('use_value' => FALSE), + static $specials = [ + 'BETWEEN' => ['delimiter' => ' AND '], + 'NOT BETWEEN' => ['delimiter' => ' AND '], + 'IN' => ['delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'], + 'NOT IN' => ['delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'], + 'EXISTS' => ['prefix' => ' (', 'postfix' => ')'], + 'NOT EXISTS' => ['prefix' => ' (', 'postfix' => ')'], + 'IS NULL' => ['use_value' => FALSE], + 'IS NOT NULL' => ['use_value' => FALSE], // Use backslash for escaping wildcard characters. - 'LIKE' => array('postfix' => " ESCAPE '\\\\'"), - 'NOT LIKE' => array('postfix' => " ESCAPE '\\\\'"), + 'LIKE' => ['postfix' => " ESCAPE '\\\\'"], + 'NOT LIKE' => ['postfix' => " ESCAPE '\\\\'"], // These ones are here for performance reasons. - '=' => array(), - '<' => array(), - '>' => array(), - '>=' => array(), - '<=' => array(), - ); + '=' => [], + '<' => [], + '>' => [], + '>=' => [], + '<=' => [], + ]; if (isset($specials[$operator])) { $return = $specials[$operator]; } @@ -324,10 +324,10 @@ protected function mapConditionOperator($operator) { // We need to upper case because PHP index matches are case sensitive but // do not need the more expensive Unicode::strtoupper() because SQL statements are ASCII. $operator = strtoupper($operator); - $return = isset($specials[$operator]) ? $specials[$operator] : array(); + $return = isset($specials[$operator]) ? $specials[$operator] : []; } - $return += array('operator' => $operator); + $return += ['operator' => $operator]; return $return; } diff --git a/core/lib/Drupal/Core/Database/Query/ConditionInterface.php b/core/lib/Drupal/Core/Database/Query/ConditionInterface.php index bd0b52b..45e31a3 100644 --- a/core/lib/Drupal/Core/Database/Query/ConditionInterface.php +++ b/core/lib/Drupal/Core/Database/Query/ConditionInterface.php @@ -63,7 +63,7 @@ public function condition($field, $value = NULL, $operator = '='); * @return \Drupal\Core\Database\Query\ConditionInterface * The called object. */ - public function where($snippet, $args = array()); + public function where($snippet, $args = []); /** * Sets a condition that the specified field be NULL. diff --git a/core/lib/Drupal/Core/Database/Query/Delete.php b/core/lib/Drupal/Core/Database/Query/Delete.php index 65f96c9..def8838 100644 --- a/core/lib/Drupal/Core/Database/Query/Delete.php +++ b/core/lib/Drupal/Core/Database/Query/Delete.php @@ -31,7 +31,7 @@ class Delete extends Query implements ConditionInterface { * @param array $options * Array of database options. */ - public function __construct(Connection $connection, $table, array $options = array()) { + public function __construct(Connection $connection, $table, array $options = []) { $options['return'] = Database::RETURN_AFFECTED; parent::__construct($connection, $options); $this->table = $table; @@ -46,7 +46,7 @@ public function __construct(Connection $connection, $table, array $options = arr * The number of rows affected by the delete query. */ public function execute() { - $values = array(); + $values = []; if (count($this->condition)) { $this->condition->compile($this->connection, $this); $values = $this->condition->arguments(); diff --git a/core/lib/Drupal/Core/Database/Query/Insert.php b/core/lib/Drupal/Core/Database/Query/Insert.php index a0fa599..f99a965 100644 --- a/core/lib/Drupal/Core/Database/Query/Insert.php +++ b/core/lib/Drupal/Core/Database/Query/Insert.php @@ -30,7 +30,7 @@ class Insert extends Query implements \Countable { * @param array $options * Array of database options. */ - public function __construct($connection, $table, array $options = array()) { + public function __construct($connection, $table, array $options = []) { if (!isset($options['return'])) { $options['return'] = Database::RETURN_INSERT_ID; } @@ -97,7 +97,7 @@ public function execute() { } // Re-initialize the values array so that we can re-use this query. - $this->insertValues = array(); + $this->insertValues = []; // Transaction commits here where $transaction looses scope. @@ -124,7 +124,7 @@ public function __toString() { // For simplicity, we will use the $placeholders array to inject // default keywords even though they are not, strictly speaking, // placeholders for prepared statements. - $placeholders = array(); + $placeholders = []; $placeholders = array_pad($placeholders, count($this->defaultFields), 'default'); $placeholders = array_pad($placeholders, count($this->insertFields), '?'); diff --git a/core/lib/Drupal/Core/Database/Query/InsertTrait.php b/core/lib/Drupal/Core/Database/Query/InsertTrait.php index a97c132..f291da1 100644 --- a/core/lib/Drupal/Core/Database/Query/InsertTrait.php +++ b/core/lib/Drupal/Core/Database/Query/InsertTrait.php @@ -21,14 +21,14 @@ * * @var array */ - protected $insertFields = array(); + protected $insertFields = []; /** * An array of fields that should be set to their database-defined defaults. * * @var array */ - protected $defaultFields = array(); + protected $defaultFields = []; /** * A nested array of values to insert. @@ -45,7 +45,7 @@ * * @var array */ - protected $insertValues = array(); + protected $insertValues = []; /** * Adds a set of field->value pairs to be inserted. @@ -67,7 +67,7 @@ * @return $this * The called object. */ - public function fields(array $fields, array $values = array()) { + public function fields(array $fields, array $values = []) { if (empty($this->insertFields)) { if (empty($values)) { if (!is_numeric(key($fields))) { @@ -150,10 +150,10 @@ public function useDefaults(array $fields) { */ protected function getInsertPlaceholderFragment(array $nested_insert_values, array $default_fields) { $max_placeholder = 0; - $values = array(); + $values = []; if ($nested_insert_values) { foreach ($nested_insert_values as $insert_values) { - $placeholders = array(); + $placeholders = []; // Default fields aren't really placeholders, but this is the most convenient // way to handle them. diff --git a/core/lib/Drupal/Core/Database/Query/Merge.php b/core/lib/Drupal/Core/Database/Query/Merge.php index 8bd02fa..43188ec 100644 --- a/core/lib/Drupal/Core/Database/Query/Merge.php +++ b/core/lib/Drupal/Core/Database/Query/Merge.php @@ -74,7 +74,7 @@ class Merge extends Query implements ConditionInterface { * * @var array */ - protected $insertFields = array(); + protected $insertFields = []; /** * An array of fields which should be set to their database-defined defaults. @@ -83,21 +83,21 @@ class Merge extends Query implements ConditionInterface { * * @var array */ - protected $defaultFields = array(); + protected $defaultFields = []; /** * An array of values to be inserted. * * @var string */ - protected $insertValues = array(); + protected $insertValues = []; /** * An array of fields that will be updated. * * @var array */ - protected $updateFields = array(); + protected $updateFields = []; /** * Array of fields to update to an expression in case of a duplicate record. @@ -112,7 +112,7 @@ class Merge extends Query implements ConditionInterface { * * @var array */ - protected $expressionFields = array(); + protected $expressionFields = []; /** * Flag indicating whether an UPDATE is necessary. @@ -131,7 +131,7 @@ class Merge extends Query implements ConditionInterface { * @param array $options * Array of database options. */ - public function __construct(Connection $connection, $table, array $options = array()) { + public function __construct(Connection $connection, $table, array $options = []) { $options['return'] = Database::RETURN_AFFECTED; parent::__construct($connection, $options); $this->table = $table; @@ -190,10 +190,10 @@ public function updateFields(array $fields) { * The called object. */ public function expression($field, $expression, array $arguments = NULL) { - $this->expressionFields[$field] = array( + $this->expressionFields[$field] = [ 'expression' => $expression, 'arguments' => $arguments, - ); + ]; $this->needsUpdate = TRUE; return $this; } @@ -214,7 +214,7 @@ public function expression($field, $expression, array $arguments = NULL) { * @return \Drupal\Core\Database\Query\Merge * The called object. */ - public function insertFields(array $fields, array $values = array()) { + public function insertFields(array $fields, array $values = []) { if ($values) { $fields = array_combine($fields, $values); } @@ -267,7 +267,7 @@ public function useDefaults(array $fields) { * @return \Drupal\Core\Database\Query\Merge * The called object. */ - public function fields(array $fields, array $values = array()) { + public function fields(array $fields, array $values = []) { if ($values) { $fields = array_combine($fields, $values); } @@ -300,7 +300,7 @@ public function fields(array $fields, array $values = array()) { * * @return $this */ - public function keys(array $fields, array $values = array()) { + public function keys(array $fields, array $values = []) { if ($values) { $fields = array_combine($fields, $values); } @@ -329,10 +329,10 @@ public function keys(array $fields, array $values = array()) { public function key($field, $value = NULL) { // @todo D9: Remove this backwards-compatibility shim. if (is_array($field)) { - $this->keys($field, isset($value) ? $value : array()); + $this->keys($field, isset($value) ? $value : []); } else { - $this->keys(array($field => $value)); + $this->keys([$field => $value]); } return $this; } @@ -351,9 +351,9 @@ public function __toString() { public function execute() { // Default options for merge queries. - $this->queryOptions += array( + $this->queryOptions += [ 'throw_exception' => TRUE, - ); + ]; try { if (!count($this->condition)) { diff --git a/core/lib/Drupal/Core/Database/Query/Query.php b/core/lib/Drupal/Core/Database/Query/Query.php index 6fe3db5..94f71a5 100644 --- a/core/lib/Drupal/Core/Database/Query/Query.php +++ b/core/lib/Drupal/Core/Database/Query/Query.php @@ -56,7 +56,7 @@ * * @var array */ - protected $comments = array(); + protected $comments = []; /** * Constructs a Query object. diff --git a/core/lib/Drupal/Core/Database/Query/QueryConditionTrait.php b/core/lib/Drupal/Core/Database/Query/QueryConditionTrait.php index bc7ed5a..44cc220 100644 --- a/core/lib/Drupal/Core/Database/Query/QueryConditionTrait.php +++ b/core/lib/Drupal/Core/Database/Query/QueryConditionTrait.php @@ -77,7 +77,7 @@ public function arguments() { /** * {@inheritdoc} */ - public function where($snippet, $args = array()) { + public function where($snippet, $args = []) { $this->condition->where($snippet, $args); return $this; } diff --git a/core/lib/Drupal/Core/Database/Query/Select.php b/core/lib/Drupal/Core/Database/Query/Select.php index b7db605..7e8de35 100644 --- a/core/lib/Drupal/Core/Database/Query/Select.php +++ b/core/lib/Drupal/Core/Database/Query/Select.php @@ -20,14 +20,14 @@ class Select extends Query implements SelectInterface { * * @var array */ - protected $fields = array(); + protected $fields = []; /** * The expressions to SELECT as virtual fields. * * @var array */ - protected $expressions = array(); + protected $expressions = []; /** * The tables against which to JOIN. @@ -53,7 +53,7 @@ class Select extends Query implements SelectInterface { * * @var array */ - protected $tables = array(); + protected $tables = []; /** * The fields by which to order this query. @@ -63,14 +63,14 @@ class Select extends Query implements SelectInterface { * * @var array */ - protected $order = array(); + protected $order = []; /** * The fields by which to group. * * @var array */ - protected $group = array(); + protected $group = []; /** * The conditional object for the HAVING clause. @@ -104,7 +104,7 @@ class Select extends Query implements SelectInterface { * * @var array */ - protected $union = array(); + protected $union = []; /** * Indicates if preExecute() has already been called. @@ -129,7 +129,7 @@ class Select extends Query implements SelectInterface { * @param array $options * Array of query options. */ - public function __construct($table, $alias = NULL, Connection $connection, $options = array()) { + public function __construct($table, $alias = NULL, Connection $connection, $options = []) { $options['return'] = Database::RETURN_STATEMENT; parent::__construct($connection, $options); $conjunction = isset($options['conjunction']) ? $options['conjunction'] : 'AND'; @@ -301,7 +301,7 @@ public function havingArguments() { /** * {@inheritdoc} */ - public function having($snippet, $args = array()) { + public function having($snippet, $args = []) { $this->having->where($snippet, $args); return $this; } @@ -456,7 +456,7 @@ public function preExecute(SelectInterface $query = NULL) { // Modules may alter all queries or only those having a particular tag. if (isset($this->alterTags)) { - $hooks = array('query'); + $hooks = ['query']; foreach ($this->alterTags as $tag => $value) { $hooks[] = 'query_' . $tag; } @@ -523,11 +523,11 @@ public function addField($table_alias, $field, $alias = NULL) { } $alias = $alias_candidate; - $this->fields[$alias] = array( + $this->fields[$alias] = [ 'field' => $field, 'table' => $table_alias, 'alias' => $alias, - ); + ]; return $alias; } @@ -535,7 +535,7 @@ public function addField($table_alias, $field, $alias = NULL) { /** * {@inheritdoc} */ - public function fields($table_alias, array $fields = array()) { + public function fields($table_alias, array $fields = []) { if ($fields) { foreach ($fields as $field) { // We don't care what alias was assigned. @@ -553,7 +553,7 @@ public function fields($table_alias, array $fields = array()) { /** * {@inheritdoc} */ - public function addExpression($expression, $alias = NULL, $arguments = array()) { + public function addExpression($expression, $alias = NULL, $arguments = []) { if (empty($alias)) { $alias = 'expression'; } @@ -565,11 +565,11 @@ public function addExpression($expression, $alias = NULL, $arguments = array()) } $alias = $alias_candidate; - $this->expressions[$alias] = array( + $this->expressions[$alias] = [ 'expression' => $expression, 'alias' => $alias, 'arguments' => $arguments, - ); + ]; return $alias; } @@ -577,35 +577,35 @@ public function addExpression($expression, $alias = NULL, $arguments = array()) /** * {@inheritdoc} */ - public function join($table, $alias = NULL, $condition = NULL, $arguments = array()) { + public function join($table, $alias = NULL, $condition = NULL, $arguments = []) { return $this->addJoin('INNER', $table, $alias, $condition, $arguments); } /** * {@inheritdoc} */ - public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) { + public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = []) { return $this->addJoin('INNER', $table, $alias, $condition, $arguments); } /** * {@inheritdoc} */ - public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) { + public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = []) { return $this->addJoin('LEFT OUTER', $table, $alias, $condition, $arguments); } /** * {@inheritdoc} */ - public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) { + public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = []) { return $this->addJoin('RIGHT OUTER', $table, $alias, $condition, $arguments); } /** * {@inheritdoc} */ - public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array()) { + public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = []) { if (empty($alias)) { if ($table instanceof SelectInterface) { $alias = 'subquery'; @@ -626,13 +626,13 @@ public function addJoin($type, $table, $alias = NULL, $condition = NULL, $argume $condition = str_replace('%alias', $alias, $condition); } - $this->tables[$alias] = array( + $this->tables[$alias] = [ 'join type' => $type, 'table' => $table, 'alias' => $alias, 'condition' => $condition, 'arguments' => $arguments, - ); + ]; return $alias; } @@ -660,7 +660,7 @@ public function orderRandom() { * {@inheritdoc} */ public function range($start = NULL, $length = NULL) { - $this->range = $start !== NULL ? array('start' => $start, 'length' => $length) : array(); + $this->range = $start !== NULL ? ['start' => $start, 'length' => $length] : []; return $this; } @@ -681,10 +681,10 @@ public function union(SelectInterface $query, $type = '') { default: } - $this->union[] = array( + $this->union[] = [ 'type' => $type, 'query' => $query, - ); + ]; return $this; } @@ -755,7 +755,7 @@ protected function prepareCountQuery() { // Ordering a count query is a waste of cycles, and breaks on some // databases anyway. $orders = &$count->getOrderBy(); - $orders = array(); + $orders = []; if ($count->distinct && !empty($group_by)) { // If the query is distinct and contains a GROUP BY, we need to remove the @@ -794,7 +794,7 @@ public function __toString() { } // FIELDS and EXPRESSIONS - $fields = array(); + $fields = []; foreach ($this->tables as $alias => $table) { if (!empty($table['all_fields'])) { $fields[] = $this->connection->escapeTable($alias) . '.*'; @@ -871,7 +871,7 @@ public function __toString() { // ORDER BY if ($this->order) { $query .= "\nORDER BY "; - $fields = array(); + $fields = []; foreach ($this->order as $field => $direction) { $fields[] = $this->connection->escapeField($field) . ' ' . $direction; } diff --git a/core/lib/Drupal/Core/Database/Query/SelectExtender.php b/core/lib/Drupal/Core/Database/Query/SelectExtender.php index 808593c..56fe7c1 100644 --- a/core/lib/Drupal/Core/Database/Query/SelectExtender.php +++ b/core/lib/Drupal/Core/Database/Query/SelectExtender.php @@ -72,14 +72,14 @@ public function hasTag($tag) { * {@inheritdoc} */ public function hasAllTags() { - return call_user_func_array(array($this->query, 'hasAllTags'), func_get_args()); + return call_user_func_array([$this->query, 'hasAllTags'], func_get_args()); } /** * {@inheritdoc} */ public function hasAnyTag() { - return call_user_func_array(array($this->query, 'hasAnyTag'), func_get_args()); + return call_user_func_array([$this->query, 'hasAnyTag'], func_get_args()); } /** @@ -122,7 +122,7 @@ public function arguments() { /** * {@inheritdoc} */ - public function where($snippet, $args = array()) { + public function where($snippet, $args = []) { $this->query->where($snippet, $args); return $this; } @@ -166,7 +166,7 @@ public function havingArguments() { /** * {@inheritdoc} */ - public function having($snippet, $args = array()) { + public function having($snippet, $args = []) { $this->query->having($snippet, $args); return $this; } @@ -335,7 +335,7 @@ public function addField($table_alias, $field, $alias = NULL) { /** * {@inheritdoc} */ - public function fields($table_alias, array $fields = array()) { + public function fields($table_alias, array $fields = []) { $this->query->fields($table_alias, $fields); return $this; } @@ -343,42 +343,42 @@ public function fields($table_alias, array $fields = array()) { /** * {@inheritdoc} */ - public function addExpression($expression, $alias = NULL, $arguments = array()) { + public function addExpression($expression, $alias = NULL, $arguments = []) { return $this->query->addExpression($expression, $alias, $arguments); } /** * {@inheritdoc} */ - public function join($table, $alias = NULL, $condition = NULL, $arguments = array()) { + public function join($table, $alias = NULL, $condition = NULL, $arguments = []) { return $this->query->join($table, $alias, $condition, $arguments); } /** * {@inheritdoc} */ - public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) { + public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = []) { return $this->query->innerJoin($table, $alias, $condition, $arguments); } /** * {@inheritdoc} */ - public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) { + public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = []) { return $this->query->leftJoin($table, $alias, $condition, $arguments); } /** * {@inheritdoc} */ - public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = array()) { + public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = []) { return $this->query->rightJoin($table, $alias, $condition, $arguments); } /** * {@inheritdoc} */ - public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array()) { + public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = []) { return $this->query->addJoin($type, $table, $alias, $condition, $arguments); } @@ -497,7 +497,7 @@ public function __clone() { * to handle any additional methods. */ public function __call($method, $args) { - $return = call_user_func_array(array($this->query, $method), $args); + $return = call_user_func_array([$this->query, $method], $args); // Some methods will return the called object as part of a fluent interface. // Others will return some useful value. If it's a value, then the caller diff --git a/core/lib/Drupal/Core/Database/Query/SelectInterface.php b/core/lib/Drupal/Core/Database/Query/SelectInterface.php index aa358d3..59b15d0 100644 --- a/core/lib/Drupal/Core/Database/Query/SelectInterface.php +++ b/core/lib/Drupal/Core/Database/Query/SelectInterface.php @@ -214,7 +214,7 @@ public function addField($table_alias, $field, $alias = NULL); * @return \Drupal\Core\Database\Query\SelectInterface * The called object. */ - public function fields($table_alias, array $fields = array()); + public function fields($table_alias, array $fields = []); /** * Adds an expression to the list of "fields" to be SELECTed. @@ -235,7 +235,7 @@ public function fields($table_alias, array $fields = array()); * @return * The unique alias that was assigned for this expression. */ - public function addExpression($expression, $alias = NULL, $arguments = array()); + public function addExpression($expression, $alias = NULL, $arguments = []); /** * Default Join against another table in the database. @@ -263,7 +263,7 @@ public function addExpression($expression, $alias = NULL, $arguments = array()); * @return * The unique alias that was assigned for this table. */ - public function join($table, $alias = NULL, $condition = NULL, $arguments = array()); + public function join($table, $alias = NULL, $condition = NULL, $arguments = []); /** * Inner Join against another table in the database. @@ -289,7 +289,7 @@ public function join($table, $alias = NULL, $condition = NULL, $arguments = arra * @return * The unique alias that was assigned for this table. */ - public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = array()); + public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = []); /** * Left Outer Join against another table in the database. @@ -315,7 +315,7 @@ public function innerJoin($table, $alias = NULL, $condition = NULL, $arguments = * @return * The unique alias that was assigned for this table. */ - public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = array()); + public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = []); /** * Right Outer Join against another table in the database. @@ -347,7 +347,7 @@ public function leftJoin($table, $alias = NULL, $condition = NULL, $arguments = * db_query('B')->leftJoin('A'). This functionality has been deprecated * because SQLite does not support it. */ - public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = array()); + public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = []); /** * Join against another table in the database. @@ -380,7 +380,7 @@ public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = * @return * The unique alias that was assigned for this table. */ - public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = array()); + public function addJoin($type, $table, $alias = NULL, $condition = NULL, $arguments = []); /** * Orders the result set by a given field. @@ -574,7 +574,7 @@ public function havingArguments(); * * @return $this */ - public function having($snippet, $args = array()); + public function having($snippet, $args = []); /** * Compiles the HAVING clause for later retrieval. diff --git a/core/lib/Drupal/Core/Database/Query/TableSortExtender.php b/core/lib/Drupal/Core/Database/Query/TableSortExtender.php index 285f1d6..4f739ee 100644 --- a/core/lib/Drupal/Core/Database/Query/TableSortExtender.php +++ b/core/lib/Drupal/Core/Database/Query/TableSortExtender.php @@ -12,7 +12,7 @@ class TableSortExtender extends SelectExtender { /** * The array of fields that can be sorted by. */ - protected $header = array(); + protected $header = []; public function __construct(SelectInterface $query, Connection $connection) { parent::__construct($query, $connection); diff --git a/core/lib/Drupal/Core/Database/Query/Truncate.php b/core/lib/Drupal/Core/Database/Query/Truncate.php index 64520ee..1711ade 100644 --- a/core/lib/Drupal/Core/Database/Query/Truncate.php +++ b/core/lib/Drupal/Core/Database/Query/Truncate.php @@ -28,7 +28,7 @@ class Truncate extends Query { * @param array $options * Array of database options. */ - public function __construct(Connection $connection, $table, array $options = array()) { + public function __construct(Connection $connection, $table, array $options = []) { $options['return'] = Database::RETURN_AFFECTED; parent::__construct($connection, $options); $this->table = $table; @@ -55,7 +55,7 @@ public function compiled() { * Return value is dependent on the database type. */ public function execute() { - return $this->connection->query((string) $this, array(), $this->queryOptions); + return $this->connection->query((string) $this, [], $this->queryOptions); } /** diff --git a/core/lib/Drupal/Core/Database/Query/Update.php b/core/lib/Drupal/Core/Database/Query/Update.php index d6b93b7..ba0661c 100644 --- a/core/lib/Drupal/Core/Database/Query/Update.php +++ b/core/lib/Drupal/Core/Database/Query/Update.php @@ -26,14 +26,14 @@ class Update extends Query implements ConditionInterface { * * @var array */ - protected $fields = array(); + protected $fields = []; /** * An array of values to update to. * * @var array */ - protected $arguments = array(); + protected $arguments = []; /** * Array of fields to update to an expression in case of a duplicate record. @@ -48,7 +48,7 @@ class Update extends Query implements ConditionInterface { * * @var array */ - protected $expressionFields = array(); + protected $expressionFields = []; /** * Constructs an Update query object. @@ -60,7 +60,7 @@ class Update extends Query implements ConditionInterface { * @param array $options * Array of database options. */ - public function __construct(Connection $connection, $table, array $options = array()) { + public function __construct(Connection $connection, $table, array $options = []) { $options['return'] = Database::RETURN_AFFECTED; parent::__construct($connection, $options); $this->table = $table; @@ -102,10 +102,10 @@ public function fields(array $fields) { * The called object. */ public function expression($field, $expression, array $arguments = NULL) { - $this->expressionFields[$field] = array( + $this->expressionFields[$field] = [ 'expression' => $expression, 'arguments' => $arguments, - ); + ]; return $this; } @@ -121,7 +121,7 @@ public function execute() { // Expressions take priority over literal fields, so we process those first // and remove any literal fields that conflict. $fields = $this->fields; - $update_values = array(); + $update_values = []; foreach ($this->expressionFields as $field => $data) { if (!empty($data['arguments'])) { $update_values += $data['arguments']; @@ -161,7 +161,7 @@ public function __toString() { // Expressions take priority over literal fields, so we process those first // and remove any literal fields that conflict. $fields = $this->fields; - $update_fields = array(); + $update_fields = []; foreach ($this->expressionFields as $field => $data) { if ($data['expression'] instanceof SelectInterface) { // Compile and cast expression subquery to a string. diff --git a/core/lib/Drupal/Core/Database/Query/Upsert.php b/core/lib/Drupal/Core/Database/Query/Upsert.php index dec2d3b..a406d7a 100644 --- a/core/lib/Drupal/Core/Database/Query/Upsert.php +++ b/core/lib/Drupal/Core/Database/Query/Upsert.php @@ -96,7 +96,7 @@ public function execute() { } $max_placeholder = 0; - $values = array(); + $values = []; foreach ($this->insertValues as $insert_values) { foreach ($insert_values as $value) { $values[':db_insert_placeholder_' . $max_placeholder++] = $value; @@ -106,7 +106,7 @@ public function execute() { $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(); + $this->insertValues = []; return $last_insert_id; } diff --git a/core/lib/Drupal/Core/Database/Schema.php b/core/lib/Drupal/Core/Database/Schema.php index 8b9eb7e..eb98bb1 100644 --- a/core/lib/Drupal/Core/Database/Schema.php +++ b/core/lib/Drupal/Core/Database/Schema.php @@ -77,10 +77,10 @@ public function nextPlaceholder() { * A keyed array with information about the schema, table name and prefix. */ protected function getPrefixInfo($table = 'default', $add_prefix = TRUE) { - $info = array( + $info = [ 'schema' => $this->defaultSchema, 'prefix' => $this->connection->tablePrefix($table), - ); + ]; if ($add_prefix) { $table = $info['prefix'] . $table; } @@ -224,7 +224,7 @@ public function findTables($table_expression) { // Convert the table expression from its SQL LIKE syntax to a regular // expression and escape the delimiter that will be used for matching. - $table_expression = str_replace(array('%', '_'), array('.*?', '.'), preg_quote($table_expression, '/')); + $table_expression = str_replace(['%', '_'], ['.*?', '.'], preg_quote($table_expression, '/')); $tables = preg_grep('/^' . $table_expression . '$/i', $tables); return $tables; @@ -320,7 +320,7 @@ public function fieldExists($table, $column) { * @throws \Drupal\Core\Database\SchemaObjectExistsException * If the specified table already has a field by that name. */ - abstract public function addField($table, $field, $spec, $keys_new = array()); + abstract public function addField($table, $field, $spec, $keys_new = []); /** * Drop a field. @@ -576,7 +576,7 @@ public function fieldExists($table, $column) { * @throws \Drupal\Core\Database\SchemaObjectExistsException * If the specified destination field already exists. */ - abstract public function changeField($table, $field, $field_new, $spec, $keys_new = array()); + abstract public function changeField($table, $field, $field_new, $spec, $keys_new = []); /** * Create a new table from a Drupal table definition. @@ -591,7 +591,7 @@ public function fieldExists($table, $column) { */ public function createTable($name, $table) { if ($this->tableExists($name)) { - throw new SchemaObjectExistsException(t('Table @name already exists.', array('@name' => $name))); + throw new SchemaObjectExistsException(t('Table @name already exists.', ['@name' => $name])); } $statements = $this->createTableSql($name, $table); foreach ($statements as $statement) { @@ -612,7 +612,7 @@ public function createTable($name, $table) { * An array of field names. */ public function fieldNames($fields) { - $return = array(); + $return = []; foreach ($fields as $field) { if (is_array($field)) { $return[] = $field[0]; diff --git a/core/lib/Drupal/Core/Database/Statement.php b/core/lib/Drupal/Core/Database/Statement.php index d448532..8060fbc 100644 --- a/core/lib/Drupal/Core/Database/Statement.php +++ b/core/lib/Drupal/Core/Database/Statement.php @@ -39,7 +39,7 @@ protected function __construct(Connection $dbh) { /** * {@inheritdoc} */ - public function execute($args = array(), $options = array()) { + public function execute($args = [], $options = []) { if (isset($options['fetch'])) { if (is_string($options['fetch'])) { // \PDO::FETCH_PROPS_LATE tells __construct() to run before properties @@ -84,7 +84,7 @@ public function fetchCol($index = 0) { * {@inheritdoc} */ public function fetchAllAssoc($key, $fetch = NULL) { - $return = array(); + $return = []; if (isset($fetch)) { if (is_string($fetch)) { $this->setFetchMode(\PDO::FETCH_CLASS, $fetch); @@ -106,7 +106,7 @@ public function fetchAllAssoc($key, $fetch = NULL) { * {@inheritdoc} */ public function fetchAllKeyed($key_index = 0, $value_index = 1) { - $return = array(); + $return = []; $this->setFetchMode(\PDO::FETCH_NUM); foreach ($this as $record) { $return[$record[$key_index]] = $record[$value_index]; @@ -146,7 +146,7 @@ public function rowCount() { /** * {@inheritdoc} */ - public function setFetchMode($mode, $a1 = NULL, $a2 = array()) { + public function setFetchMode($mode, $a1 = NULL, $a2 = []) { // Call \PDOStatement::setFetchMode to set fetch mode. // \PDOStatement is picky about the number of arguments in some cases so we // need to be pass the exact number of arguments we where given. diff --git a/core/lib/Drupal/Core/Database/StatementEmpty.php b/core/lib/Drupal/Core/Database/StatementEmpty.php index 32b29d5..343b90c 100644 --- a/core/lib/Drupal/Core/Database/StatementEmpty.php +++ b/core/lib/Drupal/Core/Database/StatementEmpty.php @@ -26,7 +26,7 @@ class StatementEmpty implements \Iterator, StatementInterface { /** * {@inheritdoc} */ - public function execute($args = array(), $options = array()) { + public function execute($args = [], $options = []) { return FALSE; } @@ -50,7 +50,7 @@ public function rowCount() { /** * {@inheritdoc} */ - public function setFetchMode($mode, $a1 = NULL, $a2 = array()) { + public function setFetchMode($mode, $a1 = NULL, $a2 = []) { return; } @@ -86,28 +86,28 @@ public function fetchAssoc() { * {@inheritdoc} */ public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) { - return array(); + return []; } /** * {@inheritdoc} */ public function fetchCol($index = 0) { - return array(); + return []; } /** * {@inheritdoc} */ public function fetchAllKeyed($key_index = 0, $value_index = 1) { - return array(); + return []; } /** * {@inheritdoc} */ public function fetchAllAssoc($key, $fetch = NULL) { - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Database/StatementInterface.php b/core/lib/Drupal/Core/Database/StatementInterface.php index 5bc9e48..42ac14b 100644 --- a/core/lib/Drupal/Core/Database/StatementInterface.php +++ b/core/lib/Drupal/Core/Database/StatementInterface.php @@ -51,7 +51,7 @@ * @return * TRUE on success, or FALSE on failure. */ - public function execute($args = array(), $options = array()); + public function execute($args = [], $options = []); /** * Gets the query string of this statement. @@ -90,7 +90,7 @@ public function rowCount(); * If $mode is PDO::FETCH_CLASS, the optional arguments to pass to the * constructor. */ - public function setFetchMode($mode, $a1 = NULL, $a2 = array()); + public function setFetchMode($mode, $a1 = NULL, $a2 = []); /** * Fetches the next row from a result set. diff --git a/core/lib/Drupal/Core/Database/StatementPrefetch.php b/core/lib/Drupal/Core/Database/StatementPrefetch.php index ab6236a..b33932e 100644 --- a/core/lib/Drupal/Core/Database/StatementPrefetch.php +++ b/core/lib/Drupal/Core/Database/StatementPrefetch.php @@ -43,7 +43,7 @@ class StatementPrefetch implements \Iterator, StatementInterface { * * @var Array */ - protected $data = array(); + protected $data = []; /** * The current row, retrieved in \PDO::FETCH_ASSOC format. @@ -93,12 +93,12 @@ class StatementPrefetch implements \Iterator, StatementInterface { * * @var Array */ - protected $fetchOptions = array( + protected $fetchOptions = [ 'class' => 'stdClass', - 'constructor_args' => array(), + 'constructor_args' => [], 'object' => NULL, 'column' => 0, - ); + ]; /** * Holds the default fetch style. @@ -112,12 +112,12 @@ class StatementPrefetch implements \Iterator, StatementInterface { * * @var Array */ - protected $defaultFetchOptions = array( + protected $defaultFetchOptions = [ 'class' => 'stdClass', - 'constructor_args' => array(), + 'constructor_args' => [], 'object' => NULL, 'column' => 0, - ); + ]; /** * Is rowCount() execution allowed. @@ -126,7 +126,7 @@ class StatementPrefetch implements \Iterator, StatementInterface { */ public $allowRowCount = FALSE; - public function __construct(\PDO $pdo_connection, Connection $connection, $query, array $driver_options = array()) { + public function __construct(\PDO $pdo_connection, Connection $connection, $query, array $driver_options = []) { $this->pdoConnection = $pdo_connection; $this->dbh = $connection; $this->queryString = $query; @@ -136,7 +136,7 @@ public function __construct(\PDO $pdo_connection, Connection $connection, $query /** * {@inheritdoc} */ - public function execute($args = array(), $options = array()) { + public function execute($args = [], $options = []) { if (isset($options['fetch'])) { if (is_string($options['fetch'])) { // Default to an object. Note: db fields will be added to the object @@ -181,7 +181,7 @@ public function execute($args = array(), $options = array()) { $this->columnNames = array_keys($this->data[0]); } else { - $this->columnNames = array(); + $this->columnNames = []; } if (!empty($logger)) { @@ -219,7 +219,7 @@ protected function throwPDOException() { * @return \PDOStatement * A PDOStatement object. */ - protected function getStatement($query, &$args = array()) { + protected function getStatement($query, &$args = []) { return $this->dbh->prepare($query); } @@ -233,7 +233,7 @@ public function getQueryString() { /** * {@inheritdoc} */ - public function setFetchMode($mode, $a1 = NULL, $a2 = array()) { + public function setFetchMode($mode, $a1 = NULL, $a2 = []) { $this->defaultFetchStyle = $mode; switch ($mode) { case \PDO::FETCH_CLASS: @@ -409,7 +409,7 @@ public function fetchField($index = 0) { /** * {@inheritdoc} */ - public function fetchObject($class_name = NULL, $constructor_args = array()) { + public function fetchObject($class_name = NULL, $constructor_args = []) { if (isset($this->currentRow)) { if (!isset($class_name)) { // Directly cast to an object to avoid a function call. @@ -417,7 +417,7 @@ public function fetchObject($class_name = NULL, $constructor_args = array()) { } else { $this->fetchStyle = \PDO::FETCH_CLASS; - $this->fetchOptions = array('constructor_args' => $constructor_args); + $this->fetchOptions = ['constructor_args' => $constructor_args]; // Grab the row in the format specified above. $result = $this->current(); // Reset the fetch parameters to the value stored using setFetchMode(). @@ -461,7 +461,7 @@ public function fetchAll($mode = NULL, $column_index = NULL, $constructor_argume $this->fetchOptions['constructor_args'] = $constructor_arguments; } - $result = array(); + $result = []; // Traverse the array as PHP would have done. while (isset($this->currentRow)) { // Grab the row in the format specified above. @@ -480,7 +480,7 @@ public function fetchAll($mode = NULL, $column_index = NULL, $constructor_argume */ public function fetchCol($index = 0) { if (isset($this->columnNames[$index])) { - $result = array(); + $result = []; // Traverse the array as PHP would have done. while (isset($this->currentRow)) { $result[] = $this->currentRow[$this->columnNames[$index]]; @@ -489,7 +489,7 @@ public function fetchCol($index = 0) { return $result; } else { - return array(); + return []; } } @@ -498,12 +498,12 @@ public function fetchCol($index = 0) { */ public function fetchAllKeyed($key_index = 0, $value_index = 1) { if (!isset($this->columnNames[$key_index]) || !isset($this->columnNames[$value_index])) - return array(); + return []; $key = $this->columnNames[$key_index]; $value = $this->columnNames[$value_index]; - $result = array(); + $result = []; // Traverse the array as PHP would have done. while (isset($this->currentRow)) { $result[$this->currentRow[$key]] = $this->currentRow[$value]; @@ -519,7 +519,7 @@ public function fetchAllAssoc($key, $fetch_style = NULL) { $this->fetchStyle = isset($fetch_style) ? $fetch_style : $this->defaultFetchStyle; $this->fetchOptions = $this->defaultFetchOptions; - $result = array(); + $result = []; // Traverse the array as PHP would have done. while (isset($this->currentRow)) { // Grab the row in its raw \PDO::FETCH_ASSOC format. diff --git a/core/lib/Drupal/Core/Database/database.api.php b/core/lib/Drupal/Core/Database/database.api.php index 3e0fbf8..a15e5ec 100644 --- a/core/lib/Drupal/Core/Database/database.api.php +++ b/core/lib/Drupal/Core/Database/database.api.php @@ -482,60 +482,60 @@ function hook_query_TAG_alter(Drupal\Core\Database\Query\AlterableInterface $que * @ingroup schemaapi */ function hook_schema() { - $schema['node'] = array( + $schema['node'] = [ // Example (partial) specification for table "node". 'description' => 'The base table for nodes.', - 'fields' => array( - 'nid' => array( + 'fields' => [ + 'nid' => [ 'description' => 'The primary identifier for a node.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, - ), - 'vid' => array( + ], + 'vid' => [ 'description' => 'The current {node_field_revision}.vid version identifier.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'type' => array( + ], + 'type' => [ 'description' => 'The type of this node.', 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => '', - ), - 'title' => array( + ], + 'title' => [ 'description' => 'The node title.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), - ), - 'indexes' => array( - 'node_changed' => array('changed'), - 'node_created' => array('created'), - ), - 'unique keys' => array( - 'nid_vid' => array('nid', 'vid'), - 'vid' => array('vid'), - ), + ], + ], + 'indexes' => [ + 'node_changed' => ['changed'], + 'node_created' => ['created'], + ], + 'unique keys' => [ + 'nid_vid' => ['nid', 'vid'], + 'vid' => ['vid'], + ], // For documentation purposes only; foreign keys are not created in the // database. - 'foreign keys' => array( - 'node_revision' => array( + 'foreign keys' => [ + 'node_revision' => [ 'table' => 'node_field_revision', - 'columns' => array('vid' => 'vid'), - ), - 'node_author' => array( + 'columns' => ['vid' => 'vid'], + ], + 'node_author' => [ 'table' => 'users', - 'columns' => array('uid' => 'uid'), - ), - ), - 'primary key' => array('nid'), - ); + 'columns' => ['uid' => 'uid'], + ], + ], + 'primary key' => ['nid'], + ]; return $schema; } diff --git a/core/lib/Drupal/Core/Datetime/DateFormatter.php b/core/lib/Drupal/Core/Datetime/DateFormatter.php index eb107e8..f571db7 100644 --- a/core/lib/Drupal/Core/Datetime/DateFormatter.php +++ b/core/lib/Drupal/Core/Datetime/DateFormatter.php @@ -54,7 +54,7 @@ class DateFormatter implements DateFormatterInterface { protected $requestStack; protected $country = NULL; - protected $dateFormats = array(); + protected $dateFormats = []; /** * Contains the different date interval units. @@ -65,7 +65,7 @@ class DateFormatter implements DateFormatterInterface { * * @var array */ - protected $units = array( + protected $units = [ '1 year|@count years' => 31536000, '1 month|@count months' => 2592000, '1 week|@count weeks' => 604800, @@ -73,7 +73,7 @@ class DateFormatter implements DateFormatterInterface { '1 hour|@count hours' => 3600, '1 min|@count min' => 60, '1 sec|@count sec' => 1, - ); + ]; /** * Constructs a Date object. @@ -115,10 +115,10 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N } // Create a DrupalDateTime object from the timestamp and timezone. - $create_settings = array( + $create_settings = [ 'langcode' => $langcode, 'country' => $this->country(), - ); + ]; $date = DrupalDateTime::createFromTimestamp($timestamp, $this->timezones[$timezone], $create_settings); // If we have a non-custom date format use the provided date format pattern. @@ -132,9 +132,9 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N } // Call $date->format(). - $settings = array( + $settings = [ 'langcode' => $langcode, - ); + ]; return $date->format($format, $settings); } @@ -146,7 +146,7 @@ public function formatInterval($interval, $granularity = 2, $langcode = NULL) { foreach ($this->units as $key => $value) { $key = explode('|', $key); if ($interval >= $value) { - $output .= ($output ? ' ' : '') . $this->formatPlural(floor($interval / $value), $key[0], $key[1], array(), array('langcode' => $langcode)); + $output .= ($output ? ' ' : '') . $this->formatPlural(floor($interval / $value), $key[0], $key[1], [], ['langcode' => $langcode]); $interval %= $value; $granularity--; } @@ -160,7 +160,7 @@ public function formatInterval($interval, $granularity = 2, $langcode = NULL) { break; } } - return $output ? $output : $this->t('0 sec', array(), array('langcode' => $langcode)); + return $output ? $output : $this->t('0 sec', [], ['langcode' => $langcode]); } /** @@ -179,7 +179,7 @@ public function getSampleDateFormats($langcode = NULL, $timestamp = NULL, $timez /** * {@inheritdoc} */ - public function formatTimeDiffUntil($timestamp, $options = array()) { + public function formatTimeDiffUntil($timestamp, $options = []) { $request_time = $this->requestStack->getCurrentRequest()->server->get('REQUEST_TIME'); return $this->formatDiff($request_time, $timestamp, $options); } @@ -187,7 +187,7 @@ public function formatTimeDiffUntil($timestamp, $options = array()) { /** * {@inheritdoc} */ - public function formatTimeDiffSince($timestamp, $options = array()) { + public function formatTimeDiffSince($timestamp, $options = []) { $request_time = $this->requestStack->getCurrentRequest()->server->get('REQUEST_TIME'); return $this->formatDiff($timestamp, $request_time, $options); } @@ -195,14 +195,14 @@ public function formatTimeDiffSince($timestamp, $options = array()) { /** * {@inheritdoc} */ - public function formatDiff($from, $to, $options = array()) { + public function formatDiff($from, $to, $options = []) { - $options += array( + $options += [ 'granularity' => 2, 'langcode' => NULL, 'strict' => TRUE, 'return_as_object' => FALSE, - ); + ]; if ($options['strict'] && $from > $to) { $string = $this->t('0 seconds'); @@ -227,18 +227,18 @@ public function formatDiff($from, $to, $options = array()) { // don't take the "invert" property into account, the resulting output value // will always be positive. $max_age = 1e99; - foreach (array('y', 'm', 'd', 'h', 'i', 's') as $value) { + foreach (['y', 'm', 'd', 'h', 'i', 's'] as $value) { if ($interval->$value > 0) { // Switch over the keys to call formatPlural() explicitly with literal // strings for all different possibilities. switch ($value) { case 'y': - $interval_output = $this->formatPlural($interval->y, '1 year', '@count years', array(), array('langcode' => $options['langcode'])); + $interval_output = $this->formatPlural($interval->y, '1 year', '@count years', [], ['langcode' => $options['langcode']]); $max_age = min($max_age, 365 * 86400); break; case 'm': - $interval_output = $this->formatPlural($interval->m, '1 month', '@count months', array(), array('langcode' => $options['langcode'])); + $interval_output = $this->formatPlural($interval->m, '1 month', '@count months', [], ['langcode' => $options['langcode']]); $max_age = min($max_age, 30 * 86400); break; @@ -249,14 +249,14 @@ public function formatDiff($from, $to, $options = array()) { $days = $interval->d; $weeks = floor($days / 7); if ($weeks) { - $interval_output .= $this->formatPlural($weeks, '1 week', '@count weeks', array(), array('langcode' => $options['langcode'])); + $interval_output .= $this->formatPlural($weeks, '1 week', '@count weeks', [], ['langcode' => $options['langcode']]); $days -= $weeks * 7; $granularity--; $max_age = min($max_age, 7 * 86400); } if ((!$output || $weeks > 0) && $granularity > 0 && $days > 0) { - $interval_output .= ($interval_output ? ' ' : '') . $this->formatPlural($days, '1 day', '@count days', array(), array('langcode' => $options['langcode'])); + $interval_output .= ($interval_output ? ' ' : '') . $this->formatPlural($days, '1 day', '@count days', [], ['langcode' => $options['langcode']]); $max_age = min($max_age, 86400); } else { @@ -267,17 +267,17 @@ public function formatDiff($from, $to, $options = array()) { break; case 'h': - $interval_output = $this->formatPlural($interval->h, '1 hour', '@count hours', array(), array('langcode' => $options['langcode'])); + $interval_output = $this->formatPlural($interval->h, '1 hour', '@count hours', [], ['langcode' => $options['langcode']]); $max_age = min($max_age, 3600); break; case 'i': - $interval_output = $this->formatPlural($interval->i, '1 minute', '@count minutes', array(), array('langcode' => $options['langcode'])); + $interval_output = $this->formatPlural($interval->i, '1 minute', '@count minutes', [], ['langcode' => $options['langcode']]); $max_age = min($max_age, 60); break; case 's': - $interval_output = $this->formatPlural($interval->s, '1 second', '@count seconds', array(), array('langcode' => $options['langcode'])); + $interval_output = $this->formatPlural($interval->s, '1 second', '@count seconds', [], ['langcode' => $options['langcode']]); $max_age = min($max_age, 1); break; @@ -323,7 +323,7 @@ public function formatDiff($from, $to, $options = array()) { protected function dateFormat($format, $langcode) { if (!isset($this->dateFormats[$format][$langcode])) { $original_language = $this->languageManager->getConfigOverrideLanguage(); - $this->languageManager->setConfigOverrideLanguage(new Language(array('id' => $langcode))); + $this->languageManager->setConfigOverrideLanguage(new Language(['id' => $langcode])); $this->dateFormats[$format][$langcode] = $this->dateFormatStorage->load($format); $this->languageManager->setConfigOverrideLanguage($original_language); } diff --git a/core/lib/Drupal/Core/Datetime/DateFormatterInterface.php b/core/lib/Drupal/Core/Datetime/DateFormatterInterface.php index 3515ee4..6bddf8f 100644 --- a/core/lib/Drupal/Core/Datetime/DateFormatterInterface.php +++ b/core/lib/Drupal/Core/Datetime/DateFormatterInterface.php @@ -112,7 +112,7 @@ public function getSampleDateFormats($langcode = NULL, $timestamp = NULL, $timez * @see \Drupal\Core\Datetime\DateFormatterInterface::formatDiff() * @see \Drupal\Core\Datetime\DateFormatterInterface::formatTimeDiffSince() */ - public function formatTimeDiffUntil($timestamp, $options = array()); + public function formatTimeDiffUntil($timestamp, $options = []); /** * Formats the time difference from a timestamp to the current request time. @@ -142,7 +142,7 @@ public function formatTimeDiffUntil($timestamp, $options = array()); * @see \Drupal\Core\Datetime\DateFormatterInterface::formatDiff() * @see \Drupal\Core\Datetime\DateFormatterInterface::formatTimeDiffUntil() */ - public function formatTimeDiffSince($timestamp, $options = array()); + public function formatTimeDiffSince($timestamp, $options = []); /** * Formats a time interval between two timestamps. @@ -174,6 +174,6 @@ public function formatTimeDiffSince($timestamp, $options = array()); * @see \Drupal\Core\Datetime\DateFormatterInterface::formatTimeDiffSince() * @see \Drupal\Core\Datetime\DateFormatterInterface::formatTimeDiffUntil() */ - public function formatDiff($from, $to, $options = array()); + public function formatDiff($from, $to, $options = []); } diff --git a/core/lib/Drupal/Core/Datetime/DateHelper.php b/core/lib/Drupal/Core/Datetime/DateHelper.php index 70db9b3..b3a8ce7 100644 --- a/core/lib/Drupal/Core/Datetime/DateHelper.php +++ b/core/lib/Drupal/Core/Datetime/DateHelper.php @@ -27,7 +27,7 @@ class DateHelper { public static function monthNamesUntranslated() { // Force the key to use the correct month value, rather than // starting with zero. - return array( + return [ 1 => 'January', 2 => 'February', 3 => 'March', @@ -40,7 +40,7 @@ public static function monthNamesUntranslated() { 10 => 'October', 11 => 'November', 12 => 'December', - ); + ]; } /** @@ -52,7 +52,7 @@ public static function monthNamesUntranslated() { public static function monthNamesAbbrUntranslated() { // Force the key to use the correct month value, rather than // starting with zero. - return array( + return [ 1 => 'Jan', 2 => 'Feb', 3 => 'Mar', @@ -65,7 +65,7 @@ public static function monthNamesAbbrUntranslated() { 10 => 'Oct', 11 => 'Nov', 12 => 'Dec', - ); + ]; } /** @@ -81,21 +81,21 @@ public static function monthNamesAbbrUntranslated() { public static function monthNames($required = FALSE) { // Force the key to use the correct month value, rather than // starting with zero. - $monthnames = array( - 1 => t('January', array(), array('context' => 'Long month name')), - 2 => t('February', array(), array('context' => 'Long month name')), - 3 => t('March', array(), array('context' => 'Long month name')), - 4 => t('April', array(), array('context' => 'Long month name')), - 5 => t('May', array(), array('context' => 'Long month name')), - 6 => t('June', array(), array('context' => 'Long month name')), - 7 => t('July', array(), array('context' => 'Long month name')), - 8 => t('August', array(), array('context' => 'Long month name')), - 9 => t('September', array(), array('context' => 'Long month name')), - 10 => t('October', array(), array('context' => 'Long month name')), - 11 => t('November', array(), array('context' => 'Long month name')), - 12 => t('December', array(), array('context' => 'Long month name')), - ); - $none = array('' => ''); + $monthnames = [ + 1 => t('January', [], ['context' => 'Long month name']), + 2 => t('February', [], ['context' => 'Long month name']), + 3 => t('March', [], ['context' => 'Long month name']), + 4 => t('April', [], ['context' => 'Long month name']), + 5 => t('May', [], ['context' => 'Long month name']), + 6 => t('June', [], ['context' => 'Long month name']), + 7 => t('July', [], ['context' => 'Long month name']), + 8 => t('August', [], ['context' => 'Long month name']), + 9 => t('September', [], ['context' => 'Long month name']), + 10 => t('October', [], ['context' => 'Long month name']), + 11 => t('November', [], ['context' => 'Long month name']), + 12 => t('December', [], ['context' => 'Long month name']), + ]; + $none = ['' => '']; return !$required ? $none + $monthnames : $monthnames; } @@ -112,21 +112,21 @@ public static function monthNames($required = FALSE) { public static function monthNamesAbbr($required = FALSE) { // Force the key to use the correct month value, rather than // starting with zero. - $monthnames = array( - 1 => t('Jan', array(), array('context' => 'Abbreviated month name')), - 2 => t('Feb', array(), array('context' => 'Abbreviated month name')), - 3 => t('Mar', array(), array('context' => 'Abbreviated month name')), - 4 => t('Apr', array(), array('context' => 'Abbreviated month name')), - 5 => t('May', array(), array('context' => 'Abbreviated month name')), - 6 => t('Jun', array(), array('context' => 'Abbreviated month name')), - 7 => t('Jul', array(), array('context' => 'Abbreviated month name')), - 8 => t('Aug', array(), array('context' => 'Abbreviated month name')), - 9 => t('Sep', array(), array('context' => 'Abbreviated month name')), - 10 => t('Oct', array(), array('context' => 'Abbreviated month name')), - 11 => t('Nov', array(), array('context' => 'Abbreviated month name')), - 12 => t('Dec', array(), array('context' => 'Abbreviated month name')), - ); - $none = array('' => ''); + $monthnames = [ + 1 => t('Jan', [], ['context' => 'Abbreviated month name']), + 2 => t('Feb', [], ['context' => 'Abbreviated month name']), + 3 => t('Mar', [], ['context' => 'Abbreviated month name']), + 4 => t('Apr', [], ['context' => 'Abbreviated month name']), + 5 => t('May', [], ['context' => 'Abbreviated month name']), + 6 => t('Jun', [], ['context' => 'Abbreviated month name']), + 7 => t('Jul', [], ['context' => 'Abbreviated month name']), + 8 => t('Aug', [], ['context' => 'Abbreviated month name']), + 9 => t('Sep', [], ['context' => 'Abbreviated month name']), + 10 => t('Oct', [], ['context' => 'Abbreviated month name']), + 11 => t('Nov', [], ['context' => 'Abbreviated month name']), + 12 => t('Dec', [], ['context' => 'Abbreviated month name']), + ]; + $none = ['' => '']; return !$required ? $none + $monthnames : $monthnames; } @@ -137,7 +137,7 @@ public static function monthNamesAbbr($required = FALSE) { * An array of week day names */ public static function weekDaysUntranslated() { - return array( + return [ 'Sunday', 'Monday', 'Tuesday', @@ -145,7 +145,7 @@ public static function weekDaysUntranslated() { 'Thursday', 'Friday', 'Saturday', - ); + ]; } /** @@ -159,7 +159,7 @@ public static function weekDaysUntranslated() { * An array of week day names */ public static function weekDays($required = FALSE) { - $weekdays = array( + $weekdays = [ t('Sunday'), t('Monday'), t('Tuesday'), @@ -167,8 +167,8 @@ public static function weekDays($required = FALSE) { t('Thursday'), t('Friday'), t('Saturday'), - ); - $none = array('' => ''); + ]; + $none = ['' => '']; return !$required ? $none + $weekdays : $weekdays; } @@ -183,16 +183,16 @@ public static function weekDays($required = FALSE) { * An array of week day abbreviations */ public static function weekDaysAbbr($required = FALSE) { - $weekdays = array( - t('Sun', array(), array('context' => 'Abbreviated weekday')), - t('Mon', array(), array('context' => 'Abbreviated weekday')), - t('Tue', array(), array('context' => 'Abbreviated weekday')), - t('Wed', array(), array('context' => 'Abbreviated weekday')), - t('Thu', array(), array('context' => 'Abbreviated weekday')), - t('Fri', array(), array('context' => 'Abbreviated weekday')), - t('Sat', array(), array('context' => 'Abbreviated weekday')), - ); - $none = array('' => ''); + $weekdays = [ + t('Sun', [], ['context' => 'Abbreviated weekday']), + t('Mon', [], ['context' => 'Abbreviated weekday']), + t('Tue', [], ['context' => 'Abbreviated weekday']), + t('Wed', [], ['context' => 'Abbreviated weekday']), + t('Thu', [], ['context' => 'Abbreviated weekday']), + t('Fri', [], ['context' => 'Abbreviated weekday']), + t('Sat', [], ['context' => 'Abbreviated weekday']), + ]; + $none = ['' => '']; return !$required ? $none + $weekdays : $weekdays; } @@ -207,16 +207,16 @@ public static function weekDaysAbbr($required = FALSE) { * An array of week day 2 letter abbreviations */ public static function weekDaysAbbr2($required = FALSE) { - $weekdays = array( - t('Su', array(), array('context' => 'Abbreviated weekday')), - t('Mo', array(), array('context' => 'Abbreviated weekday')), - t('Tu', array(), array('context' => 'Abbreviated weekday')), - t('We', array(), array('context' => 'Abbreviated weekday')), - t('Th', array(), array('context' => 'Abbreviated weekday')), - t('Fr', array(), array('context' => 'Abbreviated weekday')), - t('Sa', array(), array('context' => 'Abbreviated weekday')), - ); - $none = array('' => ''); + $weekdays = [ + t('Su', [], ['context' => 'Abbreviated weekday']), + t('Mo', [], ['context' => 'Abbreviated weekday']), + t('Tu', [], ['context' => 'Abbreviated weekday']), + t('We', [], ['context' => 'Abbreviated weekday']), + t('Th', [], ['context' => 'Abbreviated weekday']), + t('Fr', [], ['context' => 'Abbreviated weekday']), + t('Sa', [], ['context' => 'Abbreviated weekday']), + ]; + $none = ['' => '']; return !$required ? $none + $weekdays : $weekdays; } @@ -231,16 +231,16 @@ public static function weekDaysAbbr2($required = FALSE) { * An array of week day 1 letter abbreviations */ public static function weekDaysAbbr1($required = FALSE) { - $weekdays = array( - t('S', array(), array('context' => 'Abbreviated 1 letter weekday Sunday')), - t('M', array(), array('context' => 'Abbreviated 1 letter weekday Monday')), - t('T', array(), array('context' => 'Abbreviated 1 letter weekday Tuesday')), - t('W', array(), array('context' => 'Abbreviated 1 letter weekday Wednesday')), - t('T', array(), array('context' => 'Abbreviated 1 letter weekday Thursday')), - t('F', array(), array('context' => 'Abbreviated 1 letter weekday Friday')), - t('S', array(), array('context' => 'Abbreviated 1 letter weekday Saturday')), - ); - $none = array('' => ''); + $weekdays = [ + t('S', [], ['context' => 'Abbreviated 1 letter weekday Sunday']), + t('M', [], ['context' => 'Abbreviated 1 letter weekday Monday']), + t('T', [], ['context' => 'Abbreviated 1 letter weekday Tuesday']), + t('W', [], ['context' => 'Abbreviated 1 letter weekday Wednesday']), + t('T', [], ['context' => 'Abbreviated 1 letter weekday Thursday']), + t('F', [], ['context' => 'Abbreviated 1 letter weekday Friday']), + t('S', [], ['context' => 'Abbreviated 1 letter weekday Saturday']), + ]; + $none = ['' => '']; return !$required ? $none + $weekdays : $weekdays; } @@ -296,7 +296,7 @@ public static function years($min = 0, $max = 0, $required = FALSE) { if (empty($max)) { $max = intval(date('Y', REQUEST_TIME) + 3); } - $none = array('' => ''); + $none = ['' => '']; $range = range($min, $max); $range = array_combine($range, $range); return !$required ? $none + $range : $range; @@ -328,7 +328,7 @@ public static function days($required = FALSE, $month = NULL, $year = NULL) { if (empty($max)) { $max = 31; } - $none = array('' => ''); + $none = ['' => '']; $range = range(1, $max); $range = array_combine($range, $range); return !$required ? $none + $range : $range; @@ -349,7 +349,7 @@ public static function days($required = FALSE, $month = NULL, $year = NULL) { * An array of hours in the selected format. */ public static function hours($format = 'H', $required = FALSE) { - $hours = array(); + $hours = []; if ($format == 'h' || $format == 'g') { $min = 1; $max = 12; @@ -362,7 +362,7 @@ public static function hours($format = 'H', $required = FALSE) { $formatted = ($format == 'H' || $format == 'h') ? DrupalDateTime::datePad($i) : $i; $hours[$i] = $formatted; } - $none = array('' => ''); + $none = ['' => '']; return !$required ? $none + $hours : $hours; } @@ -382,7 +382,7 @@ public static function hours($format = 'H', $required = FALSE) { * An array of minutes in the selected format. */ public static function minutes($format = 'i', $required = FALSE, $increment = 1) { - $minutes = array(); + $minutes = []; // Ensure $increment has a value so we don't loop endlessly. if (empty($increment)) { $increment = 1; @@ -391,7 +391,7 @@ public static function minutes($format = 'i', $required = FALSE, $increment = 1) $formatted = $format == 'i' ? DrupalDateTime::datePad($i) : $i; $minutes[$i] = $formatted; } - $none = array('' => ''); + $none = ['' => '']; return !$required ? $none + $minutes : $minutes; } @@ -411,7 +411,7 @@ public static function minutes($format = 'i', $required = FALSE, $increment = 1) * An array of seconds in the selected format. */ public static function seconds($format = 's', $required = FALSE, $increment = 1) { - $seconds = array(); + $seconds = []; // Ensure $increment has a value so we don't loop endlessly. if (empty($increment)) { $increment = 1; @@ -420,7 +420,7 @@ public static function seconds($format = 's', $required = FALSE, $increment = 1) $formatted = $format == 's' ? DrupalDateTime::datePad($i) : $i; $seconds[$i] = $formatted; } - $none = array('' => ''); + $none = ['' => '']; return !$required ? $none + $seconds : $seconds; } @@ -435,11 +435,11 @@ public static function seconds($format = 's', $required = FALSE, $increment = 1) * An array of AM and PM options. */ public static function ampm($required = FALSE) { - $none = array('' => ''); - $ampm = array( - 'am' => t('am', array(), array('context' => 'ampm')), - 'pm' => t('pm', array(), array('context' => 'ampm')), - ); + $none = ['' => '']; + $ampm = [ + 'am' => t('am', [], ['context' => 'ampm']), + 'pm' => t('pm', [], ['context' => 'ampm']), + ]; return !$required ? $none + $ampm : $ampm; } diff --git a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php index faa0d02..572a6e3 100644 --- a/core/lib/Drupal/Core/Datetime/DrupalDateTime.php +++ b/core/lib/Drupal/Core/Datetime/DrupalDateTime.php @@ -48,7 +48,7 @@ class DrupalDateTime extends DateTimePlus { * - debug: (optional) Boolean choice to leave debug values in the * date object for debugging purposes. Defaults to FALSE. */ - public function __construct($time = 'now', $timezone = NULL, $settings = array()) { + public function __construct($time = 'now', $timezone = NULL, $settings = []) { if (!isset($settings['langcode'])) { $settings['langcode'] = \Drupal::languageManager()->getCurrentLanguage()->getId(); } @@ -87,7 +87,7 @@ protected function prepareTimezone($timezone) { * The formatted value of the date. Since the format may contain user input, * this value should be escaped when output. */ - public function format($format, $settings = array()) { + public function format($format, $settings = []) { $langcode = !empty($settings['langcode']) ? $settings['langcode'] : $this->langcode; $value = ''; // Format the date and catch errors. @@ -98,7 +98,7 @@ public function format($format, $settings = array()) { // Paired backslashes are isolated to prevent errors in // read-ahead evaluation. The read-ahead expression ensures that // A matches, but not \A. - $format = preg_replace(array('/\\\\\\\\/', '/(?formatTranslationCache[$langcode][$code][$string])) { - $options = array('langcode' => $langcode); + $options = ['langcode' => $langcode]; if ($code == 'F') { $options['context'] = 'Long month name'; } @@ -117,7 +117,7 @@ public function format($format, $settings = array()) { $this->formatTranslationCache[$langcode][$code][$string] = $string; } else { - $this->formatTranslationCache[$langcode][$code][$string] = $this->t($string, array(), $options); + $this->formatTranslationCache[$langcode][$code][$string] = $this->t($string, [], $options); } } return $this->formatTranslationCache[$langcode][$code][$string]; diff --git a/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php b/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php index 12ab03b..63b9abb 100644 --- a/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php +++ b/core/lib/Drupal/Core/Datetime/Element/DateElementBase.php @@ -66,7 +66,7 @@ protected static function datetimeRangeYears($string, $date = NULL) { $min_year = min($value_year, $min_year); $max_year = max($value_year, $max_year); } - return array($min_year, $max_year); + return [$min_year, $max_year]; } } diff --git a/core/lib/Drupal/Core/Datetime/Element/Datelist.php b/core/lib/Drupal/Core/Datetime/Element/Datelist.php index f39d0a2..59177e7 100644 --- a/core/lib/Drupal/Core/Datetime/Element/Datelist.php +++ b/core/lib/Drupal/Core/Datetime/Element/Datelist.php @@ -19,22 +19,22 @@ class Datelist extends DateElementBase { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, - '#element_validate' => array( - array($class, 'validateDatelist'), - ), - '#process' => array( - array($class, 'processDatelist'), - ), + '#element_validate' => [ + [$class, 'validateDatelist'], + ], + '#process' => [ + [$class, 'processDatelist'], + ], '#theme' => 'datetime_form', - '#theme_wrappers' => array('datetime_wrapper'), - '#date_part_order' => array('year', 'month', 'day', 'hour', 'minute'), + '#theme_wrappers' => ['datetime_wrapper'], + '#date_part_order' => ['year', 'month', 'day', 'hour', 'minute'], '#date_year_range' => '1900:2050', '#date_increment' => 1, - '#date_date_callbacks' => array(), + '#date_date_callbacks' => [], '#date_timezone' => '', - ); + ]; } /** @@ -197,8 +197,8 @@ public static function processDatelist(&$element, FormStateInterface $form_state $element['#tree'] = TRUE; // Determine the order of the date elements. - $order = !empty($element['#date_part_order']) ? $element['#date_part_order'] : array('year', 'month', 'day'); - $text_parts = !empty($element['#date_text_parts']) ? $element['#date_text_parts'] : array(); + $order = !empty($element['#date_part_order']) ? $element['#date_part_order'] : ['year', 'month', 'day']; + $text_parts = !empty($element['#date_text_parts']) ? $element['#date_text_parts'] : []; // Output multi-selector for date. foreach ($order as $part) { @@ -248,7 +248,7 @@ public static function processDatelist(&$element, FormStateInterface $form_state default: $format = ''; - $options = array(); + $options = []; $title = ''; } @@ -259,7 +259,7 @@ public static function processDatelist(&$element, FormStateInterface $form_state } $element['#attributes']['title'] = $title; - $element[$part] = array( + $element[$part] = [ '#type' => in_array($part, $text_parts) ? 'textfield' : 'select', '#title' => $title, '#title_display' => 'invisible', @@ -269,7 +269,7 @@ public static function processDatelist(&$element, FormStateInterface $form_state '#required' => $element['#required'], '#error_no_message' => FALSE, '#empty_option' => $title, - ); + ]; } // Allows custom callbacks to alter the element. @@ -315,7 +315,7 @@ public static function validateDatelist(&$element, FormStateInterface $form_stat } elseif (!empty($all_empty)) { foreach ($all_empty as $value) { - $form_state->setError($element[$value], t('A value must be selected for %part.', array('%part' => $value))); + $form_state->setError($element[$value], t('A value must be selected for %part.', ['%part' => $value])); } } else { @@ -326,7 +326,7 @@ public static function validateDatelist(&$element, FormStateInterface $form_stat } // If the input is invalid and an error doesn't exist, set one. elseif ($form_state->getError($element) === NULL) { - $form_state->setError($element, t('The %field date is invalid.', array('%field' => !empty($element['#title']) ? $element['#title'] : ''))); + $form_state->setError($element, t('The %field date is invalid.', ['%field' => !empty($element['#title']) ? $element['#title'] : ''])); } } } diff --git a/core/lib/Drupal/Core/Datetime/Element/Datetime.php b/core/lib/Drupal/Core/Datetime/Element/Datetime.php index 44a3949..d005475 100644 --- a/core/lib/Drupal/Core/Datetime/Element/Datetime.php +++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php @@ -38,30 +38,30 @@ public function getInfo() { } $class = get_class($this); - return array( + return [ '#input' => TRUE, - '#element_validate' => array( - array($class, 'validateDatetime'), - ), - '#process' => array( - array($class, 'processDatetime'), - array($class, 'processGroup'), - ), - '#pre_render' => array( - array($class, 'preRenderGroup'), - ), + '#element_validate' => [ + [$class, 'validateDatetime'], + ], + '#process' => [ + [$class, 'processDatetime'], + [$class, 'processGroup'], + ], + '#pre_render' => [ + [$class, 'preRenderGroup'], + ], '#theme' => 'datetime_form', - '#theme_wrappers' => array('datetime_wrapper'), + '#theme_wrappers' => ['datetime_wrapper'], '#date_date_format' => $date_format, '#date_date_element' => 'date', - '#date_date_callbacks' => array(), + '#date_date_callbacks' => [], '#date_time_format' => $time_format, '#date_time_element' => 'time', - '#date_time_callbacks' => array(), + '#date_time_callbacks' => [], '#date_year_range' => '1900:2050', '#date_increment' => 1, '#date_timezone' => '', - ); + ]; } /** @@ -88,27 +88,27 @@ public static function valueCallback(&$element, $input, FormStateInterface $form catch (\Exception $e) { $date = NULL; } - $input = array( + $input = [ 'date' => $date_input, 'time' => $time_input, 'object' => $date, - ); + ]; } else { $date = $element['#default_value']; if ($date instanceof DrupalDateTime && !$date->hasErrors()) { - $input = array( + $input = [ 'date' => $date->format($element['#date_date_format']), 'time' => $date->format($element['#date_time_format']), 'object' => $date, - ); + ]; } else { - $input = array( + $input = [ 'date' => '', 'time' => '', 'object' => NULL, - ); + ]; } } return $input; @@ -213,7 +213,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form * The form element whose value has been processed. */ public static function processDatetime(&$element, FormStateInterface $form_state, &$complete_form) { - $format_settings = array(); + $format_settings = []; // The value callback has populated the #value array. $date = !empty($element['#value']['object']) ? $element['#value']['object'] : NULL; @@ -235,10 +235,10 @@ public static function processDatetime(&$element, FormStateInterface $form_state // Creating format examples on every individual date item is messy, and // placeholders are invalid for HTML5 date and datetime, so an example // format is appended to the title to appear in tooltips. - $extra_attributes = array( - 'title' => t('Date (e.g. @format)', array('@format' => static::formatExample($date_format))), + $extra_attributes = [ + 'title' => t('Date (e.g. @format)', ['@format' => static::formatExample($date_format)]), 'type' => $element['#date_date_element'], - ); + ]; // Adds the HTML5 date attributes. if ($date instanceof DrupalDateTime && !$date->hasErrors()) { @@ -248,13 +248,13 @@ public static function processDatetime(&$element, FormStateInterface $form_state $html5_max = clone($date); $html5_max->setDate($range[1], 12, 31)->setTime(23, 59, 59); - $extra_attributes += array( + $extra_attributes += [ 'min' => $html5_min->format($date_format, $format_settings), 'max' => $html5_max->format($date_format, $format_settings), - ); + ]; } - $element['date'] = array( + $element['date'] = [ '#type' => 'date', '#title' => t('Date'), '#title_display' => 'invisible', @@ -264,7 +264,7 @@ public static function processDatetime(&$element, FormStateInterface $form_state '#size' => max(12, strlen($element['#value']['date'])), '#error_no_message' => TRUE, '#date_date_format' => $element['#date_date_format'], - ); + ]; // Allows custom callbacks to alter the element. if (!empty($element['#date_date_callbacks'])) { @@ -282,12 +282,12 @@ public static function processDatetime(&$element, FormStateInterface $form_state $time_value = !empty($date) ? $date->format($time_format, $format_settings) : $element['#value']['time']; // Adds the HTML5 attributes. - $extra_attributes = array( - 'title' => t('Time (e.g. @format)', array('@format' => static::formatExample($time_format))), + $extra_attributes = [ + 'title' => t('Time (e.g. @format)', ['@format' => static::formatExample($time_format)]), 'type' => $element['#date_time_element'], 'step' => $element['#date_increment'], - ); - $element['time'] = array( + ]; + $element['time'] = [ '#type' => 'date', '#title' => t('Time'), '#title_display' => 'invisible', @@ -296,7 +296,7 @@ public static function processDatetime(&$element, FormStateInterface $form_state '#required' => $element['#required'], '#size' => 12, '#error_no_message' => TRUE, - ); + ]; // Allows custom callbacks to alter the element. if (!empty($element['#date_time_callbacks'])) { @@ -343,7 +343,7 @@ public static function validateDatetime(&$element, FormStateInterface $form_stat // If there's empty input and the field is required, set an error. A // reminder of the required format in the message provides a good UX. elseif (empty($input['date']) && empty($input['time']) && $element['#required']) { - $form_state->setError($element, t('The %field date is required. Please enter a date in the format %format.', array('%field' => $title, '%format' => static::formatExample($format)))); + $form_state->setError($element, t('The %field date is required. Please enter a date in the format %format.', ['%field' => $title, '%format' => static::formatExample($format)])); } else { // If the date is valid, set it. @@ -354,7 +354,7 @@ public static function validateDatetime(&$element, FormStateInterface $form_stat // If the date is invalid, set an error. A reminder of the required // format in the message provides a good UX. else { - $form_state->setError($element, t('The %field date is invalid. Please enter a date in the format %format.', array('%field' => $title, '%format' => static::formatExample($format)))); + $form_state->setError($element, t('The %field date is invalid. Please enter a date in the format %format.', ['%field' => $title, '%format' => static::formatExample($format)])); } } } diff --git a/core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php b/core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php index d11cf54..1ffa010 100644 --- a/core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php +++ b/core/lib/Drupal/Core/Datetime/Plugin/Field/FieldWidget/TimestampDatetimeWidget.php @@ -30,12 +30,12 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $date_format = DateFormat::load('html_date')->getPattern(); $time_format = DateFormat::load('html_time')->getPattern(); $default_value = isset($items[$delta]->value) ? DrupalDateTime::createFromTimestamp($items[$delta]->value) : ''; - $element['value'] = $element + array( + $element['value'] = $element + [ '#type' => 'datetime', '#default_value' => $default_value, '#date_year_range' => '1902:2037', - ); - $element['value']['#description'] = $this->t('Format: %format. Leave blank to use the time of form submission.', array('%format' => Datetime::formatExample($date_format . ' ' . $time_format))); + ]; + $element['value']['#description'] = $this->t('Format: %format. Leave blank to use the time of form submission.', ['%format' => Datetime::formatExample($date_format . ' ' . $time_format)]); return $element; } diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php index 52254a1..f636fb0 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php @@ -20,7 +20,7 @@ public function process(ContainerBuilder $container) { // Add services tagged 'access_check' to the access_manager service. $access_manager = $container->getDefinition('access_manager.check_provider'); foreach ($container->findTaggedServiceIds('access_check') as $id => $attributes) { - $applies = array(); + $applies = []; $method = 'access'; $needs_incoming_request = FALSE; foreach ($attributes as $attribute) { @@ -34,7 +34,7 @@ public function process(ContainerBuilder $container) { $needs_incoming_request = TRUE; } } - $access_manager->addMethodCall('addCheckService', array($id, $method, $applies, $needs_incoming_request)); + $access_manager->addMethodCall('addCheckService', [$id, $method, $applies, $needs_incoming_request]); } } diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php index a106cfc..5e13eea 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php @@ -24,7 +24,7 @@ public function process(ContainerBuilder $container) { $definition = $container->getDefinition('kernel_destruct_subscriber'); $services = $container->findTaggedServiceIds('needs_destruction'); foreach ($services as $id => $attributes) { - $definition->addMethodCall('registerService', array($id)); + $definition->addMethodCall('registerService', [$id]); } } diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterStreamWrappersPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterStreamWrappersPass.php index 7abf49f..f1ea8cd 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterStreamWrappersPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterStreamWrappersPass.php @@ -24,7 +24,7 @@ public function process(ContainerBuilder $container) { $class = $container->getDefinition($id)->getClass(); $scheme = $attributes[0]['scheme']; - $stream_wrapper_manager->addMethodCall('addStreamWrapper', array($id, $class, $scheme)); + $stream_wrapper_manager->addMethodCall('addStreamWrapper', [$id, $class, $scheme]); } } diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php index 04b56aa..5e8ee4a 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php @@ -107,17 +107,17 @@ public function process(ContainerBuilder $container) { // Determine the ID. if (!isset($interface)) { - throw new LogicException(vsprintf("Service consumer '%s' class method %s::%s() has to type-hint an interface.", array( + throw new LogicException(vsprintf("Service consumer '%s' class method %s::%s() has to type-hint an interface.", [ $consumer_id, $consumer->getClass(), $method_name, - ))); + ])); } $interface = $interface->getName(); // Find all tagged handlers. - $handlers = array(); - $extra_arguments = array(); + $handlers = []; + $extra_arguments = []; foreach ($container->findTaggedServiceIds($tag) as $id => $attributes) { // Validate the interface. $handler = $container->getDefinition($id); @@ -142,7 +142,7 @@ public function process(ContainerBuilder $container) { // Add a method call for each handler to the consumer service // definition. foreach ($handlers as $id => $priority) { - $arguments = array(); + $arguments = []; $arguments[$interface_pos] = new Reference($id); if (isset($priority_pos)) { $arguments[$priority_pos] = $priority; diff --git a/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php b/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php index ed2b35f..7f3cb5d 100644 --- a/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php +++ b/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php @@ -14,13 +14,13 @@ * * @var array */ - protected $_serviceIds = array(); + protected $_serviceIds = []; /** * {@inheritdoc} */ public function __sleep() { - $this->_serviceIds = array(); + $this->_serviceIds = []; $vars = get_object_vars($this); foreach ($vars as $key => $value) { if (is_object($value) && isset($value->_serviceId)) { @@ -52,7 +52,7 @@ public function __wakeup() { foreach ($this->_serviceIds as $key => $service_id) { $this->$key = $container->get($service_id); } - $this->_serviceIds = array(); + $this->_serviceIds = []; } } diff --git a/core/lib/Drupal/Core/Diff/DiffFormatter.php b/core/lib/Drupal/Core/Diff/DiffFormatter.php index 52f2894..3e8cb33 100644 --- a/core/lib/Drupal/Core/Diff/DiffFormatter.php +++ b/core/lib/Drupal/Core/Diff/DiffFormatter.php @@ -17,17 +17,17 @@ class DiffFormatter extends DiffFormatterBase { * * @var array */ - protected $rows = array(); + protected $rows = []; /** * The line stats. * * @var array */ - protected $line_stats = array( - 'counter' => array('x' => 0, 'y' => 0), - 'offset' => array('x' => 0, 'y' => 0), - ); + protected $line_stats = [ + 'counter' => ['x' => 0, 'y' => 0], + 'offset' => ['x' => 0, 'y' => 0], + ]; /** * Creates a DiffFormatter to render diffs in a table. @@ -45,7 +45,7 @@ public function __construct(ConfigFactoryInterface $config_factory) { * {@inheritdoc} */ protected function _start_diff() { - $this->rows = array(); + $this->rows = []; } /** @@ -59,16 +59,16 @@ protected function _end_diff() { * {@inheritdoc} */ protected function _block_header($xbeg, $xlen, $ybeg, $ylen) { - return array( - array( + return [ + [ 'data' => $xbeg + $this->line_stats['offset']['x'], 'colspan' => 2, - ), - array( + ], + [ 'data' => $ybeg + $this->line_stats['offset']['y'], 'colspan' => 2, - ) - ); + ] + ]; } /** @@ -96,16 +96,16 @@ protected function _lines($lines, $prefix=' ', $color='white') { * An array representing a table row. */ protected function addedLine($line) { - return array( - array( + return [ + [ 'data' => '+', 'class' => 'diff-marker', - ), - array( + ], + [ 'data' => ['#markup' => $line], 'class' => 'diff-context diff-addedline', - ) - ); + ] + ]; } /** @@ -118,16 +118,16 @@ protected function addedLine($line) { * An array representing a table row. */ protected function deletedLine($line) { - return array( - array( + return [ + [ 'data' => '-', 'class' => 'diff-marker', - ), - array( + ], + [ 'data' => ['#markup' => $line], 'class' => 'diff-context diff-deletedline', - ) - ); + ] + ]; } /** @@ -140,13 +140,13 @@ protected function deletedLine($line) { * An array representing a table row. */ protected function contextLine($line) { - return array( + return [ ' ', - array( + [ 'data' => ['#markup' => $line], 'class' => 'diff-context', - ) - ); + ] + ]; } /** @@ -156,10 +156,10 @@ protected function contextLine($line) { * An array representing a table row. */ protected function emptyLine() { - return array( + return [ ' ', ' ', - ); + ]; } /** diff --git a/core/lib/Drupal/Core/Display/VariantBase.php b/core/lib/Drupal/Core/Display/VariantBase.php index 5110d20..4f7ce9e 100644 --- a/core/lib/Drupal/Core/Display/VariantBase.php +++ b/core/lib/Drupal/Core/Display/VariantBase.php @@ -69,9 +69,9 @@ public function setWeight($weight) { * {@inheritdoc} */ public function getConfiguration() { - return array( + return [ 'id' => $this->getPluginId(), - ) + $this->configuration; + ] + $this->configuration; } /** @@ -86,11 +86,11 @@ public function setConfiguration(array $configuration) { * {@inheritdoc} */ public function defaultConfiguration() { - return array( + return [ 'label' => '', 'uuid' => '', 'weight' => 0, - ); + ]; } /** @@ -104,13 +104,13 @@ public function calculateDependencies() { * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form['label'] = array( + $form['label'] = [ '#type' => 'textfield', '#title' => $this->t('Label'), '#description' => $this->t('The label for this display variant.'), '#default_value' => $this->label(), '#maxlength' => '255', - ); + ]; return $form; } diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 3ccb2d7..e497407 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -136,7 +136,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { * * @var \Drupal\Core\Extension\Extension[] */ - protected $moduleData = array(); + protected $moduleData = []; /** * The class loader object. @@ -380,7 +380,7 @@ public static function findSitePath(Request $request, $require_settings = TRUE, } $http_host = $request->getHttpHost(); - $sites = array(); + $sites = []; include $app_root . '/sites/sites.php'; $uri = explode('/', $script_name); @@ -473,7 +473,7 @@ public function shutdown() { $this->booted = FALSE; $this->container = NULL; $this->moduleList = NULL; - $this->moduleData = array(); + $this->moduleData = []; } /** @@ -562,21 +562,21 @@ public function preHandle(Request $request) { * {@inheritdoc} */ public function discoverServiceProviders() { - $this->serviceYamls = array( - 'app' => array(), - 'site' => array(), - ); - $this->serviceProviderClasses = array( - 'app' => array(), - 'site' => array(), - ); + $this->serviceYamls = [ + 'app' => [], + 'site' => [], + ]; + $this->serviceProviderClasses = [ + 'app' => [], + 'site' => [], + ]; $this->serviceYamls['app']['core'] = 'core/core.services.yml'; $this->serviceProviderClasses['app']['core'] = 'Drupal\Core\CoreServiceProvider'; // Retrieve enabled modules and register their namespaces. if (!isset($this->moduleList)) { $extensions = $this->getConfigStorage()->read('core.extension'); - $this->moduleList = isset($extensions['module']) ? $extensions['module'] : array(); + $this->moduleList = isset($extensions['module']) ? $extensions['module'] : []; } $module_filenames = $this->getModuleFileNames(); $this->classLoaderAddMultiplePsr4($this->getModuleNamespacesPsr4($module_filenames)); @@ -722,7 +722,7 @@ protected function moduleData($module) { if (!$this->moduleData) { // First, find profiles. $listing = new ExtensionDiscovery($this->root); - $listing->setProfileDirectories(array()); + $listing->setProfileDirectories([]); $all_profiles = $listing->scan('profile'); $profiles = array_intersect_key($all_profiles, $this->moduleList); @@ -733,7 +733,7 @@ protected function moduleData($module) { if ($parent_profile && !isset($profiles[$parent_profile])) { // In case both profile directories contain the same extension, the // actual profile always has precedence. - $profiles = array($parent_profile => $all_profiles[$parent_profile]) + $profiles; + $profiles = [$parent_profile => $all_profiles[$parent_profile]] + $profiles; } $profile_directories = array_map(function ($profile) { @@ -753,7 +753,7 @@ protected function moduleData($module) { * @todo Remove obsolete $module_list parameter. Only $module_filenames is * needed. */ - public function updateModules(array $module_list, array $module_filenames = array()) { + public function updateModules(array $module_list, array $module_filenames = []) { $this->moduleList = $module_list; foreach ($module_filenames as $name => $extension) { $this->moduleData[$name] = $extension; @@ -786,7 +786,7 @@ public function updateModules(array $module_list, array $module_filenames = arra * The cache key used for the service container. */ protected function getContainerCacheKey() { - $parts = array('service_container', $this->environment, \Drupal::VERSION, Settings::get('deployment_identifier'), PHP_OS, serialize(Settings::get('container_yamls'))); + $parts = ['service_container', $this->environment, \Drupal::VERSION, Settings::get('deployment_identifier'), PHP_OS, serialize(Settings::get('container_yamls'))]; return implode(':', $parts); } @@ -796,9 +796,9 @@ protected function getContainerCacheKey() { * @return array An array of kernel parameters */ protected function getKernelParameters() { - return array( + return [ 'kernel.environment' => $this->environment, - ); + ]; } /** @@ -994,7 +994,7 @@ protected function initializeSettings(Request $request) { // Initialize our list of trusted HTTP Host headers to protect against // header attacks. - $host_patterns = Settings::get('trusted_host_patterns', array()); + $host_patterns = Settings::get('trusted_host_patterns', []); if (PHP_SAPI !== 'cli' && !empty($host_patterns)) { if (static::setupTrustedHosts($request, $host_patterns) === FALSE) { throw new BadRequestHttpException('The provided host name is not valid for this server.'); @@ -1058,7 +1058,7 @@ protected function initializeRequestGlobals(Request $request) { * Returns service instances to persist from an old container to a new one. */ protected function getServicesToPersist(ContainerInterface $container) { - $persist = array(); + $persist = []; foreach ($container->getParameter('persist_ids') as $id) { // It's pointless to persist services not yet initialized. if ($container->initialized($id)) { @@ -1087,7 +1087,7 @@ protected function persistServices(ContainerInterface $container, array $persist public function rebuildContainer() { // Empty module properties and for them to be reloaded from scratch. $this->moduleList = NULL; - $this->moduleData = array(); + $this->moduleData = []; $this->containerNeedsRebuild = TRUE; return $this->initializeContainer(); } @@ -1119,7 +1119,7 @@ public function invalidateContainer() { * @return ContainerInterface */ protected function attachSynthetic(ContainerInterface $container) { - $persist = array(); + $persist = []; if (isset($this->container)) { $persist = $this->getServicesToPersist($this->container); } @@ -1161,7 +1161,7 @@ protected function compileContainer() { // - Element // - Entity // - Plugin - foreach (array('Core', 'Component') as $parent_directory) { + foreach (['Core', 'Component'] as $parent_directory) { $path = 'core/lib/Drupal/' . $parent_directory; $parent_namespace = 'Drupal\\' . $parent_directory; foreach (new \DirectoryIterator($this->root . '/' . $path) as $component) { @@ -1186,7 +1186,7 @@ protected function compileContainer() { $default_language_values = Language::$defaultValues; if ($system = $this->getConfigStorage()->read('system.site')) { if ($default_language_values['id'] != $system['langcode']) { - $default_language_values = array('id' => $system['langcode']); + $default_language_values = ['id' => $system['langcode']]; } } $container->setParameter('language.default_values', $default_language_values); @@ -1220,7 +1220,7 @@ protected function compileContainer() { // the container during the lifetime of the kernel (e.g., during a kernel // reboot). Include synthetic services, because by definition, they cannot // be automatically reinstantiated. Also include services tagged to persist. - $persist_ids = array(); + $persist_ids = []; foreach ($container->getDefinitions() as $id => $definition) { // It does not make sense to persist the container itself, exclude it. if ($id !== 'service_container' && ($definition->isSynthetic() || $definition->getTag('persist'))) { @@ -1240,10 +1240,10 @@ protected function compileContainer() { */ protected function initializeServiceProviders() { $this->discoverServiceProviders(); - $this->serviceProviders = array( - 'app' => array(), - 'site' => array(), - ); + $this->serviceProviders = [ + 'app' => [], + 'site' => [], + ]; foreach ($this->serviceProviderClasses as $origin => $classes) { foreach ($classes as $name => $class) { if (!is_object($class)) { @@ -1323,14 +1323,14 @@ protected function getConfigStorage() { * @return array */ protected function getModulesParameter() { - $extensions = array(); + $extensions = []; foreach ($this->moduleList as $name => $weight) { if ($data = $this->moduleData($name)) { - $extensions[$name] = array( + $extensions[$name] = [ 'type' => $data->getType(), 'pathname' => $data->getPathname(), 'filename' => $data->getExtensionFilename(), - ); + ]; } } return $extensions; @@ -1344,7 +1344,7 @@ protected function getModulesParameter() { * respective *.info.yml file. */ protected function getModuleFileNames() { - $filenames = array(); + $filenames = []; foreach ($this->moduleList as $module => $weight) { if ($data = $this->moduleData($module)) { $filenames[$module] = $data->getPathname(); @@ -1365,7 +1365,7 @@ protected function getModuleFileNames() { * value is the PSR-4 base directory associated with the module namespace. */ protected function getModuleNamespacesPsr4($module_file_names) { - $namespaces = array(); + $namespaces = []; foreach ($module_file_names as $module => $filename) { $namespaces["Drupal\\$module"] = dirname($filename) . '/src'; } @@ -1380,7 +1380,7 @@ protected function getModuleNamespacesPsr4($module_file_names) { * is either a PSR-4 base directory, or an array of PSR-4 base directories * associated with this namespace. */ - protected function classLoaderAddMultiplePsr4(array $namespaces = array()) { + protected function classLoaderAddMultiplePsr4(array $namespaces = []) { foreach ($namespaces as $prefix => $paths) { if (is_array($paths)) { foreach ($paths as $key => $value) { diff --git a/core/lib/Drupal/Core/DrupalKernelInterface.php b/core/lib/Drupal/Core/DrupalKernelInterface.php index 4f7e9c4..1eaaae3 100644 --- a/core/lib/Drupal/Core/DrupalKernelInterface.php +++ b/core/lib/Drupal/Core/DrupalKernelInterface.php @@ -100,7 +100,7 @@ public function getAppRoot(); * @param array $module_filenames * List of module filenames, keyed by module name. */ - public function updateModules(array $module_list, array $module_filenames = array()); + public function updateModules(array $module_list, array $module_filenames = []); /** * Force a container rebuild. diff --git a/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php b/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php index b74f21b..4e17852 100644 --- a/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php +++ b/core/lib/Drupal/Core/Entity/Annotation/ConfigEntityType.php @@ -31,7 +31,7 @@ class ConfigEntityType extends EntityType { * {@inheritdoc} */ public function get() { - $this->definition['group_label'] = new TranslatableMarkup('Configuration', array(), array('context' => 'Entity type group')); + $this->definition['group_label'] = new TranslatableMarkup('Configuration', [], ['context' => 'Entity type group']); return parent::get(); } diff --git a/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php b/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php index 4995d44..0817c93 100644 --- a/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php +++ b/core/lib/Drupal/Core/Entity/Annotation/ContentEntityType.php @@ -32,7 +32,7 @@ class ContentEntityType extends EntityType { * {@inheritdoc} */ public function get() { - $this->definition['group_label'] = new TranslatableMarkup('Content', array(), array('context' => 'Entity type group')); + $this->definition['group_label'] = new TranslatableMarkup('Content', [], ['context' => 'Entity type group']); return parent::get(); } diff --git a/core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php b/core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php index c3949e7..96bc6b1 100644 --- a/core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php +++ b/core/lib/Drupal/Core/Entity/Annotation/EntityReferenceSelection.php @@ -60,7 +60,7 @@ class EntityReferenceSelection extends Plugin { * * @var array (optional) */ - public $entity_types = array(); + public $entity_types = []; /** * The weight of the plugin in it's group. diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 7c0a458..9b95443 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -46,14 +46,14 @@ * * @var array */ - protected $values = array(); + protected $values = []; /** * The array of fields, each being an instance of FieldItemListInterface. * * @var array */ - protected $fields = array(); + protected $fields = []; /** * Local cache for field definitions. @@ -111,7 +111,7 @@ * * @var array */ - protected $translations = array(); + protected $translations = []; /** * A flag indicating whether a translation object is being initialized. @@ -139,14 +139,14 @@ * * @var array */ - protected $entityKeys = array(); + protected $entityKeys = []; /** * Holds translatable entity keys such as the label. * * @var array */ - protected $translatableEntityKeys = array(); + protected $translatableEntityKeys = []; /** * Whether entity validation was performed. @@ -165,7 +165,7 @@ /** * {@inheritdoc} */ - public function __construct(array $values, $entity_type, $bundle = FALSE, $translations = array()) { + public function __construct(array $values, $entity_type, $bundle = FALSE, $translations = []) { $this->entityTypeId = $entity_type; $this->entityKeys['bundle'] = $bundle ? $bundle : $this->entityTypeId; $this->langcodeKey = $this->getEntityType()->getKey('langcode'); @@ -220,7 +220,7 @@ public function __construct(array $values, $entity_type, $bundle = FALSE, $trans // Initialize translations. Ensure we have at least an entry for the default // language. - $data = array('status' => static::TRANSLATION_EXISTING); + $data = ['status' => static::TRANSLATION_EXISTING]; $this->translations[LanguageInterface::LANGCODE_DEFAULT] = $data; $this->setDefaultLangcode(); if ($translations) { @@ -242,7 +242,7 @@ protected function getLanguages() { // we return a mock language object to avoid disrupting the consuming // code. if (!isset($this->languages[$this->defaultLangcode])) { - $this->languages[$this->defaultLangcode] = new Language(array('id' => $this->defaultLangcode)); + $this->languages[$this->defaultLangcode] = new Language(['id' => $this->defaultLangcode]); } } return $this->languages; @@ -408,7 +408,7 @@ public function __sleep() { $this->values[$name][$langcode] = $field->getValue(); } } - $this->fields = array(); + $this->fields = []; $this->fieldDefinitions = NULL; $this->languages = NULL; $this->clearTranslationCache(); @@ -517,7 +517,7 @@ public function set($name, $value, $notify = TRUE) { * {@inheritdoc} */ public function getFields($include_computed = TRUE) { - $fields = array(); + $fields = []; foreach ($this->getFieldDefinitions() as $name => $definition) { if ($include_computed || !$definition->isComputed()) { $fields[$name] = $this->get($name); @@ -572,7 +572,7 @@ public function getFieldDefinitions() { * {@inheritdoc} */ public function toArray() { - $values = array(); + $values = []; foreach ($this->getFields() as $name => $property) { $values[$name] = $property->getValue(); } @@ -684,7 +684,7 @@ public function onChange($name) { // Update the default internal language cache. $this->setDefaultLangcode(); if (isset($this->translations[$this->defaultLangcode])) { - $message = SafeMarkup::format('A translation already exists for the specified language (@langcode).', array('@langcode' => $this->defaultLangcode)); + $message = SafeMarkup::format('A translation already exists for the specified language (@langcode).', ['@langcode' => $this->defaultLangcode]); throw new \InvalidArgumentException($message); } $this->updateFieldLangcodes($this->defaultLangcode); @@ -695,7 +695,7 @@ public function onChange($name) { $items = $this->get($this->langcodeKey); if ($items->value != $this->activeLangcode) { $items->setValue($this->activeLangcode, FALSE); - $message = SafeMarkup::format('The translation language cannot be changed (@langcode).', array('@langcode' => $this->activeLangcode)); + $message = SafeMarkup::format('The translation language cannot be changed (@langcode).', ['@langcode' => $this->activeLangcode]); throw new \LogicException($message); } } @@ -706,7 +706,7 @@ public function onChange($name) { // read-only. See https://www.drupal.org/node/2443991. if (isset($this->values[$this->defaultLangcodeKey]) && $this->get($this->defaultLangcodeKey)->value != $this->isDefaultTranslation()) { $this->get($this->defaultLangcodeKey)->setValue($this->isDefaultTranslation(), FALSE); - $message = SafeMarkup::format('The default translation flag cannot be changed (@langcode).', array('@langcode' => $this->activeLangcode)); + $message = SafeMarkup::format('The default translation flag cannot be changed (@langcode).', ['@langcode' => $this->activeLangcode]); throw new \LogicException($message); } break; @@ -815,7 +815,7 @@ public function isNewTranslation() { /** * {@inheritdoc} */ - public function addTranslation($langcode, array $values = array()) { + public function addTranslation($langcode, array $values = []) { // Make sure we do not attempt to create a translation if an invalid // language is specified or the entity cannot be translated. $this->getLanguages(); @@ -967,7 +967,7 @@ public function __isset($name) { public function __unset($name) { // Unsetting a field means emptying it. if ($this->hasField($name)) { - $this->get($name)->setValue(array()); + $this->get($name)->setValue([]); } // For non-field properties, unset the internal value. else { @@ -1013,13 +1013,13 @@ public function __clone() { $this->typedData = NULL; $definitions = $this->getFieldDefinitions(); foreach ($this->fields as $name => $values) { - $this->fields[$name] = array(); + $this->fields[$name] = []; // Untranslatable fields may have multiple references for the same field // object keyed by language. To avoid creating different field objects // we retain just the original value, as references will be recreated // later as needed. if (!$definitions[$name]->isTranslatable() && count($values) > 1) { - $values = array_intersect_key($values, array(LanguageInterface::LANGCODE_DEFAULT => TRUE)); + $values = array_intersect_key($values, [LanguageInterface::LANGCODE_DEFAULT => TRUE]); } foreach ($values as $langcode => $items) { $this->fields[$name][$langcode] = clone $items; @@ -1059,7 +1059,7 @@ public function label() { * {@inheritdoc} */ public function referencedEntities() { - $referenced_entities = array(); + $referenced_entities = []; // Gather a list of referenced entities. foreach ($this->getFields() as $field_items) { @@ -1178,7 +1178,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { * {@inheritdoc} */ public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) { - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php index 84d24de..bc0bdf3 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php @@ -55,8 +55,8 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['#title'] = $this->getQuestion(); $form['#attributes']['class'][] = 'confirmation'; - $form['description'] = array('#markup' => $this->getDescription()); - $form[$this->getFormName()] = array('#type' => 'hidden', '#value' => 1); + $form['description'] = ['#markup' => $this->getDescription()]; + $form[$this->getFormName()] = ['#type' => 'hidden', '#value' => 1]; // By default, render the form using theme_confirm_form(). if (!isset($form['#theme'])) { @@ -77,16 +77,16 @@ public function form(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ protected function actions(array $form, FormStateInterface $form_state) { - return array( - 'submit' => array( + return [ + 'submit' => [ '#type' => 'submit', '#value' => $this->getConfirmText(), - '#submit' => array( - array($this, 'submitForm'), - ), - ), + '#submit' => [ + [$this, 'submitForm'], + ], + ], 'cancel' => ConfirmFormHelper::buildCancelLink($this, $this->getRequest()), - ); + ]; } /** diff --git a/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php b/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php index ac94c26..9a70ef5 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityDeleteForm.php @@ -34,19 +34,19 @@ public function buildForm(array $form, FormStateInterface $form_state) { $languages[] = $language->getName(); } - $form['deleted_translations'] = array( + $form['deleted_translations'] = [ '#theme' => 'item_list', '#title' => $this->t('The following @entity-type translations will be deleted:', [ '@entity-type' => $entity->getEntityType()->getLowercaseLabel() ]), '#items' => $languages, - ); + ]; $form['actions']['submit']['#value'] = $this->t('Delete all translations'); } } else { - $form['actions']['submit']['#value'] = $this->t('Delete @language translation', array('@language' => $entity->language()->getName())); + $form['actions']['submit']['#value'] = $this->t('Delete @language translation', ['@language' => $entity->language()->getName()]); } return $form; @@ -129,11 +129,11 @@ public function getQuestion() { $entity = $this->getEntity(); if (!$entity->isDefaultTranslation()) { - return $this->t('Are you sure you want to delete the @language translation of the @entity-type %label?', array( + return $this->t('Are you sure you want to delete the @language translation of the @entity-type %label?', [ '@language' => $entity->language()->getName(), '@entity-type' => $this->getEntity()->getEntityType()->getLowercaseLabel(), '%label' => $this->getEntity()->label(), - )); + ]); } return $this->traitGetQuestion(); diff --git a/core/lib/Drupal/Core/Entity/ContentEntityNullStorage.php b/core/lib/Drupal/Core/Entity/ContentEntityNullStorage.php index 5d3379f..3dc00c9 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityNullStorage.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityNullStorage.php @@ -15,7 +15,7 @@ class ContentEntityNullStorage extends ContentEntityStorageBase { * {@inheritdoc} */ public function loadMultiple(array $ids = NULL) { - return array(); + return []; } /** @@ -47,8 +47,8 @@ public function deleteRevision($revision_id) { /** * {@inheritdoc} */ - public function loadByProperties(array $values = array()) { - return array(); + public function loadByProperties(array $values = []) { + return []; } /** @@ -104,7 +104,7 @@ protected function doDeleteRevisionFieldItems(ContentEntityInterface $revision) * {@inheritdoc} */ protected function readFieldItemsToPurge(FieldDefinitionInterface $field_definition, $batch_size) { - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index afdce40..5c5c2af 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -84,7 +84,7 @@ protected function doCreate(array $values) { } $bundle = $values[$this->bundleKey]; } - $entity = new $this->entityClass(array(), $this->entityTypeId, $bundle); + $entity = new $this->entityClass([], $this->entityTypeId, $bundle); $this->initFieldValues($entity, $values); return $entity; } @@ -582,11 +582,11 @@ protected function cleanIds(array $ids) { */ protected function getFromPersistentCache(array &$ids = NULL) { if (!$this->entityType->isPersistentlyCacheable() || empty($ids)) { - return array(); + return []; } - $entities = array(); + $entities = []; // Build the list of cache entries to retrieve. - $cid_map = array(); + $cid_map = []; foreach ($ids as $id) { $cid_map[$id] = $this->buildCacheId($id); } @@ -615,10 +615,10 @@ protected function setPersistentCache($entities) { return; } - $cache_tags = array( + $cache_tags = [ $this->entityTypeId . '_values', 'entity_field_info', - ); + ]; foreach ($entities as $id => $entity) { $this->cacheBackend->set($this->buildCacheId($id), $entity, CacheBackendInterface::CACHE_PERMANENT, $cache_tags); } @@ -629,7 +629,7 @@ protected function setPersistentCache($entities) { */ public function resetCache(array $ids = NULL) { if ($ids) { - $cids = array(); + $cids = []; foreach ($ids as $id) { unset($this->entities[$id]); $cids[] = $this->buildCacheId($id); @@ -639,9 +639,9 @@ public function resetCache(array $ids = NULL) { } } else { - $this->entities = array(); + $this->entities = []; if ($this->entityType->isPersistentlyCacheable()) { - Cache::invalidateTags(array($this->entityTypeId . '_values')); + Cache::invalidateTags([$this->entityTypeId . '_values']); } } } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityType.php b/core/lib/Drupal/Core/Entity/ContentEntityType.php index 6d8d619..400374b 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityType.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityType.php @@ -12,10 +12,10 @@ class ContentEntityType extends EntityType implements ContentEntityTypeInterface */ public function __construct($definition) { parent::__construct($definition); - $this->handlers += array( + $this->handlers += [ 'storage' => 'Drupal\Core\Entity\Sql\SqlContentEntityStorage', 'view_builder' => 'Drupal\Core\Entity\EntityViewBuilder', - ); + ]; } /** diff --git a/core/lib/Drupal/Core/Entity/DependencyTrait.php b/core/lib/Drupal/Core/Entity/DependencyTrait.php index f56a6a0..1ba2579 100644 --- a/core/lib/Drupal/Core/Entity/DependencyTrait.php +++ b/core/lib/Drupal/Core/Entity/DependencyTrait.php @@ -12,7 +12,7 @@ * * @var array */ - protected $dependencies = array(); + protected $dependencies = []; /** * Adds a dependency. @@ -30,7 +30,7 @@ */ protected function addDependency($type, $name) { if (empty($this->dependencies[$type])) { - $this->dependencies[$type] = array($name); + $this->dependencies[$type] = [$name]; if (count($this->dependencies) > 1) { // Ensure a consistent order of type keys. ksort($this->dependencies); diff --git a/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php b/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php index 7fa45a5..38baa15 100644 --- a/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php +++ b/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php @@ -54,7 +54,7 @@ public function getComponent($name); * * @return $this */ - public function setComponent($name, array $options = array()); + public function setComponent($name, array $options = []); /** * Sets a component to be hidden. diff --git a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php index 23fd0b5..b90b517 100644 --- a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php +++ b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php @@ -31,7 +31,7 @@ public function getInfo() { // Apply default form element properties. $info['#target_type'] = NULL; $info['#selection_handler'] = 'default'; - $info['#selection_settings'] = array(); + $info['#selection_settings'] = []; $info['#tags'] = FALSE; $info['#autocreate'] = NULL; // This should only be set to FALSE if proper validation by the selection @@ -42,8 +42,8 @@ public function getInfo() { // it's value is properly checked for access. $info['#process_default_value'] = TRUE; - $info['#element_validate'] = array(array($class, 'validateEntityAutocomplete')); - array_unshift($info['#process'], array($class, 'processEntityAutocomplete')); + $info['#element_validate'] = [[$class, 'validateEntityAutocomplete']]; + array_unshift($info['#process'], [$class, 'processEntityAutocomplete']); return $info; } @@ -60,7 +60,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form elseif (!empty($element['#default_value']) && !is_array($element['#default_value'])) { // Convert the default value into an array for easier processing in // static::getEntityLabels(). - $element['#default_value'] = array($element['#default_value']); + $element['#default_value'] = [$element['#default_value']]; } if ($element['#default_value']) { @@ -136,11 +136,11 @@ public static function processEntityAutocomplete(array &$element, FormStateInter } $element['#autocomplete_route_name'] = 'system.entity_autocomplete'; - $element['#autocomplete_route_parameters'] = array( + $element['#autocomplete_route_parameters'] = [ 'target_type' => $element['#target_type'], 'selection_handler' => $element['#selection_handler'], 'selection_settings_key' => $selection_settings_key, - ); + ]; return $element; } @@ -152,11 +152,11 @@ public static function validateEntityAutocomplete(array &$element, FormStateInte $value = NULL; if (!empty($element['#value'])) { - $options = array( + $options = [ 'target_type' => $element['#target_type'], 'handler' => $element['#selection_handler'], 'handler_settings' => $element['#selection_settings'], - ); + ]; /** @var /Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface $handler */ $handler = \Drupal::service('plugin.manager.entity_reference_selection')->getInstance($options); $autocreate = (bool) $element['#autocreate'] && $handler instanceof SelectionWithAutocreateInterface; @@ -167,7 +167,7 @@ public static function validateEntityAutocomplete(array &$element, FormStateInte $value = $element['#value']; } else { - $input_values = $element['#tags'] ? Tags::explode($element['#value']) : array($element['#value']); + $input_values = $element['#tags'] ? Tags::explode($element['#value']) : [$element['#value']]; foreach ($input_values as $input) { $match = static::extractEntityIdFromAutocompleteInput($input); @@ -178,17 +178,17 @@ public static function validateEntityAutocomplete(array &$element, FormStateInte } if ($match !== NULL) { - $value[] = array( + $value[] = [ 'target_id' => $match, - ); + ]; } elseif ($autocreate) { /** @var \Drupal\Core\Entity\EntityReferenceSelection\SelectionWithAutocreateInterface $handler */ // Auto-create item. See an example of how this is handled in // \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::presave(). - $value[] = array( + $value[] = [ 'entity' => $handler->createNewEntity($element['#target_type'], $element['#autocreate']['bundle'], $input, $element['#autocreate']['uid']), - ); + ]; } } } @@ -207,7 +207,7 @@ public static function validateEntityAutocomplete(array &$element, FormStateInte $valid_ids = $handler->validateReferenceableEntities($ids); if ($invalid_ids = array_diff($ids, $valid_ids)) { foreach ($invalid_ids as $invalid_id) { - $form_state->setError($element, t('The referenced entity (%type: %id) does not exist.', array('%type' => $element['#target_type'], '%id' => $invalid_id))); + $form_state->setError($element, t('The referenced entity (%type: %id) does not exist.', ['%type' => $element['#target_type'], '%id' => $invalid_id])); } } } @@ -233,7 +233,7 @@ public static function validateEntityAutocomplete(array &$element, FormStateInte foreach ($invalid_new_entities as $entity) { /** @var \Drupal\Core\Entity\EntityInterface $entity */ - $form_state->setError($element, t('This entity (%type: %label) cannot be referenced.', array('%type' => $element['#target_type'], '%label' => $entity->label()))); + $form_state->setError($element, t('This entity (%type: %label) cannot be referenced.', ['%type' => $element['#target_type'], '%label' => $entity->label()])); } } } @@ -275,10 +275,10 @@ protected static function matchEntityByTitle(SelectionInterface $handler, $input $entities = array_reduce($entities_by_bundle, function ($flattened, $bundle_entities) { return $flattened + $bundle_entities; }, []); - $params = array( + $params = [ '%value' => $input, '@value' => $input, - ); + ]; if (empty($entities)) { if ($strict) { // Error if there are no entities available for a required field. @@ -292,12 +292,12 @@ protected static function matchEntityByTitle(SelectionInterface $handler, $input } elseif (count($entities) > 1) { // More helpful error if there are only a few matching entities. - $multiples = array(); + $multiples = []; foreach ($entities as $id => $name) { $multiples[] = $name . ' (' . $id . ')'; } $params['@id'] = $id; - $form_state->setError($element, t('Multiple entities match this reference; "%multiple". Specify the one you want by appending the id in parentheses, like "@value (@id)".', array('%multiple' => implode('", "', $multiples)))); + $form_state->setError($element, t('Multiple entities match this reference; "%multiple". Specify the one you want by appending the id in parentheses, like "@value (@id)".', ['%multiple' => implode('", "', $multiples)])); } else { // Take the one and only matching entity. @@ -318,7 +318,7 @@ protected static function matchEntityByTitle(SelectionInterface $handler, $input * A string of entity labels separated by commas. */ public static function getEntityLabels(array $entities) { - $entity_labels = array(); + $entity_labels = []; foreach ($entities as $entity) { // Use the special view label, since some entities allow the label to be // viewed, even if the entity is not allowed to be viewed. diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 2c6dbc1..f36f74f 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -190,7 +190,7 @@ public function toUrl($rel = 'canonical', array $options = []) { if (isset($link_templates[$rel])) { $route_parameters = $this->urlRouteParameters($rel); - $route_name = "entity.{$this->entityTypeId}." . str_replace(array('-', 'drupal:'), array('_', ''), $rel); + $route_name = "entity.{$this->entityTypeId}." . str_replace(['-', 'drupal:'], ['_', ''], $rel); $uri = new Url($route_name, $route_parameters); } else { @@ -275,7 +275,7 @@ public function toLink($text = NULL, $rel = 'canonical', array $options = []) { /** * {@inheritdoc} */ - public function url($rel = 'canonical', $options = array()) { + public function url($rel = 'canonical', $options = []) { // While self::toUrl() will throw an exception if the entity has no id, // the expected result for a URL is always a string. if ($this->id() === NULL || !$this->hasLinkTemplate($rel)) { @@ -353,7 +353,7 @@ public function language() { } // Make sure we return a proper language object. $langcode = !empty($this->langcode) ? $this->langcode : LanguageInterface::LANGCODE_NOT_SPECIFIED; - $language = new Language(array('id' => $langcode)); + $language = new Language(['id' => $langcode]); return $language; } @@ -369,7 +369,7 @@ public function save() { */ public function delete() { if (!$this->isNew()) { - $this->entityManager()->getStorage($this->entityTypeId)->delete(array($this->id() => $this)); + $this->entityManager()->getStorage($this->entityTypeId)->delete([$this->id() => $this]); } } @@ -452,7 +452,7 @@ public static function postLoad(EntityStorageInterface $storage, array &$entitie * {@inheritdoc} */ public function referencedEntities() { - return array(); + return []; } /** @@ -510,7 +510,7 @@ public static function loadMultiple(array $ids = NULL) { /** * {@inheritdoc} */ - public static function create(array $values = array()) { + public static function create(array $values = []) { $entity_manager = \Drupal::entityManager(); return $entity_manager->getStorage($entity_manager->getEntityTypeFromClass(get_called_class()))->create($values); } @@ -585,7 +585,7 @@ public function setOriginalId($id) { * {@inheritdoc} */ public function toArray() { - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php index b2f64df..2443344 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php @@ -95,23 +95,23 @@ public static function collectRenderDisplay(FieldableEntityInterface $entity, $f } // Else create a fresh runtime object. if (empty($display)) { - $display = $storage->create(array( + $display = $storage->create([ 'targetEntityType' => $entity_type, 'bundle' => $bundle, 'mode' => $form_mode, 'status' => TRUE, - )); + ]); } // Let the display know which form mode was originally requested. $display->originalMode = $form_mode; // Let modules alter the display. - $display_context = array( + $display_context = [ 'entity_type' => $entity_type, 'bundle' => $bundle, 'form_mode' => $form_mode, - ); + ]; \Drupal::moduleHandler()->alter('entity_form_display', $display, $display_context); return $display; @@ -136,13 +136,13 @@ public function getRenderer($field_name) { // Instantiate the widget object from the stored display properties. if (($configuration = $this->getComponent($field_name)) && isset($configuration['type']) && ($definition = $this->getFieldDefinition($field_name))) { - $widget = $this->pluginManager->getInstance(array( + $widget = $this->pluginManager->getInstance([ 'field_definition' => $definition, 'form_mode' => $this->originalMode, // No need to prepare, defaults have been merged in setComponent(). 'prepare' => FALSE, 'configuration' => $configuration - )); + ]); } else { $widget = NULL; @@ -158,7 +158,7 @@ public function getRenderer($field_name) { */ public function buildForm(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state) { // Set #parents to 'top-level' by default. - $form += array('#parents' => array()); + $form += ['#parents' => []]; // Let each widget generate the form elements. foreach ($this->getComponents() as $name => $options) { @@ -185,7 +185,7 @@ public function buildForm(FieldableEntityInterface $entity, array &$form, FormSt $this->renderer->addCacheableDependency($form, $this); // Add a process callback so we can assign weights and hide extra fields. - $form['#process'][] = array($this, 'processForm'); + $form['#process'][] = [$this, 'processForm']; } /** @@ -203,7 +203,7 @@ public function processForm($element, FormStateInterface $form_state, $form) { // Hide extra fields. $extra_fields = \Drupal::entityManager()->getExtraFields($this->targetEntityType, $this->bundle); - $extra_fields = isset($extra_fields['form']) ? $extra_fields['form'] : array(); + $extra_fields = isset($extra_fields['form']) ? $extra_fields['form'] : []; foreach ($extra_fields as $extra_field => $info) { if (!$this->getComponent($extra_field)) { $element[$extra_field]['#access'] = FALSE; @@ -216,7 +216,7 @@ public function processForm($element, FormStateInterface $form_state, $form) { * {@inheritdoc} */ public function extractFormValues(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state) { - $extracted = array(); + $extracted = []; foreach ($entity as $name => $items) { if ($widget = $this->getRenderer($name)) { $widget->extractFormValues($items, $form, $form_state); @@ -316,19 +316,19 @@ protected function movePropertyPathViolationsRelativeToField($field_name, Constr * {@inheritdoc} */ public function getPluginCollections() { - $configurations = array(); + $configurations = []; foreach ($this->getComponents() as $field_name => $configuration) { if (!empty($configuration['type']) && ($field_definition = $this->getFieldDefinition($field_name))) { - $configurations[$configuration['type']] = $configuration + array( + $configurations[$configuration['type']] = $configuration + [ 'field_definition' => $field_definition, 'form_mode' => $this->mode, - ); + ]; } } - return array( + return [ 'widgets' => new EntityDisplayPluginCollection($this->pluginManager, $configurations) - ); + ]; } } diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php index a6b83cf..74b15b6 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php @@ -70,12 +70,12 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn */ public static function collectRenderDisplays($entities, $view_mode) { if (empty($entities)) { - return array(); + return []; } // Collect entity type and bundles. $entity_type = current($entities)->getEntityTypeId(); - $bundles = array(); + $bundles = []; foreach ($entities as $entity) { $bundles[$entity->bundle()] = TRUE; } @@ -84,7 +84,7 @@ public static function collectRenderDisplays($entities, $view_mode) { // For each bundle, check the existence and status of: // - the display for the view mode, // - the 'default' display. - $candidate_ids = array(); + $candidate_ids = []; foreach ($bundles as $bundle) { if ($view_mode != 'default') { $candidate_ids[$bundle][] = $entity_type . '.' . $bundle . '.' . $view_mode; @@ -97,7 +97,7 @@ public static function collectRenderDisplays($entities, $view_mode) { ->execute(); // For each bundle, select the first valid candidate display, if any. - $load_ids = array(); + $load_ids = []; foreach ($bundles as $bundle) { foreach ($candidate_ids[$bundle] as $candidate_id) { if (isset($results[$candidate_id])) { @@ -111,30 +111,30 @@ public static function collectRenderDisplays($entities, $view_mode) { $storage = \Drupal::entityManager()->getStorage('entity_view_display'); $displays = $storage->loadMultiple($load_ids); - $displays_by_bundle = array(); + $displays_by_bundle = []; foreach ($bundles as $bundle) { // Use the selected display if any, or create a fresh runtime object. if (isset($load_ids[$bundle])) { $display = $displays[$load_ids[$bundle]]; } else { - $display = $storage->create(array( + $display = $storage->create([ 'targetEntityType' => $entity_type, 'bundle' => $bundle, 'mode' => $view_mode, 'status' => TRUE, - )); + ]); } // Let the display know which view mode was originally requested. $display->originalMode = $view_mode; // Let modules alter the display. - $display_context = array( + $display_context = [ 'entity_type' => $entity_type, 'bundle' => $bundle, 'view_mode' => $view_mode, - ); + ]; \Drupal::moduleHandler()->alter('entity_view_display', $display, $display_context); $displays_by_bundle[$bundle] = $display; @@ -159,7 +159,7 @@ public static function collectRenderDisplays($entities, $view_mode) { * @see \Drupal\Core\Entity\Entity\EntityViewDisplay::collectRenderDisplays() */ public static function collectRenderDisplay(FieldableEntityInterface $entity, $view_mode) { - $displays = static::collectRenderDisplays(array($entity), $view_mode); + $displays = static::collectRenderDisplays([$entity], $view_mode); return $displays[$entity->bundle()]; } @@ -193,13 +193,13 @@ public function getRenderer($field_name) { // Instantiate the formatter object from the stored display properties. if (($configuration = $this->getComponent($field_name)) && isset($configuration['type']) && ($definition = $this->getFieldDefinition($field_name))) { - $formatter = $this->pluginManager->getInstance(array( + $formatter = $this->pluginManager->getInstance([ 'field_definition' => $definition, 'view_mode' => $this->originalMode, // No need to prepare, defaults have been merged in setComponent(). 'prepare' => FALSE, 'configuration' => $configuration - )); + ]); } else { $formatter = NULL; @@ -214,7 +214,7 @@ public function getRenderer($field_name) { * {@inheritdoc} */ public function build(FieldableEntityInterface $entity) { - $build = $this->buildMultiple(array($entity)); + $build = $this->buildMultiple([$entity]); return $build[0]; } @@ -222,9 +222,9 @@ public function build(FieldableEntityInterface $entity) { * {@inheritdoc} */ public function buildMultiple(array $entities) { - $build_list = array(); + $build_list = []; foreach ($entities as $key => $entity) { - $build_list[$key] = array(); + $build_list[$key] = []; } // Run field formatters. @@ -232,7 +232,7 @@ public function buildMultiple(array $entities) { if ($formatter = $this->getRenderer($name)) { // Group items across all entities and pass them to the formatter's // prepareView() method. - $grouped_items = array(); + $grouped_items = []; foreach ($entities as $id => $entity) { $items = $entity->get($name); $items->filterEmptyItems(); @@ -272,11 +272,11 @@ public function buildMultiple(array $entities) { } // Let other modules alter the renderable array. - $context = array( + $context = [ 'entity' => $entity, 'view_mode' => $this->originalMode, 'display' => $this, - ); + ]; \Drupal::moduleHandler()->alter('entity_display_build', $build_list[$id], $context); } @@ -287,19 +287,19 @@ public function buildMultiple(array $entities) { * {@inheritdoc} */ public function getPluginCollections() { - $configurations = array(); + $configurations = []; foreach ($this->getComponents() as $field_name => $configuration) { if (!empty($configuration['type']) && ($field_definition = $this->getFieldDefinition($field_name))) { - $configurations[$configuration['type']] = $configuration + array( + $configurations[$configuration['type']] = $configuration + [ 'field_definition' => $field_definition, 'view_mode' => $this->originalMode, - ); + ]; } } - return array( + return [ 'formatters' => new EntityDisplayPluginCollection($this->pluginManager, $configurations) - ); + ]; } } diff --git a/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php b/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php index cfcb5fc..f1509a1 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessControlHandler.php @@ -18,7 +18,7 @@ class EntityAccessControlHandler extends EntityHandlerBase implements EntityAcce * * @var array */ - protected $accessCache = array(); + protected $accessCache = []; /** * The entity type ID of the access control handler instance. @@ -207,18 +207,18 @@ protected function setCache($access, $cid, $operation, $langcode, AccountInterfa * {@inheritdoc} */ public function resetCache() { - $this->accessCache = array(); + $this->accessCache = []; } /** * {@inheritdoc} */ - public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array(), $return_as_object = FALSE) { + public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = [], $return_as_object = FALSE) { $account = $this->prepareUser($account); - $context += array( + $context += [ 'entity_type_id' => $this->entityTypeId, 'langcode' => LanguageInterface::LANGCODE_DEFAULT, - ); + ]; $cid = $entity_bundle ? 'create:' . $entity_bundle : 'create'; if (($access = $this->getCache($cid, 'create', $context['langcode'], $account)) !== NULL) { @@ -236,8 +236,8 @@ public function createAccess($entity_bundle = NULL, AccountInterface $account = // - No modules say to deny access. // - At least one module says to grant access. $access = array_merge( - $this->moduleHandler()->invokeAll('entity_create_access', array($account, $context, $entity_bundle)), - $this->moduleHandler()->invokeAll($this->entityTypeId . '_create_access', array($account, $context, $entity_bundle)) + $this->moduleHandler()->invokeAll('entity_create_access', [$account, $context, $entity_bundle]), + $this->moduleHandler()->invokeAll($this->entityTypeId . '_create_access', [$account, $context, $entity_bundle]) ); $return = $this->processAccessHookResults($access); @@ -312,19 +312,19 @@ public function fieldAccess($operation, FieldDefinitionInterface $field_definiti // Invoke hook and collect grants/denies for field access from other // modules. Our default access flag is masked under the ':default' key. - $grants = array(':default' => $default); + $grants = [':default' => $default]; $hook_implementations = $this->moduleHandler()->getImplementations('entity_field_access'); foreach ($hook_implementations as $module) { - $grants = array_merge($grants, array($module => $this->moduleHandler()->invoke($module, 'entity_field_access', array($operation, $field_definition, $account, $items)))); + $grants = array_merge($grants, [$module => $this->moduleHandler()->invoke($module, 'entity_field_access', [$operation, $field_definition, $account, $items])]); } // Also allow modules to alter the returned grants/denies. - $context = array( + $context = [ 'operation' => $operation, 'field_definition' => $field_definition, 'items' => $items, 'account' => $account, - ); + ]; $this->moduleHandler()->alter('entity_field_access', $grants, $context); $result = $this->processAccessHookResults($grants); diff --git a/core/lib/Drupal/Core/Entity/EntityAccessControlHandlerInterface.php b/core/lib/Drupal/Core/Entity/EntityAccessControlHandlerInterface.php index 0bec9c2..5532996 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessControlHandlerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessControlHandlerInterface.php @@ -60,7 +60,7 @@ public function access(EntityInterface $entity, $operation, AccountInterface $ac * returned, i.e. TRUE means access is explicitly allowed, FALSE means * access is either explicitly forbidden or "no opinion". */ - public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = array(), $return_as_object = FALSE); + public function createAccess($entity_bundle = NULL, AccountInterface $account = NULL, array $context = [], $return_as_object = FALSE); /** * Clears all cached access checks. diff --git a/core/lib/Drupal/Core/Entity/EntityAutocompleteMatcher.php b/core/lib/Drupal/Core/Entity/EntityAutocompleteMatcher.php index 01a29b2..55372f9 100644 --- a/core/lib/Drupal/Core/Entity/EntityAutocompleteMatcher.php +++ b/core/lib/Drupal/Core/Entity/EntityAutocompleteMatcher.php @@ -50,13 +50,13 @@ public function __construct(SelectionPluginManagerInterface $selection_manager) * @see \Drupal\system\Controller\EntityAutocompleteController */ public function getMatches($target_type, $selection_handler, $selection_settings, $string = '') { - $matches = array(); + $matches = []; - $options = array( + $options = [ 'target_type' => $target_type, 'handler' => $selection_handler, 'handler_settings' => $selection_settings, - ); + ]; $handler = $this->selectionManager->getInstance($options); if (isset($string)) { @@ -73,7 +73,7 @@ public function getMatches($target_type, $selection_handler, $selection_settings $key = preg_replace('/\s\s+/', ' ', str_replace("\n", '', trim(Html::decodeEntities(strip_tags($key))))); // Names containing commas or quotes must be wrapped in quotes. $key = Tags::encode($key); - $matches[] = array('value' => $key, 'label' => $label); + $matches[] = ['value' => $key, 'label' => $label]; } } } diff --git a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php index 759183b..d8c39e4 100644 --- a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php +++ b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php @@ -57,8 +57,8 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['#title'] = $this->getQuestion(); $form['#attributes']['class'][] = 'confirmation'; - $form['description'] = array('#markup' => $this->getDescription()); - $form[$this->getFormName()] = array('#type' => 'hidden', '#value' => 1); + $form['description'] = ['#markup' => $this->getDescription()]; + $form[$this->getFormName()] = ['#type' => 'hidden', '#value' => 1]; // By default, render the form using theme_confirm_form(). if (!isset($form['#theme'])) { @@ -71,16 +71,16 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ protected function actions(array $form, FormStateInterface $form_state) { - return array( - 'submit' => array( + return [ + 'submit' => [ '#type' => 'submit', '#value' => $this->getConfirmText(), - '#submit' => array( - array($this, 'submitForm'), - ), - ), + '#submit' => [ + [$this, 'submitForm'], + ], + ], 'cancel' => ConfirmFormHelper::buildCancelLink($this, $this->getRequest()), - ); + ]; } /** diff --git a/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php b/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php index 927dcd3..c3404b6 100644 --- a/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php +++ b/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php @@ -47,7 +47,7 @@ class EntityConstraintViolationList extends ConstraintViolationList implements E * @param array $violations * The array of violations. */ - public function __construct(FieldableEntityInterface $entity, array $violations = array()) { + public function __construct(FieldableEntityInterface $entity, array $violations = []) { parent::__construct($violations); $this->entity = $entity; } @@ -156,7 +156,7 @@ public function filterByFields(array $field_names) { * {@inheritdoc} */ public function filterByFieldAccess(AccountInterface $account = NULL) { - $filtered_fields = array(); + $filtered_fields = []; foreach ($this->getFieldNames() as $field_name) { if (!$this->entity->get($field_name)->access('edit', $account)) { $filtered_fields[] = $field_name; diff --git a/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php b/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php index 3ead817..70dec2c 100644 --- a/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php +++ b/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php @@ -42,7 +42,7 @@ public function needsUpdates() { * {@inheritdoc} */ public function getChangeSummary() { - $summary = array(); + $summary = []; foreach ($this->getChangeList() as $entity_type_id => $change_list) { // Process entity type definition changes. @@ -259,7 +259,7 @@ protected function doFieldUpdate($op, $storage_definition = NULL, $original_stor */ protected function getChangeList() { $this->entityManager->useCaches(FALSE); - $change_list = array(); + $change_list = []; foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { $original = $this->entityManager->getLastInstalledDefinition($entity_type_id); @@ -275,7 +275,7 @@ protected function getChangeList() { } if ($this->entityManager->getStorage($entity_type_id) instanceof DynamicallyFieldableEntityStorageInterface) { - $field_changes = array(); + $field_changes = []; $storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id); $original_storage_definitions = $this->entityManager->getLastInstalledFieldStorageDefinitions($entity_type_id); diff --git a/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php b/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php index 8d5352b..2faf45c 100644 --- a/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php +++ b/core/lib/Drupal/Core/Entity/EntityDeleteFormTrait.php @@ -44,10 +44,10 @@ * {@inheritdoc} */ public function getQuestion() { - return $this->t('Are you sure you want to delete the @entity-type %label?', array( + return $this->t('Are you sure you want to delete the @entity-type %label?', [ '@entity-type' => $this->getEntity()->getEntityType()->getLowercaseLabel(), '%label' => $this->getEntity()->label(), - )); + ]); } /** @@ -65,10 +65,10 @@ public function getConfirmText() { */ protected function getDeletionMessage() { $entity = $this->getEntity(); - return $this->t('The @entity-type %label has been deleted.', array( + return $this->t('The @entity-type %label has been deleted.', [ '@entity-type' => $entity->getEntityType()->getLowercaseLabel(), '%label' => $entity->label(), - )); + ]); } /** @@ -109,10 +109,10 @@ protected function getRedirectUrl() { */ protected function logDeletionMessage() { $entity = $this->getEntity(); - $this->logger($entity->getEntityType()->getProvider())->notice('The @entity-type %label has been deleted.', array( + $this->logger($entity->getEntityType()->getProvider())->notice('The @entity-type %label has been deleted.', [ '@entity-type' => $entity->getEntityType()->getLowercaseLabel(), '%label' => $entity->label(), - )); + ]); } /** diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index 4de891a..f0509f3 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -69,14 +69,14 @@ * * @var array */ - protected $content = array(); + protected $content = []; /** * List of components that are set to be hidden. * * @var array */ - protected $hidden = array(); + protected $hidden = []; /** * The original view or form mode that was requested (case of view/form modes @@ -91,7 +91,7 @@ * * @var array */ - protected $plugins = array(); + protected $plugins = []; /** * Context in which this entity will be used (e.g. 'display', 'form'). @@ -157,14 +157,14 @@ protected function init() { // Fill in defaults for extra fields. $context = $this->displayContext == 'view' ? 'display' : $this->displayContext; $extra_fields = \Drupal::entityManager()->getExtraFields($this->targetEntityType, $this->bundle); - $extra_fields = isset($extra_fields[$context]) ? $extra_fields[$context] : array(); + $extra_fields = isset($extra_fields[$context]) ? $extra_fields[$context] : []; foreach ($extra_fields as $name => $definition) { if (!isset($this->content[$name]) && !isset($this->hidden[$name])) { // Extra fields are visible by default unless they explicitly say so. if (!isset($definition['visible']) || $definition['visible'] == TRUE) { - $this->content[$name] = array( + $this->content[$name] = [ 'weight' => $definition['weight'] - ); + ]; } else { $this->hidden[$name] = TRUE; @@ -319,7 +319,7 @@ public function getComponent($name) { /** * {@inheritdoc} */ - public function setComponent($name, array $options = array()) { + public function setComponent($name, array $options = []) { // If no weight specified, make sure the field sinks at the bottom. if (!isset($options['weight'])) { $max = $this->getHighestWeight(); @@ -356,7 +356,7 @@ public function removeComponent($name) { * {@inheritdoc} */ public function getHighestWeight() { - $weights = array(); + $weights = []; // Collect weights for the components in the display. foreach ($this->content as $options) { @@ -366,7 +366,7 @@ public function getHighestWeight() { } // Let other modules feedback about their own additions. - $weights = array_merge($weights, \Drupal::moduleHandler()->invokeAll('field_info_max_weight', array($this->targetEntityType, $this->bundle, $this->displayContext, $this->mode))); + $weights = array_merge($weights, \Drupal::moduleHandler()->invokeAll('field_info_max_weight', [$this->targetEntityType, $this->bundle, $this->displayContext, $this->mode])); return $weights ? max($weights) : NULL; } @@ -388,7 +388,7 @@ protected function getFieldDefinitions() { // For "official" view modes and form modes, ignore fields whose // definition states they should not be displayed. if ($this->mode !== static::CUSTOM_MODE) { - $definitions = array_filter($definitions, array($this, 'fieldHasDisplayOptions')); + $definitions = array_filter($definitions, [$this, 'fieldHasDisplayOptions']); } $this->fieldDefinitions = $definitions; } diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayRepository.php b/core/lib/Drupal/Core/Entity/EntityDisplayRepository.php index 0ee4317..d959881 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayRepository.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayRepository.php @@ -187,7 +187,7 @@ public function getFormModeOptionsByBundle($entity_type_id, $bundle) { * An array of display mode labels, keyed by the display mode ID. */ protected function getDisplayModeOptions($display_type, $entity_type_id) { - $options = array('default' => t('Default')); + $options = ['default' => t('Default')]; foreach ($this->getDisplayModesByEntityType($display_type, $entity_type_id) as $mode => $settings) { $options[$mode] = $settings['label']; } @@ -213,7 +213,7 @@ protected function getDisplayModeOptionsByBundle($display_type, $entity_type_id, // Filter out modes for which the entity display is disabled // (or non-existent). - $load_ids = array(); + $load_ids = []; // Get the list of available entity displays for the current bundle. foreach (array_keys($options) as $mode) { $load_ids[] = $entity_type_id . '.' . $bundle . '.' . $mode; diff --git a/core/lib/Drupal/Core/Entity/EntityForm.php b/core/lib/Drupal/Core/Entity/EntityForm.php index a83af35..f2651f3 100644 --- a/core/lib/Drupal/Core/Entity/EntityForm.php +++ b/core/lib/Drupal/Core/Entity/EntityForm.php @@ -204,9 +204,9 @@ protected function actionsElement(array $form, FormStateInterface $form_state) { $count = 0; foreach (Element::children($element) as $action) { - $element[$action] += array( + $element[$action] += [ '#weight' => ++$count * 5, - ); + ]; } if (!empty($element)) { @@ -226,11 +226,11 @@ protected function actions(array $form, FormStateInterface $form_state) { // @todo Consider renaming the action key from submit to save. The impacts // are hard to predict. For example, see // \Drupal\language\Element\LanguageConfiguration::processLanguageConfiguration(). - $actions['submit'] = array( + $actions['submit'] = [ '#type' => 'submit', '#value' => $this->t('Save'), - '#submit' => array('::submitForm', '::save'), - ); + '#submit' => ['::submitForm', '::save'], + ]; if (!$this->entity->isNew() && $this->entity->hasLinkTemplate('delete-form')) { $route_info = $this->entity->urlInfo('delete-form'); @@ -239,14 +239,14 @@ protected function actions(array $form, FormStateInterface $form_state) { $query['destination'] = $this->getRequest()->query->get('destination'); $route_info->setOption('query', $query); } - $actions['delete'] = array( + $actions['delete'] = [ '#type' => 'link', '#title' => $this->t('Delete'), '#access' => $this->entity->access('delete'), - '#attributes' => array( - 'class' => array('button', 'button--danger'), - ), - ); + '#attributes' => [ + 'class' => ['button', 'button--danger'], + ], + ]; $actions['delete']['#url'] = $route_info; } @@ -294,7 +294,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) { // properties. if (isset($form['#entity_builders'])) { foreach ($form['#entity_builders'] as $function) { - call_user_func_array($function, array($entity->getEntityTypeId(), $entity, &$form, &$form_state)); + call_user_func_array($function, [$entity->getEntityTypeId(), $entity, &$form, &$form_state]); } } @@ -391,7 +391,7 @@ protected function prepareInvokeAll($hook, FormStateInterface $form_state) { if (function_exists($function)) { // Ensure we pass an updated translation object and form display at // each invocation, since they depend on form state which is alterable. - $args = array($this->entity, $this->operation, &$form_state); + $args = [$this->entity, $this->operation, &$form_state]; call_user_func_array($function, $args); } } diff --git a/core/lib/Drupal/Core/Entity/EntityFormBuilder.php b/core/lib/Drupal/Core/Entity/EntityFormBuilder.php index ff4b917..d5f0baf 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityFormBuilder.php @@ -40,7 +40,7 @@ public function __construct(EntityManagerInterface $entity_manager, FormBuilderI /** * {@inheritdoc} */ - public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = array()) { + public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = []) { $form_object = $this->entityManager->getFormObject($entity->getEntityTypeId(), $operation); $form_object->setEntity($entity); diff --git a/core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php b/core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php index bfcead1..2265cd0 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityFormBuilderInterface.php @@ -53,6 +53,6 @@ * @see \Drupal\Core\Entity\EntityTypeInterface::setFormClass() * @see system_entity_type_build() */ - public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = array()); + public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = []); } diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php index 3a38e07..8890fb7 100644 --- a/core/lib/Drupal/Core/Entity/EntityInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityInterface.php @@ -112,7 +112,7 @@ public function label(); * * @see \Drupal\Core\Entity\EntityInterface::toUrl */ - public function urlInfo($rel = 'canonical', array $options = array()); + public function urlInfo($rel = 'canonical', array $options = []); /** * Gets the URL object for the entity. @@ -150,7 +150,7 @@ public function urlInfo($rel = 'canonical', array $options = array()); * @throws \Drupal\Core\Entity\EntityMalformedException * @throws \Drupal\Core\Entity\Exception\UndefinedLinkTemplateException */ - public function toUrl($rel = 'canonical', array $options = array()); + public function toUrl($rel = 'canonical', array $options = []); /** * Gets the public URL for this entity. @@ -169,7 +169,7 @@ public function toUrl($rel = 'canonical', array $options = array()); * * @see \Drupal\Core\Entity\EntityInterface::toUrl */ - public function url($rel = 'canonical', $options = array()); + public function url($rel = 'canonical', $options = []); /** * Deprecated way of generating a link to the entity. See toLink(). @@ -264,7 +264,7 @@ public static function loadMultiple(array $ids = NULL); * @return static * The entity object. */ - public static function create(array $values = array()); + public static function create(array $values = []); /** * Saves an entity permanently. diff --git a/core/lib/Drupal/Core/Entity/EntityListBuilder.php b/core/lib/Drupal/Core/Entity/EntityListBuilder.php index b9c8db3..7f46915 100644 --- a/core/lib/Drupal/Core/Entity/EntityListBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityListBuilder.php @@ -120,7 +120,7 @@ protected function getLabel(EntityInterface $entity) { */ public function getOperations(EntityInterface $entity) { $operations = $this->getDefaultOperations($entity); - $operations += $this->moduleHandler()->invokeAll('entity_operation', array($entity)); + $operations += $this->moduleHandler()->invokeAll('entity_operation', [$entity]); $this->moduleHandler->alter('entity_operation', $operations, $entity); uasort($operations, '\Drupal\Component\Utility\SortArray::sortByWeightElement'); @@ -138,20 +138,20 @@ public function getOperations(EntityInterface $entity) { * self::getOperations(). */ protected function getDefaultOperations(EntityInterface $entity) { - $operations = array(); + $operations = []; if ($entity->access('update') && $entity->hasLinkTemplate('edit-form')) { - $operations['edit'] = array( + $operations['edit'] = [ 'title' => $this->t('Edit'), 'weight' => 10, 'url' => $entity->urlInfo('edit-form'), - ); + ]; } if ($entity->access('delete') && $entity->hasLinkTemplate('delete-form')) { - $operations['delete'] = array( + $operations['delete'] = [ 'title' => $this->t('Delete'), 'weight' => 100, 'url' => $entity->urlInfo('delete-form'), - ); + ]; } return $operations; @@ -198,10 +198,10 @@ public function buildRow(EntityInterface $entity) { * @see \Drupal\Core\Entity\EntityListBuilder::buildRow() */ public function buildOperations(EntityInterface $entity) { - $build = array( + $build = [ '#type' => 'operations', '#links' => $this->getOperations($entity), - ); + ]; return $build; } @@ -214,17 +214,17 @@ public function buildOperations(EntityInterface $entity) { * @todo Add a link to add a new item to the #empty text. */ public function render() { - $build['table'] = array( + $build['table'] = [ '#type' => 'table', '#header' => $this->buildHeader(), '#title' => $this->getTitle(), - '#rows' => array(), - '#empty' => $this->t('There is no @label yet.', array('@label' => $this->entityType->getLabel())), + '#rows' => [], + '#empty' => $this->t('There is no @label yet.', ['@label' => $this->entityType->getLabel()]), '#cache' => [ 'contexts' => $this->entityType->getListCacheContexts(), 'tags' => $this->entityType->getListCacheTags(), ], - ); + ]; foreach ($this->load() as $entity) { if ($row = $this->buildRow($entity)) { $build['table']['#rows'][$entity->id()] = $row; @@ -233,9 +233,9 @@ public function render() { // Only add the pager if a limit is specified. if ($this->limit) { - $build['pager'] = array( + $build['pager'] = [ '#type' => 'pager', - ); + ]; } return $build; } diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index bf4acf3..fa2ddf8 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -265,7 +265,7 @@ public function getEntityTypeLabels($group = FALSE) { * * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. */ - public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = array()) { + public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = []) { return $this->container->get('entity.repository')->getTranslationFromContext($entity, $langcode, $context); } diff --git a/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php b/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php index 1b35d4a..53b43fd 100644 --- a/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php +++ b/core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php @@ -37,10 +37,10 @@ public function getInstance(array $options) { } // Initialize default options. - $options += array( + $options += [ 'handler' => $this->getPluginId($options['target_type'], 'default'), - 'handler_settings' => array(), - ); + 'handler_settings' => [], + ]; // A specific selection plugin ID was already specified. if (strpos($options['handler'], ':') !== FALSE) { @@ -62,7 +62,7 @@ public function getPluginId($target_type, $base_plugin_id) { $selection_handler_groups = $this->getSelectionGroups($target_type); // Sort the selection plugins by weight and select the best match. - uasort($selection_handler_groups[$base_plugin_id], array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); + uasort($selection_handler_groups[$base_plugin_id], ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']); end($selection_handler_groups[$base_plugin_id]); $plugin_id = key($selection_handler_groups[$base_plugin_id]); @@ -73,7 +73,7 @@ public function getPluginId($target_type, $base_plugin_id) { * {@inheritdoc} */ public function getSelectionGroups($entity_type_id) { - $plugins = array(); + $plugins = []; $definitions = $this->getDefinitions(); // Do not display the 'broken' plugin in the UI. @@ -92,19 +92,19 @@ public function getSelectionGroups($entity_type_id) { * {@inheritdoc} */ public function getSelectionHandler(FieldDefinitionInterface $field_definition, EntityInterface $entity = NULL) { - $options = array( + $options = [ 'target_type' => $field_definition->getFieldStorageDefinition()->getSetting('target_type'), 'handler' => $field_definition->getSetting('handler'), - 'handler_settings' => $field_definition->getSetting('handler_settings') ?: array(), + 'handler_settings' => $field_definition->getSetting('handler_settings') ?: [], 'entity' => $entity, - ); + ]; return $this->getInstance($options); } /** * {@inheritdoc} */ - public function getFallbackPluginId($plugin_id, array $configuration = array()) { + public function getFallbackPluginId($plugin_id, array $configuration = []) { return 'broken'; } diff --git a/core/lib/Drupal/Core/Entity/EntityRepository.php b/core/lib/Drupal/Core/Entity/EntityRepository.php index 5fb7501..986cc50 100644 --- a/core/lib/Drupal/Core/Entity/EntityRepository.php +++ b/core/lib/Drupal/Core/Entity/EntityRepository.php @@ -79,7 +79,7 @@ public function loadEntityByConfigTarget($entity_type_id, $target) { /** * {@inheritdoc} */ - public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = array()) { + public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = []) { $translation = $entity; if ($entity instanceof TranslatableInterface && count($entity->getTranslationLanguages()) > 1) { @@ -92,7 +92,7 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N // negotiation, unless the current translation is already the desired one. if ($entity->language()->getId() != $langcode) { $context['data'] = $entity; - $context += array('operation' => 'entity_view', 'langcode' => $langcode); + $context += ['operation' => 'entity_view', 'langcode' => $langcode]; $candidates = $this->languageManager->getFallbackCandidates($context); // Ensure the default language has the proper language code. diff --git a/core/lib/Drupal/Core/Entity/EntityRepositoryInterface.php b/core/lib/Drupal/Core/Entity/EntityRepositoryInterface.php index efbfb6b..d1229d4 100644 --- a/core/lib/Drupal/Core/Entity/EntityRepositoryInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityRepositoryInterface.php @@ -67,6 +67,6 @@ public function loadEntityByConfigTarget($entity_type_id, $target); * * @see \Drupal\Core\Language\LanguageManagerInterface::getFallbackCandidates() */ - public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = array()); + public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = []); } diff --git a/core/lib/Drupal/Core/Entity/EntityResolverManager.php b/core/lib/Drupal/Core/Entity/EntityResolverManager.php index 79e62d1..b9e2227 100644 --- a/core/lib/Drupal/Core/Entity/EntityResolverManager.php +++ b/core/lib/Drupal/Core/Entity/EntityResolverManager.php @@ -70,13 +70,13 @@ protected function getControllerClass(array $defaults) { // Check if the class exists and if so use the buildForm() method from the // interface. if (class_exists($controller)) { - return array($controller, 'buildForm'); + return [$controller, 'buildForm']; } } if (strpos($controller, ':') === FALSE) { if (method_exists($controller, '__invoke')) { - return array($controller, '__invoke'); + return [$controller, '__invoke']; } if (function_exists($controller)) { return $controller; @@ -91,7 +91,7 @@ protected function getControllerClass(array $defaults) { // that could not exist at this point. There is however no other way to // do it, as the container does not allow static introspection. list($class_or_service, $method) = explode(':', $controller, 2); - return array($this->classResolver->getInstanceFromDefinition($class_or_service), $method); + return [$this->classResolver->getInstanceFromDefinition($class_or_service), $method]; } elseif (strpos($controller, '::') !== FALSE) { // Controller in the class::method notation. @@ -114,7 +114,7 @@ protected function getControllerClass(array $defaults) { */ protected function setParametersFromReflection($controller, Route $route) { $entity_types = $this->getEntityTypes(); - $parameter_definitions = $route->getOption('parameters') ?: array(); + $parameter_definitions = $route->getOption('parameters') ?: []; $result = FALSE; @@ -136,10 +136,10 @@ protected function setParametersFromReflection($controller, Route $route) { $entity_type = $entity_types[$parameter_name]; $entity_class = $entity_type->getClass(); if (($reflection_class = $parameter->getClass()) && (is_subclass_of($entity_class, $reflection_class->name) || $entity_class == $reflection_class->name)) { - $parameter_definitions += array($parameter_name => array()); - $parameter_definitions[$parameter_name] += array( + $parameter_definitions += [$parameter_name => []]; + $parameter_definitions[$parameter_name] += [ 'type' => 'entity:' . $parameter_name, - ); + ]; $result = TRUE; } } @@ -167,7 +167,7 @@ protected function setParametersFromEntityInformation(Route $route) { } if (isset($entity_type) && isset($this->getEntityTypes()[$entity_type])) { - $parameter_definitions = $route->getOption('parameters') ?: array(); + $parameter_definitions = $route->getOption('parameters') ?: []; // First try to figure out whether there is already a parameter upcasting // the same entity type already. @@ -182,11 +182,11 @@ protected function setParametersFromEntityInformation(Route $route) { } if (!isset($parameter_definitions[$entity_type])) { - $parameter_definitions[$entity_type] = array(); + $parameter_definitions[$entity_type] = []; } - $parameter_definitions[$entity_type] += array( + $parameter_definitions[$entity_type] += [ 'type' => 'entity:' . $entity_type, - ); + ]; if (!empty($parameter_definitions)) { $route->setOption('parameters', $parameter_definitions); } diff --git a/core/lib/Drupal/Core/Entity/EntityStorageBase.php b/core/lib/Drupal/Core/Entity/EntityStorageBase.php index f583121..99698df 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageBase.php @@ -14,7 +14,7 @@ * * @var array */ - protected $entities = array(); + protected $entities = []; /** * Entity type ID for this storage. @@ -105,7 +105,7 @@ public function getEntityType() { * {@inheritdoc} */ public function loadUnchanged($id) { - $this->resetCache(array($id)); + $this->resetCache([$id]); return $this->load($id); } @@ -119,7 +119,7 @@ public function resetCache(array $ids = NULL) { } } else { - $this->entities = array(); + $this->entities = []; } } @@ -133,7 +133,7 @@ public function resetCache(array $ids = NULL) { * Array of entities from the entity cache. */ protected function getFromStaticCache(array $ids) { - $entities = array(); + $entities = []; // Load any available entities from the internal cache. if ($this->entityType->isStaticallyCacheable() && !empty($this->entities)) { $entities += array_intersect_key($this->entities, array_flip($ids)); @@ -164,15 +164,15 @@ protected function setStaticCache(array $entities) { */ protected function invokeHook($hook, EntityInterface $entity) { // Invoke the hook. - $this->moduleHandler()->invokeAll($this->entityTypeId . '_' . $hook, array($entity)); + $this->moduleHandler()->invokeAll($this->entityTypeId . '_' . $hook, [$entity]); // Invoke the respective entity-level hook. - $this->moduleHandler()->invokeAll('entity_' . $hook, array($entity)); + $this->moduleHandler()->invokeAll('entity_' . $hook, [$entity]); } /** * {@inheritdoc} */ - public function create(array $values = array()) { + public function create(array $values = []) { $entity_class = $this->entityClass; $entity_class::preCreate($this, $values); @@ -209,7 +209,7 @@ protected function doCreate(array $values) { * {@inheritdoc} */ public function load($id) { - $entities = $this->loadMultiple(array($id)); + $entities = $this->loadMultiple([$id]); return isset($entities[$id]) ? $entities[$id] : NULL; } @@ -217,7 +217,7 @@ public function load($id) { * {@inheritdoc} */ public function loadMultiple(array $ids = NULL) { - $entities = array(); + $entities = []; // Create a new variable which is either a prepared version of the $ids // array for later comparison with the entity cache, or FALSE if no $ids @@ -317,7 +317,7 @@ protected function postLoad(array &$entities) { * An array of entity objects implementing the EntityInterface. */ protected function mapFromStorageRecords(array $records) { - $entities = array(); + $entities = []; foreach ($records as $record) { $entity = new $this->entityClass($record, $this->entityTypeId); $entities[$entity->id()] = $entity; @@ -460,7 +460,7 @@ protected function doPreSave(EntityInterface $entity) { * Specifies whether the entity is being updated or created. */ protected function doPostSave(EntityInterface $entity, $update) { - $this->resetCache(array($entity->id())); + $this->resetCache([$entity->id()]); // The entity is no longer new. $entity->enforceIsNew(FALSE); @@ -496,12 +496,12 @@ protected function buildPropertyQuery(QueryInterface $entity_query, array $value /** * {@inheritdoc} */ - public function loadByProperties(array $values = array()) { + public function loadByProperties(array $values = []) { // Build a query to fetch the entity IDs. $entity_query = $this->getQuery(); $this->buildPropertyQuery($entity_query, $values); $result = $entity_query->execute(); - return $result ? $this->loadMultiple($result) : array(); + return $result ? $this->loadMultiple($result) : []; } /** diff --git a/core/lib/Drupal/Core/Entity/EntityStorageInterface.php b/core/lib/Drupal/Core/Entity/EntityStorageInterface.php index e403123..50166d6 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageInterface.php @@ -102,7 +102,7 @@ public function deleteRevision($revision_id); * @return \Drupal\Core\Entity\EntityInterface[] * An array of entity objects indexed by their ids. */ - public function loadByProperties(array $values = array()); + public function loadByProperties(array $values = []); /** * Constructs a new entity object, without permanently saving it. @@ -114,7 +114,7 @@ public function loadByProperties(array $values = array()); * @return \Drupal\Core\Entity\EntityInterface * A new entity object. */ - public function create(array $values = array()); + public function create(array $values = []); /** * Deletes permanently saved entities. diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index a63415b..0c554e8 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -42,7 +42,7 @@ class EntityType implements EntityTypeInterface { * * @var array */ - protected $entity_keys = array(); + protected $entity_keys = []; /** * The unique identifier of this entity type. @@ -79,7 +79,7 @@ class EntityType implements EntityTypeInterface { * * @var array */ - protected $handlers = array(); + protected $handlers = []; /** * The name of the default administrative permission. @@ -101,7 +101,7 @@ class EntityType implements EntityTypeInterface { * * @var array */ - protected $links = array(); + protected $links = []; /** * The name of a callback that returns the label of the entity. @@ -257,7 +257,7 @@ class EntityType implements EntityTypeInterface { * * @var array[] */ - protected $constraints = array(); + protected $constraints = []; /** * Any additional properties and values. @@ -286,15 +286,15 @@ public function __construct($definition) { } // Ensure defaults. - $this->entity_keys += array( + $this->entity_keys += [ 'revision' => '', 'bundle' => '', 'langcode' => '', 'default_langcode' => 'default_langcode', - ); - $this->handlers += array( + ]; + $this->handlers += [ 'access' => 'Drupal\Core\Entity\EntityAccessControlHandler', - ); + ]; if (isset($this->handlers['storage'])) { $this->checkStorageClass($this->handlers['storage']); } @@ -798,7 +798,7 @@ public function getGroup() { * {@inheritdoc} */ public function getGroupLabel() { - return !empty($this->group_label) ? $this->group_label : $this->t('Other', array(), array('context' => 'Entity type group')); + return !empty($this->group_label) ? $this->group_label : $this->t('Other', [], ['context' => 'Entity type group']); } /** diff --git a/core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php b/core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php index 4f4213f..98223ce 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeEventSubscriberTrait.php @@ -22,7 +22,7 @@ * @see \Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents() */ public static function getEntityTypeEvents() { - $event = array('onEntityTypeEvent', 100); + $event = ['onEntityTypeEvent', 100]; $events[EntityTypeEvents::CREATE][] = $event; $events[EntityTypeEvents::UPDATE][] = $event; $events[EntityTypeEvents::DELETE][] = $event; diff --git a/core/lib/Drupal/Core/Entity/EntityTypeRepository.php b/core/lib/Drupal/Core/Entity/EntityTypeRepository.php index 6d3d376..d89b75e 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeRepository.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeRepository.php @@ -62,8 +62,8 @@ public function getEntityTypeLabels($group = FALSE) { } // Make sure that the 'Content' group is situated at the top. - $content = $this->t('Content', array(), array('context' => 'Entity type group')); - $options = array((string) $content => $options[(string) $content]) + $options; + $content = $this->t('Content', [], ['context' => 'Entity type group']); + $options = [(string) $content => $options[(string) $content]] + $options; } return $options; diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php index 8bfb3a3..b5814b5 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -95,14 +95,14 @@ public static function createInstance(ContainerInterface $container, EntityTypeI * {@inheritdoc} */ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { - $build_list = $this->viewMultiple(array($entity), $view_mode, $langcode); + $build_list = $this->viewMultiple([$entity], $view_mode, $langcode); // The default ::buildMultiple() #pre_render callback won't run, because we // extract a child element of the default renderable array. Thus we must // assign an alternative #pre_render callback that applies the necessary // transformations and then still calls ::buildMultiple(). $build = $build_list[0]; - $build['#pre_render'][] = array($this, 'build'); + $build['#pre_render'][] = [$this, 'build']; return $build; } @@ -110,11 +110,11 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N /** * {@inheritdoc} */ - public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) { - $build_list = array( + public function viewMultiple(array $entities = [], $view_mode = 'full', $langcode = NULL) { + $build_list = [ '#sorted' => TRUE, - '#pre_render' => array(array($this, 'buildMultiple')), - ); + '#pre_render' => [[$this, 'buildMultiple']], + ]; $weight = 0; foreach ($entities as $key => $entity) { // Ensure that from now on we are dealing with the proper translation @@ -124,7 +124,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la // Set build defaults. $build_list[$key] = $this->getBuildDefaults($entity, $view_mode); $entityType = $this->entityTypeId; - $this->moduleHandler()->alter(array($entityType . '_build_defaults', 'entity_build_defaults'), $build_list[$key], $entity, $view_mode); + $this->moduleHandler()->alter([$entityType . '_build_defaults', 'entity_build_defaults'], $build_list[$key], $entity, $view_mode); $build_list[$key]['#weight'] = $weight++; } @@ -147,30 +147,30 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode) { $context = []; $this->moduleHandler()->alter('entity_view_mode', $view_mode, $entity, $context); - $build = array( + $build = [ '#theme' => $this->entityTypeId, "#{$this->entityTypeId}" => $entity, '#view_mode' => $view_mode, // Collect cache defaults for this entity. - '#cache' => array( + '#cache' => [ 'tags' => Cache::mergeTags($this->getCacheTags(), $entity->getCacheTags()), 'contexts' => $entity->getCacheContexts(), 'max-age' => $entity->getCacheMaxAge(), - ), - ); + ], + ]; // Cache the rendered output if permitted by the view mode and global entity // type configuration. if ($this->isViewModeCacheable($view_mode) && !$entity->isNew() && $entity->isDefaultRevision() && $this->entityType->isRenderCacheable()) { - $build['#cache'] += array( - 'keys' => array( + $build['#cache'] += [ + 'keys' => [ 'entity_view', $this->entityTypeId, $entity->id(), $view_mode, - ), + ], 'bin' => $this->cacheBin, - ); + ]; if ($entity instanceof TranslatableInterface && count($entity->getTranslationLanguages()) > 1) { $build['#cache']['keys'][] = $entity->language()->getId(); @@ -224,7 +224,7 @@ public function build(array $build) { */ public function buildMultiple(array $build_list) { // Build the view modes and display objects. - $view_modes = array(); + $view_modes = []; $entity_type_key = "#{$this->entityTypeId}"; $view_hook = "{$this->entityTypeId}_view"; @@ -265,7 +265,7 @@ public function buildMultiple(array $build_list) { } // Allow modules to modify the render array. - $this->moduleHandler()->alter(array($view_hook, 'entity_view'), $build_list[$key], $entity, $display); + $this->moduleHandler()->alter([$view_hook, 'entity_view'], $build_list[$key], $entity, $display); } } @@ -276,7 +276,7 @@ public function buildMultiple(array $build_list) { * {@inheritdoc} */ public function buildComponents(array &$build, array $entities, array $displays, $view_mode) { - $entities_by_bundle = array(); + $entities_by_bundle = []; foreach ($entities as $id => $entity) { // Initialize the field item attributes for the fields being displayed. // The entity can include fields that are not displayed, and the display @@ -287,7 +287,7 @@ public function buildComponents(array &$build, array $entities, array $displays, foreach ($displays[$entity->bundle()]->getComponents() as $name => $options) { if ($entity->hasField($name)) { foreach ($entity->get($name) as $item) { - $item->_attributes = array(); + $item->_attributes = []; } } } @@ -296,7 +296,7 @@ public function buildComponents(array &$build, array $entities, array $displays, } // Invoke hook_entity_prepare_view(). - $this->moduleHandler()->invokeAll('entity_prepare_view', array($this->entityTypeId, $entities, $displays, $view_mode)); + $this->moduleHandler()->invokeAll('entity_prepare_view', [$this->entityTypeId, $entities, $displays, $view_mode]); // Let the displays build their render arrays. foreach ($entities_by_bundle as $bundle => $bundle_entities) { @@ -326,7 +326,7 @@ protected function alterBuild(array &$build, EntityInterface $entity, EntityView * {@inheritdoc} */ public function getCacheTags() { - return array($this->entityTypeId . '_view'); + return [$this->entityTypeId . '_view']; } /** @@ -377,12 +377,12 @@ protected function isViewModeCacheable($view_mode) { /** * {@inheritdoc} */ - public function viewField(FieldItemListInterface $items, $display_options = array()) { + public function viewField(FieldItemListInterface $items, $display_options = []) { $entity = $items->getEntity(); $field_name = $items->getFieldDefinition()->getName(); $display = $this->getSingleFieldDisplay($entity, $field_name, $display_options); - $output = array(); + $output = []; $build = $display->build($entity); if (isset($build[$field_name])) { $output = $build[$field_name]; @@ -394,7 +394,7 @@ public function viewField(FieldItemListInterface $items, $display_options = arra /** * {@inheritdoc} */ - public function viewFieldItem(FieldItemInterface $item, $display = array()) { + public function viewFieldItem(FieldItemInterface $item, $display = []) { $entity = $item->getEntity(); $field_name = $item->getFieldDefinition()->getName(); @@ -403,11 +403,11 @@ public function viewFieldItem(FieldItemInterface $item, $display = array()) { // Push the item as the single value for the field, and defer to viewField() // to build the render array for the whole list. - $clone->{$field_name}->setValue(array($item->getValue())); + $clone->{$field_name}->setValue([$item->getValue()]); $elements = $this->viewField($clone->{$field_name}, $display); // Extract the part of the render array we need. - $output = isset($elements[0]) ? $elements[0] : array(); + $output = isset($elements[0]) ? $elements[0] : []; if (isset($elements['#access'])) { $output['#access'] = $elements['#access']; } @@ -448,11 +448,11 @@ protected function getSingleFieldDisplay($entity, $field_name, $display_options) $bundle = $entity->bundle(); $key = $entity_type_id . ':' . $bundle . ':' . $field_name . ':' . hash('crc32b', serialize($display_options)); if (!isset($this->singleFieldDisplays[$key])) { - $this->singleFieldDisplays[$key] = EntityViewDisplay::create(array( + $this->singleFieldDisplays[$key] = EntityViewDisplay::create([ 'targetEntityType' => $entity_type_id, 'bundle' => $bundle, 'status' => TRUE, - ))->setComponent($field_name, $display_options); + ])->setComponent($field_name, $display_options); } $display = $this->singleFieldDisplays[$key]; } diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php b/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php index b86b592..3da4487 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php @@ -70,7 +70,7 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N * comments belongs to, or not passing one, and having the comments node not * be available for loading. */ - public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL); + public function viewMultiple(array $entities = [], $view_mode = 'full', $langcode = NULL); /** * Resets the entity render cache. @@ -122,7 +122,7 @@ public function resetCache(array $entities = NULL); * * @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewFieldItem() */ - public function viewField(FieldItemListInterface $items, $display_options = array()); + public function viewField(FieldItemListInterface $items, $display_options = []); /** * Builds a renderable array for a single field item. @@ -138,7 +138,7 @@ public function viewField(FieldItemListInterface $items, $display_options = arra * * @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewField() */ - public function viewFieldItem(FieldItemInterface $item, $display_options = array()); + public function viewFieldItem(FieldItemInterface $item, $display_options = []); /** * The cache tag associated with this entity view builder. diff --git a/core/lib/Drupal/Core/Entity/Event/BundleConfigImportValidate.php b/core/lib/Drupal/Core/Entity/Event/BundleConfigImportValidate.php index 680c0e3..03ef29c 100644 --- a/core/lib/Drupal/Core/Entity/Event/BundleConfigImportValidate.php +++ b/core/lib/Drupal/Core/Entity/Event/BundleConfigImportValidate.php @@ -64,7 +64,7 @@ public function onConfigImporterValidate(ConfigImporterEvent $event) { ->execute(); if (!empty($entity_ids)) { $entity = $this->entityManager->getStorage($entity_type_id)->load($bundle_id); - $event->getConfigImporter()->logError($this->t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', array('%entity_type' => $bundle_of_entity_type->getLabel(), '%bundle_label' => $bundle_of_entity_type->getBundleLabel(), '%bundle' => $entity->label()))); + $event->getConfigImporter()->logError($this->t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', ['%entity_type' => $bundle_of_entity_type->getLabel(), '%bundle_label' => $bundle_of_entity_type->getBundleLabel(), '%bundle' => $entity->label()])); } } } diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php index 478bca7..de77e09 100644 --- a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php @@ -86,9 +86,9 @@ public static function createInstance(ContainerInterface $container, EntityTypeI /** * {@inheritdoc} */ - public function doCreate(array $values = array()) { + public function doCreate(array $values = []) { // Set default language to site default if not provided. - $values += array($this->getEntityType()->getKey('langcode') => $this->languageManager->getDefaultLanguage()->getId()); + $values += [$this->getEntityType()->getKey('langcode') => $this->languageManager->getDefaultLanguage()->getId()]; $entity = new $this->entityClass($values, $this->entityTypeId); // @todo This is handled by ContentEntityStorageBase, which assumes diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php index 5242e8d..98be20e 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/EntityDeriver.php @@ -17,7 +17,7 @@ class EntityDeriver implements ContainerDeriverInterface { * * @var array */ - protected $derivatives = array(); + protected $derivatives = []; /** * The base plugin ID this derivative is for. @@ -86,18 +86,18 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives[''] = $base_plugin_definition; // Add definitions for each entity type and bundle. foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { - $this->derivatives[$entity_type_id] = array( + $this->derivatives[$entity_type_id] = [ 'label' => $entity_type->getLabel(), 'constraints' => $entity_type->getConstraints(), - ) + $base_plugin_definition; + ] + $base_plugin_definition; // Incorporate the bundles as entity:$entity_type:$bundle, if any. foreach ($this->bundleInfoService->getBundleInfo($entity_type_id) as $bundle => $bundle_info) { if ($bundle !== $entity_type_id) { - $this->derivatives[$entity_type_id . ':' . $bundle] = array( + $this->derivatives[$entity_type_id . ':' . $bundle] = [ 'label' => $bundle_info['label'], 'constraints' => $this->derivatives[$entity_type_id]['constraints'] - ) + $base_plugin_definition; + ] + $base_plugin_definition; } } } diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php index 2a9f172..eafb6d8 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php @@ -113,7 +113,7 @@ public function getProperties($include_computed = FALSE) { if (!$this->entity instanceof FieldableEntityInterface) { // @todo: Add support for config entities in // https://www.drupal.org/node/1818574. - return array(); + return []; } return $this->entity->getFields($include_computed); } diff --git a/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php b/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php index 7877289..d8d21fd 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Derivative/DefaultSelectionDeriver.php @@ -50,8 +50,8 @@ public static function create(ContainerInterface $container, $base_plugin_id) { public function getDerivativeDefinitions($base_plugin_definition) { foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { $this->derivatives[$entity_type_id] = $base_plugin_definition; - $this->derivatives[$entity_type_id]['entity_types'] = array($entity_type_id); - $this->derivatives[$entity_type_id]['label'] = t('@entity_type selection', array('@entity_type' => $entity_type->getLabel())); + $this->derivatives[$entity_type_id]['entity_types'] = [$entity_type_id]; + $this->derivatives[$entity_type_id]['label'] = t('@entity_type selection', ['@entity_type' => $entity_type->getLabel()]); $this->derivatives[$entity_type_id]['base_plugin_label'] = (string) $base_plugin_definition['label']; // If the entity type doesn't provide a 'label' key in its plugin diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php index d74fb6e..f53eeb6 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php +++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/Broken.php @@ -20,9 +20,9 @@ class Broken implements SelectionInterface { * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form['selection_handler'] = array( + $form['selection_handler'] = [ '#markup' => t('The selected selection handler is broken.'), - ); + ]; return $form; } @@ -40,7 +40,7 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s * {@inheritdoc} */ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) { - return array(); + return []; } /** @@ -54,7 +54,7 @@ public function countReferenceableEntities($match = NULL, $match_operator = 'CON * {@inheritdoc} */ public function validateReferenceableEntities(array $ids) { - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php index 9565e77..9a8f6cd 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php +++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php @@ -108,26 +108,26 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $bundles = $this->entityManager->getBundleInfo($entity_type_id); // Merge-in default values. - $selection_handler_settings += array( + $selection_handler_settings += [ // For the 'target_bundles' setting, a NULL value is equivalent to "allow // entities from any bundle to be referenced" and an empty array value is // equivalent to "no entities from any bundle can be referenced". 'target_bundles' => NULL, - 'sort' => array( + 'sort' => [ 'field' => '_none', - ), + ], 'auto_create' => FALSE, 'auto_create_bundle' => NULL, - ); + ]; if ($entity_type->hasKey('bundle')) { - $bundle_options = array(); + $bundle_options = []; foreach ($bundles as $bundle_name => $bundle_info) { $bundle_options[$bundle_name] = $bundle_info['label']; } natsort($bundle_options); - $form['target_bundles'] = array( + $form['target_bundles'] = [ '#type' => 'checkboxes', '#title' => $this->t('Bundles'), '#options' => $bundle_options, @@ -138,7 +138,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#element_validate' => [[get_class($this), 'elementValidateFilter']], '#ajax' => TRUE, '#limit_validation_errors' => [], - ); + ]; $form['target_bundles_update'] = [ '#type' => 'submit', @@ -151,14 +151,14 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta ]; } else { - $form['target_bundles'] = array( + $form['target_bundles'] = [ '#type' => 'value', - '#value' => array(), - ); + '#value' => [], + ]; } if ($entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { - $fields = array(); + $fields = []; foreach (array_keys($bundles) as $bundle) { $bundle_fields = array_filter($this->entityManager->getFieldDefinitions($entity_type_id, $bundle), function ($field_definition) { return !$field_definition->isComputed(); @@ -171,57 +171,57 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta // @todo: Use property labels instead of the column name. if (count($columns) > 1) { foreach ($columns as $column_name => $column_info) { - $fields[$field_name . '.' . $column_name] = $this->t('@label (@column)', array('@label' => $field_definition->getLabel(), '@column' => $column_name)); + $fields[$field_name . '.' . $column_name] = $this->t('@label (@column)', ['@label' => $field_definition->getLabel(), '@column' => $column_name]); } } else { - $fields[$field_name] = $this->t('@label', array('@label' => $field_definition->getLabel())); + $fields[$field_name] = $this->t('@label', ['@label' => $field_definition->getLabel()]); } } } - $form['sort']['field'] = array( + $form['sort']['field'] = [ '#type' => 'select', '#title' => $this->t('Sort by'), - '#options' => array( + '#options' => [ '_none' => $this->t('- None -'), - ) + $fields, + ] + $fields, '#ajax' => TRUE, - '#limit_validation_errors' => array(), + '#limit_validation_errors' => [], '#default_value' => $selection_handler_settings['sort']['field'], - ); + ]; - $form['sort']['settings'] = array( + $form['sort']['settings'] = [ '#type' => 'container', - '#attributes' => array('class' => array('entity_reference-settings')), + '#attributes' => ['class' => ['entity_reference-settings']], '#process' => [[EntityReferenceItem::class, 'formProcessMergeParent']], - ); + ]; if ($selection_handler_settings['sort']['field'] != '_none') { // Merge-in default values. - $selection_handler_settings['sort'] += array( + $selection_handler_settings['sort'] += [ 'direction' => 'ASC', - ); + ]; - $form['sort']['settings']['direction'] = array( + $form['sort']['settings']['direction'] = [ '#type' => 'select', '#title' => $this->t('Sort direction'), '#required' => TRUE, - '#options' => array( + '#options' => [ 'ASC' => $this->t('Ascending'), 'DESC' => $this->t('Descending'), - ), + ], '#default_value' => $selection_handler_settings['sort']['direction'], - ); + ]; } } - $form['auto_create'] = array( + $form['auto_create'] = [ '#type' => 'checkbox', '#title' => $this->t("Create referenced entities if they don't already exist"), '#default_value' => $selection_handler_settings['auto_create'], '#weight' => -2, - ); + ]; if ($entity_type->hasKey('bundle')) { $bundles = array_intersect_key($bundle_options, array_filter((array) $selection_handler_settings['target_bundles'])); @@ -287,10 +287,10 @@ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTA $result = $query->execute(); if (empty($result)) { - return array(); + return []; } - $options = array(); + $options = []; $entities = $this->entityManager->getStorage($target_type)->loadMultiple($result); foreach ($entities as $entity_id => $entity) { $bundle = $entity->bundle(); @@ -314,7 +314,7 @@ public function countReferenceableEntities($match = NULL, $match_operator = 'CON * {@inheritdoc} */ public function validateReferenceableEntities(array $ids) { - $result = array(); + $result = []; if ($ids) { $target_type = $this->configuration['target_type']; $entity_type = $this->entityManager->getDefinition($target_type); @@ -335,10 +335,10 @@ public function createNewEntity($entity_type_id, $bundle, $label, $uid) { $bundle_key = $entity_type->getKey('bundle'); $label_key = $entity_type->getKey('label'); - $entity = $this->entityManager->getStorage($entity_type_id)->create(array( + $entity = $this->entityManager->getStorage($entity_type_id)->create([ $bundle_key => $bundle, $label_key => $label, - )); + ]); if ($entity instanceof EntityOwnerInterface) { $entity->setOwnerId($uid); @@ -432,9 +432,9 @@ protected function reAlterQuery(AlterableInterface $query, $tag, $base_table) { $old_tags = $query->alterTags; $old_metadata = $query->alterMetaData; - $query->alterTags = array($tag => TRUE); + $query->alterTags = [$tag => TRUE]; $query->alterMetaData['base_table'] = $base_table; - $this->moduleHandler->alter(array('query', 'query_' . $tag), $query); + $this->moduleHandler->alter(['query', 'query_' . $tag], $query); // Restore the tags and metadata. $query->alterTags = $old_tags; diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php index 513213f..161e9f2 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraint.php @@ -37,7 +37,7 @@ class BundleConstraint extends Constraint { public function getBundleOption() { // Support passing the bundle as string, but force it to be an array. if (!is_array($this->bundle)) { - $this->bundle = array($this->bundle); + $this->bundle = [$this->bundle]; } return $this->bundle; } @@ -53,7 +53,7 @@ public function getDefaultOption() { * {@inheritdoc} */ public function getRequiredOptions() { - return array('bundle'); + return ['bundle']; } } diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php index 0a09889..39e99af 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php @@ -19,7 +19,7 @@ public function validate($entity, Constraint $constraint) { } if (!in_array($entity->bundle(), $constraint->getBundleOption())) { - $this->context->addViolation($constraint->message, array('%bundle' => implode(', ', $constraint->getBundleOption()))); + $this->context->addViolation($constraint->message, ['%bundle' => implode(', ', $constraint->getBundleOption())]); } } diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php index c9f2d81..c39152f 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraint.php @@ -40,7 +40,7 @@ public function getDefaultOption() { * {@inheritdoc} */ public function getRequiredOptions() { - return array('type'); + return ['type']; } } diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php index 5d2b862..89c5e8e 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php @@ -20,7 +20,7 @@ public function validate($entity, Constraint $constraint) { /** @var $entity \Drupal\Core\Entity\EntityInterface */ if ($entity->getEntityTypeId() != $constraint->type) { - $this->context->addViolation($constraint->message, array('%type' => $constraint->type)); + $this->context->addViolation($constraint->message, ['%type' => $constraint->type]); } } diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php index ab8d64c..56c75d9 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/ReferenceAccessConstraintValidator.php @@ -43,7 +43,7 @@ public function validate($value, Constraint $constraint) { // referenced entity. if ($check_permission && !$referenced_entity->access('view')) { $type = $value->getFieldDefinition()->getSetting('target_type'); - $this->context->addViolation($constraint->message, array('%type' => $type, '%id' => $id)); + $this->context->addViolation($constraint->message, ['%type' => $type, '%id' => $id]); } } } diff --git a/core/lib/Drupal/Core/Entity/Query/ConditionAggregateBase.php b/core/lib/Drupal/Core/Entity/Query/ConditionAggregateBase.php index 50884db..27ec70c 100644 --- a/core/lib/Drupal/Core/Entity/Query/ConditionAggregateBase.php +++ b/core/lib/Drupal/Core/Entity/Query/ConditionAggregateBase.php @@ -11,13 +11,13 @@ * {@inheritdoc} */ public function condition($field, $function = NULL, $value = NULL, $operator = NULL, $langcode = NULL) { - $this->conditions[] = array( + $this->conditions[] = [ 'field' => $field, 'function' => $function, 'value' => $value, 'operator' => $operator, 'langcode' => $langcode, - ); + ]; return $this; } diff --git a/core/lib/Drupal/Core/Entity/Query/ConditionBase.php b/core/lib/Drupal/Core/Entity/Query/ConditionBase.php index 4393935..030f51d 100644 --- a/core/lib/Drupal/Core/Entity/Query/ConditionBase.php +++ b/core/lib/Drupal/Core/Entity/Query/ConditionBase.php @@ -11,12 +11,12 @@ * {@inheritdoc} */ public function condition($field, $value = NULL, $operator = NULL, $langcode = NULL) { - $this->conditions[] = array( + $this->conditions[] = [ 'field' => $field, 'value' => $value, 'operator' => $operator, 'langcode' => $langcode, - ); + ]; return $this; } diff --git a/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php b/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php index 980d83e..d03e2b2 100644 --- a/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php +++ b/core/lib/Drupal/Core/Entity/Query/ConditionFundamentals.php @@ -12,7 +12,7 @@ * * @var array */ - protected $conditions = array(); + protected $conditions = []; /** * The conjunction of this condition group. The value is one of the following: @@ -36,7 +36,7 @@ * * @var array */ - protected $namespaces = array(); + protected $namespaces = []; /** * Constructs a Condition object. diff --git a/core/lib/Drupal/Core/Entity/Query/QueryBase.php b/core/lib/Drupal/Core/Entity/Query/QueryBase.php index 227d90c..f805747 100644 --- a/core/lib/Drupal/Core/Entity/Query/QueryBase.php +++ b/core/lib/Drupal/Core/Entity/Query/QueryBase.php @@ -29,7 +29,7 @@ * * @var array */ - protected $sort = array(); + protected $sort = []; /** * TRUE if this is a count query, FALSE if it isn't. @@ -50,14 +50,14 @@ * * @var array */ - protected $aggregate = array(); + protected $aggregate = []; /** * The list of columns to group on. * * @var array */ - protected $groupBy = array(); + protected $groupBy = []; /** * Aggregate Conditions @@ -71,14 +71,14 @@ * * @var array */ - protected $sortAggregate = array(); + protected $sortAggregate = []; /** * The query range. * * @var array */ - protected $range = array(); + protected $range = []; /** * The query metadata for alter purposes. @@ -115,14 +115,14 @@ * * @see Query::pager() */ - protected $pager = array(); + protected $pager = []; /** * List of potential namespaces of the classes belonging to this query. * * @var array */ - protected $namespaces = array(); + protected $namespaces = []; /** * Constructs this object. @@ -181,10 +181,10 @@ public function notExists($property, $langcode = NULL) { * {@inheritdoc} */ public function range($start = NULL, $length = NULL) { - $this->range = array( + $this->range = [ 'start' => $start, 'length' => $length, - ); + ]; return $this; } @@ -223,11 +223,11 @@ public function orConditionGroup() { * {@inheritdoc} */ public function sort($field, $direction = 'ASC', $langcode = NULL) { - $this->sort[] = array( + $this->sort[] = [ 'field' => $field, 'direction' => strtoupper($direction), 'langcode' => $langcode, - ); + ]; return $this; } @@ -276,10 +276,10 @@ public function pager($limit = 10, $element = NULL) { PagerSelectExtender::$maxElement = $element + 1; } - $this->pager = array( + $this->pager = [ 'limit' => $limit, 'element' => $element, - ); + ]; return $this; } @@ -381,12 +381,12 @@ public function aggregate($field, $function, $langcode = NULL, &$alias = NULL) { $alias = $this->getAggregationAlias($field, $function); } - $this->aggregate[$alias] = array( + $this->aggregate[$alias] = [ 'field' => $field, 'function' => $function, 'alias' => $alias, 'langcode' => $langcode, - ); + ]; return $this; } @@ -407,12 +407,12 @@ public function conditionAggregate($field, $function = NULL, $value = NULL, $ope public function sortAggregate($field, $function, $direction = 'ASC', $langcode = NULL) { $alias = $this->getAggregationAlias($field, $function); - $this->sortAggregate[$alias] = array( + $this->sortAggregate[$alias] = [ 'field' => $field, 'function' => $function, 'direction' => $direction, 'langcode' => $langcode, - ); + ]; $this->aggregate($field, $function, $langcode, $alias); return $this; @@ -422,10 +422,10 @@ public function sortAggregate($field, $function, $direction = 'ASC', $langcode = * {@inheritdoc} */ public function groupBy($field, $langcode = NULL) { - $this->groupBy[] = array( + $this->groupBy[] = [ 'field' => $field, 'langcode' => $langcode, - ); + ]; return $this; } @@ -456,7 +456,7 @@ protected function getAggregationAlias($field, $function) { * parent of the class and so on and so on. */ public static function getNamespaces($object) { - $namespaces = array(); + $namespaces = []; for ($class = get_class($object); $class; $class = get_parent_class($class)) { $namespaces[] = substr($class, 0, strrpos($class, '\\')); } diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php b/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php index 7bdf793..f48ab65 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/ConditionAggregate.php @@ -39,7 +39,7 @@ public function compile($conditionContainer) { $condition_class::translateCondition($condition, $sql_query, $tables->isFieldCaseSensitive($condition['field'])); $function = $condition['function']; $placeholder = ':db_placeholder_' . $conditionContainer->nextPlaceholder(); - $conditionContainer->having("$function($field) {$condition['operator']} $placeholder", array($placeholder => $condition['value'])); + $conditionContainer->having("$function($field) {$condition['operator']} $placeholder", [$placeholder => $condition['value']]); } } } diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php index 2d5df2d..7847ac9 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php @@ -31,7 +31,7 @@ class Query extends QueryBase implements QueryInterface { * * @var array */ - protected $sqlFields = array(); + protected $sqlFields = []; /** * An array of strings added as to the group by, keyed by the string to avoid @@ -39,7 +39,7 @@ class Query extends QueryBase implements QueryInterface { * * @var array */ - protected $sqlGroupBy = array(); + protected $sqlGroupBy = []; /** * @var \Drupal\Core\Database\Connection @@ -101,23 +101,23 @@ protected function prepare() { if ($this->entityType->getDataTable()) { $simple_query = FALSE; } - $this->sqlQuery = $this->connection->select($base_table, 'base_table', array('conjunction' => $this->conjunction)); + $this->sqlQuery = $this->connection->select($base_table, 'base_table', ['conjunction' => $this->conjunction]); $this->sqlQuery->addMetaData('entity_type', $this->entityTypeId); $id_field = $this->entityType->getKey('id'); // Add the key field for fetchAllKeyed(). if (!$revision_field = $this->entityType->getKey('revision')) { // When there is no revision support, the key field is the entity key. - $this->sqlFields["base_table.$id_field"] = array('base_table', $id_field); + $this->sqlFields["base_table.$id_field"] = ['base_table', $id_field]; // Now add the value column for fetchAllKeyed(). This is always the // entity id. - $this->sqlFields["base_table.$id_field" . '_1'] = array('base_table', $id_field); + $this->sqlFields["base_table.$id_field" . '_1'] = ['base_table', $id_field]; } else { // When there is revision support, the key field is the revision key. - $this->sqlFields["base_table.$revision_field"] = array('base_table', $revision_field); + $this->sqlFields["base_table.$revision_field"] = ['base_table', $revision_field]; // Now add the value column for fetchAllKeyed(). This is always the // entity id. - $this->sqlFields["base_table.$id_field"] = array('base_table', $id_field); + $this->sqlFields["base_table.$id_field"] = ['base_table', $id_field]; } if ($this->accessCheck) { $this->sqlQuery->addTag($this->entityTypeId . '_access'); @@ -164,12 +164,12 @@ protected function compile() { */ protected function addSort() { if ($this->count) { - $this->sort = array(); + $this->sort = []; } // Gather the SQL field aliases first to make sure every field table // necessary is added. This might change whether the query is simple or // not. See below for more on simple queries. - $sort = array(); + $sort = []; if ($this->sort) { foreach ($this->sort as $key => $data) { $sort[$key] = $this->getSqlField($data['field'], $data['langcode']); @@ -291,8 +291,8 @@ protected function isSimpleQuery() { */ public function __clone() { parent::__clone(); - $this->sqlFields = array(); - $this->sqlGroupBy = array(); + $this->sqlFields = []; + $this->sqlGroupBy = []; } /** diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php b/core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php index 0fa2f66..f8e42f0 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/QueryAggregate.php @@ -15,7 +15,7 @@ class QueryAggregate extends Query implements QueryAggregateInterface { * @var array * An array of expressions. */ - protected $sqlExpressions = array(); + protected $sqlExpressions = []; /** * {@inheritdoc} @@ -39,7 +39,7 @@ public function execute() { public function prepare() { parent::prepare(); // Throw away the id fields. - $this->sqlFields = array(); + $this->sqlFields = []; return $this; } @@ -105,7 +105,7 @@ protected function addGroupBy() { $sql_field = $this->getSqlField($field, $group_by['langcode']); $this->sqlGroupBy[$sql_field] = $sql_field; list($table, $real_sql_field) = explode('.', $sql_field); - $this->sqlFields[$sql_field] = array($table, $real_sql_field, $this->createSqlAlias($field, $real_sql_field)); + $this->sqlFields[$sql_field] = [$table, $real_sql_field, $this->createSqlAlias($field, $real_sql_field)]; } return $this; @@ -170,7 +170,7 @@ protected function result() { if ($this->count) { return parent::result(); } - $return = array(); + $return = []; foreach ($this->sqlQuery->execute() as $row) { $return[] = (array)$row; } diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php index c8bf59d..d860f75 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php @@ -25,7 +25,7 @@ class Tables implements TablesInterface { * * @var array */ - protected $entityTables = array(); + protected $entityTables = []; /** * Field table array, key is table name, value is alias. @@ -34,7 +34,7 @@ class Tables implements TablesInterface { * * @var array */ - protected $fieldTables = array(); + protected $fieldTables = []; /** * The entity manager. @@ -48,7 +48,7 @@ class Tables implements TablesInterface { * * @var array */ - protected $caseSensitiveFields = array(); + protected $caseSensitiveFields = []; /** * @param \Drupal\Core\Database\Query\SelectInterface $sql_query @@ -77,7 +77,7 @@ public function addField($field, $type, $langcode) { $count = count($specifiers) - 1; // This will contain the definitions of the last specifier seen by the // system. - $propertyDefinitions = array(); + $propertyDefinitions = []; $entity_type = $this->entityManager->getDefinition($entity_type_id); $field_storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id); @@ -180,7 +180,7 @@ public function addField($field, $type, $langcode) { // queried from the data table or the base table based on where it // finds the property first. The data table is preferred, which is why // it gets added before the base table. - $entity_tables = array(); + $entity_tables = []; if ($all_revisions && $field_storage && $field_storage->isRevisionable()) { $data_table = $entity_type->getRevisionDataTable(); $entity_base_table = $entity_type->getRevisionTable(); @@ -262,7 +262,7 @@ public function addField($field, $type, $langcode) { // Add the new entity base table using the table and sql column. $join_condition = '%alias.' . $entity_type->getKey('id') . " = $table.$sql_column"; $base_table = $this->sqlQuery->leftJoin($entity_type->getBaseTable(), NULL, $join_condition); - $propertyDefinitions = array(); + $propertyDefinitions = []; $key++; $index_prefix .= "$next_index_prefix."; } @@ -328,7 +328,7 @@ protected function ensureFieldTable($index_prefix, &$field, $type, $langcode, $b } protected function addJoin($type, $table, $join_condition, $langcode, $delta = NULL) { - $arguments = array(); + $arguments = []; if ($langcode) { $entity_type_id = $this->sqlQuery->getMetaData('entity_type'); $entity_type = $this->entityManager->getDefinition($entity_type_id); diff --git a/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php b/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php index 5f20c3f..4fd6a32 100644 --- a/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php +++ b/core/lib/Drupal/Core/Entity/Sql/DefaultTableMapping.php @@ -22,7 +22,7 @@ class DefaultTableMapping implements TableMappingInterface { * * @var \Drupal\Core\Field\FieldStorageDefinitionInterface[] */ - protected $fieldStorageDefinitions = array(); + protected $fieldStorageDefinitions = []; /** * A list of field names per table. @@ -33,7 +33,7 @@ class DefaultTableMapping implements TableMappingInterface { * * @var array[] */ - protected $fieldNames = array(); + protected $fieldNames = []; /** * A list of database columns which store denormalized data per table. @@ -44,7 +44,7 @@ class DefaultTableMapping implements TableMappingInterface { * * @var array[] */ - protected $extraColumns = array(); + protected $extraColumns = []; /** * A mapping of column names per field name. @@ -58,7 +58,7 @@ class DefaultTableMapping implements TableMappingInterface { * * @var array[] */ - protected $columnMapping = array(); + protected $columnMapping = []; /** * A list of all database columns per table. @@ -73,7 +73,7 @@ class DefaultTableMapping implements TableMappingInterface { * * @var array[] */ - protected $allColumns = array(); + protected $allColumns = []; /** * Constructs a DefaultTableMapping. @@ -101,7 +101,7 @@ public function getTableNames() { */ public function getAllColumns($table_name) { if (!isset($this->allColumns[$table_name])) { - $this->allColumns[$table_name] = array(); + $this->allColumns[$table_name] = []; foreach ($this->getFieldNames($table_name) as $field_name) { $this->allColumns[$table_name] = array_merge($this->allColumns[$table_name], array_values($this->getColumnNames($field_name))); @@ -128,7 +128,7 @@ public function getFieldNames($table_name) { if (isset($this->fieldNames[$table_name])) { return $this->fieldNames[$table_name]; } - return array(); + return []; } /** @@ -148,15 +148,15 @@ public function getFieldTableName($field_name) { /** @var \Drupal\Core\Entity\Sql\SqlContentEntityStorage $storage */ $storage = \Drupal::entityManager()->getStorage($this->entityType->id()); $storage_definition = $this->fieldStorageDefinitions[$field_name]; - $table_names = array( + $table_names = [ $storage->getDataTable(), $storage->getBaseTable(), $storage->getRevisionTable(), $this->getDedicatedDataTableName($storage_definition), - ); + ]; // Collect field columns. - $field_columns = array(); + $field_columns = []; foreach (array_keys($storage_definition->getColumns()) as $property_name) { $field_columns[] = $this->getFieldColumnName($storage_definition, $property_name); } @@ -184,7 +184,7 @@ public function getFieldTableName($field_name) { */ public function getColumnNames($field_name) { if (!isset($this->columnMapping[$field_name])) { - $this->columnMapping[$field_name] = array(); + $this->columnMapping[$field_name] = []; if (isset($this->fieldStorageDefinitions[$field_name]) && !$this->fieldStorageDefinitions[$field_name]->hasCustomStorage()) { foreach (array_keys($this->fieldStorageDefinitions[$field_name]->getColumns()) as $property_name) { $this->columnMapping[$field_name][$property_name] = $this->getFieldColumnName($this->fieldStorageDefinitions[$field_name], $property_name); @@ -242,7 +242,7 @@ public function getExtraColumns($table_name) { if (isset($this->extraColumns[$table_name])) { return $this->extraColumns[$table_name]; } - return array(); + return []; } /** @@ -307,7 +307,7 @@ public function getDedicatedTableNames() { * {@inheritdoc} */ public function getReservedColumns() { - return array('deleted'); + return ['deleted']; } /** diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index e115bd2..99d7ab7 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -286,7 +286,7 @@ public function getTableMapping(array $storage_definitions = NULL) { return $table_mapping->allowsSharedTableStorage($definition); }); - $key_fields = array_values(array_filter(array($this->idKey, $this->revisionKey, $this->bundleKey, $this->uuidKey, $this->langcodeKey))); + $key_fields = array_values(array_filter([$this->idKey, $this->revisionKey, $this->bundleKey, $this->uuidKey, $this->langcodeKey])); $all_fields = array_keys($shared_table_definitions); $revisionable_fields = array_keys(array_filter($shared_table_definitions, function (FieldStorageDefinitionInterface $definition) { return $definition->isRevisionable(); @@ -298,11 +298,11 @@ public function getTableMapping(array $storage_definitions = NULL) { // log. // @todo Provide automatic definitions for revision metadata fields in // https://www.drupal.org/node/2248983. - $revision_metadata_fields = array_intersect(array( + $revision_metadata_fields = array_intersect([ 'revision_timestamp', 'revision_uid', 'revision_log', - ), $all_fields); + ], $all_fields); $revisionable = $this->entityType->isRevisionable(); $translatable = $this->entityType->isTranslatable(); @@ -316,7 +316,7 @@ public function getTableMapping(array $storage_definitions = NULL) { // denormalized in the base table but also stored in the revision table // together with the entity ID and the revision ID as identifiers. $table_mapping->setFieldNames($this->baseTable, array_diff($all_fields, $revision_metadata_fields)); - $revision_key_fields = array($this->idKey, $this->revisionKey); + $revision_key_fields = [$this->idKey, $this->revisionKey]; $table_mapping->setFieldNames($this->revisionTable, array_merge($revision_key_fields, $revisionable_fields)); } elseif (!$revisionable && $translatable) { @@ -328,7 +328,7 @@ public function getTableMapping(array $storage_definitions = NULL) { // the data table. $table_mapping ->setFieldNames($this->baseTable, $key_fields) - ->setFieldNames($this->dataTable, array_values(array_diff($all_fields, array($this->uuidKey)))); + ->setFieldNames($this->dataTable, array_values(array_diff($all_fields, [$this->uuidKey]))); } elseif ($revisionable && $translatable) { // The revisionable multilingual layout stores key field values in the @@ -343,14 +343,14 @@ public function getTableMapping(array $storage_definitions = NULL) { // Like in the multilingual, non-revisionable case the UUID is not // in the data table. Additionally, do not store revision metadata // fields in the data table. - $data_fields = array_values(array_diff($all_fields, array($this->uuidKey), $revision_metadata_fields)); + $data_fields = array_values(array_diff($all_fields, [$this->uuidKey], $revision_metadata_fields)); $table_mapping->setFieldNames($this->dataTable, $data_fields); - $revision_base_fields = array_merge(array($this->idKey, $this->revisionKey, $this->langcodeKey), $revision_metadata_fields); + $revision_base_fields = array_merge([$this->idKey, $this->revisionKey, $this->langcodeKey], $revision_metadata_fields); $table_mapping->setFieldNames($this->revisionTable, $revision_base_fields); - $revision_data_key_fields = array($this->idKey, $this->revisionKey, $this->langcodeKey); - $revision_data_fields = array_diff($revisionable_fields, $revision_metadata_fields, array($this->langcodeKey)); + $revision_data_key_fields = [$this->idKey, $this->revisionKey, $this->langcodeKey]; + $revision_data_fields = array_diff($revisionable_fields, $revision_metadata_fields, [$this->langcodeKey]); $table_mapping->setFieldNames($this->revisionDataTable, array_merge($revision_data_key_fields, $revision_data_fields)); } @@ -358,21 +358,21 @@ public function getTableMapping(array $storage_definitions = NULL) { $dedicated_table_definitions = array_filter($definitions, function (FieldStorageDefinitionInterface $definition) use ($table_mapping) { return $table_mapping->requiresDedicatedTableStorage($definition); }); - $extra_columns = array( + $extra_columns = [ 'bundle', 'deleted', 'entity_id', 'revision_id', 'langcode', 'delta', - ); + ]; foreach ($dedicated_table_definitions as $field_name => $definition) { $tables = [$table_mapping->getDedicatedDataTableName($definition)]; if ($revisionable && $definition->isRevisionable()) { $tables[] = $table_mapping->getDedicatedRevisionTableName($definition); } foreach ($tables as $table_name) { - $table_mapping->setFieldNames($table_name, array($field_name)); + $table_mapping->setFieldNames($table_name, [$field_name]); $table_mapping->setExtraColumns($table_name, $extra_columns); } } @@ -415,7 +415,7 @@ protected function doLoadMultiple(array $ids = NULL) { * Array of entities from the storage. */ protected function getFromStorage(array $ids = NULL) { - $entities = array(); + $entities = []; if (!empty($ids)) { // Sanitize IDs. Before feeding ID array into buildQuery, check whether @@ -450,12 +450,12 @@ protected function getFromStorage(array $ids = NULL) { */ protected function mapFromStorageRecords(array $records, $load_from_revision = FALSE) { if (!$records) { - return array(); + return []; } - $values = array(); + $values = []; foreach ($records as $id => $record) { - $values[$id] = array(); + $values[$id] = []; // Skip the item delta and item value levels (if possible) but let the // field assign the value as suiting. This avoids unnecessary array // hierarchies and saves memory here. @@ -475,13 +475,13 @@ protected function mapFromStorageRecords(array $records, $load_from_revision = F } // Initialize translations array. - $translations = array_fill_keys(array_keys($values), array()); + $translations = array_fill_keys(array_keys($values), []); // Load values from shared and dedicated tables. $this->loadFromSharedTables($values, $translations); $this->loadFromDedicatedTables($values, $load_from_revision); - $entities = array(); + $entities = []; foreach ($values as $id => $entity_values) { $bundle = $this->bundleKey ? $entity_values[$this->bundleKey][LanguageInterface::LANGCODE_DEFAULT] : FALSE; // Turn the record into an entity class. @@ -505,7 +505,7 @@ protected function loadFromSharedTables(array &$values, array &$translations) { // latest revision. Otherwise we fall back to the data table. $table = $this->revisionDataTable ?: $this->dataTable; $alias = $this->revisionDataTable ? 'revision' : 'data'; - $query = $this->database->select($table, $alias, array('fetch' => \PDO::FETCH_ASSOC)) + $query = $this->database->select($table, $alias, ['fetch' => \PDO::FETCH_ASSOC]) ->fields($alias) ->condition($alias . '.' . $this->idKey, array_keys($values), 'IN') ->orderBy($alias . '.' . $this->idKey); @@ -514,7 +514,7 @@ protected function loadFromSharedTables(array &$values, array &$translations) { if ($this->revisionDataTable) { // Find revisioned fields that are not entity keys. Exclude the langcode // key as the base table holds only the default language. - $base_fields = array_diff($table_mapping->getFieldNames($this->baseTable), array($this->langcodeKey)); + $base_fields = array_diff($table_mapping->getFieldNames($this->baseTable), [$this->langcodeKey]); $revisioned_fields = array_diff($table_mapping->getFieldNames($this->revisionDataTable), $base_fields); // Find fields that are not revisioned or entity keys. Data fields have @@ -541,7 +541,7 @@ protected function loadFromSharedTables(array &$values, array &$translations) { } // Get the revision IDs. - $revision_ids = array(); + $revision_ids = []; foreach ($values as $entity_values) { $revision_ids[] = $entity_values[$this->revisionKey][LanguageInterface::LANGCODE_DEFAULT]; } @@ -584,7 +584,7 @@ protected function doLoadRevisionFieldItems($revision_id) { $revision = NULL; // Build and execute the query. - $query_result = $this->buildQuery(array(), $revision_id)->execute(); + $query_result = $this->buildQuery([], $revision_id)->execute(); $records = $query_result->fetchAllAssoc($this->idKey); if (!empty($records)) { @@ -655,7 +655,7 @@ protected function buildQuery($ids, $revision_id = FALSE) { $query->addTag($this->entityTypeId . '_load_multiple'); if ($revision_id) { - $query->join($this->revisionTable, 'revision', "revision.{$this->idKey} = base.{$this->idKey} AND revision.{$this->revisionKey} = :revisionId", array(':revisionId' => $revision_id)); + $query->join($this->revisionTable, 'revision', "revision.{$this->idKey} = base.{$this->idKey} AND revision.{$this->revisionKey} = :revisionId", [':revisionId' => $revision_id]); } elseif ($this->revisionTable) { $query->join($this->revisionTable, 'revision', "revision.{$this->revisionKey} = base.{$this->revisionKey}"); @@ -838,7 +838,7 @@ protected function doSaveFieldItems(ContentEntityInterface $entity, array $names } else { $insert_id = $this->database - ->insert($this->baseTable, array('return' => Database::RETURN_INSERT_ID)) + ->insert($this->baseTable, ['return' => Database::RETURN_INSERT_ID]) ->fields((array) $record) ->execute(); // Even if this is a new entity the ID key might have been set, in which @@ -950,7 +950,7 @@ protected function mapToStorageRecord(ContentEntityInterface $entity, $table_nam // @todo Give field types more control over this behavior in // https://www.drupal.org/node/2232427. if (!$definition->getMainPropertyName() && count($columns) == 1) { - $value = ($item = $entity->$field_name->first()) ? $item->getValue() : array(); + $value = ($item = $entity->$field_name->first()) ? $item->getValue() : []; } else { $value = isset($entity->$field_name->$column_name) ? $entity->$field_name->$column_name : NULL; @@ -1037,7 +1037,7 @@ protected function saveRevision(ContentEntityInterface $entity) { if ($entity->isNewRevision()) { $insert_id = $this->database - ->insert($this->revisionTable, array('return' => Database::RETURN_INSERT_ID)) + ->insert($this->revisionTable, ['return' => Database::RETURN_INSERT_ID]) ->fields((array) $record) ->execute(); // Even if this is a new revision, the revision ID key might have been @@ -1047,7 +1047,7 @@ protected function saveRevision(ContentEntityInterface $entity) { } if ($entity->isDefaultRevision()) { $this->database->update($this->entityType->getBaseTable()) - ->fields(array($this->revisionKey => $record->{$this->revisionKey})) + ->fields([$this->revisionKey => $record->{$this->revisionKey}]) ->condition($this->idKey, $record->{$this->idKey}) ->execute(); } @@ -1088,9 +1088,9 @@ protected function loadFromDedicatedTables(array &$values, $load_from_revision) } // Collect entities ids, bundles and languages. - $bundles = array(); - $ids = array(); - $default_langcodes = array(); + $bundles = []; + $ids = []; + $default_langcodes = []; foreach ($values as $key => $entity_values) { $bundles[$this->bundleKey ? $entity_values[$this->bundleKey][LanguageInterface::LANGCODE_DEFAULT] : $this->entityTypeId] = TRUE; $ids[] = !$load_from_revision ? $key : $entity_values[$this->revisionKey][LanguageInterface::LANGCODE_DEFAULT]; @@ -1100,8 +1100,8 @@ protected function loadFromDedicatedTables(array &$values, $load_from_revision) } // Collect impacted fields. - $storage_definitions = array(); - $definitions = array(); + $storage_definitions = []; + $definitions = []; $table_mapping = $this->getTableMapping(); foreach ($bundles as $bundle => $v) { $definitions[$bundle] = $this->entityManager->getFieldDefinitions($this->entityTypeId, $bundle); @@ -1140,14 +1140,14 @@ protected function loadFromDedicatedTables(array &$values, $load_from_revision) } if (!isset($values[$row->entity_id][$field_name][$langcode])) { - $values[$row->entity_id][$field_name][$langcode] = array(); + $values[$row->entity_id][$field_name][$langcode] = []; } // Ensure that records for non-translatable fields having invalid // languages are skipped. if ($langcode == LanguageInterface::LANGCODE_DEFAULT || $definitions[$bundle][$field_name]->isTranslatable()) { if ($storage_definition->getCardinality() == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED || count($values[$row->entity_id][$field_name][$langcode]) < $storage_definition->getCardinality()) { - $item = array(); + $item = []; // For each column declared by the field, populate the item from the // prefixed database column. foreach ($storage_definition->getColumns() as $column => $attributes) { @@ -1175,7 +1175,7 @@ protected function loadFromDedicatedTables(array &$values, $load_from_revision) * (optional) The names of the fields to be stored. Defaults to all the * available fields. */ - protected function saveToDedicatedTables(ContentEntityInterface $entity, $update = TRUE, $names = array()) { + protected function saveToDedicatedTables(ContentEntityInterface $entity, $update = TRUE, $names = []) { $vid = $entity->getRevisionId(); $id = $entity->id(); $bundle = $entity->bundle(); @@ -1230,7 +1230,7 @@ protected function saveToDedicatedTables(ContentEntityInterface $entity, $update // Prepare the multi-insert query. $do_insert = FALSE; - $columns = array('entity_id', 'revision_id', 'bundle', 'delta', 'langcode'); + $columns = ['entity_id', 'revision_id', 'bundle', 'delta', 'langcode']; foreach ($storage_definition->getColumns() as $column => $attributes) { $columns[] = $table_mapping->getFieldColumnName($storage_definition, $column); } @@ -1239,7 +1239,7 @@ protected function saveToDedicatedTables(ContentEntityInterface $entity, $update $revision_query = $this->database->insert($revision_name)->fields($columns); } - $langcodes = $field_definition->isTranslatable() ? $translation_langcodes : array($default_langcode); + $langcodes = $field_definition->isTranslatable() ? $translation_langcodes : [$default_langcode]; foreach ($langcodes as $langcode) { $delta_count = 0; $items = $entity->getTranslation($langcode)->get($field_name); @@ -1247,13 +1247,13 @@ protected function saveToDedicatedTables(ContentEntityInterface $entity, $update foreach ($items as $delta => $item) { // We now know we have something to insert. $do_insert = TRUE; - $record = array( + $record = [ 'entity_id' => $id, 'revision_id' => $vid, 'bundle' => $bundle, 'delta' => $delta, 'langcode' => $langcode, - ); + ]; foreach ($storage_definition->getColumns() as $column => $attributes) { $column_name = $table_mapping->getFieldColumnName($storage_definition, $column); // Serialize the value if specified in the column schema. @@ -1436,11 +1436,11 @@ public function onFieldStorageDefinitionDelete(FieldStorageDefinitionInterface $ $table = $table_mapping->getDedicatedDataTableName($storage_definition); $revision_table = $table_mapping->getDedicatedRevisionTableName($storage_definition); $this->database->update($table) - ->fields(array('deleted' => 1)) + ->fields(['deleted' => 1]) ->execute(); if ($this->entityType->isRevisionable()) { $this->database->update($revision_table) - ->fields(array('deleted' => 1)) + ->fields(['deleted' => 1]) ->execute(); } } @@ -1486,12 +1486,12 @@ public function onFieldDefinitionDelete(FieldDefinitionInterface $field_definiti $table_name = $table_mapping->getDedicatedDataTableName($storage_definition); $revision_name = $table_mapping->getDedicatedRevisionTableName($storage_definition); $this->database->update($table_name) - ->fields(array('deleted' => 1)) + ->fields(['deleted' => 1]) ->condition('bundle', $field_definition->getTargetBundle()) ->execute(); if ($this->entityType->isRevisionable()) { $this->database->update($revision_name) - ->fields(array('deleted' => 1)) + ->fields(['deleted' => 1]) ->condition('bundle', $field_definition->getTargetBundle()) ->execute(); } @@ -1520,27 +1520,27 @@ protected function readFieldItemsToPurge(FieldDefinitionInterface $field_definit $table_name = $table_mapping->getDedicatedDataTableName($storage_definition, $is_deleted); // Get the entities which we want to purge first. - $entity_query = $this->database->select($table_name, 't', array('fetch' => \PDO::FETCH_ASSOC)); + $entity_query = $this->database->select($table_name, 't', ['fetch' => \PDO::FETCH_ASSOC]); $or = $entity_query->orConditionGroup(); foreach ($storage_definition->getColumns() as $column_name => $data) { $or->isNotNull($table_mapping->getFieldColumnName($storage_definition, $column_name)); } $entity_query ->distinct(TRUE) - ->fields('t', array('entity_id')) + ->fields('t', ['entity_id']) ->condition('bundle', $field_definition->getTargetBundle()) ->range(0, $batch_size); // Create a map of field data table column names to field column names. - $column_map = array(); + $column_map = []; foreach ($storage_definition->getColumns() as $column_name => $data) { $column_map[$table_mapping->getFieldColumnName($storage_definition, $column_name)] = $column_name; } - $entities = array(); - $items_by_entity = array(); + $entities = []; + $items_by_entity = []; foreach ($entity_query->execute() as $row) { - $item_query = $this->database->select($table_name, 't', array('fetch' => \PDO::FETCH_ASSOC)) + $item_query = $this->database->select($table_name, 't', ['fetch' => \PDO::FETCH_ASSOC]) ->fields('t') ->condition('entity_id', $row['entity_id']) ->orderBy('delta'); @@ -1553,7 +1553,7 @@ protected function readFieldItemsToPurge(FieldDefinitionInterface $field_definit // factory, see https://www.drupal.org/node/1867228. $entities[$item_row['revision_id']] = _field_create_entity_from_ids((object) $item_row); } - $item = array(); + $item = []; foreach ($column_map as $db_column => $field_column) { $item[$field_column] = $item_row[$db_column]; } @@ -1624,7 +1624,7 @@ public function countFieldData($storage_definition, $as_bool = FALSE) { $query->condition($or); if (!$as_bool) { $query - ->fields('t', array('entity_id')) + ->fields('t', ['entity_id']) ->distinct(TRUE); } } @@ -1649,7 +1649,7 @@ public function countFieldData($storage_definition, $as_bool = FALSE) { $query->condition($or); if (!$as_bool) { $query - ->fields('t', array($this->idKey)) + ->fields('t', [$this->idKey]) ->distinct(TRUE); } } diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index 0d64e31..21a242a 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -521,7 +521,7 @@ protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $res $storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id); foreach ($table_names as $table_name) { if (!isset($schema[$table_name])) { - $schema[$table_name] = array(); + $schema[$table_name] = []; } foreach ($table_mapping->getFieldNames($table_name) as $field_name) { if (!isset($storage_definitions[$field_name])) { @@ -564,12 +564,12 @@ protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $res * A list of entity type tables, keyed by table key. */ protected function getEntitySchemaTables() { - return array_filter(array( + return array_filter([ 'base_table' => $this->storage->getBaseTable(), 'revision_table' => $this->storage->getRevisionTable(), 'data_table' => $this->storage->getDataTable(), 'revision_data_table' => $this->storage->getRevisionDataTable(), - )); + ]); } /** @@ -674,7 +674,7 @@ protected function getFieldUniqueKeys($field_name, array $field_schema, array $c * The schema definition for the specified key. */ protected function getFieldSchemaData($field_name, array $field_schema, array $column_mapping, $schema_key) { - $data = array(); + $data = []; foreach ($field_schema[$schema_key] as $key => $columns) { // To avoid clashes with entity-level indexes or unique keys we use @@ -689,7 +689,7 @@ protected function getFieldSchemaData($field_name, array $field_schema, array $c // name and length. if (is_array($column)) { list($column_name, $length) = $column; - $data[$real_key][] = array($column_mapping[$column_name], $length); + $data[$real_key][] = [$column_mapping[$column_name], $length]; } else { $data[$real_key][] = $column_mapping[$column]; @@ -742,7 +742,7 @@ protected function getFieldSchemaIdentifierName($entity_type_id, $field_name, $k * The schema definition for the foreign keys. */ protected function getFieldForeignKeys($field_name, array $field_schema, array $column_mapping) { - $foreign_keys = array(); + $foreign_keys = []; foreach ($field_schema['foreign keys'] as $specifier => $specification) { // To avoid clashes with entity-level foreign keys we use @@ -771,7 +771,7 @@ protected function getFieldForeignKeys($field_name, array $field_schema, array $ * The entity schema data array. */ protected function loadEntitySchemaData(EntityTypeInterface $entity_type) { - return $this->installedStorageSchema()->get($entity_type->id() . '.entity_schema_data', array()); + return $this->installedStorageSchema()->get($entity_type->id() . '.entity_schema_data', []); } /** @@ -807,7 +807,7 @@ protected function deleteEntitySchemaData(EntityTypeInterface $entity_type) { * The field schema data array. */ protected function loadFieldSchemaData(FieldStorageDefinitionInterface $storage_definition) { - return $this->installedStorageSchema()->get($storage_definition->getTargetEntityTypeId() . '.field_schema_data.' . $storage_definition->getName(), array()); + return $this->installedStorageSchema()->get($storage_definition->getTargetEntityTypeId() . '.field_schema_data.' . $storage_definition->getName(), []); } /** @@ -844,21 +844,21 @@ protected function deleteFieldSchemaData(FieldStorageDefinitionInterface $storag protected function initializeBaseTable(ContentEntityTypeInterface $entity_type) { $entity_type_id = $entity_type->id(); - $schema = array( + $schema = [ 'description' => "The base table for $entity_type_id entities.", - 'primary key' => array($entity_type->getKey('id')), - 'indexes' => array(), - 'foreign keys' => array(), - ); + 'primary key' => [$entity_type->getKey('id')], + 'indexes' => [], + 'foreign keys' => [], + ]; if ($entity_type->hasKey('revision')) { $revision_key = $entity_type->getKey('revision'); $key_name = $this->getEntityIndexName($entity_type, $revision_key); - $schema['unique keys'][$key_name] = array($revision_key); - $schema['foreign keys'][$entity_type_id . '__revision'] = array( + $schema['unique keys'][$key_name] = [$revision_key]; + $schema['foreign keys'][$entity_type_id . '__revision'] = [ 'table' => $this->storage->getRevisionTable(), - 'columns' => array($revision_key => $revision_key), - ); + 'columns' => [$revision_key => $revision_key], + ]; } $this->addTableDefaults($schema); @@ -880,19 +880,19 @@ protected function initializeRevisionTable(ContentEntityTypeInterface $entity_ty $id_key = $entity_type->getKey('id'); $revision_key = $entity_type->getKey('revision'); - $schema = array( + $schema = [ 'description' => "The revision table for $entity_type_id entities.", - 'primary key' => array($revision_key), - 'indexes' => array(), - 'foreign keys' => array( - $entity_type_id . '__revisioned' => array( + 'primary key' => [$revision_key], + 'indexes' => [], + 'foreign keys' => [ + $entity_type_id . '__revisioned' => [ 'table' => $this->storage->getBaseTable(), - 'columns' => array($id_key => $id_key), - ), - ), - ); + 'columns' => [$id_key => $id_key], + ], + ], + ]; - $schema['indexes'][$this->getEntityIndexName($entity_type, $id_key)] = array($id_key); + $schema['indexes'][$this->getEntityIndexName($entity_type, $id_key)] = [$id_key]; $this->addTableDefaults($schema); @@ -912,23 +912,23 @@ protected function initializeDataTable(ContentEntityTypeInterface $entity_type) $entity_type_id = $entity_type->id(); $id_key = $entity_type->getKey('id'); - $schema = array( + $schema = [ 'description' => "The data table for $entity_type_id entities.", - 'primary key' => array($id_key, $entity_type->getKey('langcode')), - 'indexes' => array( - $entity_type_id . '__id__default_langcode__langcode' => array($id_key, $entity_type->getKey('default_langcode'), $entity_type->getKey('langcode')), - ), - 'foreign keys' => array( - $entity_type_id => array( + 'primary key' => [$id_key, $entity_type->getKey('langcode')], + 'indexes' => [ + $entity_type_id . '__id__default_langcode__langcode' => [$id_key, $entity_type->getKey('default_langcode'), $entity_type->getKey('langcode')], + ], + 'foreign keys' => [ + $entity_type_id => [ 'table' => $this->storage->getBaseTable(), - 'columns' => array($id_key => $id_key), - ), - ), - ); + 'columns' => [$id_key => $id_key], + ], + ], + ]; if ($entity_type->hasKey('revision')) { $key = $entity_type->getKey('revision'); - $schema['indexes'][$this->getEntityIndexName($entity_type, $key)] = array($key); + $schema['indexes'][$this->getEntityIndexName($entity_type, $key)] = [$key]; } $this->addTableDefaults($schema); @@ -950,23 +950,23 @@ protected function initializeRevisionDataTable(ContentEntityTypeInterface $entit $id_key = $entity_type->getKey('id'); $revision_key = $entity_type->getKey('revision'); - $schema = array( + $schema = [ 'description' => "The revision data table for $entity_type_id entities.", - 'primary key' => array($revision_key, $entity_type->getKey('langcode')), - 'indexes' => array( - $entity_type_id . '__id__default_langcode__langcode' => array($id_key, $entity_type->getKey('default_langcode'), $entity_type->getKey('langcode')), - ), - 'foreign keys' => array( - $entity_type_id => array( + 'primary key' => [$revision_key, $entity_type->getKey('langcode')], + 'indexes' => [ + $entity_type_id . '__id__default_langcode__langcode' => [$id_key, $entity_type->getKey('default_langcode'), $entity_type->getKey('langcode')], + ], + 'foreign keys' => [ + $entity_type_id => [ 'table' => $this->storage->getBaseTable(), - 'columns' => array($id_key => $id_key), - ), - $entity_type_id . '__revision' => array( + 'columns' => [$id_key => $id_key], + ], + $entity_type_id . '__revision' => [ 'table' => $this->storage->getRevisionTable(), - 'columns' => array($revision_key => $revision_key), - ) - ), - ); + 'columns' => [$revision_key => $revision_key], + ] + ], + ]; $this->addTableDefaults($schema); @@ -980,12 +980,12 @@ protected function initializeRevisionDataTable(ContentEntityTypeInterface $entit * The schema definition array for a single table, passed by reference. */ protected function addTableDefaults(&$schema) { - $schema += array( - 'fields' => array(), - 'unique keys' => array(), - 'indexes' => array(), - 'foreign keys' => array(), - ); + $schema += [ + 'fields' => [], + 'unique keys' => [], + 'indexes' => [], + 'foreign keys' => [], + ]; } /** @@ -1130,7 +1130,7 @@ protected function createSharedTableSchema(FieldStorageDefinitionInterface $stor // Iterate over the mapped table to find the ones that will host the created // field schema. - $schema = array(); + $schema = []; foreach ($shared_table_names as $table_name) { foreach ($table_mapping->getFieldNames($table_name) as $field_name) { if ($field_name == $created_field_name) { @@ -1310,15 +1310,15 @@ protected function updateDedicatedTableSchema(FieldStorageDefinitionInterface $s foreach ($schema['indexes'] as $name => $columns) { if (!isset($original_schema['indexes'][$name]) || $columns != $original_schema['indexes'][$name]) { $real_name = $this->getFieldIndexName($storage_definition, $name); - $real_columns = array(); + $real_columns = []; foreach ($columns as $column_name) { // Indexes can be specified as either a column name or an array with // column name and length. Allow for either case. if (is_array($column_name)) { - $real_columns[] = array( + $real_columns[] = [ $table_mapping->getFieldColumnName($storage_definition, $column_name[0]), $column_name[1], - ); + ]; } else { $real_columns[] = $table_mapping->getFieldColumnName($storage_definition, $column_name); @@ -1384,7 +1384,7 @@ protected function updateSharedTableSchema(FieldStorageDefinitionInterface $stor // Iterate over the mapped table to find the ones that host the deleted // field schema. $original_schema = $this->loadFieldSchemaData($original); - $schema = array(); + $schema = []; foreach ($table_mapping->getTableNames() as $table_name) { foreach ($table_mapping->getFieldNames($table_name) as $field_name) { if ($field_name == $updated_field_name) { @@ -1579,7 +1579,7 @@ protected function hasNullFieldPropertyData($table_name, $column_name) { * Exception thrown if the schema contains reserved column names. */ protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) { - $schema = array(); + $schema = []; $field_schema = $storage_definition->getSchema(); // Check that the schema does not include forbidden column names. @@ -1651,7 +1651,7 @@ protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $st protected function addSharedTableFieldIndex(FieldStorageDefinitionInterface $storage_definition, &$schema, $not_null = FALSE, $size = NULL) { $name = $storage_definition->getName(); $real_key = $this->getFieldSchemaIdentifierName($storage_definition->getTargetEntityTypeId(), $name); - $schema['indexes'][$real_key] = array($size ? array($name, $size) : $name); + $schema['indexes'][$real_key] = [$size ? [$name, $size] : $name]; if ($not_null) { $schema['fields'][$name]['not null'] = TRUE; } @@ -1671,7 +1671,7 @@ protected function addSharedTableFieldIndex(FieldStorageDefinitionInterface $sto protected function addSharedTableFieldUniqueKey(FieldStorageDefinitionInterface $storage_definition, &$schema) { $name = $storage_definition->getName(); $real_key = $this->getFieldSchemaIdentifierName($storage_definition->getTargetEntityTypeId(), $name); - $schema['unique keys'][$real_key] = array($name); + $schema['unique keys'][$real_key] = [$name]; $schema['fields'][$name]['not null'] = TRUE; } @@ -1690,10 +1690,10 @@ protected function addSharedTableFieldUniqueKey(FieldStorageDefinitionInterface protected function addSharedTableFieldForeignKey(FieldStorageDefinitionInterface $storage_definition, &$schema, $foreign_table, $foreign_column) { $name = $storage_definition->getName(); $real_key = $this->getFieldSchemaIdentifierName($storage_definition->getTargetEntityTypeId(), $name); - $schema['foreign keys'][$real_key] = array( + $schema['foreign keys'][$real_key] = [ 'table' => $foreign_table, - 'columns' => array($name => $foreign_column), - ); + 'columns' => [$name => $foreign_column], + ]; } /** @@ -1723,20 +1723,20 @@ protected function getDedicatedTableSchema(FieldStorageDefinitionInterface $stor $id_definition = $this->fieldStorageDefinitions[$this->entityType->getKey('id')]; if ($id_definition->getType() == 'integer') { - $id_schema = array( + $id_schema = [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'The entity id this data is attached to', - ); + ]; } else { - $id_schema = array( + $id_schema = [ 'type' => 'varchar_ascii', 'length' => 128, 'not null' => TRUE, 'description' => 'The entity id this data is attached to', - ); + ]; } // Define the revision ID schema. @@ -1745,61 +1745,61 @@ protected function getDedicatedTableSchema(FieldStorageDefinitionInterface $stor $revision_id_schema['description'] = 'The entity revision id this data is attached to, which for an unversioned entity type is the same as the entity id'; } elseif ($this->fieldStorageDefinitions[$this->entityType->getKey('revision')]->getType() == 'integer') { - $revision_id_schema = array( + $revision_id_schema = [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'The entity revision id this data is attached to', - ); + ]; } else { - $revision_id_schema = array( + $revision_id_schema = [ 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'description' => 'The entity revision id this data is attached to', - ); + ]; } - $data_schema = array( + $data_schema = [ 'description' => $description_current, - 'fields' => array( - 'bundle' => array( + 'fields' => [ + 'bundle' => [ 'type' => 'varchar_ascii', 'length' => 128, 'not null' => TRUE, 'default' => '', 'description' => 'The field instance bundle to which this row belongs, used when deleting a field instance', - ), - 'deleted' => array( + ], + 'deleted' => [ 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, 'description' => 'A boolean indicating whether this data item has been deleted' - ), + ], 'entity_id' => $id_schema, 'revision_id' => $revision_id_schema, - 'langcode' => array( + 'langcode' => [ 'type' => 'varchar_ascii', 'length' => 32, 'not null' => TRUE, 'default' => '', 'description' => 'The language code for this data item.', - ), - 'delta' => array( + ], + 'delta' => [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'The sequence number for this data item, used for multi-value fields', - ), - ), - 'primary key' => array('entity_id', 'deleted', 'delta', 'langcode'), - 'indexes' => array( - 'bundle' => array('bundle'), - 'revision_id' => array('revision_id'), - ), - ); + ], + ], + 'primary key' => ['entity_id', 'deleted', 'delta', 'langcode'], + 'indexes' => [ + 'bundle' => ['bundle'], + 'revision_id' => ['revision_id'], + ], + ]; // Check that the schema does not include forbidden column names. $schema = $storage_definition->getSchema(); @@ -1826,10 +1826,10 @@ protected function getDedicatedTableSchema(FieldStorageDefinitionInterface $stor // Indexes can be specified as either a column name or an array with // column name and length. Allow for either case. if (is_array($column_name)) { - $data_schema['indexes'][$real_name][] = array( + $data_schema['indexes'][$real_name][] = [ $table_mapping->getFieldColumnName($storage_definition, $column_name[0]), $column_name[1], - ); + ]; } else { $data_schema['indexes'][$real_name][] = $table_mapping->getFieldColumnName($storage_definition, $column_name); @@ -1844,10 +1844,10 @@ protected function getDedicatedTableSchema(FieldStorageDefinitionInterface $stor // Unique keys can be specified as either a column name or an array with // column name and length. Allow for either case. if (is_array($column_name)) { - $data_schema['unique keys'][$real_name][] = array( + $data_schema['unique keys'][$real_name][] = [ $table_mapping->getFieldColumnName($storage_definition, $column_name[0]), $column_name[1], - ); + ]; } else { $data_schema['unique keys'][$real_name][] = $table_mapping->getFieldColumnName($storage_definition, $column_name); @@ -1865,17 +1865,17 @@ protected function getDedicatedTableSchema(FieldStorageDefinitionInterface $stor } } - $dedicated_table_schema = array($table_mapping->getDedicatedDataTableName($storage_definition) => $data_schema); + $dedicated_table_schema = [$table_mapping->getDedicatedDataTableName($storage_definition) => $data_schema]; // If the entity type is revisionable, construct the revision table. $entity_type = $entity_type ?: $this->entityType; if ($entity_type->isRevisionable()) { $revision_schema = $data_schema; $revision_schema['description'] = $description_revision; - $revision_schema['primary key'] = array('entity_id', 'revision_id', 'deleted', 'delta', 'langcode'); + $revision_schema['primary key'] = ['entity_id', 'revision_id', 'deleted', 'delta', 'langcode']; $revision_schema['fields']['revision_id']['not null'] = TRUE; $revision_schema['fields']['revision_id']['description'] = 'The entity revision id this data is attached to'; - $dedicated_table_schema += array($table_mapping->getDedicatedRevisionTableName($storage_definition) => $revision_schema); + $dedicated_table_schema += [$table_mapping->getDedicatedRevisionTableName($storage_definition) => $revision_schema]; } return $dedicated_table_schema; diff --git a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php index 12e7f8d..be6405a 100644 --- a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php +++ b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php @@ -19,7 +19,7 @@ class EntityDataDefinition extends ComplexDataDefinitionBase implements EntityDa * @return static */ public static function create($entity_type_id = NULL) { - $definition = new static(array()); + $definition = new static([]); // Set the passed entity type. if (isset($entity_type_id)) { $definition->setEntityTypeId($entity_type_id); @@ -41,7 +41,7 @@ public static function createFromDataType($data_type) { $definition->setEntityTypeId($parts[1]); } if (isset($parts[2])) { - $definition->setBundles(array($parts[2])); + $definition->setBundles([$parts[2]]); } return $definition; } @@ -55,7 +55,7 @@ public function getPropertyDefinitions() { // Return an empty array for entities that are not content entities. $entity_type_class = \Drupal::entityManager()->getDefinition($entity_type_id)->getClass(); if (!in_array('Drupal\Core\Entity\FieldableEntityInterface', class_implements($entity_type_class))) { - $this->propertyDefinitions = array(); + $this->propertyDefinitions = []; } else { // @todo: Add support for handling multiple bundles. @@ -71,7 +71,7 @@ public function getPropertyDefinitions() { } else { // No entity type given. - $this->propertyDefinitions = array(); + $this->propertyDefinitions = []; } } return $this->propertyDefinitions; @@ -115,7 +115,7 @@ public function setEntityTypeId($entity_type_id) { */ public function getBundles() { $bundle = isset($this->definition['constraints']['Bundle']) ? $this->definition['constraints']['Bundle'] : NULL; - return is_string($bundle) ? array($bundle) : $bundle; + return is_string($bundle) ? [$bundle] : $bundle; } /** diff --git a/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php index fe2e008..4d020fd 100644 --- a/core/lib/Drupal/Core/Entity/entity.api.php +++ b/core/lib/Drupal/Core/Entity/entity.api.php @@ -933,12 +933,12 @@ function hook_ENTITY_TYPE_presave(Drupal\Core\Entity\EntityInterface $entity) { function hook_entity_insert(Drupal\Core\Entity\EntityInterface $entity) { // Insert the new entity into a fictional table of all entities. db_insert('example_entity') - ->fields(array( + ->fields([ 'type' => $entity->getEntityTypeId(), 'id' => $entity->id(), 'created' => REQUEST_TIME, 'updated' => REQUEST_TIME, - )) + ]) ->execute(); } @@ -957,11 +957,11 @@ function hook_entity_insert(Drupal\Core\Entity\EntityInterface $entity) { function hook_ENTITY_TYPE_insert(Drupal\Core\Entity\EntityInterface $entity) { // Insert the new entity into a fictional table of this type of entity. db_insert('example_entity') - ->fields(array( + ->fields([ 'id' => $entity->id(), 'created' => REQUEST_TIME, 'updated' => REQUEST_TIME, - )) + ]) ->execute(); } @@ -981,9 +981,9 @@ function hook_ENTITY_TYPE_insert(Drupal\Core\Entity\EntityInterface $entity) { function hook_entity_update(Drupal\Core\Entity\EntityInterface $entity) { // Update the entity's entry in a fictional table of all entities. db_update('example_entity') - ->fields(array( + ->fields([ 'updated' => REQUEST_TIME, - )) + ]) ->condition('type', $entity->getEntityTypeId()) ->condition('id', $entity->id()) ->execute(); @@ -1005,9 +1005,9 @@ function hook_entity_update(Drupal\Core\Entity\EntityInterface $entity) { function hook_ENTITY_TYPE_update(Drupal\Core\Entity\EntityInterface $entity) { // Update the entity's entry in a fictional table of this type of entity. db_update('example_entity') - ->fields(array( + ->fields([ 'updated' => REQUEST_TIME, - )) + ]) ->condition('id', $entity->id()) ->execute(); } @@ -1057,10 +1057,10 @@ function hook_ENTITY_TYPE_translation_create(\Drupal\Core\Entity\EntityInterface * @see hook_ENTITY_TYPE_translation_insert() */ function hook_entity_translation_insert(\Drupal\Core\Entity\EntityInterface $translation) { - $variables = array( + $variables = [ '@language' => $translation->language()->getName(), '@label' => $translation->getUntranslated()->label(), - ); + ]; \Drupal::logger('example')->notice('The @language translation of @label has just been stored.', $variables); } @@ -1077,10 +1077,10 @@ function hook_entity_translation_insert(\Drupal\Core\Entity\EntityInterface $tra * @see hook_entity_translation_insert() */ function hook_ENTITY_TYPE_translation_insert(\Drupal\Core\Entity\EntityInterface $translation) { - $variables = array( + $variables = [ '@language' => $translation->language()->getName(), '@label' => $translation->getUntranslated()->label(), - ); + ]; \Drupal::logger('example')->notice('The @language translation of @label has just been stored.', $variables); } @@ -1096,10 +1096,10 @@ function hook_ENTITY_TYPE_translation_insert(\Drupal\Core\Entity\EntityInterface * @see hook_ENTITY_TYPE_translation_delete() */ function hook_entity_translation_delete(\Drupal\Core\Entity\EntityInterface $translation) { - $variables = array( + $variables = [ '@language' => $translation->language()->getName(), '@label' => $translation->label(), - ); + ]; \Drupal::logger('example')->notice('The @language translation of @label has just been deleted.', $variables); } @@ -1115,10 +1115,10 @@ function hook_entity_translation_delete(\Drupal\Core\Entity\EntityInterface $tra * @see hook_entity_translation_delete() */ function hook_ENTITY_TYPE_translation_delete(\Drupal\Core\Entity\EntityInterface $translation) { - $variables = array( + $variables = [ '@language' => $translation->language()->getName(), '@label' => $translation->label(), - ); + ]; \Drupal::logger('example')->notice('The @language translation of @label has just been deleted.', $variables); } @@ -1145,8 +1145,8 @@ function hook_entity_predelete(Drupal\Core\Entity\EntityInterface $entity) { // Log the count in a table that records this statistic for deleted entities. db_merge('example_deleted_entity_statistics') - ->key(array('type' => $type, 'id' => $id)) - ->fields(array('count' => $count)) + ->key(['type' => $type, 'id' => $id]) + ->fields(['count' => $count]) ->execute(); } @@ -1173,8 +1173,8 @@ function hook_ENTITY_TYPE_predelete(Drupal\Core\Entity\EntityInterface $entity) // Log the count in a table that records this statistic for deleted entities. db_merge('example_deleted_entity_statistics') - ->key(array('type' => $type, 'id' => $id)) - ->fields(array('count' => $count)) + ->key(['type' => $type, 'id' => $id]) + ->fields(['count' => $count]) ->execute(); } @@ -1277,10 +1277,10 @@ function hook_entity_view(array &$build, \Drupal\Core\Entity\EntityInterface $en // This assumes a 'mymodule_addition' extra field has been defined for the // entity bundle in hook_entity_extra_field_info(). if ($display->getComponent('mymodule_addition')) { - $build['mymodule_addition'] = array( + $build['mymodule_addition'] = [ '#markup' => mymodule_addition($entity), '#theme' => 'mymodule_my_additional_field', - ); + ]; } } @@ -1309,10 +1309,10 @@ function hook_ENTITY_TYPE_view(array &$build, \Drupal\Core\Entity\EntityInterfac // This assumes a 'mymodule_addition' extra field has been defined for the // entity bundle in hook_entity_extra_field_info(). if ($display->getComponent('mymodule_addition')) { - $build['mymodule_addition'] = array( + $build['mymodule_addition'] = [ '#markup' => mymodule_addition($entity), '#theme' => 'mymodule_my_additional_field', - ); + ]; } } @@ -1417,7 +1417,7 @@ function hook_entity_prepare_view($entity_type_id, array $entities, array $displ // Only do the extra work if the component is configured to be // displayed. This assumes a 'mymodule_addition' extra field has been // defined for the entity bundle in hook_entity_extra_field_info(). - $ids = array(); + $ids = []; foreach ($entities as $id => $entity) { if ($displays[$entity->bundle()]->getComponent('mymodule_addition')) { $ids[] = $id; @@ -1628,9 +1628,9 @@ function hook_ENTITY_TYPE_prepare_form(\Drupal\Core\Entity\EntityInterface $enti function hook_entity_form_display_alter(\Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display, array $context) { // Hide the 'user_picture' field from the register form. if ($context['entity_type'] == 'user' && $context['form_mode'] == 'register') { - $form_display->setComponent('user_picture', array( + $form_display->setComponent('user_picture', [ 'type' => 'hidden', - )); + ]); } } @@ -1651,7 +1651,7 @@ function hook_entity_form_display_alter(\Drupal\Core\Entity\Display\EntityFormDi */ function hook_entity_base_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) { if ($entity_type->id() == 'node') { - $fields = array(); + $fields = []; $fields['mymodule_text'] = BaseFieldDefinition::create('string') ->setLabel(t('The text')) ->setDescription(t('A text property added by mymodule.')) @@ -1715,7 +1715,7 @@ function hook_entity_base_field_info_alter(&$fields, \Drupal\Core\Entity\EntityT function hook_entity_bundle_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) { // Add a property only to nodes of the 'article' bundle. if ($entity_type->id() == 'node' && $bundle == 'article') { - $fields = array(); + $fields = []; $fields['mymodule_text_more'] = BaseFieldDefinition::create('string') ->setLabel(t('More text')) ->setComputed(TRUE) @@ -1770,7 +1770,7 @@ function hook_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface ->execute(); // Fetch all fields and key them by field name. $field_storages = FieldStorageConfig::loadMultiple($ids); - $result = array(); + $result = []; foreach ($field_storages as $field_storage) { $result[$field_storage->getName()] = $field_storage; } @@ -1809,12 +1809,12 @@ function hook_entity_field_storage_info_alter(&$fields, \Drupal\Core\Entity\Enti * @see \Drupal\Core\Entity\EntityListBuilderInterface::getOperations() */ function hook_entity_operation(\Drupal\Core\Entity\EntityInterface $entity) { - $operations = array(); - $operations['translate'] = array( + $operations = []; + $operations['translate'] = [ 'title' => t('Translate'), 'url' => \Drupal\Core\Url::fromRoute('foo_module.entity.translate'), 'weight' => 50, - ); + ]; return $operations; } @@ -1830,9 +1830,9 @@ function hook_entity_operation(\Drupal\Core\Entity\EntityInterface $entity) { */ function hook_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) { // Alter the title and weight. - $operations['translate']['title'] = t('Translate @entity_type', array( + $operations['translate']['title'] = t('Translate @entity_type', [ '@entity_type' => $entity->getEntityTypeId(), - )); + ]); $operations['translate']['weight'] = 99; } @@ -1955,7 +1955,7 @@ function hook_ENTITY_TYPE_field_values_init(\Drupal\Core\Entity\FieldableEntityI * \Drupal\Core\Entity\EntityFieldManagerInterface::getExtraFields(). */ function hook_entity_extra_field_info() { - $extra = array(); + $extra = []; $module_language_enabled = \Drupal::moduleHandler()->moduleExists('language'); $description = t('Node module element'); @@ -1968,19 +1968,19 @@ function hook_entity_extra_field_info() { if ($module_language_enabled) { $configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', $bundle->id()); if ($configuration->isLanguageAlterable()) { - $extra['node'][$bundle->id()]['form']['language'] = array( + $extra['node'][$bundle->id()]['form']['language'] = [ 'label' => t('Language'), 'description' => $description, 'weight' => 0, - ); + ]; } } - $extra['node'][$bundle->id()]['display']['language'] = array( + $extra['node'][$bundle->id()]['display']['language'] = [ 'label' => t('Language'), 'description' => $description, 'weight' => 0, 'visible' => FALSE, - ); + ]; } return $extra; diff --git a/core/lib/Drupal/Core/EventSubscriber/AjaxResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/AjaxResponseSubscriber.php index e2ffc05..701c433 100644 --- a/core/lib/Drupal/Core/EventSubscriber/AjaxResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/AjaxResponseSubscriber.php @@ -110,8 +110,8 @@ public function onResponse(FilterResponseEvent $event) { * {@inheritdoc} */ public static function getSubscribedEvents() { - $events[KernelEvents::RESPONSE][] = array('onResponse', -100); - $events[KernelEvents::REQUEST][] = array('onRequest', 50); + $events[KernelEvents::RESPONSE][] = ['onResponse', -100]; + $events[KernelEvents::REQUEST][] = ['onRequest', 50]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php index ad2eb5e..d727ed3 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php @@ -55,13 +55,13 @@ public function __construct(ThemeHandlerInterface $theme_handler) { * @throws \Drupal\Core\Config\ConfigNameException */ public function onConfigImporterValidate(ConfigImporterEvent $event) { - foreach (array('delete', 'create', 'update') as $op) { + foreach (['delete', 'create', 'update'] as $op) { foreach ($event->getConfigImporter()->getUnprocessedConfiguration($op) as $name) { try { Config::validateName($name); } catch (ConfigNameException $e) { - $message = $this->t('The config name @config_name is invalid.', array('@config_name' => $name)); + $message = $this->t('The config name @config_name is invalid.', ['@config_name' => $name]); $event->getConfigImporter()->logError($message); } } @@ -89,7 +89,7 @@ protected function validateModules(ConfigImporter $config_importer) { $module_data = $this->getModuleData(); $nonexistent_modules = array_keys(array_diff_key($core_extension['module'], $module_data)); foreach ($nonexistent_modules as $module) { - $config_importer->logError($this->t('Unable to install the %module module since it does not exist.', array('%module' => $module))); + $config_importer->logError($this->t('Unable to install the %module module since it does not exist.', ['%module' => $module])); } // Ensure that all modules being installed have their dependencies met. @@ -106,7 +106,7 @@ protected function validateModules(ConfigImporter $config_importer) { $message = $this->formatPlural(count($missing_dependencies), 'Unable to install the %module module since it requires the %required_module module.', 'Unable to install the %module module since it requires the %required_module modules.', - array('%module' => $module_name, '%required_module' => implode(', ', $missing_dependencies)) + ['%module' => $module_name, '%required_module' => implode(', ', $missing_dependencies)] ); $config_importer->logError($message); } @@ -123,7 +123,7 @@ protected function validateModules(ConfigImporter $config_importer) { if ($module_data[$dependent_module]->status && !in_array($dependent_module, $uninstalls, TRUE) && $dependent_module !== $install_profile) { $module_name = $module_data[$module]->info['name']; $dependent_module_name = $module_data[$dependent_module]->info['name']; - $config_importer->logError($this->t('Unable to uninstall the %module module since the %dependent_module module is installed.', array('%module' => $module_name, '%dependent_module' => $dependent_module_name))); + $config_importer->logError($this->t('Unable to uninstall the %module module since the %dependent_module module is installed.', ['%module' => $module_name, '%dependent_module' => $dependent_module_name])); } } } @@ -131,7 +131,7 @@ protected function validateModules(ConfigImporter $config_importer) { // Ensure that the install profile is not being uninstalled. if (in_array($install_profile, $uninstalls)) { $profile_name = $module_data[$install_profile]->info['name']; - $config_importer->logError($this->t('Unable to uninstall the %profile profile since it is the install profile.', array('%profile' => $profile_name))); + $config_importer->logError($this->t('Unable to uninstall the %profile profile since it is the install profile.', ['%profile' => $profile_name])); } } @@ -148,7 +148,7 @@ protected function validateThemes(ConfigImporter $config_importer) { $installs = $config_importer->getExtensionChangelist('theme', 'install'); foreach ($installs as $key => $theme) { if (!isset($theme_data[$theme])) { - $config_importer->logError($this->t('Unable to install the %theme theme since it does not exist.', array('%theme' => $theme))); + $config_importer->logError($this->t('Unable to install the %theme theme since it does not exist.', ['%theme' => $theme])); // Remove non-existing installs from the list so we can validate theme // dependencies later. unset($installs[$key]); @@ -161,7 +161,7 @@ protected function validateThemes(ConfigImporter $config_importer) { if (!isset($core_extension['theme'][$required_theme])) { $theme_name = $theme_data[$theme]->info['name']; $required_theme_name = $theme_data[$required_theme]->info['name']; - $config_importer->logError($this->t('Unable to install the %theme theme since it requires the %required_theme theme.', array('%theme' => $theme_name, '%required_theme' => $required_theme_name))); + $config_importer->logError($this->t('Unable to install the %theme theme since it requires the %required_theme theme.', ['%theme' => $theme_name, '%required_theme' => $required_theme_name])); } } } @@ -174,7 +174,7 @@ protected function validateThemes(ConfigImporter $config_importer) { if ($theme_data[$dependent_theme]->status && !in_array($dependent_theme, $uninstalls, TRUE)) { $theme_name = $theme_data[$theme]->info['name']; $dependent_theme_name = $theme_data[$dependent_theme]->info['name']; - $config_importer->logError($this->t('Unable to uninstall the %theme theme since the %dependent_theme theme is installed.', array('%theme' => $theme_name, '%dependent_theme' => $dependent_theme_name))); + $config_importer->logError($this->t('Unable to uninstall the %theme theme since the %dependent_theme theme is installed.', ['%theme' => $theme_name, '%dependent_theme' => $dependent_theme_name])); } } } @@ -207,22 +207,22 @@ protected function validateDependencies(ConfigImporter $config_importer) { if ($owner !== 'core') { $message = FALSE; if (!isset($core_extension['module'][$owner]) && isset($module_data[$owner])) { - $message = $this->t('Configuration %name depends on the %owner module that will not be installed after import.', array( + $message = $this->t('Configuration %name depends on the %owner module that will not be installed after import.', [ '%name' => $name, '%owner' => $module_data[$owner]->info['name'] - )); + ]); } elseif (!isset($core_extension['theme'][$owner]) && isset($theme_data[$owner])) { - $message = $this->t('Configuration %name depends on the %owner theme that will not be installed after import.', array( + $message = $this->t('Configuration %name depends on the %owner theme that will not be installed after import.', [ '%name' => $name, '%owner' => $theme_data[$owner]->info['name'] - )); + ]); } elseif (!isset($core_extension['module'][$owner]) && !isset($core_extension['theme'][$owner])) { - $message = $this->t('Configuration %name depends on the %owner extension that will not be installed after import.', array( + $message = $this->t('Configuration %name depends on the %owner extension that will not be installed after import.', [ '%name' => $name, '%owner' => $owner - )); + ]); } if ($message) { @@ -249,7 +249,7 @@ protected function validateDependencies(ConfigImporter $config_importer) { count($diffs), 'Configuration %name depends on the %module module that will not be installed after import.', 'Configuration %name depends on modules (%module) that will not be installed after import.', - array('%name' => $name, '%module' => implode(', ', $this->getNames($diffs, $module_data))) + ['%name' => $name, '%module' => implode(', ', $this->getNames($diffs, $module_data))] ); break; case 'theme': @@ -257,7 +257,7 @@ protected function validateDependencies(ConfigImporter $config_importer) { count($diffs), 'Configuration %name depends on the %theme theme that will not be installed after import.', 'Configuration %name depends on themes (%theme) that will not be installed after import.', - array('%name' => $name, '%theme' => implode(', ', $this->getNames($diffs, $theme_data))) + ['%name' => $name, '%theme' => implode(', ', $this->getNames($diffs, $theme_data))] ); break; case 'config': @@ -265,7 +265,7 @@ protected function validateDependencies(ConfigImporter $config_importer) { count($diffs), 'Configuration %name depends on the %config configuration that will not exist after import.', 'Configuration %name depends on configuration (%config) that will not exist after import.', - array('%name' => $name, '%config' => implode(', ', $diffs)) + ['%name' => $name, '%config' => implode(', ', $diffs)] ); break; } diff --git a/core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php index e20e52f..3309701 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigSnapshotSubscriber.php @@ -65,7 +65,7 @@ public function onConfigImporterImport(ConfigImporterEvent $event) { * An array of event listener definitions. */ static function getSubscribedEvents() { - $events[ConfigEvents::IMPORT][] = array('onConfigImporterImport', 40); + $events[ConfigEvents::IMPORT][] = ['onConfigImporterImport', 40]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php index fc491af..3516426 100644 --- a/core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/EnforcedFormResponseSubscriber.php @@ -39,8 +39,8 @@ public function onKernelResponse(FilterResponseEvent $event) { * {@inheritdoc} */ public static function getSubscribedEvents() { - $events[KernelEvents::EXCEPTION] = array('onKernelException', 128); - $events[KernelEvents::RESPONSE] = array('onKernelResponse', 128); + $events[KernelEvents::EXCEPTION] = ['onKernelException', 128]; + $events[KernelEvents::RESPONSE] = ['onKernelResponse', 128]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/EntityRouteAlterSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/EntityRouteAlterSubscriber.php index 8337d43..6d2ddc8 100644 --- a/core/lib/Drupal/Core/EventSubscriber/EntityRouteAlterSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/EntityRouteAlterSubscriber.php @@ -53,7 +53,7 @@ public function onRoutingRouteAlterSetType(RouteBuildEvent $event) { * {@inheritdoc} */ static function getSubscribedEvents() { - $events[RoutingEvents::ALTER][] = array('onRoutingRouteAlterSetType', -150); + $events[RoutingEvents::ALTER][] = ['onRoutingRouteAlterSetType', -150]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php index 2853b98..c8835f7 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php @@ -34,7 +34,7 @@ protected static function getPriority() { * The event to process. */ public function on400(GetResponseForExceptionEvent $event) { - $response = new JsonResponse(array('message' => $event->getException()->getMessage()), Response::HTTP_BAD_REQUEST); + $response = new JsonResponse(['message' => $event->getException()->getMessage()], Response::HTTP_BAD_REQUEST); $event->setResponse($response); } @@ -45,7 +45,7 @@ public function on400(GetResponseForExceptionEvent $event) { * The event to process. */ public function on403(GetResponseForExceptionEvent $event) { - $response = new JsonResponse(array('message' => $event->getException()->getMessage()), Response::HTTP_FORBIDDEN); + $response = new JsonResponse(['message' => $event->getException()->getMessage()], Response::HTTP_FORBIDDEN); $event->setResponse($response); } @@ -56,7 +56,7 @@ public function on403(GetResponseForExceptionEvent $event) { * The event to process. */ public function on404(GetResponseForExceptionEvent $event) { - $response = new JsonResponse(array('message' => $event->getException()->getMessage()), Response::HTTP_NOT_FOUND); + $response = new JsonResponse(['message' => $event->getException()->getMessage()], Response::HTTP_NOT_FOUND); $event->setResponse($response); } @@ -67,7 +67,7 @@ public function on404(GetResponseForExceptionEvent $event) { * The event to process. */ public function on405(GetResponseForExceptionEvent $event) { - $response = new JsonResponse(array('message' => $event->getException()->getMessage()), Response::HTTP_METHOD_NOT_ALLOWED); + $response = new JsonResponse(['message' => $event->getException()->getMessage()], Response::HTTP_METHOD_NOT_ALLOWED); $event->setResponse($response); } diff --git a/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php index f1088bf..ab50f21 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ExceptionTestSiteSubscriber.php @@ -37,7 +37,7 @@ public function on500(GetResponseForExceptionEvent $event) { $exception = $event->getException(); $error = Error::decodeException($exception); - $headers = array(); + $headers = []; // When running inside the testing framework, we relay the errors // to the tested site by the way of HTTP headers. @@ -45,15 +45,15 @@ public function on500(GetResponseForExceptionEvent $event) { // $number does not use drupal_static as it should not be reset // as it uniquely identifies each PHP error. static $number = 0; - $assertion = array( + $assertion = [ $error['@message'], $error['%type'], - array( + [ 'function' => $error['%function'], 'file' => $error['%file'], 'line' => $error['%line'], - ), - ); + ], + ]; $headers['X-Drupal-Assertion-' . $number] = rawurlencode(serialize($assertion)); $number++; } diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index 3db181a..9313b99 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -283,7 +283,7 @@ protected function setExpiresNoCache(Response $response) { * An array of event listener definitions. */ public static function getSubscribedEvents() { - $events[KernelEvents::RESPONSE][] = array('onRespond'); + $events[KernelEvents::RESPONSE][] = ['onRespond']; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php index 4b04be6..237f375 100644 --- a/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php @@ -20,7 +20,7 @@ class KernelDestructionSubscriber implements EventSubscriberInterface, Container * * @var array */ - protected $services = array(); + protected $services = []; /** * Registers a service for destruction. @@ -59,7 +59,7 @@ public function onKernelTerminate(PostResponseEvent $event) { * An array of event listener definitions. */ static function getSubscribedEvents() { - $events[KernelEvents::TERMINATE][] = array('onKernelTerminate', 100); + $events[KernelEvents::TERMINATE][] = ['onKernelTerminate', 100]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php index 57d43ec..ba82988 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MaintenanceModeSubscriber.php @@ -103,7 +103,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) { // If the request format is not 'html' then show default maintenance // mode page else show a text/plain page with maintenance message. if ($request->getRequestFormat() !== 'html') { - $response = new Response($this->getSiteMaintenanceMessage(), 503, array('Content-Type' => 'text/plain')); + $response = new Response($this->getSiteMaintenanceMessage(), 503, ['Content-Type' => 'text/plain']); $event->setResponse($response); return; } @@ -118,7 +118,7 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) { // settings page. if ($route_match->getRouteName() != 'system.site_maintenance_mode') { if ($this->account->hasPermission('administer site configuration')) { - $this->drupalSetMessage($this->t('Operating in maintenance mode. Go online.', array(':url' => $this->urlGenerator->generate('system.site_maintenance_mode'))), 'status', FALSE); + $this->drupalSetMessage($this->t('Operating in maintenance mode. Go online.', [':url' => $this->urlGenerator->generate('system.site_maintenance_mode')]), 'status', FALSE); } else { $this->drupalSetMessage($this->t('Operating in maintenance mode.'), 'status', FALSE); @@ -135,9 +135,9 @@ public function onKernelRequestMaintenance(GetResponseEvent $event) { * The formatted site maintenance message. */ protected function getSiteMaintenanceMessage() { - return SafeMarkup::format($this->config->get('system.maintenance')->get('message'), array( + return SafeMarkup::format($this->config->get('system.maintenance')->get('message'), [ '@site' => $this->config->get('system.site')->get('name'), - )); + ]); } /** @@ -151,8 +151,8 @@ protected function drupalSetMessage($message = NULL, $type = 'status', $repeat = * {@inheritdoc} */ public static function getSubscribedEvents() { - $events[KernelEvents::REQUEST][] = array('onKernelRequestMaintenance', 30); - $events[KernelEvents::EXCEPTION][] = array('onKernelRequestMaintenance'); + $events[KernelEvents::REQUEST][] = ['onKernelRequestMaintenance', 30]; + $events[KernelEvents::EXCEPTION][] = ['onKernelRequestMaintenance']; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php index 56ac921..bb95b83 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MenuRouterRebuildSubscriber.php @@ -47,7 +47,7 @@ public function __construct(LockBackendInterface $lock, MenuLinkManagerInterface */ public function onRouterRebuild(Event $event) { $this->menuLinksRebuild(); - Cache::invalidateTags(array('local_task')); + Cache::invalidateTags(['local_task']); } /** @@ -82,7 +82,7 @@ protected function menuLinksRebuild() { */ static function getSubscribedEvents() { // Run after CachedRouteRebuildSubscriber. - $events[RoutingEvents::FINISHED][] = array('onRouterRebuild', 100); + $events[RoutingEvents::FINISHED][] = ['onRouterRebuild', 100]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php index 271ddbe..19590ae 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ParamConverterSubscriber.php @@ -45,7 +45,7 @@ public function onRoutingRouteAlterSetParameterConverters(RouteBuildEvent $event */ static function getSubscribedEvents() { // Run after \Drupal\system\EventSubscriber\AdminRouteSubscriber. - $events[RoutingEvents::ALTER][] = array('onRoutingRouteAlterSetParameterConverters', -220); + $events[RoutingEvents::ALTER][] = ['onRoutingRouteAlterSetParameterConverters', -220]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/PathRootsSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/PathRootsSubscriber.php index 824c4e8..7d87199 100644 --- a/core/lib/Drupal/Core/EventSubscriber/PathRootsSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/PathRootsSubscriber.php @@ -65,10 +65,10 @@ public function onRouteFinished() { * {@inheritdoc} */ public static function getSubscribedEvents() { - $events = array(); + $events = []; // Try to set a low priority to ensure that all routes are already added. - $events[RoutingEvents::ALTER][] = array('onRouteAlter', -1024); - $events[RoutingEvents::FINISHED][] = array('onRouteFinished'); + $events[RoutingEvents::ALTER][] = ['onRouteAlter', -1024]; + $events[RoutingEvents::FINISHED][] = ['onRouteFinished']; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php index 77dbdbc..737c77c 100644 --- a/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/PathSubscriber.php @@ -71,8 +71,8 @@ public function onKernelTerminate(PostResponseEvent $event) { * An array of event listener definitions. */ static function getSubscribedEvents() { - $events[KernelEvents::CONTROLLER][] = array('onKernelController', 200); - $events[KernelEvents::TERMINATE][] = array('onKernelTerminate', 200); + $events[KernelEvents::CONTROLLER][] = ['onKernelController', 200]; + $events[KernelEvents::TERMINATE][] = ['onKernelTerminate', 200]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php index b9a64d5..bf5ca05 100644 --- a/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php @@ -166,8 +166,8 @@ public function sanitizeDestination(GetResponseEvent $event) { * An array of event listener definitions. */ static function getSubscribedEvents() { - $events[KernelEvents::RESPONSE][] = array('checkRedirectUrl'); - $events[KernelEvents::REQUEST][] = array('sanitizeDestination', 100); + $events[KernelEvents::RESPONSE][] = ['checkRedirectUrl']; + $events[KernelEvents::REQUEST][] = ['sanitizeDestination', 100]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/ReplicaDatabaseIgnoreSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ReplicaDatabaseIgnoreSubscriber.php index 64968ba..b0228f8 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ReplicaDatabaseIgnoreSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ReplicaDatabaseIgnoreSubscriber.php @@ -48,7 +48,7 @@ public function checkReplicaServer(GetResponseEvent $event) { * {@inheritdoc} */ static function getSubscribedEvents() { - $events[KernelEvents::REQUEST][] = array('checkReplicaServer'); + $events[KernelEvents::REQUEST][] = ['checkReplicaServer']; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php index 7431e96..765b1de 100644 --- a/core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/RequestCloseSubscriber.php @@ -49,7 +49,7 @@ public function onTerminate(PostResponseEvent $event) { * An array of event listener definitions. */ static function getSubscribedEvents() { - $events[KernelEvents::TERMINATE][] = array('onTerminate', 100); + $events[KernelEvents::TERMINATE][] = ['onTerminate', 100]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/RouteEnhancerSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RouteEnhancerSubscriber.php index ebc699b..f12174a 100644 --- a/core/lib/Drupal/Core/EventSubscriber/RouteEnhancerSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/RouteEnhancerSubscriber.php @@ -41,7 +41,7 @@ public function onRouteAlter(RouteBuildEvent $event) { * {@inheritdoc} */ static function getSubscribedEvents() { - $events[RoutingEvents::ALTER][] = array('onRouteAlter', -300); + $events[RoutingEvents::ALTER][] = ['onRouteAlter', -300]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/RouteFilterSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RouteFilterSubscriber.php index 901aa0c..79f98a4 100644 --- a/core/lib/Drupal/Core/EventSubscriber/RouteFilterSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/RouteFilterSubscriber.php @@ -43,7 +43,7 @@ public function onRouteAlter(RouteBuildEvent $event) { * {@inheritdoc} */ static function getSubscribedEvents() { - $events[RoutingEvents::ALTER][] = array('onRouteAlter', -300); + $events[RoutingEvents::ALTER][] = ['onRouteAlter', -300]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/RouteMethodSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RouteMethodSubscriber.php index c88e306..b43ebf4 100644 --- a/core/lib/Drupal/Core/EventSubscriber/RouteMethodSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/RouteMethodSubscriber.php @@ -27,7 +27,7 @@ public function onRouteBuilding(RouteBuildEvent $event) { foreach ($event->getRouteCollection() as $route) { $methods = $route->getMethods(); if (empty($methods)) { - $route->setMethods(array('GET', 'POST')); + $route->setMethods(['GET', 'POST']); } } } @@ -38,7 +38,7 @@ public function onRouteBuilding(RouteBuildEvent $event) { static function getSubscribedEvents() { // Set a higher priority to ensure that routes get the default HTTP methods // as early as possible. - $events[RoutingEvents::ALTER][] = array('onRouteBuilding', 5000); + $events[RoutingEvents::ALTER][] = ['onRouteBuilding', 5000]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php index 85489cc..0f40c5a 100644 --- a/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/SpecialAttributesRouteSubscriber.php @@ -16,7 +16,7 @@ class SpecialAttributesRouteSubscriber extends RouteSubscriberBase { * {@inheritdoc} */ protected function alterRoutes(RouteCollection $collection) { - $special_variables = array( + $special_variables = [ 'system_path', '_legacy', '_raw_variables', @@ -25,7 +25,7 @@ protected function alterRoutes(RouteCollection $collection) { '_content', '_controller', '_form', - ); + ]; foreach ($collection->all() as $name => $route) { if ($not_allowed_variables = array_intersect($route->compile()->getVariables(), $special_variables)) { $reserved = implode(', ', $not_allowed_variables); diff --git a/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php b/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php index 1480cbf..390a364 100644 --- a/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php +++ b/core/lib/Drupal/Core/Executable/ExecutablePluginBase.php @@ -24,7 +24,7 @@ public function getConfigDefinitions() { if (!empty($definition['configuration'])) { return $definition['configuration']; } - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Extension/Discovery/RecursiveExtensionFilterIterator.php b/core/lib/Drupal/Core/Extension/Discovery/RecursiveExtensionFilterIterator.php index 5c3ebc3..ac69f01 100644 --- a/core/lib/Drupal/Core/Extension/Discovery/RecursiveExtensionFilterIterator.php +++ b/core/lib/Drupal/Core/Extension/Discovery/RecursiveExtensionFilterIterator.php @@ -38,11 +38,11 @@ class RecursiveExtensionFilterIterator extends \RecursiveFilterIterator { * * @var array */ - protected $whitelist = array( + protected $whitelist = [ 'profiles', 'modules', 'themes', - ); + ]; /** * List of directory names to skip when recursing. @@ -53,7 +53,7 @@ class RecursiveExtensionFilterIterator extends \RecursiveFilterIterator { * * @var array */ - protected $blacklist = array( + protected $blacklist = [ // Object-oriented code subdirectories. 'src', 'lib', @@ -72,7 +72,7 @@ class RecursiveExtensionFilterIterator extends \RecursiveFilterIterator { 'fixtures', // @todo ./tests/Drupal should be ./tests/src/Drupal 'Drupal', - ); + ]; /** * Whether to include test directories when recursing. diff --git a/core/lib/Drupal/Core/Extension/Extension.php b/core/lib/Drupal/Core/Extension/Extension.php index 0238714..7cb6b56 100644 --- a/core/lib/Drupal/Core/Extension/Extension.php +++ b/core/lib/Drupal/Core/Extension/Extension.php @@ -152,7 +152,7 @@ public function __call($method, array $args) { if (!isset($this->splFileInfo)) { $this->splFileInfo = new \SplFileInfo($this->pathname); } - return call_user_func_array(array($this->splFileInfo, $method), $args); + return call_user_func_array([$this->splFileInfo, $method], $args); } /** @@ -163,11 +163,11 @@ public function __call($method, array $args) { public function serialize() { // Don't serialize the app root, since this could change if the install is // moved. - $data = array( + $data = [ 'type' => $this->type, 'pathname' => $this->pathname, 'filename' => $this->filename, - ); + ]; // @todo ThemeHandler::listInfo(), ThemeHandler::rebuildThemeData(), and // system_list() are adding custom properties to the Extension object. diff --git a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php index 0d9283c..13a3c6e 100644 --- a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php +++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php @@ -68,7 +68,7 @@ class ExtensionDiscovery { * * @var array */ - protected static $files = array(); + protected static $files = []; /** * List of installation profile directories to additionally scan. @@ -205,7 +205,7 @@ public function scan($type, $include_tests = NULL) { $include_tests = Settings::get('extension_discovery_scan_tests') || drupal_valid_test_ua(); } - $files = array(); + $files = []; foreach ($searchdirs as $dir) { // Discover all extensions in the directory, unless we did already. if (!isset(static::$files[$this->root][$dir][$include_tests])) { @@ -234,7 +234,7 @@ public function scan($type, $include_tests = NULL) { * @return $this */ public function setProfileDirectoriesFromSettings() { - $this->profileDirectories = array(); + $this->profileDirectories = []; $profile = drupal_get_profile(); // For SimpleTest to be able to test modules packaged together with a // distribution we need to include the profile of the parent site (in @@ -323,8 +323,8 @@ protected function filterByProfileDirectories(array $all_files) { * The sorted list of extensions. */ protected function sort(array $all_files, array $weights) { - $origins = array(); - $profiles = array(); + $origins = []; + $profiles = []; foreach ($all_files as $key => $file) { // If the extension does not belong to a profile, just apply the weight // of the originating directory. @@ -378,7 +378,7 @@ protected function sort(array $all_files, array $weights) { * The filtered list of extensions, keyed by extension name. */ protected function process(array $all_files) { - $files = array(); + $files = []; // Duplicate files found in later search directories take precedence over // earlier ones; they replace the extension in the existing $files array. foreach ($all_files as $file) { @@ -404,7 +404,7 @@ protected function process(array $all_files) { * @see \Drupal\Core\Extension\Discovery\RecursiveExtensionFilterIterator */ protected function scanDirectory($dir, $include_tests) { - $files = array(); + $files = []; // In order to scan top-level directories, absolute directory paths have to // be used (which also improves performance, since any configured PHP diff --git a/core/lib/Drupal/Core/Extension/InfoParser.php b/core/lib/Drupal/Core/Extension/InfoParser.php index 4981885..594a83e 100644 --- a/core/lib/Drupal/Core/Extension/InfoParser.php +++ b/core/lib/Drupal/Core/Extension/InfoParser.php @@ -12,7 +12,7 @@ class InfoParser extends InfoParserDynamic { * * @var array */ - protected static $parsedInfos = array(); + protected static $parsedInfos = []; /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index 914bb5d..3b00cea 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -15,7 +15,7 @@ class InfoParserDynamic implements InfoParserInterface { */ public function parse($filename) { if (!file_exists($filename)) { - $parsed_info = array(); + $parsed_info = []; } else { try { @@ -42,7 +42,7 @@ public function parse($filename) { * An array of required keys. */ protected function getRequiredKeys() { - return array('type', 'core', 'name'); + return ['type', 'core', 'name']; } } diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index f857bf1..cfbaa61 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -106,9 +106,9 @@ class ModuleHandler implements ModuleHandlerInterface { * @see \Drupal\Core\DrupalKernel * @see \Drupal\Core\CoreServiceProvider */ - public function __construct($root, array $module_list = array(), CacheBackendInterface $cache_backend) { + public function __construct($root, array $module_list = [], CacheBackendInterface $cache_backend) { $this->root = $root; - $this->moduleList = array(); + $this->moduleList = []; foreach ($module_list as $name => $module) { $this->moduleList[$name] = new Extension($this->root, $module['type'], $module['pathname'], $module['filename']); } @@ -178,7 +178,7 @@ public function getModule($name) { /** * {@inheritdoc} */ - public function setModuleList(array $module_list = array()) { + public function setModuleList(array $module_list = []) { $this->moduleList = $module_list; // Reset the implementations, so a new call triggers a reloading of the // available hooks. @@ -221,7 +221,7 @@ protected function add($type, $name, $path) { */ public function buildModuleDependencies(array $modules) { foreach ($modules as $module) { - $graph[$module->getName()]['edges'] = array(); + $graph[$module->getName()]['edges'] = []; if (isset($module->info['dependencies']) && is_array($module->info['dependencies'])) { foreach ($module->info['dependencies'] as $dependency) { $dependency_data = static::parseDependency($dependency); @@ -232,8 +232,8 @@ public function buildModuleDependencies(array $modules) { $graph_object = new Graph($graph); $graph = $graph_object->searchAndSort(); foreach ($graph as $module_name => $data) { - $modules[$module_name]->required_by = isset($data['reverse_paths']) ? $data['reverse_paths'] : array(); - $modules[$module_name]->requires = isset($data['paths']) ? $data['paths'] : array(); + $modules[$module_name]->required_by = isset($data['reverse_paths']) ? $data['reverse_paths'] : []; + $modules[$module_name]->requires = isset($data['paths']) ? $data['paths'] : []; $modules[$module_name]->sort = $data['weight']; } return $modules; @@ -305,7 +305,7 @@ public function getHookInfo() { * @see \Drupal\Core\Extension\ModuleHandler::getHookInfo() */ protected function buildHookInfo() { - $this->hookInfo = array(); + $this->hookInfo = []; // Make sure that the modules are loaded before checking. $this->reload(); // $this->invokeAll() would cause an infinite recursion. @@ -356,7 +356,7 @@ public function resetImplementations() { // invoked, since this can quickly lead to // \Drupal::moduleHandler()->implementsHook() being called several thousand // times per request. - $this->cacheBackend->set('module_implements', array()); + $this->cacheBackend->set('module_implements', []); $this->cacheBackend->delete('hook_info'); } @@ -383,7 +383,7 @@ public function implementsHook($module, $hook) { /** * {@inheritdoc} */ - public function invoke($module, $hook, array $args = array()) { + public function invoke($module, $hook, array $args = []) { if (!$this->implementsHook($module, $hook)) { return; } @@ -394,8 +394,8 @@ public function invoke($module, $hook, array $args = array()) { /** * {@inheritdoc} */ - public function invokeAll($hook, array $args = array()) { - $return = array(); + public function invokeAll($hook, array $args = []) { + $return = []; $implementations = $this->getImplementations($hook); foreach ($implementations as $module) { $function = $module . '_' . $hook; @@ -438,7 +438,7 @@ public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { // list of functions to call, and on subsequent calls, iterate through them // quickly. if (!isset($this->alterFunctions[$cid])) { - $this->alterFunctions[$cid] = array(); + $this->alterFunctions[$cid] = []; $hook = $type . '_alter'; $modules = $this->getImplementations($hook); if (!isset($extra_types)) { @@ -452,7 +452,7 @@ public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { else { // For multiple hooks, we need $modules to contain every module that // implements at least one of them. - $extra_modules = array(); + $extra_modules = []; foreach ($extra_types as $extra_type) { $extra_modules = array_merge($extra_modules, $this->getImplementations($extra_type . '_alter')); } @@ -516,8 +516,8 @@ public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) { */ protected function getImplementationInfo($hook) { if (!isset($this->implementations)) { - $this->implementations = array(); - $this->verified = array(); + $this->implementations = []; + $this->verified = []; if ($cache = $this->cacheBackend->get('module_implements')) { $this->implementations = $cache->data; } @@ -561,7 +561,7 @@ protected function getImplementationInfo($hook) { * @see \Drupal\Core\Extension\ModuleHandler::getImplementationInfo() */ protected function buildImplementationInfo($hook) { - $implementations = array(); + $implementations = []; $hook_info = $this->getHookInfo(); foreach ($this->moduleList as $module => $extension) { $include_file = isset($hook_info[$hook]['group']) && $this->loadInclude($module, 'inc', $module . '.' . $hook_info[$hook]['group']); @@ -658,7 +658,7 @@ protected function verifyImplementations(&$implementations, $hook) { * @see drupal_check_incompatibility() */ public static function parseDependency($dependency) { - $value = array(); + $value = []; // Split out the optional project name. if (strpos($dependency, ':') !== FALSE) { list($project_name, $dependency) = explode(':', $dependency); @@ -691,11 +691,11 @@ public static function parseDependency($dependency) { } // Equivalence can be checked by adding two restrictions. if ($op == '=' || $op == '==') { - $value['versions'][] = array('op' => '<', 'version' => ($matches['major'] + 1) . '.x'); + $value['versions'][] = ['op' => '<', 'version' => ($matches['major'] + 1) . '.x']; $op = '>='; } } - $value['versions'][] = array('op' => $op, 'version' => $matches['major'] . '.' . $matches['minor']); + $value['versions'][] = ['op' => $op, 'version' => $matches['major'] . '.' . $matches['minor']]; } } } @@ -706,7 +706,7 @@ public static function parseDependency($dependency) { * {@inheritdoc} */ public function getModuleDirectories() { - $dirs = array(); + $dirs = []; foreach ($this->getModuleList() as $name => $module) { $dirs[$name] = $this->root . '/' . $module->getPath(); } diff --git a/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php b/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php index e0336dd..6b2738c 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php @@ -73,7 +73,7 @@ public function getModule($name); * An associative array whose keys are the names of the modules and whose * values are Extension objects. */ - public function setModuleList(array $module_list = array()); + public function setModuleList(array $module_list = []); /** * Adds a module to the list of currently active modules. @@ -220,7 +220,7 @@ public function implementsHook($module, $hook); * @return mixed * The return value of the hook implementation. */ - public function invoke($module, $hook, array $args = array()); + public function invoke($module, $hook, array $args = []); /** * Invokes a hook in all enabled modules that implement it. @@ -236,7 +236,7 @@ public function invoke($module, $hook, array $args = array()); * recursively. Note: integer keys in arrays will be lost, as the merge is * done using array_merge_recursive(). */ - public function invokeAll($hook, array $args = array()); + public function invokeAll($hook, array $args = []); /** * Passes alterable variables to specific hook_TYPE_alter() implementations. diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index 0dfe322..102b500 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -79,14 +79,14 @@ public function install(array $module_list, $enable_dependencies = TRUE) { if ($enable_dependencies) { // Get all module data so we can find dependencies and sort. $module_data = system_rebuild_module_data(); - $module_list = $module_list ? array_combine($module_list, $module_list) : array(); + $module_list = $module_list ? array_combine($module_list, $module_list) : []; if ($missing_modules = array_diff_key($module_list, $module_data)) { // One or more of the given modules doesn't exist. throw new MissingDependencyException(sprintf('Unable to install modules %s due to missing modules %s.', implode(', ', $module_list), implode(', ', $missing_modules))); } // Only process currently uninstalled modules. - $installed_modules = $extension_config->get('module') ?: array(); + $installed_modules = $extension_config->get('module') ?: []; if (!$module_list = array_diff_key($module_list, $installed_modules)) { // Nothing to do. All modules already installed. return TRUE; @@ -127,7 +127,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { if ($sync_status) { $source_storage = $config_installer->getSourceStorage(); } - $modules_installed = array(); + $modules_installed = []; foreach ($module_list as $module) { $enabled = $extension_config->get("module.$module") !== NULL; if (!$enabled) { @@ -160,7 +160,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { $current_module_filenames = $this->moduleHandler->getModuleList(); $current_modules = array_fill_keys(array_keys($current_module_filenames), 0); $current_modules = module_config_sort(array_merge($current_modules, $extension_config->get('module'))); - $module_filenames = array(); + $module_filenames = []; foreach ($current_modules as $name => $weight) { if (isset($current_module_filenames[$name])) { $module_filenames[$name] = $current_module_filenames[$name]; @@ -191,7 +191,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { $this->updateKernel($module_filenames); // Allow modules to react prior to the installation of a module. - $this->moduleHandler->invokeAll('module_preinstall', array($module)); + $this->moduleHandler->invokeAll('module_preinstall', [$module]); // Now install the module's schema if necessary. drupal_install_schema($module); @@ -287,7 +287,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { $this->moduleHandler->invoke($module, 'install'); // Record the fact that it was installed. - \Drupal::logger('system')->info('%module module installed.', array('%module' => $module)); + \Drupal::logger('system')->info('%module module installed.', ['%module' => $module]); } } @@ -302,7 +302,7 @@ public function install(array $module_list, $enable_dependencies = TRUE) { \Drupal::service('router.builder')->rebuild(); } - $this->moduleHandler->invokeAll('modules_installed', array($modules_installed)); + $this->moduleHandler->invokeAll('modules_installed', [$modules_installed]); } return TRUE; @@ -314,14 +314,14 @@ public function install(array $module_list, $enable_dependencies = TRUE) { public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // Get all module data so we can find dependencies and sort. $module_data = system_rebuild_module_data(); - $module_list = $module_list ? array_combine($module_list, $module_list) : array(); + $module_list = $module_list ? array_combine($module_list, $module_list) : []; if (array_diff_key($module_list, $module_data)) { // One or more of the given modules doesn't exist. return FALSE; } $extension_config = \Drupal::configFactory()->getEditable('core.extension'); - $installed_modules = $extension_config->get('module') ?: array(); + $installed_modules = $extension_config->get('module') ?: []; if (!$module_list = array_intersect_key($module_list, $installed_modules)) { // Nothing to do. All modules already uninstalled. return TRUE; @@ -381,7 +381,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { } // Allow modules to react prior to the uninstallation of a module. - $this->moduleHandler->invokeAll('module_preuninstall', array($module)); + $this->moduleHandler->invokeAll('module_preuninstall', [$module]); // Uninstall the module. module_load_install($module); @@ -457,7 +457,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { // @see https://www.drupal.org/node/2208429 \Drupal::service('theme_handler')->refreshInfo(); - \Drupal::logger('system')->info('%module module uninstalled.', array('%module' => $module)); + \Drupal::logger('system')->info('%module module uninstalled.', ['%module' => $module]); $schema_store = \Drupal::keyValue('system.schema'); $schema_store->delete($module); @@ -474,7 +474,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) { drupal_get_installed_schema_version(NULL, TRUE); // Let other modules react. - $this->moduleHandler->invokeAll('modules_uninstalled', array($module_list)); + $this->moduleHandler->invokeAll('modules_uninstalled', [$module_list]); // Flush all persistent caches. // Any cache entry might implicitly depend on the uninstalled modules, @@ -509,14 +509,14 @@ protected function removeCacheBins($module) { try { $factory = \Drupal::service($definition['factory_service']); if (method_exists($factory, $definition['factory_method'])) { - $backend = call_user_func_array(array($factory, $definition['factory_method']), $definition['arguments']); + $backend = call_user_func_array([$factory, $definition['factory_method']], $definition['arguments']); if ($backend instanceof CacheBackendInterface) { $backend->removeBin(); } } } catch (\Exception $e) { - watchdog_exception('system', $e, 'Failed to remove cache bin defined by the service %id.', array('%id' => $id)); + watchdog_exception('system', $e, 'Failed to remove cache bin defined by the service %id.', ['%id' => $id]); } } } @@ -548,13 +548,13 @@ protected function updateKernel($module_filenames) { * {@inheritdoc} */ public function validateUninstall(array $module_list) { - $reasons = array(); + $reasons = []; foreach ($module_list as $module) { foreach ($this->uninstallValidators as $validator) { $validation_reasons = $validator->validate($module); if (!empty($validation_reasons)) { if (!isset($reasons[$module])) { - $reasons[$module] = array(); + $reasons[$module] = []; } $reasons[$module] = array_merge($reasons[$module], $validation_reasons); } diff --git a/core/lib/Drupal/Core/Extension/ThemeHandler.php b/core/lib/Drupal/Core/Extension/ThemeHandler.php index 3363efc..2fd75e1 100644 --- a/core/lib/Drupal/Core/Extension/ThemeHandler.php +++ b/core/lib/Drupal/Core/Extension/ThemeHandler.php @@ -17,13 +17,13 @@ class ThemeHandler implements ThemeHandlerInterface { * * @see _system_default_theme_features() */ - protected $defaultFeatures = array( + protected $defaultFeatures = [ 'favicon', 'logo', 'node_user_picture', 'comment_user_picture', 'comment_user_verification', - ); + ]; /** * A list of all currently available themes. @@ -178,14 +178,14 @@ public function uninstall(array $theme_list) { */ public function listInfo() { if (!isset($this->list)) { - $this->list = array(); + $this->list = []; $themes = $this->systemThemeList(); // @todo Ensure that systemThemeList() does not contain an empty list // during the batch installer, see https://www.drupal.org/node/2322619. if (empty($themes)) { $this->refreshInfo(); - $this->list = $this->list ?: array(); - $themes = \Drupal::state()->get('system.theme.data', array()); + $this->list = $this->list ?: []; + $themes = \Drupal::state()->get('system.theme.data', []); } foreach ($themes as $theme) { $this->addTheme($theme); @@ -247,13 +247,13 @@ public function rebuildThemeData() { $themes = $listing->scan('theme'); $engines = $listing->scan('theme_engine'); $extension_config = $this->configFactory->get('core.extension'); - $installed = $extension_config->get('theme') ?: array(); + $installed = $extension_config->get('theme') ?: []; // Set defaults for theme info. - $defaults = array( + $defaults = [ 'engine' => 'twig', 'base theme' => 'stable', - 'regions' => array( + 'regions' => [ 'sidebar_first' => 'Left sidebar', 'sidebar_second' => 'Right sidebar', 'content' => 'Content', @@ -266,17 +266,17 @@ public function rebuildThemeData() { 'page_top' => 'Page top', 'page_bottom' => 'Page bottom', 'breadcrumb' => 'Breadcrumb', - ), + ], 'description' => '', 'features' => $this->defaultFeatures, 'screenshot' => 'screenshot.png', 'php' => DRUPAL_MINIMUM_PHP, - 'libraries' => array(), - ); + 'libraries' => [], + ]; - $sub_themes = array(); - $files_theme = array(); - $files_theme_engine = array(); + $sub_themes = []; + $files_theme = []; + $files_theme_engine = []; // Read info files for each theme. foreach ($themes as $key => $theme) { // @todo Remove all code that relies on the $status property. @@ -382,18 +382,18 @@ public function getBaseThemes(array $themes, $theme) { * @return array * An array of base themes. */ - protected function doGetBaseThemes(array $themes, $theme, $used_themes = array()) { + protected function doGetBaseThemes(array $themes, $theme, $used_themes = []) { if (!isset($themes[$theme]->info['base theme'])) { - return array(); + return []; } $base_key = $themes[$theme]->info['base theme']; // Does the base theme exist? if (!isset($themes[$base_key])) { - return array($base_key => NULL); + return [$base_key => NULL]; } - $current_base_theme = array($base_key => $themes[$base_key]->info['name']); + $current_base_theme = [$base_key => $themes[$base_key]->info['name']]; // Is the base theme itself a child of another theme? if (isset($themes[$base_key]->info['base theme'])) { @@ -403,7 +403,7 @@ protected function doGetBaseThemes(array $themes, $theme, $used_themes = array() } // Prevent loops. if (!empty($used_themes[$base_key])) { - return array($base_key => NULL); + return [$base_key => NULL]; } $used_themes[$base_key] = TRUE; return $this->doGetBaseThemes($themes, $base_key, $used_themes) + $current_base_theme; @@ -457,7 +457,7 @@ protected function systemThemeList() { * {@inheritdoc} */ public function getThemeDirectories() { - $dirs = array(); + $dirs = []; foreach ($this->listInfo() as $name => $theme) { $dirs[$name] = $this->root . '/' . $theme->getPath(); } diff --git a/core/lib/Drupal/Core/Extension/ThemeInstaller.php b/core/lib/Drupal/Core/Extension/ThemeInstaller.php index 050e04a..37cb252 100644 --- a/core/lib/Drupal/Core/Extension/ThemeInstaller.php +++ b/core/lib/Drupal/Core/Extension/ThemeInstaller.php @@ -111,7 +111,7 @@ public function install(array $theme_list, $install_dependencies = TRUE) { } // Only process themes that are not installed currently. - $installed_themes = $extension_config->get('theme') ?: array(); + $installed_themes = $extension_config->get('theme') ?: []; if (!$theme_list = array_diff_key($theme_list, $installed_themes)) { // Nothing to do. All themes already installed. return TRUE; @@ -143,10 +143,10 @@ public function install(array $theme_list, $install_dependencies = TRUE) { $theme_list = array_keys($theme_list); } else { - $installed_themes = $extension_config->get('theme') ?: array(); + $installed_themes = $extension_config->get('theme') ?: []; } - $themes_installed = array(); + $themes_installed = []; foreach ($theme_list as $key) { // Only process themes that are not already installed. $installed = $extension_config->get("theme.$key") !== NULL; @@ -175,7 +175,7 @@ public function install(array $theme_list, $install_dependencies = TRUE) { $this->themeHandler->addTheme($theme_data[$key]); // Update the current theme data accordingly. - $current_theme_data = $this->state->get('system.theme.data', array()); + $current_theme_data = $this->state->get('system.theme.data', []); $current_theme_data[$key] = $theme_data[$key]; $this->state->set('system.theme.data', $current_theme_data); @@ -196,14 +196,14 @@ public function install(array $theme_list, $install_dependencies = TRUE) { $themes_installed[] = $key; // Record the fact that it was installed. - $this->logger->info('%theme theme installed.', array('%theme' => $key)); + $this->logger->info('%theme theme installed.', ['%theme' => $key]); } $this->cssCollectionOptimizer->deleteAll(); $this->resetSystem(); // Invoke hook_themes_installed() after the themes have been installed. - $this->moduleHandler->invokeAll('themes_installed', array($themes_installed)); + $this->moduleHandler->invokeAll('themes_installed', [$themes_installed]); return !empty($themes_installed); } @@ -240,7 +240,7 @@ public function uninstall(array $theme_list) { } $this->cssCollectionOptimizer->deleteAll(); - $current_theme_data = $this->state->get('system.theme.data', array()); + $current_theme_data = $this->state->get('system.theme.data', []); foreach ($theme_list as $key) { // The value is not used; the weight is ignored for themes currently. $extension_config->clear("theme.$key"); @@ -280,7 +280,7 @@ protected function resetSystem() { // @todo It feels wrong to have the requirement to clear the local tasks // cache here. - Cache::invalidateTags(array('local_task')); + Cache::invalidateTags(['local_task']); $this->themeRegistryRebuild(); } diff --git a/core/lib/Drupal/Core/Extension/module.api.php b/core/lib/Drupal/Core/Extension/module.api.php index 74fc766..944d354 100644 --- a/core/lib/Drupal/Core/Extension/module.api.php +++ b/core/lib/Drupal/Core/Extension/module.api.php @@ -84,12 +84,12 @@ * @see hook_hook_info_alter() */ function hook_hook_info() { - $hooks['token_info'] = array( + $hooks['token_info'] = [ 'group' => 'tokens', - ); - $hooks['tokens'] = array( + ]; + $hooks['tokens'] = [ 'group' => 'tokens', - ); + ]; return $hooks; } @@ -398,7 +398,7 @@ function hook_install_tasks(&$install_state) { // processor-intensive batch process needs to be triggered later on in the // installation. $myprofile_needs_batch_processing = \Drupal::state()->get('myprofile.needs_batch_processing', FALSE); - $tasks = array( + $tasks = [ // This is an example of a task that defines a form which the user who is // installing the site will be asked to fill out. To implement this task, // your profile would define a function named myprofile_data_import_form() @@ -408,10 +408,10 @@ function hook_install_tasks(&$install_state) { // \Drupal::state()->set('myprofile.needs_batch_processing', TRUE) if the // user has entered data which requires that batch processing will need to // occur later on. - 'myprofile_data_import_form' => array( + 'myprofile_data_import_form' => [ 'display_name' => t('Data import options'), 'type' => 'form', - ), + ], // Similarly, to implement this task, your profile would define a function // named myprofile_settings_form() with associated validation and submit // handlers. This form might be used to collect and save additional @@ -419,10 +419,10 @@ function hook_install_tasks(&$install_state) { // steps required for your profile to act as an "installation wizard"; you // can simply define as many tasks of type 'form' as you wish to execute, // and the forms will be presented to the user, one after another. - 'myprofile_settings_form' => array( + 'myprofile_settings_form' => [ 'display_name' => t('Additional options'), 'type' => 'form', - ), + ], // This is an example of a task that performs batch operations. To // implement this task, your profile would define a function named // myprofile_batch_processing() which returns a batch API array definition @@ -430,12 +430,12 @@ function hook_install_tasks(&$install_state) { // 'myprofile.needs_batch_processing' variable used here, this task will be // hidden and skipped unless your profile set it to TRUE in one of the // previous tasks. - 'myprofile_batch_processing' => array( + 'myprofile_batch_processing' => [ 'display_name' => t('Import additional data'), 'display' => $myprofile_needs_batch_processing, 'type' => 'batch', 'run' => $myprofile_needs_batch_processing ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP, - ), + ], // This is an example of a task that will not be displayed in the list that // the user sees. To implement this task, your profile would define a // function named myprofile_final_site_setup(), in which additional, @@ -449,9 +449,9 @@ function hook_install_tasks(&$install_state) { // tasks are complete, with a link to reload the current page and therefore // pass on to the final Drupal installation tasks when the user is ready to // do so). - 'myprofile_final_site_setup' => array( - ), - ); + 'myprofile_final_site_setup' => [ + ], + ]; return $tasks; } @@ -622,12 +622,12 @@ function hook_update_N(&$sandbox) { // Example function body for adding a field to a database table, which does // not require a batch operation: - $spec = array( + $spec = [ 'type' => 'varchar', 'description' => "New Col", 'length' => 20, 'not null' => FALSE, - ); + ]; $schema = Database::getConnection()->schema(); $schema->addField('mytable1', 'newcol', $spec); @@ -647,7 +647,7 @@ function hook_update_N(&$sandbox) { // Update in chunks of 20. $records = Database::getConnection()->select('mytable1', 'm') - ->fields('m', array('myprimarykey', 'otherfield')) + ->fields('m', ['myprimarykey', 'otherfield']) ->condition('myprimarykey', $sandbox['current_pk'], '>') ->range(0, 20) ->orderBy('myprimarykey', 'ASC') @@ -656,7 +656,7 @@ function hook_update_N(&$sandbox) { // Here, you would make an update something related to this record. In this // example, some text is added to the other field. Database::getConnection()->update('mytable1') - ->fields(array('otherfield' => $record->otherfield . '-suffix')) + ->fields(['otherfield' => $record->otherfield . '-suffix']) ->condition('myprimarykey', $record->myprimarykey) ->execute(); @@ -767,9 +767,9 @@ function hook_update_dependencies() { // Indicate that the mymodule_update_8001() function provided by this module // must run after the another_module_update_8003() function provided by the // 'another_module' module. - $dependencies['mymodule'][8001] = array( + $dependencies['mymodule'][8001] = [ 'another_module' => 8003, - ); + ]; // Indicate that the mymodule_update_8002() function provided by this module // must run before the yet_another_module_update_8005() function provided by // the 'yet_another_module' module. (Note that declaring dependencies in this @@ -777,9 +777,9 @@ function hook_update_dependencies() { // following problem: If a site has already run the yet_another_module // module's database updates before it updates its codebase to pick up the // newest mymodule code, then the dependency declared here will be ignored.) - $dependencies['yet_another_module'][8005] = array( + $dependencies['yet_another_module'][8005] = [ 'mymodule' => 8002, - ); + ]; return $dependencies; } @@ -834,18 +834,18 @@ function hook_update_last_removed() { * @see hook_updater_info_alter() */ function hook_updater_info() { - return array( - 'module' => array( + return [ + 'module' => [ 'class' => 'Drupal\Core\Updater\Module', 'name' => t('Update modules'), 'weight' => 0, - ), - 'theme' => array( + ], + 'theme' => [ 'class' => 'Drupal\Core\Updater\Theme', 'name' => t('Update themes'), 'weight' => 0, - ), - ); + ], + ]; } /** @@ -928,24 +928,24 @@ function hook_updater_info_alter(&$updaters) { * - REQUIREMENT_ERROR: The requirement failed with an error. */ function hook_requirements($phase) { - $requirements = array(); + $requirements = []; // Report Drupal version if ($phase == 'runtime') { - $requirements['drupal'] = array( + $requirements['drupal'] = [ 'title' => t('Drupal'), 'value' => \Drupal::VERSION, 'severity' => REQUIREMENT_INFO - ); + ]; } // Test PHP version - $requirements['php'] = array( + $requirements['php'] = [ 'title' => t('PHP'), 'value' => ($phase == 'runtime') ? \Drupal::l(phpversion(), new Url('system.php')) : phpversion(), - ); + ]; if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) { - $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', array('%version' => DRUPAL_MINIMUM_PHP)); + $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => DRUPAL_MINIMUM_PHP]); $requirements['php']['severity'] = REQUIREMENT_ERROR; } @@ -954,17 +954,17 @@ function hook_requirements($phase) { $cron_last = \Drupal::state()->get('system.cron_last'); if (is_numeric($cron_last)) { - $requirements['cron']['value'] = t('Last run @time ago', array('@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last))); + $requirements['cron']['value'] = t('Last run @time ago', ['@time' => \Drupal::service('date.formatter')->formatTimeDiffSince($cron_last)]); } else { - $requirements['cron'] = array( - 'description' => t('Cron has not run. It appears cron jobs have not been setup on your system. Check the help pages for configuring cron jobs.', array(':url' => 'https://www.drupal.org/cron')), + $requirements['cron'] = [ + 'description' => t('Cron has not run. It appears cron jobs have not been setup on your system. Check the help pages for configuring cron jobs.', [':url' => 'https://www.drupal.org/cron']), 'severity' => REQUIREMENT_ERROR, 'value' => t('Never run'), - ); + ]; } - $requirements['cron']['description'] .= ' ' . t('You can run cron manually.', array(':cron' => \Drupal::url('system.run_cron'))); + $requirements['cron']['description'] .= ' ' . t('You can run cron manually.', [':cron' => \Drupal::url('system.run_cron')]); $requirements['cron']['title'] = t('Cron maintenance tasks'); } diff --git a/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php b/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php index 92786b1..1a24391 100644 --- a/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php +++ b/core/lib/Drupal/Core/Field/Annotation/FieldFormatter.php @@ -61,7 +61,7 @@ class FieldFormatter extends Plugin { * * @var array */ - public $field_types = array(); + public $field_types = []; /** * An integer to determine the weight of this formatter relative to other diff --git a/core/lib/Drupal/Core/Field/Annotation/FieldWidget.php b/core/lib/Drupal/Core/Field/Annotation/FieldWidget.php index 22d7796..38d3f86 100644 --- a/core/lib/Drupal/Core/Field/Annotation/FieldWidget.php +++ b/core/lib/Drupal/Core/Field/Annotation/FieldWidget.php @@ -60,7 +60,7 @@ class FieldWidget extends Plugin { * * @var array */ - public $field_types = array(); + public $field_types = []; /** * Does the field widget handles multiple values at once. diff --git a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php index 594f31d..199e80a 100644 --- a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php +++ b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php @@ -42,7 +42,7 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI /** * @var array */ - protected $indexes = array(); + protected $indexes = []; /** * Creates a new field definition. @@ -54,7 +54,7 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI * A new field definition object. */ public static function create($type) { - $field_definition = new static(array()); + $field_definition = new static([]); $field_definition->type = $type; $field_definition->itemDefinition = FieldItemDataDefinition::create($field_definition); // Create a definition for the items, and initialize it with the default @@ -414,7 +414,7 @@ public function setDisplayOptions($display_context, array $options) { public function setDisplayConfigurable($display_context, $configurable) { // If no explicit display options have been specified, default to 'hidden'. if (empty($this->definition['display'][$display_context])) { - $this->definition['display'][$display_context]['options'] = array('type' => 'hidden'); + $this->definition['display'][$display_context]['options'] = ['type' => 'hidden']; } $this->definition['display'][$display_context]['configurable'] = $configurable; return $this; @@ -463,9 +463,9 @@ public function getDefaultValue(FieldableEntityInterface $entity) { if (isset($value) && !is_array($value)) { $properties = $this->getPropertyNames(); $property = reset($properties); - $value = array( - array($property => $value), - ); + $value = [ + [$property => $value], + ]; } // Allow the field type to process default values. $field_item_list_class = $this->getClass(); @@ -482,10 +482,10 @@ public function setDefaultValue($value) { // Unless the value is an empty array, we may need to transform it. if (!is_array($value) || !empty($value)) { if (!is_array($value)) { - $value = array(array($this->getMainPropertyName() => $value)); + $value = [[$this->getMainPropertyName() => $value]]; } elseif (is_array($value) && !is_numeric(array_keys($value)[0])) { - $value = array(0 => $value); + $value = [0 => $value]; } } $this->definition['default_value'] = $value; @@ -633,12 +633,12 @@ public function getSchema() { $class = $definition['class']; $schema = $class::schema($this); // Fill in default values. - $schema += array( - 'columns' => array(), - 'unique keys' => array(), - 'indexes' => array(), - 'foreign keys' => array(), - ); + $schema += [ + 'columns' => [], + 'unique keys' => [], + 'indexes' => [], + 'foreign keys' => [], + ]; // Merge custom indexes with those specified by the field type. Custom // indexes prevail. diff --git a/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php b/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php index d21ac96..0a53d98 100644 --- a/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php +++ b/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php @@ -25,12 +25,12 @@ public function getConstraints() { */ public function referencedEntities() { if (empty($this->list)) { - return array(); + return []; } // Collect the IDs of existing entities to load, and directly grab the // "autocreate" entities that are already populated in $item->entity. - $target_entities = $ids = array(); + $target_entities = $ids = []; foreach ($this->list as $delta => $item) { if ($item->target_id !== NULL) { $ids[$delta] = $item->target_id; @@ -64,7 +64,7 @@ public static function processDefaultValue($default_value, FieldableEntityInterf if ($default_value) { // Convert UUIDs to numeric IDs. - $uuids = array(); + $uuids = []; foreach ($default_value as $delta => $properties) { if (isset($properties['target_uuid'])) { $uuids[$delta] = $properties['target_uuid']; @@ -79,7 +79,7 @@ public static function processDefaultValue($default_value, FieldableEntityInterf ->getStorage($target_type) ->loadMultiple($entity_ids); - $entity_uuids = array(); + $entity_uuids = []; foreach ($entities as $id => $entity) { $entity_uuids[$entity->uuid()] = $id; } @@ -107,7 +107,7 @@ public function defaultValuesFormSubmit(array $element, array &$form, FormStateI $default_value = parent::defaultValuesFormSubmit($element, $form, $form_state); // Convert numeric IDs to UUIDs to ensure config deployability. - $ids = array(); + $ids = []; foreach ($default_value as $delta => $properties) { if (isset($properties['entity']) && $properties['entity']->isNew()) { // This may be a newly created term. diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php index d7ddd18..76366bf 100644 --- a/core/lib/Drupal/Core/Field/FieldConfigBase.php +++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php @@ -89,7 +89,7 @@ * * @var array */ - protected $settings = array(); + protected $settings = []; /** * Flag indicating whether the field is required. @@ -139,7 +139,7 @@ * * @var array */ - protected $default_value = array(); + protected $default_value = []; /** * The name of a callback function that returns default values. @@ -413,9 +413,9 @@ public function setDefaultValue($value) { $key = $this->getFieldStorageDefinition()->getPropertyNames()[0]; // Convert to the multi value format to support fields with a cardinality // greater than 1. - $value = array( - array($key => $value), - ); + $value = [ + [$key => $value], + ]; } $this->default_value = $value; return $this; diff --git a/core/lib/Drupal/Core/Field/FieldItemBase.php b/core/lib/Drupal/Core/Field/FieldItemBase.php index d489c8e..84d73ec 100644 --- a/core/lib/Drupal/Core/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Field/FieldItemBase.php @@ -23,14 +23,14 @@ * {@inheritdoc} */ public static function defaultStorageSettings() { - return array(); + return []; } /** * {@inheritdoc} */ public static function defaultFieldSettings() { - return array(); + return []; } /** @@ -106,7 +106,7 @@ public function setValue($values, $notify = TRUE) { // given. if (isset($values) && !is_array($values)) { $keys = array_keys($this->definition->getPropertyDefinitions()); - $values = array($keys[0] => $values); + $values = [$keys[0] => $values]; } parent::setValue($values, $notify); } @@ -183,7 +183,7 @@ public function __unset($name) { /** * {@inheritdoc} */ - public function view($display_options = array()) { + public function view($display_options = []) { $view_builder = \Drupal::entityManager()->getViewBuilder($this->getEntity()->getEntityTypeId()); return $view_builder->viewFieldItem($this, $display_options); } @@ -217,14 +217,14 @@ public function deleteRevision() { } * {@inheritdoc} */ public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) { - return array(); + return []; } /** * {@inheritdoc} */ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { - return array(); + return []; } /** @@ -259,7 +259,7 @@ public static function fieldSettingsFromConfigData(array $settings) { * {@inheritdoc} */ public static function calculateDependencies(FieldDefinitionInterface $field_definition) { - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Field/FieldItemInterface.php b/core/lib/Drupal/Core/Field/FieldItemInterface.php index a257dd0..69906c1 100644 --- a/core/lib/Drupal/Core/Field/FieldItemInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemInterface.php @@ -173,7 +173,7 @@ public function __unset($property_name); * @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewFieldItem() * @see \Drupal\Core\Field\FieldItemListInterface::view() */ - public function view($display_options = array()); + public function view($display_options = []); /** * Defines custom presave behavior for field values. diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index ebdb276..787f9be 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -24,7 +24,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface { * * @var \Drupal\Core\Field\FieldItemInterface[] */ - protected $list = array(); + protected $list = []; /** * The langcode of the field values held in the object. @@ -99,7 +99,7 @@ public function filterEmptyItems() { * @todo Revisit the need when all entity types are converted to NG entities. */ public function getValue($include_computed = FALSE) { - $values = array(); + $values = []; foreach ($this->list as $delta => $item) { $values[$delta] = $item->getValue($include_computed); } @@ -113,7 +113,7 @@ public function setValue($values, $notify = TRUE) { // Support passing in only the value of the first item, either as a literal // (value of the first property) or as an array of properties. if (isset($values) && (!is_array($values) || (!empty($values) && !is_numeric(current(array_keys($values)))))) { - $values = array(0 => $values); + $values = [0 => $values]; } parent::setValue($values, $notify); } @@ -249,7 +249,7 @@ protected function delegateMethod($method) { /** * {@inheritdoc} */ - public function view($display_options = array()) { + public function view($display_options = []) { $view_builder = \Drupal::entityManager()->getViewBuilder($this->getEntity()->getEntityTypeId()); return $view_builder->viewField($this, $display_options); } @@ -278,10 +278,10 @@ public function getConstraints() { if ($cardinality != FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { $constraints[] = $this->getTypedDataManager() ->getValidationConstraintManager() - ->create('Count', array( + ->create('Count', [ 'max' => $cardinality, - 'maxMessage' => t('%name: this field cannot hold more than @count values.', array('%name' => $this->getFieldDefinition()->getLabel(), '@count' => $cardinality)), - )); + 'maxMessage' => t('%name: this field cannot hold more than @count values.', ['%name' => $this->getFieldDefinition()->getLabel(), '@count' => $cardinality]), + ]); } return $constraints; @@ -294,7 +294,7 @@ public function defaultValuesForm(array &$form, FormStateInterface $form_state) if (empty($this->getFieldDefinition()->getDefaultValueCallback())) { if ($widget = $this->defaultValueWidget($form_state)) { // Place the input in a separate place in the submitted values tree. - $element = array('#parents' => array('default_value_input')); + $element = ['#parents' => ['default_value_input']]; $element += $widget->form($this, $element, $form_state); return $element; @@ -365,7 +365,7 @@ protected function defaultValueWidget(FormStateInterface $form_state) { $entity_form_display = entity_get_form_display($entity->getEntityTypeId(), $entity->bundle(), 'default'); $widget = $entity_form_display->getRenderer($this->getFieldDefinition()->getName()); if (!$widget) { - $widget = \Drupal::service('plugin.manager.field.widget')->getInstance(array('field_definition' => $this->getFieldDefinition())); + $widget = \Drupal::service('plugin.manager.field.widget')->getInstance(['field_definition' => $this->getFieldDefinition()]); } $form_state->set('default_value_widget', $widget); diff --git a/core/lib/Drupal/Core/Field/FieldItemListInterface.php b/core/lib/Drupal/Core/Field/FieldItemListInterface.php index 2266c9c..1cd4c3f 100644 --- a/core/lib/Drupal/Core/Field/FieldItemListInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemListInterface.php @@ -179,7 +179,7 @@ public function deleteRevision(); * @see \Drupal\Core\Entity\EntityViewBuilderInterface::viewField() * @see \Drupal\Core\Field\FieldItemInterface::view() */ - public function view($display_options = array()); + public function view($display_options = []); /** * Populates a specified number of field items with valid sample data. diff --git a/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php b/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php index d1adaa9..c45ef90 100644 --- a/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php +++ b/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php @@ -34,7 +34,7 @@ public function __construct(EntityManagerInterface $entity_manager, TranslationI * {@inheritdoc} */ public function validate($module_name) { - $reasons = array(); + $reasons = []; // We skip fields provided by the Field module as it implements field // purging. @@ -48,10 +48,10 @@ public function validate($module_name) { if ($storage_definition->getProvider() == $module_name) { $storage = $this->entityManager->getStorage($entity_type_id); if ($storage instanceof FieldableEntityStorageInterface && $storage->countFieldData($storage_definition, TRUE)) { - $reasons[] = $this->t('There is data for the field @field-name on entity type @entity_type', array( + $reasons[] = $this->t('There is data for the field @field-name on entity type @entity_type', [ '@field-name' => $storage_definition->getName(), '@entity_type' => $entity_type->getLabel(), - )); + ]); } } } diff --git a/core/lib/Drupal/Core/Field/FieldStorageDefinitionEventSubscriberTrait.php b/core/lib/Drupal/Core/Field/FieldStorageDefinitionEventSubscriberTrait.php index 5ac4b6e..895045b 100644 --- a/core/lib/Drupal/Core/Field/FieldStorageDefinitionEventSubscriberTrait.php +++ b/core/lib/Drupal/Core/Field/FieldStorageDefinitionEventSubscriberTrait.php @@ -22,7 +22,7 @@ * @see \Symfony\Component\EventDispatcher\EventSubscriberInterface::getSubscribedEvents() */ public static function getFieldStorageDefinitionEvents() { - $event = array('onFieldStorageDefinitionEvent', 100); + $event = ['onFieldStorageDefinitionEvent', 100]; $events[FieldStorageDefinitionEvents::CREATE][] = $event; $events[FieldStorageDefinitionEvents::UPDATE][] = $event; $events[FieldStorageDefinitionEvents::DELETE][] = $event; diff --git a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php index 09c6a12..df55295 100644 --- a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php +++ b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php @@ -61,7 +61,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac * @return \Drupal\Core\Field\FieldItemInterface * The instantiated object. */ - public function createInstance($field_type, array $configuration = array()) { + public function createInstance($field_type, array $configuration = []) { $configuration['data_definition'] = $configuration['field_definition']->getItemDefinition(); return $this->typedDataManager->createInstance("field_item:$field_type", $configuration); } @@ -106,7 +106,7 @@ public function getDefaultStorageSettings($type) { $plugin_class = DefaultFactory::getPluginClass($type, $plugin_definition); return $plugin_class::defaultStorageSettings(); } - return array(); + return []; } /** @@ -118,7 +118,7 @@ public function getDefaultFieldSettings($type) { $plugin_class = DefaultFactory::getPluginClass($type, $plugin_definition); return $plugin_class::defaultFieldSettings(); } - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Field/FormatterBase.php b/core/lib/Drupal/Core/Field/FormatterBase.php index db7587a..3b3abcc 100644 --- a/core/lib/Drupal/Core/Field/FormatterBase.php +++ b/core/lib/Drupal/Core/Field/FormatterBase.php @@ -60,7 +60,7 @@ * Any third party settings. */ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings) { - parent::__construct(array(), $plugin_id, $plugin_definition); + parent::__construct([], $plugin_id, $plugin_definition); $this->fieldDefinition = $field_definition; $this->settings = $settings; @@ -85,7 +85,7 @@ public function view(FieldItemListInterface $items, $langcode = NULL) { $entity = $items->getEntity(); $entity_type = $entity->getEntityTypeId(); $field_name = $this->fieldDefinition->getName(); - $info = array( + $info = [ '#theme' => 'field', '#title' => $this->fieldDefinition->getLabel(), '#label_display' => $this->label, @@ -100,7 +100,7 @@ public function view(FieldItemListInterface $items, $langcode = NULL) { '#items' => $items, '#formatter' => $this->getPluginId(), '#is_multiple' => $this->fieldDefinition->getFieldStorageDefinition()->isMultiple(), - ); + ]; $elements = array_merge($info, $elements); } @@ -112,14 +112,14 @@ public function view(FieldItemListInterface $items, $langcode = NULL) { * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - return array(); + return []; } /** * {@inheritdoc} */ public function settingsSummary() { - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Field/FormatterPluginManager.php b/core/lib/Drupal/Core/Field/FormatterPluginManager.php index ca9bd06..c4df0f5 100644 --- a/core/lib/Drupal/Core/Field/FormatterPluginManager.php +++ b/core/lib/Drupal/Core/Field/FormatterPluginManager.php @@ -52,7 +52,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac /** * {@inheritdoc} */ - public function createInstance($plugin_id, array $configuration = array()) { + public function createInstance($plugin_id, array $configuration = []) { $plugin_definition = $this->getDefinition($plugin_id); $plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition); @@ -119,10 +119,10 @@ public function getInstance(array $options) { $plugin_id = $field_type_definition['default_formatter']; } - $configuration += array( + $configuration += [ 'field_definition' => $field_definition, 'view_mode' => $options['view_mode'], - ); + ]; return $this->createInstance($plugin_id, $configuration); } @@ -139,11 +139,11 @@ public function getInstance(array $options) { */ public function prepareConfiguration($field_type, array $configuration) { // Fill in defaults for missing properties. - $configuration += array( + $configuration += [ 'label' => 'above', - 'settings' => array(), - 'third_party_settings' => array(), - ); + 'settings' => [], + 'third_party_settings' => [], + ]; // If no formatter is specified, use the default formatter. if (!isset($configuration['type'])) { $field_type = $this->fieldTypeManager->getDefinition($field_type); @@ -168,10 +168,10 @@ public function prepareConfiguration($field_type, array $configuration) { */ public function getOptions($field_type = NULL) { if (!isset($this->formatterOptions)) { - $options = array(); + $options = []; $field_types = $this->fieldTypeManager->getDefinitions(); $formatter_types = $this->getDefinitions(); - uasort($formatter_types, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); + uasort($formatter_types, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']); foreach ($formatter_types as $name => $formatter_type) { foreach ($formatter_type['field_types'] as $formatter_field_type) { // Check that the field type exists. @@ -183,7 +183,7 @@ public function getOptions($field_type = NULL) { $this->formatterOptions = $options; } if ($field_type) { - return !empty($this->formatterOptions[$field_type]) ? $this->formatterOptions[$field_type] : array(); + return !empty($this->formatterOptions[$field_type]) ? $this->formatterOptions[$field_type] : []; } return $this->formatterOptions; } @@ -204,7 +204,7 @@ public function getDefaultSettings($type) { $plugin_class = DefaultFactory::getPluginClass($type, $plugin_definition); return $plugin_class::defaultSettings(); } - return array(); + return []; } } diff --git a/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php b/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php index 0d99338..de57317 100644 --- a/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php +++ b/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php @@ -16,7 +16,7 @@ class FieldItemDeriver implements ContainerDeriverInterface { * * @var array */ - protected $derivatives = array(); + protected $derivatives = []; /** * The base plugin ID this derivative is for. diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php index 60c632a..c52a2d7b 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php @@ -67,10 +67,10 @@ public function settingsForm(array $form, FormStateInterface $form_state) { foreach ($this->getOutputFormats() as $format_name => $format) { if (is_array($format)) { if ($format_name == 'default') { - $formats[$format_name] = $this->t('Field settings (@on_label / @off_label)', array('@on_label' => $format[0], '@off_label' => $format[1])); + $formats[$format_name] = $this->t('Field settings (@on_label / @off_label)', ['@on_label' => $format[0], '@off_label' => $format[1]]); } else { - $formats[$format_name] = $this->t('@on_label / @off_label', array('@on_label' => $format[0], '@off_label' => $format[1])); + $formats[$format_name] = $this->t('@on_label / @off_label', ['@on_label' => $format[0], '@off_label' => $format[1]]); } } else { diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php index 0c38929..58e8fff 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/DecimalFormatter.php @@ -26,12 +26,12 @@ class DecimalFormatter extends NumericFormatterBase { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'thousand_separator' => '', 'decimal_separator' => '.', 'scale' => 2, 'prefix_suffix' => TRUE, - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** @@ -40,22 +40,22 @@ public static function defaultSettings() { public function settingsForm(array $form, FormStateInterface $form_state) { $elements = parent::settingsForm($form, $form_state); - $elements['decimal_separator'] = array( + $elements['decimal_separator'] = [ '#type' => 'select', '#title' => t('Decimal marker'), - '#options' => array('.' => t('Decimal point'), ',' => t('Comma')), + '#options' => ['.' => t('Decimal point'), ',' => t('Comma')], '#default_value' => $this->getSetting('decimal_separator'), '#weight' => 5, - ); - $elements['scale'] = array( + ]; + $elements['scale'] = [ '#type' => 'number', - '#title' => t('Scale', array(), array('context' => 'decimal places')), + '#title' => t('Scale', [], ['context' => 'decimal places']), '#min' => 0, '#max' => 10, '#default_value' => $this->getSetting('scale'), '#description' => t('The number of digits to the right of the decimal.'), '#weight' => 6, - ); + ]; return $elements; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php index fa83359..d98b268 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php @@ -118,23 +118,23 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'view_mode' => 'default', 'link' => FALSE, - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - $elements['view_mode'] = array( + $elements['view_mode'] = [ '#type' => 'select', '#options' => $this->entityDisplayRepository->getViewModeOptions($this->getFieldSetting('target_type')), '#title' => t('View mode'), '#default_value' => $this->getSetting('view_mode'), '#required' => TRUE, - ); + ]; return $elements; } @@ -143,11 +143,11 @@ public function settingsForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function settingsSummary() { - $summary = array(); + $summary = []; $view_modes = $this->entityDisplayRepository->getViewModeOptions($this->getFieldSetting('target_type')); $view_mode = $this->getSetting('view_mode'); - $summary[] = t('Rendered as @mode', array('@mode' => isset($view_modes[$view_mode]) ? $view_modes[$view_mode] : $view_mode)); + $summary[] = t('Rendered as @mode', ['@mode' => isset($view_modes[$view_mode]) ? $view_modes[$view_mode] : $view_mode]); return $summary; } @@ -157,7 +157,7 @@ public function settingsSummary() { */ public function viewElements(FieldItemListInterface $items, $langcode) { $view_mode = $this->getSetting('view_mode'); - $elements = array(); + $elements = []; foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) { // Due to render caching and delayed calls, the viewElements() method @@ -195,7 +195,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { // entity's url. Since we don't know what the markup of the entity will // be, we shouldn't rely on it for structured data such as RDFa. if (!empty($items[$delta]->_attributes) && !$entity->isNew() && $entity->hasLinkTemplate('canonical')) { - $items[$delta]->_attributes += array('resource' => $entity->toUrl()->toString()); + $items[$delta]->_attributes += ['resource' => $entity->toUrl()->toString()]; } } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php index f413227..1c3d044 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceFormatterBase.php @@ -40,7 +40,7 @@ * @see ::prepareView() */ protected function getEntitiesToView(EntityReferenceFieldItemListInterface $items, $langcode) { - $entities = array(); + $entities = []; foreach ($items as $delta => $item) { // Ignore items where no entity could be loaded in prepareView(). @@ -120,7 +120,7 @@ public function prepareView(array $entities_items) { // "multiple entity load" to load all the entities for the multiple // "entity reference item lists" being displayed. We thus cannot use // \Drupal\Core\Field\EntityReferenceFieldItemList::referencedEntities(). - $ids = array(); + $ids = []; foreach ($entities_items as $items) { foreach ($items as $item) { // To avoid trying to reload non-existent entities in diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php index 62e54a7..9fa695d 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php @@ -22,19 +22,19 @@ class EntityReferenceIdFormatter extends EntityReferenceFormatterBase { * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) { if ($entity->id()) { - $elements[$delta] = array( + $elements[$delta] = [ '#plain_text' => $entity->id(), // Create a cache tag entry for the referenced entity. In the case // that the referenced entity is deleted, the cache for referring // entities must be cleared. - '#cache' => array( + '#cache' => [ 'tags' => $entity->getCacheTags(), - ), - ); + ], + ]; } } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php index 2084339..4c6b496 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php @@ -24,20 +24,20 @@ class EntityReferenceLabelFormatter extends EntityReferenceFormatterBase { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'link' => TRUE, - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - $elements['link'] = array( + $elements['link'] = [ '#title' => t('Link label to the referenced entity'), '#type' => 'checkbox', '#default_value' => $this->getSetting('link'), - ); + ]; return $elements; } @@ -46,7 +46,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function settingsSummary() { - $summary = array(); + $summary = []; $summary[] = $this->getSetting('link') ? t('Link to the referenced entity') : t('No link'); return $summary; } @@ -55,7 +55,7 @@ public function settingsSummary() { * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; $output_as_link = $this->getSetting('link'); foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) { @@ -84,7 +84,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { ]; if (!empty($items[$delta]->_attributes)) { - $elements[$delta]['#options'] += array('attributes' => array()); + $elements[$delta]['#options'] += ['attributes' => []]; $elements[$delta]['#options']['attributes'] += $items[$delta]->_attributes; // Unset field item attributes since they have been included in the // formatter output and shouldn't be rendered in the field template. @@ -92,7 +92,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { } } else { - $elements[$delta] = array('#plain_text' => $label); + $elements[$delta] = ['#plain_text' => $label]; } $elements[$delta]['#cache']['tags'] = $entity->getCacheTags(); } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/IntegerFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/IntegerFormatter.php index 17ddf9c..058de4d 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/IntegerFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/IntegerFormatter.php @@ -23,10 +23,10 @@ class IntegerFormatter extends NumericFormatterBase { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'thousand_separator' => '', 'prefix_suffix' => TRUE, - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php index 3a0ee89..43bbaa5 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php @@ -89,11 +89,11 @@ public static function defaultSettings() { */ public function settingsForm(array $form, FormStateInterface $form_state) { $form = parent::settingsForm($form, $form_state); - $form['native_language'] = array( + $form['native_language'] = [ '#title' => $this->t('Display in native language'), '#type' => 'checkbox', '#default_value' => $this->getSetting('native_language'), - ); + ]; return $form; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/MailToFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/MailToFormatter.php index 4b9c011..3cc3430 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/MailToFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/MailToFormatter.php @@ -23,14 +23,14 @@ class MailToFormatter extends FormatterBase { * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; foreach ($items as $delta => $item) { - $elements[$delta] = array( + $elements[$delta] = [ '#type' => 'link', '#title' => $item->value, '#url' => Url::fromUri('mailto:' . $item->value), - ); + ]; } return $elements; diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php index 0e35629..cf75fac 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php @@ -18,28 +18,28 @@ * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - $options = array( + $options = [ '' => t('- None -'), '.' => t('Decimal point'), ',' => t('Comma'), ' ' => t('Space'), chr(8201) => t('Thin space'), "'" => t('Apostrophe'), - ); - $elements['thousand_separator'] = array( + ]; + $elements['thousand_separator'] = [ '#type' => 'select', '#title' => t('Thousand marker'), '#options' => $options, '#default_value' => $this->getSetting('thousand_separator'), '#weight' => 0, - ); + ]; - $elements['prefix_suffix'] = array( + $elements['prefix_suffix'] = [ '#type' => 'checkbox', '#title' => t('Display prefix and suffix'), '#default_value' => $this->getSetting('prefix_suffix'), '#weight' => 10, - ); + ]; return $elements; } @@ -48,7 +48,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function settingsSummary() { - $summary = array(); + $summary = []; $summary[] = $this->numberFormat(1234.1234567890); if ($this->getSetting('prefix_suffix')) { @@ -62,7 +62,7 @@ public function settingsSummary() { * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; $settings = $this->getFieldSettings(); foreach ($items as $delta => $item) { @@ -70,8 +70,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) { // Account for prefix and suffix. if ($this->getSetting('prefix_suffix')) { - $prefixes = isset($settings['prefix']) ? array_map(array('Drupal\Core\Field\FieldFilteredMarkup', 'create'), explode('|', $settings['prefix'])) : array(''); - $suffixes = isset($settings['suffix']) ? array_map(array('Drupal\Core\Field\FieldFilteredMarkup', 'create'), explode('|', $settings['suffix'])) : array(''); + $prefixes = isset($settings['prefix']) ? array_map(['Drupal\Core\Field\FieldFilteredMarkup', 'create'], explode('|', $settings['prefix'])) : ['']; + $suffixes = isset($settings['suffix']) ? array_map(['Drupal\Core\Field\FieldFilteredMarkup', 'create'], explode('|', $settings['suffix'])) : ['']; $prefix = (count($prefixes) > 1) ? $this->formatPlural($item->value, $prefixes[0], $prefixes[1]) : $prefixes[0]; $suffix = (count($suffixes) > 1) ? $this->formatPlural($item->value, $suffixes[0], $suffixes[1]) : $suffixes[0]; $output = $prefix . $output . $suffix; @@ -79,10 +79,10 @@ public function viewElements(FieldItemListInterface $items, $langcode) { // Output the raw value in a content attribute if the text of the HTML // element differs from the raw value (for example when a prefix is used). if (isset($item->_attributes) && $item->value != $output) { - $item->_attributes += array('content' => $item->value); + $item->_attributes += ['content' => $item->value]; } - $elements[$delta] = array('#markup' => $output); + $elements[$delta] = ['#markup' => $output]; } return $elements; diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericUnformattedFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericUnformattedFormatter.php index 9881473..63246b3 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericUnformattedFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericUnformattedFormatter.php @@ -24,10 +24,10 @@ class NumericUnformattedFormatter extends FormatterBase { * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; foreach ($items as $delta => $item) { - $elements[$delta] = array('#markup' => $item->value); + $elements[$delta] = ['#markup' => $item->value]; } return $elements; diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php index a1f618b..95ab0b2 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php @@ -113,7 +113,7 @@ public function settingsSummary() { * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; $url = NULL; if ($this->getSetting('link_to_entity')) { // For the default revision this falls back to 'canonical' diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php index 2d7ce81..55a2fb1 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php @@ -93,11 +93,11 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'future_format' => '@interval hence', 'past_format' => '@interval ago', 'granularity' => 2, - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** @@ -106,28 +106,28 @@ public static function defaultSettings() { public function settingsForm(array $form, FormStateInterface $form_state) { $elements = parent::settingsForm($form, $form_state); - $form['future_format'] = array( + $form['future_format'] = [ '#type' => 'textfield', '#title' => $this->t('Future format'), '#default_value' => $this->getSetting('future_format'), '#description' => $this->t('Use @interval where you want the formatted interval text to appear.'), - ); + ]; - $form['past_format'] = array( + $form['past_format'] = [ '#type' => 'textfield', '#title' => $this->t('Past format'), '#default_value' => $this->getSetting('past_format'), '#description' => $this->t('Use @interval where you want the formatted interval text to appear.'), - ); + ]; - $elements['granularity'] = array( + $elements['granularity'] = [ '#type' => 'number', '#title' => $this->t('Granularity'), '#description' => $this->t('How many time interval units should be shown in the formatted output.'), '#default_value' => $this->getSetting('granularity') ?: 2, '#min' => 1, '#max' => 6, - ); + ]; return $elements; } @@ -140,8 +140,8 @@ public function settingsSummary() { $future_date = strtotime('1 year 1 month 1 week 1 day 1 hour 1 minute'); $past_date = strtotime('-1 year -1 month -1 week -1 day -1 hour -1 minute'); - $summary[] = $this->t('Future date: %display', array('%display' => $this->formatTimestamp($future_date))); - $summary[] = $this->t('Past date: %display', array('%display' => $this->formatTimestamp($past_date))); + $summary[] = $this->t('Future date: %display', ['%display' => $this->formatTimestamp($future_date)]); + $summary[] = $this->t('Past date: %display', ['%display' => $this->formatTimestamp($past_date)]); return $summary; } @@ -150,7 +150,7 @@ public function settingsSummary() { * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; foreach ($items as $delta => $item) { if ($item->value) { diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php index 8efe8d5..a24f5dd 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php @@ -90,11 +90,11 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'date_format' => 'medium', 'custom_date_format' => '', 'timezone' => '', - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** @@ -103,38 +103,38 @@ public static function defaultSettings() { public function settingsForm(array $form, FormStateInterface $form_state) { $elements = parent::settingsForm($form, $form_state); - $date_formats = array(); + $date_formats = []; foreach ($this->dateFormatStorage->loadMultiple() as $machine_name => $value) { - $date_formats[$machine_name] = $this->t('@name format: @date', array('@name' => $value->label(), '@date' => $this->dateFormatter->format(REQUEST_TIME, $machine_name))); + $date_formats[$machine_name] = $this->t('@name format: @date', ['@name' => $value->label(), '@date' => $this->dateFormatter->format(REQUEST_TIME, $machine_name)]); } $date_formats['custom'] = $this->t('Custom'); - $elements['date_format'] = array( + $elements['date_format'] = [ '#type' => 'select', '#title' => $this->t('Date format'), '#options' => $date_formats, '#default_value' => $this->getSetting('date_format') ?: 'medium', - ); + ]; - $elements['custom_date_format'] = array( + $elements['custom_date_format'] = [ '#type' => 'textfield', '#title' => $this->t('Custom date format'), '#description' => $this->t('See the documentation for PHP date formats.'), '#default_value' => $this->getSetting('custom_date_format') ?: '', - ); + ]; - $elements['custom_date_format']['#states']['visible'][] = array( - ':input[name="fields[' . $this->fieldDefinition->getName() . '][settings_edit_form][settings][date_format]"]' => array('value' => 'custom'), - ); + $elements['custom_date_format']['#states']['visible'][] = [ + ':input[name="fields[' . $this->fieldDefinition->getName() . '][settings_edit_form][settings][date_format]"]' => ['value' => 'custom'], + ]; - $elements['timezone'] = array( + $elements['timezone'] = [ '#type' => 'select', '#title' => $this->t('Time zone'), - '#options' => array('' => $this->t('- Default site/user time zone -')) + system_time_zones(FALSE), + '#options' => ['' => $this->t('- Default site/user time zone -')] + system_time_zones(FALSE), '#default_value' => $this->getSetting('timezone'), - ); + ]; return $elements; } @@ -146,12 +146,12 @@ public function settingsSummary() { $summary = parent::settingsSummary(); $date_format = $this->getSetting('date_format'); - $summary[] = $this->t('Date format: @date_format', array('@date_format' => $date_format)); + $summary[] = $this->t('Date format: @date_format', ['@date_format' => $date_format]); if ($this->getSetting('date_format') === 'custom' && ($custom_date_format = $this->getSetting('custom_date_format'))) { - $summary[] = $this->t('Custom date format: @custom_date_format', array('@custom_date_format' => $custom_date_format)); + $summary[] = $this->t('Custom date format: @custom_date_format', ['@custom_date_format' => $custom_date_format]); } if ($timezone = $this->getSetting('timezone')) { - $summary[] = $this->t('Time zone: @timezone', array('@timezone' => $timezone)); + $summary[] = $this->t('Time zone: @timezone', ['@timezone' => $timezone]); } return $summary; @@ -161,7 +161,7 @@ public function settingsSummary() { * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; $date_format = $this->getSetting('date_format'); $custom_date_format = ''; diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/UriLinkFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/UriLinkFormatter.php index 8f2213e..4216351 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/UriLinkFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/UriLinkFormatter.php @@ -23,7 +23,7 @@ class UriLinkFormatter extends FormatterBase { * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; foreach ($items as $delta => $item) { if (!$item->isEmpty()) { diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php index 0193191..51a29d8 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php @@ -28,10 +28,10 @@ class BooleanItem extends FieldItemBase implements OptionsProviderInterface { * {@inheritdoc} */ public static function defaultFieldSettings() { - return array( + return [ 'on_label' => new TranslatableMarkup('On'), 'off_label' => new TranslatableMarkup('Off'), - ) + parent::defaultFieldSettings(); + ] + parent::defaultFieldSettings(); } /** @@ -49,34 +49,34 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { - return array( - 'columns' => array( - 'value' => array( + return [ + 'columns' => [ + 'value' => [ 'type' => 'int', 'size' => 'tiny', - ), - ), - ); + ], + ], + ]; } /** * {@inheritdoc} */ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { - $element = array(); + $element = []; - $element['on_label'] = array( + $element['on_label'] = [ '#type' => 'textfield', '#title' => $this->t('"On" label'), '#default_value' => $this->getSetting('on_label'), '#required' => TRUE, - ); - $element['off_label'] = array( + ]; + $element['off_label'] = [ '#type' => 'textfield', '#title' => $this->t('"Off" label'), '#default_value' => $this->getSetting('off_label'), '#required' => TRUE, - ); + ]; return $element; } @@ -85,24 +85,24 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function getPossibleValues(AccountInterface $account = NULL) { - return array(0, 1); + return [0, 1]; } /** * {@inheritdoc} */ public function getPossibleOptions(AccountInterface $account = NULL) { - return array( + return [ 0 => $this->getSetting('off_label'), 1 => $this->getSetting('on_label'), - ); + ]; } /** * {@inheritdoc} */ public function getSettableValues(AccountInterface $account = NULL) { - return array(0, 1); + return [0, 1]; } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php index b4bcac5..228c8e6 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php @@ -22,7 +22,7 @@ class CreatedItem extends TimestampItem { public function applyDefaultValue($notify = TRUE) { parent::applyDefaultValue($notify); // Created fields default to the current timestamp. - $this->setValue(array('value' => REQUEST_TIME), $notify); + $this->setValue(['value' => REQUEST_TIME], $notify); return $this; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php index a8849fd..00fe409 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php @@ -25,10 +25,10 @@ class DecimalItem extends NumericItemBase { * {@inheritdoc} */ public static function defaultStorageSettings() { - return array( + return [ 'precision' => 10, 'scale' => 2, - ) + parent::defaultStorageSettings(); + ] + parent::defaultStorageSettings(); } /** @@ -46,25 +46,25 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { - return array( - 'columns' => array( - 'value' => array( + return [ + 'columns' => [ + 'value' => [ 'type' => 'numeric', 'precision' => $field_definition->getSetting('precision'), 'scale' => $field_definition->getSetting('scale'), - ) - ), - ); + ] + ], + ]; } /** * {@inheritdoc} */ public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) { - $element = array(); + $element = []; $settings = $this->getSettings(); - $element['precision'] = array( + $element['precision'] = [ '#type' => 'number', '#title' => t('Precision'), '#min' => 10, @@ -72,17 +72,17 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state '#default_value' => $settings['precision'], '#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'), '#disabled' => $has_data, - ); + ]; - $element['scale'] = array( + $element['scale'] = [ '#type' => 'number', - '#title' => t('Scale', array(), array('context' => 'decimal places')), + '#title' => t('Scale', [], ['context' => 'decimal places']), '#min' => 0, '#max' => 10, '#default_value' => $settings['scale'], '#description' => t('The number of digits to the right of the decimal.'), '#disabled' => $has_data, - ); + ]; return $element; } @@ -94,13 +94,13 @@ public function getConstraints() { $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); $constraints = parent::getConstraints(); - $constraints[] = $constraint_manager->create('ComplexData', array( - 'value' => array( - 'Regex' => array( + $constraints[] = $constraint_manager->create('ComplexData', [ + 'value' => [ + 'Regex' => [ 'pattern' => '/^[+-]?((\d+(\.\d*)?)|(\.\d+))$/i', - ) - ), - )); + ] + ], + ]); return $constraints; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php index f42a2b4..ca30ede 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php @@ -37,14 +37,14 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { - return array( - 'columns' => array( - 'value' => array( + return [ + 'columns' => [ + 'value' => [ 'type' => 'varchar', 'length' => Email::EMAIL_MAX_LENGTH, - ), - ), - ); + ], + ], + ]; } /** @@ -54,14 +54,14 @@ public function getConstraints() { $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); $constraints = parent::getConstraints(); - $constraints[] = $constraint_manager->create('ComplexData', array( - 'value' => array( - 'Length' => array( + $constraints[] = $constraint_manager->create('ComplexData', [ + 'value' => [ + 'Length' => [ 'max' => Email::EMAIL_MAX_LENGTH, - 'maxMessage' => t('%name: the email address can not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => Email::EMAIL_MAX_LENGTH)), - ) - ), - )); + 'maxMessage' => t('%name: the email address can not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => Email::EMAIL_MAX_LENGTH]), + ] + ], + ]); return $constraints; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index e8832f3..8a51f85 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -43,19 +43,19 @@ class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterf * {@inheritdoc} */ public static function defaultStorageSettings() { - return array( + return [ 'target_type' => \Drupal::moduleHandler()->moduleExists('node') ? 'node' : 'user', - ) + parent::defaultStorageSettings(); + ] + parent::defaultStorageSettings(); } /** * {@inheritdoc} */ public static function defaultFieldSettings() { - return array( + return [ 'handler' => 'default', - 'handler_settings' => array(), - ) + parent::defaultFieldSettings(); + 'handler_settings' => [], + ] + parent::defaultFieldSettings(); } /** @@ -115,32 +115,32 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) $target_type_info = \Drupal::entityManager()->getDefinition($target_type); $properties = static::propertyDefinitions($field_definition)['target_id']; if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface') && $properties->getDataType() === 'integer') { - $columns = array( - 'target_id' => array( + $columns = [ + 'target_id' => [ 'description' => 'The ID of the target entity.', 'type' => 'int', 'unsigned' => TRUE, - ), - ); + ], + ]; } else { - $columns = array( - 'target_id' => array( + $columns = [ + 'target_id' => [ 'description' => 'The ID of the target entity.', 'type' => 'varchar_ascii', // If the target entities act as bundles for another entity type, // their IDs should not exceed the maximum length for bundles. 'length' => $target_type_info->getBundleOf() ? EntityTypeInterface::BUNDLE_MAX_LENGTH : 255, - ), - ); + ], + ]; } - $schema = array( + $schema = [ 'columns' => $columns, - 'indexes' => array( - 'target_id' => array('target_id'), - ), - ); + 'indexes' => [ + 'target_id' => ['target_id'], + ], + ]; return $schema; } @@ -279,7 +279,7 @@ public static function generateSampleValue(FieldDefinitionInterface $field_defin * {@inheritdoc} */ public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) { - $element['target_type'] = array( + $element['target_type'] = [ '#type' => 'select', '#title' => t('Type of item to reference'), '#options' => \Drupal::entityManager()->getEntityTypeLabels(TRUE), @@ -287,7 +287,7 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state '#required' => TRUE, '#disabled' => $has_data, '#size' => 1, - ); + ]; return $element; } @@ -300,7 +300,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { // Get all selection plugins for this entity type. $selection_plugins = \Drupal::service('plugin.manager.entity_reference_selection')->getSelectionGroups($this->getSetting('target_type')); - $handlers_options = array(); + $handlers_options = []; foreach (array_keys($selection_plugins) as $selection_group_id) { // We only display base plugins (e.g. 'default', 'views', ...) and not // entity type specific plugins (e.g. 'default:node', 'default:user', @@ -314,46 +314,46 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { } } - $form = array( + $form = [ '#type' => 'container', - '#process' => array(array(get_class($this), 'fieldSettingsAjaxProcess')), - '#element_validate' => array(array(get_class($this), 'fieldSettingsFormValidate')), + '#process' => [[get_class($this), 'fieldSettingsAjaxProcess']], + '#element_validate' => [[get_class($this), 'fieldSettingsFormValidate']], - ); - $form['handler'] = array( + ]; + $form['handler'] = [ '#type' => 'details', '#title' => t('Reference type'), '#open' => TRUE, '#tree' => TRUE, - '#process' => array(array(get_class($this), 'formProcessMergeParent')), - ); + '#process' => [[get_class($this), 'formProcessMergeParent']], + ]; - $form['handler']['handler'] = array( + $form['handler']['handler'] = [ '#type' => 'select', '#title' => t('Reference method'), '#options' => $handlers_options, '#default_value' => $field->getSetting('handler'), '#required' => TRUE, '#ajax' => TRUE, - '#limit_validation_errors' => array(), - ); - $form['handler']['handler_submit'] = array( + '#limit_validation_errors' => [], + ]; + $form['handler']['handler_submit'] = [ '#type' => 'submit', '#value' => t('Change handler'), - '#limit_validation_errors' => array(), - '#attributes' => array( - 'class' => array('js-hide'), - ), - '#submit' => array(array(get_class($this), 'settingsAjaxSubmit')), - ); - - $form['handler']['handler_settings'] = array( + '#limit_validation_errors' => [], + '#attributes' => [ + 'class' => ['js-hide'], + ], + '#submit' => [[get_class($this), 'settingsAjaxSubmit']], + ]; + + $form['handler']['handler_settings'] = [ '#type' => 'container', - '#attributes' => array('class' => array('entity_reference-settings')), - ); + '#attributes' => ['class' => ['entity_reference-settings']], + ]; $handler = \Drupal::service('plugin.manager.entity_reference_selection')->getSelectionHandler($field); - $form['handler']['handler_settings'] += $handler->buildConfigurationForm(array(), $form_state); + $form['handler']['handler_settings'] += $handler->buildConfigurationForm([], $form_state); return $form; } @@ -536,14 +536,14 @@ public function getSettableValues(AccountInterface $account = NULL) { public function getSettableOptions(AccountInterface $account = NULL) { $field_definition = $this->getFieldDefinition(); if (!$options = \Drupal::service('plugin.manager.entity_reference_selection')->getSelectionHandler($field_definition, $this->getEntity())->getReferenceableEntities()) { - return array(); + return []; } // Rebuild the array by changing the bundle key into the bundle label. $target_type = $field_definition->getSetting('target_type'); $bundles = \Drupal::entityManager()->getBundleInfo($target_type); - $return = array(); + $return = []; foreach ($options as $bundle => $entity_ids) { // The label does not need sanitizing since it is used as an optgroup // which is only supported by select elements and auto-escaped. @@ -573,11 +573,11 @@ public static function fieldSettingsAjaxProcess($form, FormStateInterface $form_ */ public static function fieldSettingsAjaxProcessElement(&$element, $main_form) { if (!empty($element['#ajax'])) { - $element['#ajax'] = array( - 'callback' => array(get_called_class(), 'settingsAjax'), + $element['#ajax'] = [ + 'callback' => [get_called_class(), 'settingsAjax'], 'wrapper' => $main_form['#id'], 'element' => $main_form['#array_parents'], - ); + ]; } foreach (Element::children($element) as $key) { @@ -621,7 +621,7 @@ public static function settingsAjaxSubmit($form, FormStateInterface $form_state) * {@inheritdoc} */ public static function getPreconfiguredOptions() { - $options = array(); + $options = []; // Add all the commonly referenced entity types as distinct pre-configured // options. diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php index 601bc8a..7b2234c 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/FloatItem.php @@ -36,13 +36,13 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { - return array( - 'columns' => array( - 'value' => array( + return [ + 'columns' => [ + 'value' => [ 'type' => 'float', - ), - ), - ); + ], + ], + ]; } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php index 0e95417..84691267 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/IntegerItem.php @@ -24,24 +24,24 @@ class IntegerItem extends NumericItemBase { * {@inheritdoc} */ public static function defaultStorageSettings() { - return array( + return [ 'unsigned' => FALSE, // Valid size property values include: 'tiny', 'small', 'medium', 'normal' // and 'big'. 'size' => 'normal', - ) + parent::defaultStorageSettings(); + ] + parent::defaultStorageSettings(); } /** * {@inheritdoc} */ public static function defaultFieldSettings() { - return array( + return [ 'min' => '', 'max' => '', 'prefix' => '', 'suffix' => '', - ) + parent::defaultFieldSettings(); + ] + parent::defaultFieldSettings(); } /** @@ -65,17 +65,17 @@ public function getConstraints() { // integer to be positive. if ($this->getSetting('unsigned')) { $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); - $constraints[] = $constraint_manager->create('ComplexData', array( - 'value' => array( - 'Range' => array( + $constraints[] = $constraint_manager->create('ComplexData', [ + 'value' => [ + 'Range' => [ 'min' => 0, - 'minMessage' => t('%name: The integer must be larger or equal to %min.', array( + 'minMessage' => t('%name: The integer must be larger or equal to %min.', [ '%name' => $this->getFieldDefinition()->getLabel(), '%min' => 0, - )), - ), - ), - )); + ]), + ], + ], + ]); } return $constraints; @@ -85,18 +85,18 @@ public function getConstraints() { * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { - return array( - 'columns' => array( - 'value' => array( + return [ + 'columns' => [ + 'value' => [ 'type' => 'int', // Expose the 'unsigned' setting in the field item schema. 'unsigned' => $field_definition->getSetting('unsigned'), // Expose the 'size' setting in the field item schema. For instance, // supply 'big' as a value to produce a 'bigint' type. 'size' => $field_definition->getSetting('size'), - ), - ), - ); + ], + ], + ]; } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php index 0b9bba9..18935c1 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php @@ -65,14 +65,14 @@ public static function getAllowedLanguageCodes() { * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { - return array( - 'columns' => array( - 'value' => array( + return [ + 'columns' => [ + 'value' => [ 'type' => 'varchar_ascii', 'length' => 12, - ), - ), - ); + ], + ], + ]; } /** @@ -99,7 +99,7 @@ public function setValue($values, $notify = TRUE) { public function applyDefaultValue($notify = TRUE) { // Default to the site's default language. When language module is enabled, // this behavior is configurable, see language_field_info_alter(). - $this->setValue(array('value' => \Drupal::languageManager()->getDefaultLanguage()->getId()), $notify); + $this->setValue(['value' => \Drupal::languageManager()->getDefaultLanguage()->getId()], $notify); return $this; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php index cff52d8..04045c7 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php @@ -22,22 +22,22 @@ class MapItem extends FieldItemBase { */ public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) { // The properties are dynamic and can not be defined statically. - return array(); + return []; } /** * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { - return array( - 'columns' => array( - 'value' => array( + return [ + 'columns' => [ + 'value' => [ 'type' => 'blob', 'size' => 'big', 'serialize' => TRUE, - ), - ), - ); + ], + ], + ]; } /** @@ -53,7 +53,7 @@ public function toArray() { * {@inheritdoc} */ public function setValue($values, $notify = TRUE) { - $this->values = array(); + $this->values = []; if (!isset($values)) { return; } @@ -80,7 +80,7 @@ public function setValue($values, $notify = TRUE) { */ public function __get($name) { if (!isset($this->values[$name])) { - $this->values[$name] = array(); + $this->values[$name] = []; } return $this->values[$name]; diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php index 678ab1f..23f5161 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/NumericItemBase.php @@ -14,47 +14,47 @@ * {@inheritdoc} */ public static function defaultFieldSettings() { - return array( + return [ 'min' => '', 'max' => '', 'prefix' => '', 'suffix' => '', - ) + parent::defaultFieldSettings(); + ] + parent::defaultFieldSettings(); } /** * {@inheritdoc} */ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { - $element = array(); + $element = []; $settings = $this->getSettings(); - $element['min'] = array( + $element['min'] = [ '#type' => 'number', '#title' => t('Minimum'), '#default_value' => $settings['min'], '#description' => t('The minimum value that should be allowed in this field. Leave blank for no minimum.'), - ); - $element['max'] = array( + ]; + $element['max'] = [ '#type' => 'number', '#title' => t('Maximum'), '#default_value' => $settings['max'], '#description' => t('The maximum value that should be allowed in this field. Leave blank for no maximum.'), - ); - $element['prefix'] = array( + ]; + $element['prefix'] = [ '#type' => 'textfield', '#title' => t('Prefix'), '#default_value' => $settings['prefix'], '#size' => 60, '#description' => t("Define a string that should be prefixed to the value, like '$ ' or '€ '. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."), - ); - $element['suffix'] = array( + ]; + $element['suffix'] = [ '#type' => 'textfield', '#title' => t('Suffix'), '#default_value' => $settings['suffix'], '#size' => 60, '#description' => t("Define a string that should be suffixed to the value, like ' m', ' kb/s'. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."), - ); + ]; return $element; } @@ -81,26 +81,26 @@ public function getConstraints() { if (!empty($settings['min'])) { $min = $settings['min']; - $constraints[] = $constraint_manager->create('ComplexData', array( - 'value' => array( - 'Range' => array( + $constraints[] = $constraint_manager->create('ComplexData', [ + 'value' => [ + 'Range' => [ 'min' => $min, - 'minMessage' => t('%name: the value may be no less than %min.', array('%name' => $label, '%min' => $min)), - ) - ), - )); + 'minMessage' => t('%name: the value may be no less than %min.', ['%name' => $label, '%min' => $min]), + ] + ], + ]); } if (!empty($settings['max'])) { $max = $settings['max']; - $constraints[] = $constraint_manager->create('ComplexData', array( - 'value' => array( - 'Range' => array( + $constraints[] = $constraint_manager->create('ComplexData', [ + 'value' => [ + 'Range' => [ 'max' => $max, - 'maxMessage' => t('%name: the value may be no greater than %max.', array('%name' => $label, '%max' => $max)), - ) - ), - )); + 'maxMessage' => t('%name: the value may be no greater than %max.', ['%name' => $label, '%max' => $max]), + ] + ], + ]); } return $constraints; diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php index 67414d9..b51764c 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php @@ -25,25 +25,25 @@ class StringItem extends StringItemBase { * {@inheritdoc} */ public static function defaultStorageSettings() { - return array( + return [ 'max_length' => 255, 'is_ascii' => FALSE, - ) + parent::defaultStorageSettings(); + ] + parent::defaultStorageSettings(); } /** * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { - return array( - 'columns' => array( - 'value' => array( + return [ + 'columns' => [ + 'value' => [ 'type' => $field_definition->getSetting('is_ascii') === TRUE ? 'varchar_ascii' : 'varchar', 'length' => (int) $field_definition->getSetting('max_length'), 'binary' => $field_definition->getSetting('case_sensitive'), - ), - ), - ); + ], + ], + ]; } /** @@ -54,14 +54,14 @@ public function getConstraints() { if ($max_length = $this->getSetting('max_length')) { $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); - $constraints[] = $constraint_manager->create('ComplexData', array( - 'value' => array( - 'Length' => array( + $constraints[] = $constraint_manager->create('ComplexData', [ + 'value' => [ + 'Length' => [ 'max' => $max_length, - 'maxMessage' => t('%name: may not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length)), - ), - ), - )); + 'maxMessage' => t('%name: may not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length]), + ], + ], + ]); } return $constraints; @@ -80,9 +80,9 @@ public static function generateSampleValue(FieldDefinitionInterface $field_defin * {@inheritdoc} */ public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) { - $element = array(); + $element = []; - $element['max_length'] = array( + $element['max_length'] = [ '#type' => 'number', '#title' => t('Maximum length'), '#default_value' => $this->getSetting('max_length'), @@ -90,7 +90,7 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state '#description' => t('The maximum length of the field in characters.'), '#min' => 1, '#disabled' => $has_data, - ); + ]; return $element; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php index 6a784d6..f59c10c 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItemBase.php @@ -16,9 +16,9 @@ * {@inheritdoc} */ public static function defaultStorageSettings() { - return array( + return [ 'case_sensitive' => FALSE, - ) + parent::defaultStorageSettings(); + ] + parent::defaultStorageSettings(); } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php index ae998d3..93c6b27 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringLongItem.php @@ -24,14 +24,14 @@ class StringLongItem extends StringItemBase { * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { - return array( - 'columns' => array( - 'value' => array( + return [ + 'columns' => [ + 'value' => [ 'type' => $field_definition->getSetting('case_sensitive') ? 'blob' : 'text', 'size' => 'big', - ), - ), - ); + ], + ], + ]; } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php index 98094ca..f48e4f0 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/TimestampItem.php @@ -44,13 +44,13 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { - return array( - 'columns' => array( - 'value' => array( + return [ + 'columns' => [ + 'value' => [ 'type' => 'int', - ), - ), - ); + ], + ], + ]; } } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php index 034fc16..8d1d6e6 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php @@ -52,15 +52,15 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { - return array( - 'columns' => array( - 'value' => array( + return [ + 'columns' => [ + 'value' => [ 'type' => 'varchar', 'length' => (int) $field_definition->getSetting('max_length'), 'binary' => $field_definition->getSetting('case_sensitive'), - ), - ), - ); + ], + ], + ]; } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php index 94aa8aa..2f33317 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php @@ -23,10 +23,10 @@ class UuidItem extends StringItem { * {@inheritdoc} */ public static function defaultStorageSettings() { - return array( + return [ 'max_length' => 128, 'is_ascii' => TRUE, - ) + parent::defaultStorageSettings(); + ] + parent::defaultStorageSettings(); } /** @@ -35,7 +35,7 @@ public static function defaultStorageSettings() { public function applyDefaultValue($notify = TRUE) { // Default to one field item with a generated UUID. $uuid = \Drupal::service('uuid'); - $this->setValue(array('value' => $uuid->generate()), $notify); + $this->setValue(['value' => $uuid->generate()], $notify); return $this; } @@ -44,7 +44,7 @@ public function applyDefaultValue($notify = TRUE) { */ public static function schema(FieldStorageDefinitionInterface $field_definition) { $schema = parent::schema($field_definition); - $schema['unique keys']['value'] = array('value'); + $schema['unique keys']['value'] = ['value']; return $schema; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php index 3106fbe..1d4a202 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/BooleanCheckboxWidget.php @@ -24,21 +24,21 @@ class BooleanCheckboxWidget extends WidgetBase { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'display_label' => TRUE, - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - $element['display_label'] = array( + $element['display_label'] = [ '#type' => 'checkbox', '#title' => t('Use field label instead of the "On label" as label'), '#default_value' => $this->getSetting('display_label'), '#weight' => -1, - ); + ]; return $element; } @@ -46,10 +46,10 @@ public function settingsForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function settingsSummary() { - $summary = array(); + $summary = []; $display_label = $this->getSetting('display_label'); - $summary[] = t('Use field label: @display_label', array('@display_label' => ($display_label ? t('Yes') : 'No'))); + $summary[] = t('Use field label: @display_label', ['@display_label' => ($display_label ? t('Yes') : 'No')]); return $summary; } @@ -58,10 +58,10 @@ public function settingsSummary() { * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { - $element['value'] = $element + array( + $element['value'] = $element + [ '#type' => 'checkbox', '#default_value' => !empty($items[0]->value), - ); + ]; // Override the title from the incoming $element. if ($this->getSetting('display_label')) { diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php index 9931d4e..07f66cf 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php @@ -24,29 +24,29 @@ class EmailDefaultWidget extends WidgetBase { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'size' => 60, 'placeholder' => '', - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - $element['size'] = array( + $element['size'] = [ '#type' => 'number', '#title' => $this->t('Textfield size'), '#default_value' => $this->getSetting('size'), '#required' => TRUE, '#min' => 1, - ); - $element['placeholder'] = array( + ]; + $element['placeholder'] = [ '#type' => 'textfield', '#title' => t('Placeholder'), '#default_value' => $this->getSetting('placeholder'), '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'), - ); + ]; return $element; } @@ -54,16 +54,16 @@ public function settingsForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function settingsSummary() { - $summary = array(); + $summary = []; $placeholder = $this->getSetting('placeholder'); if (!empty($placeholder)) { - $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder)); + $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]); } else { $summary[] = t('No placeholder'); } - $summary[] = t('Textfield size: @size', array('@size' => $this->getSetting('size'))); + $summary[] = t('Textfield size: @size', ['@size' => $this->getSetting('size')]); return $summary; } @@ -72,13 +72,13 @@ public function settingsSummary() { * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { - $element['value'] = $element + array( + $element['value'] = $element + [ '#type' => 'email', '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL, '#placeholder' => $this->getSetting('placeholder'), '#size' => $this->getSetting('size'), '#maxlength' => Email::EMAIL_MAX_LENGTH, - ); + ]; return $element; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php index b5e16c1..dcad488 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php @@ -26,37 +26,37 @@ class EntityReferenceAutocompleteWidget extends WidgetBase { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'match_operator' => 'CONTAINS', 'size' => '60', 'placeholder' => '', - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - $element['match_operator'] = array( + $element['match_operator'] = [ '#type' => 'radios', '#title' => t('Autocomplete matching'), '#default_value' => $this->getSetting('match_operator'), '#options' => $this->getMatchOperatorOptions(), '#description' => t('Select the method used to collect autocomplete suggestions. Note that Contains can cause performance issues on sites with thousands of entities.'), - ); - $element['size'] = array( + ]; + $element['size'] = [ '#type' => 'number', '#title' => t('Size of textfield'), '#default_value' => $this->getSetting('size'), '#min' => 1, '#required' => TRUE, - ); - $element['placeholder'] = array( + ]; + $element['placeholder'] = [ '#type' => 'textfield', '#title' => t('Placeholder'), '#default_value' => $this->getSetting('placeholder'), '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'), - ); + ]; return $element; } @@ -64,14 +64,14 @@ public function settingsForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function settingsSummary() { - $summary = array(); + $summary = []; $operators = $this->getMatchOperatorOptions(); - $summary[] = t('Autocomplete matching: @match_operator', array('@match_operator' => $operators[$this->getSetting('match_operator')])); - $summary[] = t('Textfield size: @size', array('@size' => $this->getSetting('size'))); + $summary[] = t('Autocomplete matching: @match_operator', ['@match_operator' => $operators[$this->getSetting('match_operator')]]); + $summary[] = t('Textfield size: @size', ['@size' => $this->getSetting('size')]); $placeholder = $this->getSetting('placeholder'); if (!empty($placeholder)) { - $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder)); + $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]); } else { $summary[] = t('No placeholder'); @@ -87,7 +87,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $entity = $items->getEntity(); $referenced_entities = $items->referencedEntities(); - $element += array( + $element += [ '#type' => 'entity_autocomplete', '#target_type' => $this->getFieldSetting('target_type'), '#selection_handler' => $this->getFieldSetting('handler'), @@ -99,16 +99,16 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen '#default_value' => isset($referenced_entities[$delta]) ? $referenced_entities[$delta] : NULL, '#size' => $this->getSetting('size'), '#placeholder' => $this->getSetting('placeholder'), - ); + ]; if ($this->getSelectionHandlerSetting('auto_create') && ($bundle = $this->getAutocreateBundle())) { - $element['#autocreate'] = array( + $element['#autocreate'] = [ 'bundle' => $bundle, 'uid' => ($entity instanceof EntityOwnerInterface) ? $entity->getOwnerId() : \Drupal::currentUser()->id() - ); + ]; } - return array('target_id' => $element); + return ['target_id' => $element]; } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php index cff646d..776e060 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/LanguageSelectWidget.php @@ -24,11 +24,11 @@ class LanguageSelectWidget extends WidgetBase { * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { - $element['value'] = $element + array( + $element['value'] = $element + [ '#type' => 'language_select', '#default_value' => $items[$delta]->value, '#languages' => LanguageInterface::STATE_ALL, - ); + ]; return $element; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php index 8200569..b4fac53 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php @@ -27,21 +27,21 @@ class NumberWidget extends WidgetBase { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'placeholder' => '', - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - $element['placeholder'] = array( + $element['placeholder'] = [ '#type' => 'textfield', '#title' => t('Placeholder'), '#default_value' => $this->getSetting('placeholder'), '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'), - ); + ]; return $element; } @@ -49,11 +49,11 @@ public function settingsForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function settingsSummary() { - $summary = array(); + $summary = []; $placeholder = $this->getSetting('placeholder'); if (!empty($placeholder)) { - $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder)); + $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]); } else { $summary[] = t('No placeholder'); @@ -69,11 +69,11 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $value = isset($items[$delta]->value) ? $items[$delta]->value : NULL; $field_settings = $this->getFieldSettings(); - $element += array( + $element += [ '#type' => 'number', '#default_value' => $value, '#placeholder' => $this->getSetting('placeholder'), - ); + ]; // Set the step for floating point and decimal numbers. switch ($this->fieldDefinition->getType()) { @@ -104,7 +104,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $element['#field_suffix'] = FieldFilteredMarkup::create(array_pop($suffixes)); } - return array('value' => $element); + return ['value' => $element]; } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsButtonsWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsButtonsWidget.php index 1224c63..7787106 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsButtonsWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsButtonsWidget.php @@ -35,25 +35,25 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // If required and there is one single option, preselect it. if ($this->required && count($options) == 1) { reset($options); - $selected = array(key($options)); + $selected = [key($options)]; } if ($this->multiple) { - $element += array( + $element += [ '#type' => 'checkboxes', '#default_value' => $selected, '#options' => $options, - ); + ]; } else { - $element += array( + $element += [ '#type' => 'radios', // Radio buttons need a scalar value. Take the first default value, or // default to NULL so that the form element is properly recognized as // not having a default value. '#default_value' => $selected ? reset($selected) : NULL, '#options' => $options, - ); + ]; } return $element; diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsSelectWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsSelectWidget.php index 3a71989..b623c87 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsSelectWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsSelectWidget.php @@ -29,13 +29,13 @@ class OptionsSelectWidget extends OptionsWidgetBase { public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element = parent::formElement($items, $delta, $element, $form, $form_state); - $element += array( + $element += [ '#type' => 'select', '#options' => $this->getOptions($items->getEntity()), '#default_value' => $this->getSelectedOptions($items), // Do not display a 'multiple' select box if there is only one option. '#multiple' => $this->multiple && count($this->options) > 1, - ); + ]; return $element; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php index add9cd7..174403b 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php @@ -50,7 +50,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $this->has_value = isset($items[0]->{$this->column}); // Add our custom validator. - $element['#element_validate'][] = array(get_class($this), 'validateElement'); + $element['#element_validate'][] = [get_class($this), 'validateElement']; $element['#key_column'] = $this->column; // The rest of the $element is built by child method implementations. @@ -68,7 +68,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen */ public static function validateElement(array $element, FormStateInterface $form_state) { if ($element['#required'] && $element['#value'] == '_none') { - $form_state->setError($element, t('@name field is required.', array('@name' => $element['#title']))); + $form_state->setError($element, t('@name field is required.', ['@name' => $element['#title']])); } // Massage submitted form values. @@ -80,7 +80,7 @@ public static function validateElement(array $element, FormStateInterface $form_ $values = array_values($element['#value']); } else { - $values = array($element['#value']); + $values = [$element['#value']]; } // Filter out the 'none' option. Use a strict comparison, because @@ -91,9 +91,9 @@ public static function validateElement(array $element, FormStateInterface $form_ } // Transpose selections from field => delta to delta => field. - $items = array(); + $items = []; foreach ($values as $value) { - $items[] = array($element['#key_column'] => $value); + $items[] = [$element['#key_column'] => $value]; } $form_state->setValueForElement($element, $items); } @@ -121,13 +121,13 @@ protected function getOptions(FieldableEntityInterface $entity) { } $module_handler = \Drupal::moduleHandler(); - $context = array( + $context = [ 'fieldDefinition' => $this->fieldDefinition, 'entity' => $entity, - ); + ]; $module_handler->alter('options_list', $options, $context); - array_walk_recursive($options, array($this, 'sanitizeLabel')); + array_walk_recursive($options, [$this, 'sanitizeLabel']); // Options might be nested ("optgroups"). If the widget does not support // nested options, flatten the list. @@ -153,7 +153,7 @@ protected function getSelectedOptions(FieldItemListInterface $items) { // We need to check against a flat list of options. $flat_options = OptGroup::flattenOptions($this->getOptions($items->getEntity())); - $selected_options = array(); + $selected_options = []; foreach ($items as $item) { $value = $item->{$this->column}; // Keep the value if it actually is in the list of options (needs to be diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php index e6b0ff0..5f21b5e 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextareaWidget.php @@ -23,29 +23,29 @@ class StringTextareaWidget extends WidgetBase { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'rows' => '5', 'placeholder' => '', - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - $element['rows'] = array( + $element['rows'] = [ '#type' => 'number', '#title' => t('Rows'), '#default_value' => $this->getSetting('rows'), '#required' => TRUE, '#min' => 1, - ); - $element['placeholder'] = array( + ]; + $element['placeholder'] = [ '#type' => 'textfield', '#title' => t('Placeholder'), '#default_value' => $this->getSetting('placeholder'), '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'), - ); + ]; return $element; } @@ -53,12 +53,12 @@ public function settingsForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function settingsSummary() { - $summary = array(); + $summary = []; - $summary[] = t('Number of rows: @rows', array('@rows' => $this->getSetting('rows'))); + $summary[] = t('Number of rows: @rows', ['@rows' => $this->getSetting('rows')]); $placeholder = $this->getSetting('placeholder'); if (!empty($placeholder)) { - $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder)); + $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]); } return $summary; @@ -68,13 +68,13 @@ public function settingsSummary() { * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { - $element['value'] = $element + array( + $element['value'] = $element + [ '#type' => 'textarea', '#default_value' => $items[$delta]->value, '#rows' => $this->getSetting('rows'), '#placeholder' => $this->getSetting('placeholder'), - '#attributes' => array('class' => array('js-text-full', 'text-full')), - ); + '#attributes' => ['class' => ['js-text-full', 'text-full']], + ]; return $element; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php index d89f0b2..3be1681 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php @@ -23,29 +23,29 @@ class StringTextfieldWidget extends WidgetBase { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'size' => 60, 'placeholder' => '', - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - $element['size'] = array( + $element['size'] = [ '#type' => 'number', '#title' => t('Size of textfield'), '#default_value' => $this->getSetting('size'), '#required' => TRUE, '#min' => 1, - ); - $element['placeholder'] = array( + ]; + $element['placeholder'] = [ '#type' => 'textfield', '#title' => t('Placeholder'), '#default_value' => $this->getSetting('placeholder'), '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'), - ); + ]; return $element; } @@ -53,12 +53,12 @@ public function settingsForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function settingsSummary() { - $summary = array(); + $summary = []; - $summary[] = t('Textfield size: @size', array('@size' => $this->getSetting('size'))); + $summary[] = t('Textfield size: @size', ['@size' => $this->getSetting('size')]); $placeholder = $this->getSetting('placeholder'); if (!empty($placeholder)) { - $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder)); + $summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]); } return $summary; @@ -68,14 +68,14 @@ public function settingsSummary() { * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { - $element['value'] = $element + array( + $element['value'] = $element + [ '#type' => 'textfield', '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL, '#size' => $this->getSetting('size'), '#placeholder' => $this->getSetting('placeholder'), '#maxlength' => $this->getFieldSetting('max_length'), - '#attributes' => array('class' => array('js-text-full', 'text-full')), - ); + '#attributes' => ['class' => ['js-text-full', 'text-full']], + ]; return $element; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php index 714b4e0..f89b444 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php @@ -23,29 +23,29 @@ class UriWidget extends WidgetBase { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'size' => 60, 'placeholder' => '', - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - $element['size'] = array( + $element['size'] = [ '#type' => 'number', '#title' => $this->t('Size of URI field'), '#default_value' => $this->getSetting('size'), '#required' => TRUE, '#min' => 1, - ); - $element['placeholder'] = array( + ]; + $element['placeholder'] = [ '#type' => 'textfield', '#title' => $this->t('Placeholder'), '#default_value' => $this->getSetting('placeholder'), '#description' => $this->t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'), - ); + ]; return $element; } @@ -53,12 +53,12 @@ public function settingsForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function settingsSummary() { - $summary = array(); + $summary = []; - $summary[] = $this->t('URI field size: @size', array('@size' => $this->getSetting('size'))); + $summary[] = $this->t('URI field size: @size', ['@size' => $this->getSetting('size')]); $placeholder = $this->getSetting('placeholder'); if (!empty($placeholder)) { - $summary[] = $this->t('Placeholder: @placeholder', array('@placeholder' => $placeholder)); + $summary[] = $this->t('Placeholder: @placeholder', ['@placeholder' => $placeholder]); } return $summary; @@ -68,13 +68,13 @@ public function settingsSummary() { * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { - $element['value'] = $element + array( + $element['value'] = $element + [ '#type' => 'url', '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL, '#size' => $this->getSetting('size'), '#placeholder' => $this->getSetting('placeholder'), '#maxlength' => $this->getFieldSetting('max_length'), - ); + ]; return $element; } diff --git a/core/lib/Drupal/Core/Field/PluginSettingsBase.php b/core/lib/Drupal/Core/Field/PluginSettingsBase.php index a6196ec..073bd2c 100644 --- a/core/lib/Drupal/Core/Field/PluginSettingsBase.php +++ b/core/lib/Drupal/Core/Field/PluginSettingsBase.php @@ -17,7 +17,7 @@ * * @var array */ - protected $settings = array(); + protected $settings = []; /** * The plugin settings injected by third party modules. @@ -26,7 +26,7 @@ * * @var array */ - protected $thirdPartySettings = array(); + protected $thirdPartySettings = []; /** * Whether default settings have been merged into the current $settings. @@ -39,7 +39,7 @@ * {@inheritdoc} */ public static function defaultSettings() { - return array(); + return []; } /** @@ -140,11 +140,11 @@ public function getThirdPartyProviders() { public function calculateDependencies() { if (!empty($this->thirdPartySettings)) { // Create dependencies on any modules providing third party settings. - return array( + return [ 'module' => array_keys($this->thirdPartySettings) - ); + ]; } - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php index 5f7ce3c..05ac6b2 100644 --- a/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -48,7 +48,7 @@ * Any third party settings. */ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings) { - parent::__construct(array(), $plugin_id, $plugin_definition); + parent::__construct([], $plugin_id, $plugin_definition); $this->fieldDefinition = $field_definition; $this->settings = $settings; $this->thirdPartySettings = $third_party_settings; @@ -63,25 +63,25 @@ public function form(FieldItemListInterface $items, array &$form, FormStateInter // Store field information in $form_state. if (!static::getWidgetState($parents, $field_name, $form_state)) { - $field_state = array( + $field_state = [ 'items_count' => count($items), - 'array_parents' => array(), - ); + 'array_parents' => [], + ]; static::setWidgetState($parents, $field_name, $form_state, $field_state); } // Collect widget elements. - $elements = array(); + $elements = []; // If the widget is handling multiple values (e.g Options), or if we are // displaying an individual element, just get a single form element and make // it the $delta value. if ($this->handlesMultipleValues() || isset($get_delta)) { $delta = isset($get_delta) ? $get_delta : 0; - $element = array( + $element = [ '#title' => $this->fieldDefinition->getLabel(), '#description' => FieldFilteredMarkup::create(\Drupal::token()->replace($this->fieldDefinition->getDescription())), - ); + ]; $element = $this->formSingleElement($items, $delta, $element, $form, $form_state); if ($element) { @@ -107,28 +107,28 @@ public function form(FieldItemListInterface $items, array &$form, FormStateInter // Populate the 'array_parents' information in $form_state->get('field') // after the form is built, so that we catch changes in the form structure // performed in alter() hooks. - $elements['#after_build'][] = array(get_class($this), 'afterBuild'); + $elements['#after_build'][] = [get_class($this), 'afterBuild']; $elements['#field_name'] = $field_name; $elements['#field_parents'] = $parents; // Enforce the structure of submitted values. - $elements['#parents'] = array_merge($parents, array($field_name)); + $elements['#parents'] = array_merge($parents, [$field_name]); // Most widgets need their internal structure preserved in submitted values. - $elements += array('#tree' => TRUE); + $elements += ['#tree' => TRUE]; - return array( + return [ // Aid in theming of widgets by rendering a classified container. '#type' => 'container', // Assign a different parent, to keep the main id for the widget itself. - '#parents' => array_merge($parents, array($field_name . '_wrapper')), - '#attributes' => array( - 'class' => array( + '#parents' => array_merge($parents, [$field_name . '_wrapper']), + '#attributes' => [ + 'class' => [ 'field--type-' . Html::getClass($this->fieldDefinition->getType()), 'field--name-' . Html::getClass($field_name), 'field--widget-' . Html::getClass($this->getPluginId()), - ), - ), + ], + ], 'widget' => $elements, - ); + ]; } /** @@ -161,7 +161,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f $title = $this->fieldDefinition->getLabel(); $description = FieldFilteredMarkup::create(\Drupal::token()->replace($this->fieldDefinition->getDescription())); - $elements = array(); + $elements = []; for ($delta = 0; $delta <= $max; $delta++) { // Add a new empty item if it doesn't exist yet at this delta. @@ -193,15 +193,15 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f if ($is_multiple) { // We name the element '_weight' to avoid clashing with elements // defined by widget. - $element['_weight'] = array( + $element['_weight'] = [ '#type' => 'weight', - '#title' => $this->t('Weight for row @number', array('@number' => $delta + 1)), + '#title' => $this->t('Weight for row @number', ['@number' => $delta + 1]), '#title_display' => 'invisible', // Note: this 'delta' is the FAPI #type 'weight' element's property. '#delta' => $max, '#default_value' => $items[$delta]->_weight ?: $delta, '#weight' => 100, - ); + ]; } $elements[$delta] = $element; @@ -209,7 +209,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f } if ($elements) { - $elements += array( + $elements += [ '#theme' => 'field_multiple_value_form', '#field_name' => $field_name, '#cardinality' => $cardinality, @@ -218,28 +218,28 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f '#title' => $title, '#description' => $description, '#max_delta' => $max, - ); + ]; // Add 'add more' button, if not working with a programmed form. if ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED && !$form_state->isProgrammed()) { - $id_prefix = implode('-', array_merge($parents, array($field_name))); + $id_prefix = implode('-', array_merge($parents, [$field_name])); $wrapper_id = Html::getUniqueId($id_prefix . '-add-more-wrapper'); $elements['#prefix'] = '
'; $elements['#suffix'] = '
'; - $elements['add_more'] = array( + $elements['add_more'] = [ '#type' => 'submit', '#name' => strtr($id_prefix, '-', '_') . '_add_more', '#value' => t('Add another item'), - '#attributes' => array('class' => array('field-add-more-submit')), - '#limit_validation_errors' => array(array_merge($parents, array($field_name))), - '#submit' => array(array(get_class($this), 'addMoreSubmit')), - '#ajax' => array( - 'callback' => array(get_class($this), 'addMoreAjax'), + '#attributes' => ['class' => ['field-add-more-submit']], + '#limit_validation_errors' => [array_merge($parents, [$field_name])], + '#submit' => [[get_class($this), 'addMoreSubmit']], + '#ajax' => [ + 'callback' => [get_class($this), 'addMoreAjax'], 'wrapper' => $wrapper_id, 'effect' => 'fade', - ), - ); + ], + ]; } } @@ -313,26 +313,26 @@ public static function addMoreAjax(array $form, FormStateInterface $form_state) protected function formSingleElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $entity = $items->getEntity(); - $element += array( + $element += [ '#field_parents' => $form['#parents'], // Only the first widget should be required. '#required' => $delta == 0 && $this->fieldDefinition->isRequired(), '#delta' => $delta, '#weight' => $delta, - ); + ]; $element = $this->formElement($items, $delta, $element, $form, $form_state); if ($element) { // Allow modules to alter the field widget form element. - $context = array( + $context = [ 'form' => $form, 'widget' => $this, 'items' => $items, 'delta' => $delta, 'default' => $this->isDefaultValueWidget($form_state), - ); - \Drupal::moduleHandler()->alter(array('field_widget_form', 'field_widget_' . $this->getPluginId() . '_form'), $element, $form_state, $context); + ]; + \Drupal::moduleHandler()->alter(['field_widget_form', 'field_widget_' . $this->getPluginId() . '_form'], $element, $form_state, $context); } return $element; @@ -345,7 +345,7 @@ public function extractFormValues(FieldItemListInterface $items, array $form, Fo $field_name = $this->fieldDefinition->getName(); // Extract the values from $form_state->getValues(). - $path = array_merge($form['#parents'], array($field_name)); + $path = array_merge($form['#parents'], [$field_name]); $key_exists = NULL; $values = NestedArray::getValue($form_state->getValues(), $path, $key_exists); @@ -412,7 +412,7 @@ public function flagErrors(FieldItemListInterface $items, ConstraintViolationLis if (Element::isVisibleElement($element)) { $handles_multiple = $this->handlesMultipleValues(); - $violations_by_delta = array(); + $violations_by_delta = []; foreach ($violations as $violation) { // Separate violations by delta. $property_path = explode('.', $violation->getPropertyPath()); @@ -475,21 +475,21 @@ protected static function getWidgetStateParents(array $parents, $field_name) { // Field processing data is placed at // $form_state->get(['field_storage', '#parents', ...$parents..., '#fields', $field_name]), // to avoid clashes between field names and $parents parts. - return array_merge(array('field_storage', '#parents'), $parents, array('#fields', $field_name)); + return array_merge(['field_storage', '#parents'], $parents, ['#fields', $field_name]); } /** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - return array(); + return []; } /** * {@inheritdoc} */ public function settingsSummary() { - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Field/WidgetPluginManager.php b/core/lib/Drupal/Core/Field/WidgetPluginManager.php index 6be1b9e..c7c2d79 100644 --- a/core/lib/Drupal/Core/Field/WidgetPluginManager.php +++ b/core/lib/Drupal/Core/Field/WidgetPluginManager.php @@ -74,10 +74,10 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac */ public function getInstance(array $options) { // Fill in defaults for missing properties. - $options += array( - 'configuration' => array(), + $options += [ + 'configuration' => [], 'prepare' => TRUE, - ); + ]; $configuration = $options['configuration']; $field_definition = $options['field_definition']; @@ -104,16 +104,16 @@ public function getInstance(array $options) { $plugin_id = $field_type_definition['default_widget']; } - $configuration += array( + $configuration += [ 'field_definition' => $field_definition, - ); + ]; return $this->createInstance($plugin_id, $configuration); } /** * {@inheritdoc} */ - public function createInstance($plugin_id, array $configuration = array()) { + public function createInstance($plugin_id, array $configuration = []) { $plugin_definition = $this->getDefinition($plugin_id); $plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition); @@ -139,10 +139,10 @@ public function createInstance($plugin_id, array $configuration = array()) { */ public function prepareConfiguration($field_type, array $configuration) { // Fill in defaults for missing properties. - $configuration += array( - 'settings' => array(), - 'third_party_settings' => array(), - ); + $configuration += [ + 'settings' => [], + 'third_party_settings' => [], + ]; // If no widget is specified, use the default widget. if (!isset($configuration['type'])) { $field_type = $this->fieldTypeManager->getDefinition($field_type); @@ -168,10 +168,10 @@ public function prepareConfiguration($field_type, array $configuration) { */ public function getOptions($field_type = NULL) { if (!isset($this->widgetOptions)) { - $options = array(); + $options = []; $field_types = $this->fieldTypeManager->getDefinitions(); $widget_types = $this->getDefinitions(); - uasort($widget_types, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); + uasort($widget_types, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']); foreach ($widget_types as $name => $widget_type) { foreach ($widget_type['field_types'] as $widget_field_type) { // Check that the field type exists. @@ -183,7 +183,7 @@ public function getOptions($field_type = NULL) { $this->widgetOptions = $options; } if (isset($field_type)) { - return !empty($this->widgetOptions[$field_type]) ? $this->widgetOptions[$field_type] : array(); + return !empty($this->widgetOptions[$field_type]) ? $this->widgetOptions[$field_type] : []; } return $this->widgetOptions; @@ -206,7 +206,7 @@ public function getDefaultSettings($type) { return $plugin_class::defaultSettings(); } - return array(); + return []; } } diff --git a/core/lib/Drupal/Core/File/FileSystem.php b/core/lib/Drupal/Core/File/FileSystem.php index 076bc06..d940953 100644 --- a/core/lib/Drupal/Core/File/FileSystem.php +++ b/core/lib/Drupal/Core/File/FileSystem.php @@ -95,7 +95,7 @@ public function chmod($uri, $mode = NULL) { return TRUE; } - $this->logger->error('The file permissions could not be set on %uri.', array('%uri' => $uri)); + $this->logger->error('The file permissions could not be set on %uri.', ['%uri' => $uri]); return FALSE; } diff --git a/core/lib/Drupal/Core/File/MimeType/ExtensionMimeTypeGuesser.php b/core/lib/Drupal/Core/File/MimeType/ExtensionMimeTypeGuesser.php index 5e05ec0..e9bcfb4 100644 --- a/core/lib/Drupal/Core/File/MimeType/ExtensionMimeTypeGuesser.php +++ b/core/lib/Drupal/Core/File/MimeType/ExtensionMimeTypeGuesser.php @@ -16,8 +16,8 @@ class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface { * @var array * Array of mimetypes correlated to the extensions that relate to them. */ - protected $defaultMapping = array( - 'mimetypes' => array( + protected $defaultMapping = [ + 'mimetypes' => [ 0 => 'application/andrew-inset', 1 => 'application/atom', 2 => 'application/atomcat+xml', @@ -377,10 +377,10 @@ class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface { 343 => 'x-conference/x-cooltalk', 344 => 'x-epoc/x-sisx-app', 345 => 'x-world/x-vrml', - ), + ], // Extensions added to this list MUST be lower-case. - 'extensions' => array( + 'extensions' => [ 'ez' => 0, 'atom' => 1, 'atomcat' => 2, @@ -856,8 +856,8 @@ class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface { 'weba' => 356, 'webm' => 357, 'vtt' => 358, - ), - ); + ], + ]; /** * The MIME types mapping array after going through the module handler. diff --git a/core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php b/core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php index 72df780..ace43b6 100644 --- a/core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php +++ b/core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php @@ -17,7 +17,7 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface { * * @var array */ - protected $guessers = array(); + protected $guessers = []; /** * Holds the array of guessers sorted by priority. @@ -98,7 +98,7 @@ public function addGuesser(MimeTypeGuesserInterface $guesser, $priority = 0) { * A sorted array of MIME type guesser objects. */ protected function sortGuessers() { - $sorted = array(); + $sorted = []; krsort($this->guessers); foreach ($this->guessers as $guesser) { diff --git a/core/lib/Drupal/Core/File/file.api.php b/core/lib/Drupal/Core/File/file.api.php index c26ac2b..2e804a8 100644 --- a/core/lib/Drupal/Core/File/file.api.php +++ b/core/lib/Drupal/Core/File/file.api.php @@ -33,9 +33,9 @@ function hook_file_download($uri) { $scheme = file_uri_scheme($uri); $target = file_uri_target($uri); if ($scheme == 'temporary' && $target == 'config.tar.gz') { - return array( + return [ 'Content-disposition' => 'attachment; filename="config.tar.gz"', - ); + ]; } } @@ -64,11 +64,11 @@ function hook_file_url_alter(&$uri) { $cdn1 = 'http://cdn1.example.com'; $cdn2 = 'http://cdn2.example.com'; - $cdn_extensions = array('css', 'js', 'gif', 'jpg', 'jpeg', 'png'); + $cdn_extensions = ['css', 'js', 'gif', 'jpg', 'jpeg', 'png']; // Most CDNs don't support private file transfers without a lot of hassle, // so don't support this in the common case. - $schemes = array('public'); + $schemes = ['public']; $scheme = file_uri_scheme($uri); @@ -166,11 +166,11 @@ function hook_archiver_info_alter(&$info) { * @see drupal_get_filetransfer_info() */ function hook_filetransfer_info() { - $info['sftp'] = array( + $info['sftp'] = [ 'title' => t('SFTP (Secure FTP)'), 'class' => 'Drupal\Core\FileTransfer\SFTP', 'weight' => 10, - ); + ]; return $info; } diff --git a/core/lib/Drupal/Core/FileTransfer/FTPExtension.php b/core/lib/Drupal/Core/FileTransfer/FTPExtension.php index 3617a63..7cb0c54 100644 --- a/core/lib/Drupal/Core/FileTransfer/FTPExtension.php +++ b/core/lib/Drupal/Core/FileTransfer/FTPExtension.php @@ -26,7 +26,7 @@ public function connect() { */ protected function copyFileJailed($source, $destination) { if (!@ftp_put($this->connection, $destination, $source, FTP_BINARY)) { - throw new FileTransferException("Cannot move @source to @destination", NULL, array("@source" => $source, "@destination" => $destination)); + throw new FileTransferException("Cannot move @source to @destination", NULL, ["@source" => $source, "@destination" => $destination]); } } @@ -35,7 +35,7 @@ protected function copyFileJailed($source, $destination) { */ protected function createDirectoryJailed($directory) { if (!ftp_mkdir($this->connection, $directory)) { - throw new FileTransferException("Cannot create directory @directory", NULL, array("@directory" => $directory)); + throw new FileTransferException("Cannot create directory @directory", NULL, ["@directory" => $directory]); } } @@ -45,11 +45,11 @@ protected function createDirectoryJailed($directory) { protected function removeDirectoryJailed($directory) { $pwd = ftp_pwd($this->connection); if (!ftp_chdir($this->connection, $directory)) { - throw new FileTransferException("Unable to change to directory @directory", NULL, array('@directory' => $directory)); + throw new FileTransferException("Unable to change to directory @directory", NULL, ['@directory' => $directory]); } $list = @ftp_nlist($this->connection, '.'); if (!$list) { - $list = array(); + $list = []; } foreach ($list as $item) { if ($item == '.' || $item == '..') { @@ -65,7 +65,7 @@ protected function removeDirectoryJailed($directory) { } ftp_chdir($this->connection, $pwd); if (!ftp_rmdir($this->connection, $directory)) { - throw new FileTransferException("Unable to remove to directory @directory", NULL, array('@directory' => $directory)); + throw new FileTransferException("Unable to remove to directory @directory", NULL, ['@directory' => $directory]); } } @@ -74,7 +74,7 @@ protected function removeDirectoryJailed($directory) { */ protected function removeFileJailed($destination) { if (!ftp_delete($this->connection, $destination)) { - throw new FileTransferException("Unable to remove to file @file", NULL, array('@file' => $destination)); + throw new FileTransferException("Unable to remove to file @file", NULL, ['@file' => $destination]); } } @@ -103,7 +103,7 @@ public function isFile($path) { */ function chmodJailed($path, $mode, $recursive) { if (!ftp_chmod($this->connection, $mode, $path)) { - throw new FileTransferException("Unable to set permissions on %file", NULL, array('%file' => $path)); + throw new FileTransferException("Unable to set permissions on %file", NULL, ['%file' => $path]); } if ($this->isDirectory($path) && $recursive) { $filelist = @ftp_nlist($this->connection, $path); diff --git a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php index dbe2559..a3cf678 100644 --- a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php +++ b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php @@ -210,7 +210,7 @@ function __get($name) { $full_path = drupal_realpath(substr($this->chroot . $path, 0, strlen($full_jail))); $full_path = $this->fixRemotePath($full_path, FALSE); if ($full_jail !== $full_path) { - throw new FileTransferException('@directory is outside of the @jail', NULL, array('@directory' => $path, '@jail' => $this->jail)); + throw new FileTransferException('@directory is outside of the @jail', NULL, ['@directory' => $path, '@jail' => $this->jail]); } } @@ -388,30 +388,30 @@ function setChroot() { * An array that contains a Form API definition. */ public function getSettingsForm() { - $form['username'] = array( + $form['username'] = [ '#type' => 'textfield', '#title' => t('Username'), - ); - $form['password'] = array( + ]; + $form['password'] = [ '#type' => 'password', '#title' => t('Password'), '#description' => t('Your password is not saved in the database and is only used to establish a connection.'), - ); - $form['advanced'] = array( + ]; + $form['advanced'] = [ '#type' => 'details', '#title' => t('Advanced settings'), - ); - $form['advanced']['hostname'] = array( + ]; + $form['advanced']['hostname'] = [ '#type' => 'textfield', '#title' => t('Host'), '#default_value' => 'localhost', '#description' => t('The connection will be created between your web server and the machine hosting the web server files. In the vast majority of cases, this will be the same machine, and "localhost" is correct.'), - ); - $form['advanced']['port'] = array( + ]; + $form['advanced']['port'] = [ '#type' => 'textfield', '#title' => t('Port'), '#default_value' => NULL, - ); + ]; return $form; } diff --git a/core/lib/Drupal/Core/FileTransfer/FileTransferException.php b/core/lib/Drupal/Core/FileTransfer/FileTransferException.php index 15e6570..f8d0d07 100644 --- a/core/lib/Drupal/Core/FileTransfer/FileTransferException.php +++ b/core/lib/Drupal/Core/FileTransfer/FileTransferException.php @@ -24,7 +24,7 @@ class FileTransferException extends \RuntimeException { * @param array $arguments * Arguments to be used in this exception. */ - function __construct($message, $code = 0, $arguments = array()) { + function __construct($message, $code = 0, $arguments = []) { parent::__construct($message, $code); $this->arguments = $arguments; } diff --git a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php index 647463a..2adbd1f 100644 --- a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php +++ b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php @@ -51,37 +51,37 @@ public function buildForm(array $form, FormStateInterface $form_state) { // Get all the available ways to transfer files. if (empty($_SESSION['authorize_filetransfer_info'])) { drupal_set_message($this->t('Unable to continue, no available methods of file transfer'), 'error'); - return array(); + return []; } $available_backends = $_SESSION['authorize_filetransfer_info']; if (!$this->getRequest()->isSecure()) { - $form['information']['https_warning'] = array( + $form['information']['https_warning'] = [ '#prefix' => '
', - '#markup' => $this->t('WARNING: You are not using an encrypted connection, so your password will be sent in plain text. Learn more.', array(':https-link' => 'https://www.drupal.org/https-information')), + '#markup' => $this->t('WARNING: You are not using an encrypted connection, so your password will be sent in plain text. Learn more.', [':https-link' => 'https://www.drupal.org/https-information']), '#suffix' => '
', - ); + ]; } // Decide on a default backend. - $authorize_filetransfer_default = $form_state->getValue(array('connection_settings', 'authorize_filetransfer_default')); + $authorize_filetransfer_default = $form_state->getValue(['connection_settings', 'authorize_filetransfer_default']); if (!$authorize_filetransfer_default) { $authorize_filetransfer_default = key($available_backends); } - $form['information']['main_header'] = array( + $form['information']['main_header'] = [ '#prefix' => '

', '#markup' => $this->t('To continue, provide your server connection details'), '#suffix' => '

', - ); + ]; $form['connection_settings']['#tree'] = TRUE; - $form['connection_settings']['authorize_filetransfer_default'] = array( + $form['connection_settings']['authorize_filetransfer_default'] = [ '#type' => 'select', '#title' => $this->t('Connection method'), '#default_value' => $authorize_filetransfer_default, '#weight' => -10, - ); + ]; /* * Here we create two submit buttons. For a JS enabled client, they will @@ -90,46 +90,46 @@ public function buildForm(array $form, FormStateInterface $form_state) { * what filetransfer type to use, and submit_process on the second one (which * leads to the actual operation). */ - $form['submit_connection'] = array( + $form['submit_connection'] = [ '#prefix' => "
", '#name' => 'enter_connection_settings', '#type' => 'submit', '#value' => $this->t('Enter connection settings'), '#weight' => 100, - ); + ]; - $form['submit_process'] = array( + $form['submit_process'] = [ '#name' => 'process_updates', '#type' => 'submit', '#value' => $this->t('Continue'), '#weight' => 100, - ); + ]; // Build a container for each connection type. foreach ($available_backends as $name => $backend) { $form['connection_settings']['authorize_filetransfer_default']['#options'][$name] = $backend['title']; - $form['connection_settings'][$name] = array( + $form['connection_settings'][$name] = [ '#type' => 'container', - '#attributes' => array('class' => array("filetransfer-$name", 'filetransfer')), - '#states' => array( - 'visible' => array( - 'select[name="connection_settings[authorize_filetransfer_default]"]' => array('value' => $name), - ), - ), - ); + '#attributes' => ['class' => ["filetransfer-$name", 'filetransfer']], + '#states' => [ + 'visible' => [ + 'select[name="connection_settings[authorize_filetransfer_default]"]' => ['value' => $name], + ], + ], + ]; // We can't use #prefix on the container itself since then the header won't // be hidden and shown when the containers are being manipulated via JS. - $form['connection_settings'][$name]['header'] = array( - '#markup' => '

' . $this->t('@backend connection settings', array('@backend' => $backend['title'])) . '

', - ); + $form['connection_settings'][$name]['header'] = [ + '#markup' => '

' . $this->t('@backend connection settings', ['@backend' => $backend['title']]) . '

', + ]; $form['connection_settings'][$name] += $this->addConnectionSettings($name); // Start non-JS code. - if ($form_state->getValue(array('connection_settings', 'authorize_filetransfer_default')) == $name) { + if ($form_state->getValue(['connection_settings', 'authorize_filetransfer_default']) == $name) { // Change the submit button to the submit_process one. - $form['submit_process']['#attributes'] = array(); + $form['submit_process']['#attributes'] = []; unset($form['submit_connection']); // Activate the proper filetransfer settings form. @@ -138,13 +138,13 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['connection_settings']['authorize_filetransfer_default']['#disabled'] = TRUE; // Create a button for changing the type of connection. - $form['connection_settings']['change_connection_type'] = array( + $form['connection_settings']['change_connection_type'] = [ '#name' => 'change_connection_type', '#type' => 'submit', '#value' => $this->t('Change connection type'), '#weight' => -5, - '#attributes' => array('class' => array('filetransfer-change-connection-type')), - ); + '#attributes' => ['class' => ['filetransfer-change-connection-type']], + ]; } // End non-JS code. } @@ -166,17 +166,17 @@ public function validateForm(array &$form, FormStateInterface $form_state) { $filetransfer = $this->getFiletransfer($backend, $form_connection_settings[$backend]); try { if (!$filetransfer) { - throw new \Exception($this->t('The connection protocol %backend does not exist.', array('%backend' => $backend))); + throw new \Exception($this->t('The connection protocol %backend does not exist.', ['%backend' => $backend])); } $filetransfer->connect(); } catch (\Exception $e) { // The format of this error message is similar to that used on the // database connection form in the installer. - $form_state->setErrorByName('connection_settings', $this->t('Failed to connect to the server. The server reports the following message:

@message

For more help installing or updating code on your server, see the handbook.', array( + $form_state->setErrorByName('connection_settings', $this->t('Failed to connect to the server. The server reports the following message:

@message

For more help installing or updating code on your server, see the handbook.', [ '@message' => $e->getMessage(), ':handbook_url' => 'https://www.drupal.org/documentation/install/modules-themes', - ))); + ])); } } } @@ -218,7 +218,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { case 'change_connection_type': $form_state->setRebuild(); - $form_state->unsetValue(array('connection_settings', 'authorize_filetransfer_default')); + $form_state->unsetValue(['connection_settings', 'authorize_filetransfer_default']); break; } } @@ -235,7 +235,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { * An instantiated FileTransfer object for the requested method and settings, * or FALSE if there was an error finding or instantiating it. */ - protected function getFiletransfer($backend, $settings = array()) { + protected function getFiletransfer($backend, $settings = []) { $filetransfer = FALSE; if (!empty($_SESSION['authorize_filetransfer_info'][$backend])) { $backend_info = $_SESSION['authorize_filetransfer_info'][$backend]; @@ -258,8 +258,8 @@ protected function getFiletransfer($backend, $settings = array()) { * @see hook_filetransfer_backends() */ protected function addConnectionSettings($backend) { - $defaults = array(); - $form = array(); + $defaults = []; + $form = []; // Create an instance of the file transfer class to get its settings form. $filetransfer = $this->getFiletransfer($backend); @@ -320,7 +320,7 @@ protected function runOperation($filetransfer) { unset($_SESSION['authorize_operation']); require_once $operation['file']; - return call_user_func_array($operation['callback'], array_merge(array($filetransfer), $operation['arguments'])); + return call_user_func_array($operation['callback'], array_merge([$filetransfer], $operation['arguments'])); } } diff --git a/core/lib/Drupal/Core/FileTransfer/Local.php b/core/lib/Drupal/Core/FileTransfer/Local.php index e687931..9320f4a 100644 --- a/core/lib/Drupal/Core/FileTransfer/Local.php +++ b/core/lib/Drupal/Core/FileTransfer/Local.php @@ -26,7 +26,7 @@ static function factory($jail, $settings) { */ protected function copyFileJailed($source, $destination) { if (@!copy($source, $destination)) { - throw new FileTransferException('Cannot copy %source to %destination.', NULL, array('%source' => $source, '%destination' => $destination)); + throw new FileTransferException('Cannot copy %source to %destination.', NULL, ['%source' => $source, '%destination' => $destination]); } } @@ -35,7 +35,7 @@ protected function copyFileJailed($source, $destination) { */ protected function createDirectoryJailed($directory) { if (!is_dir($directory) && @!mkdir($directory, 0777, TRUE)) { - throw new FileTransferException('Cannot create directory %directory.', NULL, array('%directory' => $directory)); + throw new FileTransferException('Cannot create directory %directory.', NULL, ['%directory' => $directory]); } } @@ -45,22 +45,22 @@ protected function createDirectoryJailed($directory) { protected function removeDirectoryJailed($directory) { if (!is_dir($directory)) { // Programmer error assertion, not something we expect users to see. - throw new FileTransferException('removeDirectoryJailed() called with a path (%directory) that is not a directory.', NULL, array('%directory' => $directory)); + throw new FileTransferException('removeDirectoryJailed() called with a path (%directory) that is not a directory.', NULL, ['%directory' => $directory]); } foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST) as $filename => $file) { if ($file->isDir()) { if (@!drupal_rmdir($filename)) { - throw new FileTransferException('Cannot remove directory %directory.', NULL, array('%directory' => $filename)); + throw new FileTransferException('Cannot remove directory %directory.', NULL, ['%directory' => $filename]); } } elseif ($file->isFile()) { if (@!drupal_unlink($filename)) { - throw new FileTransferException('Cannot remove file %file.', NULL, array('%file' => $filename)); + throw new FileTransferException('Cannot remove file %file.', NULL, ['%file' => $filename]); } } } if (@!drupal_rmdir($directory)) { - throw new FileTransferException('Cannot remove directory %directory.', NULL, array('%directory' => $directory)); + throw new FileTransferException('Cannot remove directory %directory.', NULL, ['%directory' => $directory]); } } @@ -69,7 +69,7 @@ protected function removeDirectoryJailed($directory) { */ protected function removeFileJailed($file) { if (@!drupal_unlink($file)) { - throw new FileTransferException('Cannot remove file %file.', NULL, array('%file' => $file)); + throw new FileTransferException('Cannot remove file %file.', NULL, ['%file' => $file]); } } @@ -94,12 +94,12 @@ public function chmodJailed($path, $mode, $recursive) { if ($recursive && is_dir($path)) { foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $filename => $file) { if (@!chmod($filename, $mode)) { - throw new FileTransferException('Cannot chmod %path.', NULL, array('%path' => $filename)); + throw new FileTransferException('Cannot chmod %path.', NULL, ['%path' => $filename]); } } } elseif (@!chmod($path, $mode)) { - throw new FileTransferException('Cannot chmod %path.', NULL, array('%path' => $path)); + throw new FileTransferException('Cannot chmod %path.', NULL, ['%path' => $path]); } } diff --git a/core/lib/Drupal/Core/FileTransfer/SSH.php b/core/lib/Drupal/Core/FileTransfer/SSH.php index 8250c16..256aaf4 100644 --- a/core/lib/Drupal/Core/FileTransfer/SSH.php +++ b/core/lib/Drupal/Core/FileTransfer/SSH.php @@ -24,7 +24,7 @@ function __construct($jail, $username, $password, $hostname = "localhost", $port public function connect() { $this->connection = @ssh2_connect($this->hostname, $this->port); if (!$this->connection) { - throw new FileTransferException('SSH Connection failed to @host:@port', NULL, array('@host' => $this->hostname, '@port' => $this->port)); + throw new FileTransferException('SSH Connection failed to @host:@port', NULL, ['@host' => $this->hostname, '@port' => $this->port]); } if (!@ssh2_auth_password($this->connection, $this->username, $this->password)) { throw new FileTransferException('The supplied username/password combination was not accepted.'); @@ -47,7 +47,7 @@ static function factory($jail, $settings) { */ protected function copyFileJailed($source, $destination) { if (!@ssh2_scp_send($this->connection, $source, $destination)) { - throw new FileTransferException('Cannot copy @source_file to @destination_file.', NULL, array('@source' => $source, '@destination' => $destination)); + throw new FileTransferException('Cannot copy @source_file to @destination_file.', NULL, ['@source' => $source, '@destination' => $destination]); } } @@ -56,7 +56,7 @@ protected function copyFileJailed($source, $destination) { */ protected function copyDirectoryJailed($source, $destination) { if (@!ssh2_exec($this->connection, 'cp -Rp ' . escapeshellarg($source) . ' ' . escapeshellarg($destination))) { - throw new FileTransferException('Cannot copy directory @directory.', NULL, array('@directory' => $source)); + throw new FileTransferException('Cannot copy directory @directory.', NULL, ['@directory' => $source]); } } @@ -65,7 +65,7 @@ protected function copyDirectoryJailed($source, $destination) { */ protected function createDirectoryJailed($directory) { if (@!ssh2_exec($this->connection, 'mkdir ' . escapeshellarg($directory))) { - throw new FileTransferException('Cannot create directory @directory.', NULL, array('@directory' => $directory)); + throw new FileTransferException('Cannot create directory @directory.', NULL, ['@directory' => $directory]); } } @@ -74,7 +74,7 @@ protected function createDirectoryJailed($directory) { */ protected function removeDirectoryJailed($directory) { if (@!ssh2_exec($this->connection, 'rm -Rf ' . escapeshellarg($directory))) { - throw new FileTransferException('Cannot remove @directory.', NULL, array('@directory' => $directory)); + throw new FileTransferException('Cannot remove @directory.', NULL, ['@directory' => $directory]); } } @@ -83,7 +83,7 @@ protected function removeDirectoryJailed($directory) { */ protected function removeFileJailed($destination) { if (!@ssh2_exec($this->connection, 'rm ' . escapeshellarg($destination))) { - throw new FileTransferException('Cannot remove @directory.', NULL, array('@directory' => $destination)); + throw new FileTransferException('Cannot remove @directory.', NULL, ['@directory' => $destination]); } } @@ -103,7 +103,7 @@ public function isDirectory($path) { return FALSE; } else { - throw new FileTransferException('Cannot check @path.', NULL, array('@path' => $path)); + throw new FileTransferException('Cannot check @path.', NULL, ['@path' => $path]); } } @@ -120,7 +120,7 @@ public function isFile($path) { return FALSE; } else { - throw new FileTransferException('Cannot check @path.', NULL, array('@path' => $path)); + throw new FileTransferException('Cannot check @path.', NULL, ['@path' => $path]); } } @@ -130,7 +130,7 @@ public function isFile($path) { function chmodJailed($path, $mode, $recursive) { $cmd = sprintf("chmod %s%o %s", $recursive ? '-R ' : '', $mode, escapeshellarg($path)); if (@!ssh2_exec($this->connection, $cmd)) { - throw new FileTransferException('Cannot change permissions of @path.', NULL, array('@path' => $path)); + throw new FileTransferException('Cannot change permissions of @path.', NULL, ['@path' => $path]); } } diff --git a/core/lib/Drupal/Core/Flood/DatabaseBackend.php b/core/lib/Drupal/Core/Flood/DatabaseBackend.php index 4b2f0d0..12e9102 100644 --- a/core/lib/Drupal/Core/Flood/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Flood/DatabaseBackend.php @@ -80,12 +80,12 @@ public function register($name, $window = 3600, $identifier = NULL) { */ protected function doInsert($name, $window, $identifier) { $this->connection->insert(static::TABLE_NAME) - ->fields(array( + ->fields([ 'event' => $name, 'identifier' => $identifier, 'timestamp' => REQUEST_TIME, 'expiration' => REQUEST_TIME + $window, - )) + ]) ->execute(); } diff --git a/core/lib/Drupal/Core/Flood/MemoryBackend.php b/core/lib/Drupal/Core/Flood/MemoryBackend.php index 5b3377e..ddb42bc 100644 --- a/core/lib/Drupal/Core/Flood/MemoryBackend.php +++ b/core/lib/Drupal/Core/Flood/MemoryBackend.php @@ -19,7 +19,7 @@ class MemoryBackend implements FloodInterface { /** * An array holding flood events, keyed by event name and identifier. */ - protected $events = array(); + protected $events = []; /** * Construct the MemoryBackend. diff --git a/core/lib/Drupal/Core/Form/ConfigFormBase.php b/core/lib/Drupal/Core/Form/ConfigFormBase.php index fb508f8..e7878a7 100644 --- a/core/lib/Drupal/Core/Form/ConfigFormBase.php +++ b/core/lib/Drupal/Core/Form/ConfigFormBase.php @@ -35,11 +35,11 @@ public static function create(ContainerInterface $container) { */ public function buildForm(array $form, FormStateInterface $form_state) { $form['actions']['#type'] = 'actions'; - $form['actions']['submit'] = array( + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Save configuration'), '#button_type' => 'primary', - ); + ]; // By default, render the form using system-config-form.html.twig. $form['#theme'] = 'system_config_form'; diff --git a/core/lib/Drupal/Core/Form/ConfirmFormBase.php b/core/lib/Drupal/Core/Form/ConfirmFormBase.php index 6de9fdf..4214bfc 100644 --- a/core/lib/Drupal/Core/Form/ConfirmFormBase.php +++ b/core/lib/Drupal/Core/Form/ConfirmFormBase.php @@ -42,15 +42,15 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['#title'] = $this->getQuestion(); $form['#attributes']['class'][] = 'confirmation'; - $form['description'] = array('#markup' => $this->getDescription()); - $form[$this->getFormName()] = array('#type' => 'hidden', '#value' => 1); + $form['description'] = ['#markup' => $this->getDescription()]; + $form[$this->getFormName()] = ['#type' => 'hidden', '#value' => 1]; - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->getConfirmText(), '#button_type' => 'primary', - ); + ]; $form['actions']['cancel'] = ConfirmFormHelper::buildCancelLink($this, $this->getRequest()); diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index 544ee94..0fd48c2 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -494,7 +494,7 @@ public function retrieveForm($form_id, FormStateInterface &$form_state) { $callback = [$form_state->getFormObject(), 'buildForm']; - $form = array(); + $form = []; // Assign a default CSS class name based on $form_id. // This happens here and not in self::prepareForm() in order to allow the // form constructor function to override or remove the default class. @@ -507,7 +507,7 @@ public function retrieveForm($form_id, FormStateInterface &$form_state) { // We need to pass $form_state by reference in order for forms to modify it, // since call_user_func_array() requires that referenced variables are // passed explicitly. - $args = array_merge(array($form, &$form_state), $args); + $args = array_merge([$form, &$form_state], $args); $form = call_user_func_array($callback, $args); // If the form returns a response, skip subsequent page construction by @@ -713,7 +713,7 @@ public function prepareForm($form_id, &$form, FormStateInterface &$form_state) { if (!isset($form['#build_id'])) { $form['#build_id'] = 'form-' . Crypt::randomBytesBase64(); } - $form['form_build_id'] = array( + $form['form_build_id'] = [ '#type' => 'hidden', '#value' => $form['#build_id'], '#id' => $form['#build_id'], @@ -721,8 +721,8 @@ public function prepareForm($form_id, &$form, FormStateInterface &$form_state) { // Form processing and validation requires this value, so ensure the // submitted form value appears literally, regardless of custom #tree // and #parents being set elsewhere. - '#parents' => array('form_build_id'), - ); + '#parents' => ['form_build_id'], + ]; // Add a token, based on either #token or form_id, to any form displayed to // authenticated users. This ensures that any submitted form was actually @@ -745,14 +745,14 @@ public function prepareForm($form_id, &$form, FormStateInterface &$form_state) { $placeholder = 'form_token_placeholder_' . hash('crc32b', $form_id); $form['#token'] = $placeholder; - $form['form_token'] = array( + $form['form_token'] = [ '#id' => Html::getUniqueId('edit-' . $form_id . '-form-token'), '#type' => 'token', '#default_value' => $placeholder, // Form processing and validation requires this value, so ensure the // submitted form value appears literally, regardless of custom #tree // and #parents being set elsewhere. - '#parents' => array('form_token'), + '#parents' => ['form_token'], // Instead of setting an actual CSRF token, we've set the placeholder // in form_token's #default_value and #placeholder. These will be // replaced at the very last moment. This ensures forms with a CSRF @@ -767,20 +767,20 @@ public function prepareForm($form_id, &$form, FormStateInterface &$form_state) { '#cache' => [ 'max-age' => 0, ], - ); + ]; } } if (isset($form_id)) { - $form['form_id'] = array( + $form['form_id'] = [ '#type' => 'hidden', '#value' => $form_id, '#id' => Html::getUniqueId("edit-$form_id"), // Form processing and validation requires this value, so ensure the // submitted form value appears literally, regardless of custom #tree // and #parents being set elsewhere. - '#parents' => array('form_id'), - ); + '#parents' => ['form_id'], + ]; } if (!isset($form['#id'])) { $form['#id'] = Html::getUniqueId($form_id); @@ -790,7 +790,7 @@ public function prepareForm($form_id, &$form, FormStateInterface &$form_state) { } $form += $this->elementInfo->getInfo('form'); - $form += array('#tree' => FALSE, '#parents' => array()); + $form += ['#tree' => FALSE, '#parents' => []]; $form['#validate'][] = '::validateForm'; $form['#submit'][] = '::submitForm'; @@ -800,7 +800,7 @@ public function prepareForm($form_id, &$form, FormStateInterface &$form_state) { // is in #theme_wrappers. Therefore, the #theme function only has to care // for rendering the inner form elements, not the form itself. if (!isset($form['#theme'])) { - $form['#theme'] = array($form_id); + $form['#theme'] = [$form_id]; if (isset($build_info['base_form_id'])) { $form['#theme'][] = $build_info['base_form_id']; } @@ -808,7 +808,7 @@ public function prepareForm($form_id, &$form, FormStateInterface &$form_state) { // Invoke hook_form_alter(), hook_form_BASE_FORM_ID_alter(), and // hook_form_FORM_ID_alter() implementations. - $hooks = array('form'); + $hooks = ['form']; if (isset($build_info['base_form_id'])) { $hooks[] = 'form_' . $build_info['base_form_id']; } @@ -898,13 +898,13 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state $element['#defaults_loaded'] = TRUE; } // Assign basic defaults common for all form elements. - $element += array( + $element += [ '#required' => FALSE, - '#attributes' => array(), + '#attributes' => [], '#title_display' => 'before', '#description_display' => 'after', '#errors' => NULL, - ); + ]; // Special handling if we're on the top level form element. if (isset($element['#type']) && $element['#type'] == 'form') { @@ -946,7 +946,7 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state } // All form elements should have an #array_parents property. - $element['#array_parents'] = array(); + $element['#array_parents'] = []; } if (!isset($element['#id'])) { @@ -976,7 +976,7 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state if (isset($element['#process']) && !$element['#processed']) { foreach ($element['#process'] as $callback) { $complete_form = &$form_state->getCompleteForm(); - $element = call_user_func_array($form_state->prepareCallback($callback), array(&$element, &$form_state, &$complete_form)); + $element = call_user_func_array($form_state->prepareCallback($callback), [&$element, &$form_state, &$complete_form]); } $element['#processed'] = TRUE; } @@ -1013,7 +1013,7 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state // Make child elements inherit their parent's #disabled and #allow_focus // values unless they specify their own. - foreach (array('#disabled', '#allow_focus') as $property) { + foreach (['#disabled', '#allow_focus'] as $property) { if (isset($element[$property]) && !isset($element[$key][$property])) { $element[$key][$property] = $element[$property]; } @@ -1023,7 +1023,7 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state if (!isset($element[$key]['#parents'])) { // Check to see if a tree of child elements is present. If so, // continue down the tree if required. - $element[$key]['#parents'] = $element[$key]['#tree'] && $element['#tree'] ? array_merge($element['#parents'], array($key)) : array($key); + $element[$key]['#parents'] = $element[$key]['#tree'] && $element['#tree'] ? array_merge($element['#parents'], [$key]) : [$key]; } // Ensure #array_parents follows the actual form structure. $array_parents = $element['#array_parents']; @@ -1047,7 +1047,7 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state // after normal input parsing has been completed. if (isset($element['#after_build']) && !isset($element['#after_build_done'])) { foreach ($element['#after_build'] as $callback) { - $element = call_user_func_array($form_state->prepareCallback($callback), array($element, &$form_state)); + $element = call_user_func_array($form_state->prepareCallback($callback), [$element, &$form_state]); } $element['#after_build_done'] = TRUE; } @@ -1233,7 +1233,7 @@ protected function handleInputElement($form_id, &$element, FormStateInterface &$ // Skip all value callbacks except safe ones like text if the CSRF // token was invalid. if (!$form_state->hasInvalidToken() || $this->valueCallableIsSafe($value_callable)) { - $element['#value'] = call_user_func_array($value_callable, array(&$element, $input, &$form_state)); + $element['#value'] = call_user_func_array($value_callable, [&$element, $input, &$form_state]); } else { $input = NULL; @@ -1252,7 +1252,7 @@ protected function handleInputElement($form_id, &$element, FormStateInterface &$ if (!isset($element['#value'])) { // Call #type_value without a second argument to request default_value // handling. - $element['#value'] = call_user_func_array($value_callable, array(&$element, FALSE, &$form_state)); + $element['#value'] = call_user_func_array($value_callable, [&$element, FALSE, &$form_state]); // Final catch. If we haven't set a value yet, use the explicit default // value. Avoid image buttons (which come with garbage value), so we diff --git a/core/lib/Drupal/Core/Form/FormCache.php b/core/lib/Drupal/Core/Form/FormCache.php index 13e5430..7064e10 100644 --- a/core/lib/Drupal/Core/Form/FormCache.php +++ b/core/lib/Drupal/Core/Form/FormCache.php @@ -156,7 +156,7 @@ protected function loadCachedFormState($form_build_id, FormStateInterface $form_ $build_info += ['files' => []]; foreach ($build_info['files'] as $file) { if (is_array($file)) { - $file += array('type' => 'inc', 'name' => $file['module']); + $file += ['type' => 'inc', 'name' => $file['module']]; $this->moduleHandler->loadInclude($file['module'], $file['type'], $file['name']); } elseif (file_exists($file)) { diff --git a/core/lib/Drupal/Core/Form/FormState.php b/core/lib/Drupal/Core/Form/FormState.php index ca7355d..8f06d16 100644 --- a/core/lib/Drupal/Core/Form/FormState.php +++ b/core/lib/Drupal/Core/Form/FormState.php @@ -63,10 +63,10 @@ class FormState implements FormStateInterface { * * @var array */ - protected $build_info = array( - 'args' => array(), - 'files' => array(), - ); + protected $build_info = [ + 'args' => [], + 'files' => [], + ]; /** * Similar to self::$build_info, but pertaining to @@ -76,7 +76,7 @@ class FormState implements FormStateInterface { * * @var array */ - protected $rebuild_info = array(); + protected $rebuild_info = []; /** * Normally, after the entire form processing is completed and submit handlers @@ -216,7 +216,7 @@ class FormState implements FormStateInterface { * * @var array */ - protected $values = array(); + protected $values = []; /** * An associative array of form value keys to be removed by cleanValues(). @@ -348,7 +348,7 @@ class FormState implements FormStateInterface { * * @var array */ - protected $groups = array(); + protected $groups = []; /** * This is not a special key, and no specific support is provided for it in @@ -368,7 +368,7 @@ class FormState implements FormStateInterface { * * @var array */ - protected $storage = array(); + protected $storage = []; /** * A list containing copies of all submit and button elements in the form. @@ -377,7 +377,7 @@ class FormState implements FormStateInterface { * * @var array */ - protected $buttons = array(); + protected $buttons = []; /** * Holds temporary data accessible during the current page request only. @@ -413,7 +413,7 @@ class FormState implements FormStateInterface { * * @var array */ - protected $errors = array(); + protected $errors = []; /** * Stores which errors should be limited during validation. @@ -618,7 +618,7 @@ public function setRequestMethod($method) { * @see \Symfony\Component\HttpFoundation\Request::isMethodSafe() */ protected function isRequestMethodSafe() { - return in_array($this->requestMethod, array('GET', 'HEAD')); + return in_array($this->requestMethod, ['GET', 'HEAD']); } /** @@ -862,11 +862,11 @@ public function loadInclude($module, $type, $name = NULL) { if (!isset($build_info['files']["$module:$name.$type"])) { // Only add successfully included files to the form state. if ($result = $this->moduleLoadInclude($module, $type, $name)) { - $build_info['files']["$module:$name.$type"] = array( + $build_info['files']["$module:$name.$type"] = [ 'type' => $type, 'module' => $module, 'name' => $name, - ); + ]; $this->setBuildInfo($build_info); return $result; } @@ -998,7 +998,7 @@ public function getResponse() { /** * {@inheritdoc} */ - public function setRedirect($route_name, array $route_parameters = array(), array $options = array()) { + public function setRedirect($route_name, array $route_parameters = [], array $options = []) { $url = new Url($route_name, $route_parameters, $options); return $this->setRedirectUrl($url); } @@ -1108,7 +1108,7 @@ public function clearErrors() { */ public function getError(array $element) { if ($errors = $this->getErrors()) { - $parents = array(); + $parents = []; foreach ($element['#parents'] as $parent) { $parents[] = $parent; $key = implode('][', $parents); diff --git a/core/lib/Drupal/Core/Form/FormStateInterface.php b/core/lib/Drupal/Core/Form/FormStateInterface.php index 26485a0..e67a734 100644 --- a/core/lib/Drupal/Core/Form/FormStateInterface.php +++ b/core/lib/Drupal/Core/Form/FormStateInterface.php @@ -129,7 +129,7 @@ public function getResponse(); * * @see \Drupal\Core\Form\FormSubmitterInterface::redirectForm() */ - public function setRedirect($route_name, array $route_parameters = array(), array $options = array()); + public function setRedirect($route_name, array $route_parameters = [], array $options = []); /** * Sets the redirect URL for the form. diff --git a/core/lib/Drupal/Core/Form/FormSubmitter.php b/core/lib/Drupal/Core/Form/FormSubmitter.php index a467924..4a4275e 100644 --- a/core/lib/Drupal/Core/Form/FormSubmitter.php +++ b/core/lib/Drupal/Core/Form/FormSubmitter.php @@ -104,11 +104,11 @@ public function executeSubmitHandlers(&$form, FormStateInterface &$form_state) { // Some previous submit handler has set a batch. To ensure correct // execution order, store the call in a special 'control' batch set. // See _batch_next_set(). - $batch['sets'][] = array('form_submit' => $callback); + $batch['sets'][] = ['form_submit' => $callback]; $batch['has_form_submits'] = TRUE; } else { - call_user_func_array($form_state->prepareCallback($callback), array(&$form, &$form_state)); + call_user_func_array($form_state->prepareCallback($callback), [&$form, &$form_state]); } } } diff --git a/core/lib/Drupal/Core/Form/FormValidator.php b/core/lib/Drupal/Core/Form/FormValidator.php index dbefe00..7398053 100644 --- a/core/lib/Drupal/Core/Form/FormValidator.php +++ b/core/lib/Drupal/Core/Form/FormValidator.php @@ -80,7 +80,7 @@ public function executeValidateHandlers(&$form, FormStateInterface &$form_state) } foreach ($handlers as $callback) { - call_user_func_array($form_state->prepareCallback($callback), array(&$form, &$form_state)); + call_user_func_array($form_state->prepareCallback($callback), [&$form, &$form_state]); } } @@ -128,7 +128,7 @@ public function setInvalidTokenError(FormStateInterface $form_state) { $url = $this->requestStack->getCurrentRequest()->getRequestUri(); // Setting this error will cause the form to fail validation. - $form_state->setErrorByName('form_token', $this->t('The form has become outdated. Copy any unsaved work in the form below and then reload this page.', array(':link' => $url))); + $form_state->setErrorByName('form_token', $this->t('The form has become outdated. Copy any unsaved work in the form below and then reload this page.', [':link' => $url])); } /** @@ -149,7 +149,7 @@ protected function handleErrorsWithLimitedValidation(&$form, FormStateInterface // so that only values that passed validation are left for submit callbacks. $triggering_element = $form_state->getTriggeringElement(); if (isset($triggering_element['#limit_validation_errors']) && $triggering_element['#limit_validation_errors'] !== FALSE) { - $values = array(); + $values = []; foreach ($triggering_element['#limit_validation_errors'] as $section) { // If the section exists within $form_state->getValues(), even if the // value is NULL, copy it to $values. @@ -274,7 +274,7 @@ protected function doValidateForm(&$elements, FormStateInterface &$form_state, $ elseif (isset($elements['#element_validate'])) { foreach ($elements['#element_validate'] as $callback) { $complete_form = &$form_state->getCompleteForm(); - call_user_func_array($form_state->prepareCallback($callback), array(&$elements, &$form_state, &$complete_form)); + call_user_func_array($form_state->prepareCallback($callback), [&$elements, &$form_state, &$complete_form]); } } @@ -291,7 +291,7 @@ protected function doValidateForm(&$elements, FormStateInterface &$form_state, $ // form constructors are encouraged to set #title anyway, and then set // #title_display to 'invisible'. This improves accessibility. elseif (isset($elements['#title'])) { - $form_state->setError($elements, $this->t('@name field is required.', array('@name' => $elements['#title']))); + $form_state->setError($elements, $this->t('@name field is required.', ['@name' => $elements['#title']])); } else { $form_state->setError($elements); @@ -326,7 +326,7 @@ protected function doValidateForm(&$elements, FormStateInterface &$form_state, $ protected function performRequiredValidation(&$elements, FormStateInterface &$form_state) { // Verify that the value is not longer than #maxlength. if (isset($elements['#maxlength']) && Unicode::strlen($elements['#value']) > $elements['#maxlength']) { - $form_state->setError($elements, $this->t('@name cannot be longer than %max characters but is currently %length characters long.', array('@name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%max' => $elements['#maxlength'], '%length' => Unicode::strlen($elements['#value'])))); + $form_state->setError($elements, $this->t('@name cannot be longer than %max characters but is currently %length characters long.', ['@name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%max' => $elements['#maxlength'], '%length' => Unicode::strlen($elements['#value'])])); } if (isset($elements['#options']) && isset($elements['#value'])) { @@ -337,11 +337,11 @@ protected function performRequiredValidation(&$elements, FormStateInterface &$fo $options = $elements['#options']; } if (is_array($elements['#value'])) { - $value = in_array($elements['#type'], array('checkboxes', 'tableselect')) ? array_keys($elements['#value']) : $elements['#value']; + $value = in_array($elements['#type'], ['checkboxes', 'tableselect']) ? array_keys($elements['#value']) : $elements['#value']; foreach ($value as $v) { if (!isset($options[$v])) { $form_state->setError($elements, $this->t('An illegal choice has been detected. Please contact the site administrator.')); - $this->logger->error('Illegal choice %choice in %name element.', array('%choice' => $v, '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'])); + $this->logger->error('Illegal choice %choice in %name element.', ['%choice' => $v, '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']]); } } } @@ -360,7 +360,7 @@ protected function performRequiredValidation(&$elements, FormStateInterface &$fo } elseif (!isset($options[$elements['#value']])) { $form_state->setError($elements, $this->t('An illegal choice has been detected. Please contact the site administrator.')); - $this->logger->error('Illegal choice %choice in %name element.', array('%choice' => $elements['#value'], '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'])); + $this->logger->error('Illegal choice %choice in %name element.', ['%choice' => $elements['#value'], '%name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title']]); } } } @@ -398,7 +398,7 @@ protected function determineLimitValidationErrors(FormStateInterface &$form_stat // types, #limit_validation_errors defaults to FALSE, so that full // validation is their default behavior. elseif ($triggering_element && !isset($triggering_element['#limit_validation_errors']) && !$form_state->isSubmitted()) { - return array(); + return []; } // As an extra security measure, explicitly turn off error suppression if // one of the above conditions wasn't met. Since this is also done at the diff --git a/core/lib/Drupal/Core/Form/OptGroup.php b/core/lib/Drupal/Core/Form/OptGroup.php index ac4e5fb..2ba28bd 100644 --- a/core/lib/Drupal/Core/Form/OptGroup.php +++ b/core/lib/Drupal/Core/Form/OptGroup.php @@ -21,7 +21,7 @@ class OptGroup { * An array with all hierarchical elements flattened to a single array. */ public static function flattenOptions(array $array) { - $options = array(); + $options = []; static::doFlattenOptions($array, $options); return $options; } diff --git a/core/lib/Drupal/Core/Form/form.api.php b/core/lib/Drupal/Core/Form/form.api.php index 701871f..fcf9c2e 100644 --- a/core/lib/Drupal/Core/Form/form.api.php +++ b/core/lib/Drupal/Core/Form/form.api.php @@ -73,7 +73,7 @@ function callback_batch_operation($MULTIPLE_PARAMS, &$context) { foreach ($result as $row) { // Here we actually perform our processing on the current node. - $node_storage->resetCache(array($row['nid'])); + $node_storage->resetCache([$row['nid']]); $node = $node_storage->load($row['nid']); $node->value1 = $options1; $node->value2 = $options2; @@ -85,7 +85,7 @@ function callback_batch_operation($MULTIPLE_PARAMS, &$context) { // Update our progress information. $context['sandbox']['progress']++; $context['sandbox']['current_node'] = $node->nid; - $context['message'] = t('Now processing %node', array('%node' => $node->title)); + $context['message'] = t('Now processing %node', ['%node' => $node->title]); } // Inform the batch engine that we are not finished, @@ -113,13 +113,13 @@ function callback_batch_operation($MULTIPLE_PARAMS, &$context) { function callback_batch_finished($success, $results, $operations) { if ($success) { // Here we do something meaningful with the results. - $message = t("@count items were processed.", array( + $message = t("@count items were processed.", [ '@count' => count($results), - )); - $list = array( + ]); + $list = [ '#theme' => 'item_list', '#items' => $results, - ); + ]; $message .= drupal_render($list); drupal_set_message($message); } @@ -127,10 +127,10 @@ function callback_batch_finished($success, $results, $operations) { // An error occurred. // $operations contains the operations that remained unprocessed. $error_operation = reset($operations); - $message = t('An error occurred while processing %error_operation with arguments: @arguments', array( + $message = t('An error occurred while processing %error_operation with arguments: @arguments', [ '%error_operation' => $error_operation[0], '@arguments' => print_r($error_operation[1], TRUE) - )); + ]); drupal_set_message($message, 'error'); } } @@ -152,7 +152,7 @@ function callback_batch_finished($success, $results, $operations) { */ function hook_ajax_render_alter(array &$data) { // Inject any new status messages into the content area. - $status_messages = array('#type' => 'status_messages'); + $status_messages = ['#type' => 'status_messages']; $command = new \Drupal\Core\Ajax\PrependCommand('#block-system-main .content', \Drupal::service('renderer')->renderRoot($status_messages)); $data[] = $command->render(); } @@ -201,12 +201,12 @@ function hook_ajax_render_alter(array &$data) { function hook_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { if (isset($form['type']) && $form['type']['#value'] . '_node_settings' == $form_id) { $upload_enabled_types = \Drupal::config('mymodule.settings')->get('upload_enabled_types'); - $form['workflow']['upload_' . $form['type']['#value']] = array( + $form['workflow']['upload_' . $form['type']['#value']] = [ '#type' => 'radios', '#title' => t('Attachments'), '#default_value' => in_array($form['type']['#value'], $upload_enabled_types) ? 1 : 0, - '#options' => array(t('Disabled'), t('Enabled')), - ); + '#options' => [t('Disabled'), t('Enabled')], + ]; // Add a custom submit handler to save the array of types back to the config file. $form['actions']['submit']['#submit'][] = 'mymodule_upload_enabled_types_submit'; } @@ -248,11 +248,11 @@ function hook_form_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterface $f // registration form. // Add a checkbox to registration form about agreeing to terms of use. - $form['terms_of_use'] = array( + $form['terms_of_use'] = [ '#type' => 'checkbox', '#title' => t("I agree with the website's terms and conditions."), '#required' => TRUE, - ); + ]; } /** @@ -298,11 +298,11 @@ function hook_form_BASE_FORM_ID_alter(&$form, \Drupal\Core\Form\FormStateInterfa // node form, regardless of node type. // Add a checkbox to the node form about agreeing to terms of use. - $form['terms_of_use'] = array( + $form['terms_of_use'] = [ '#type' => 'checkbox', '#title' => t("I agree with the website's terms and conditions."), '#required' => TRUE, - ); + ]; } /** diff --git a/core/lib/Drupal/Core/Http/TrustedHostsRequestFactory.php b/core/lib/Drupal/Core/Http/TrustedHostsRequestFactory.php index 59751c0..3aa0490 100644 --- a/core/lib/Drupal/Core/Http/TrustedHostsRequestFactory.php +++ b/core/lib/Drupal/Core/Http/TrustedHostsRequestFactory.php @@ -57,7 +57,7 @@ public function __construct($host) { * @return \Symfony\Component\HttpFoundation\Request * A new request object. */ - public function createRequest(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = NULL) { + public function createRequest(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = NULL) { if (empty($server['HTTP_HOST']) || ($server['HTTP_HOST'] === 'localhost' && $this->host !== 'localhost')) { $server['HTTP_HOST'] = $this->host; } diff --git a/core/lib/Drupal/Core/Image/Image.php b/core/lib/Drupal/Core/Image/Image.php index 42cdc92..e4c7876 100644 --- a/core/lib/Drupal/Core/Image/Image.php +++ b/core/lib/Drupal/Core/Image/Image.php @@ -139,7 +139,7 @@ public function save($destination = NULL) { /** * {@inheritdoc} */ - public function apply($operation, array $arguments = array()) { + public function apply($operation, array $arguments = []) { return $this->getToolkit()->apply($operation, $arguments); } @@ -147,56 +147,56 @@ public function apply($operation, array $arguments = array()) { * {@inheritdoc} */ public function createNew($width, $height, $extension = 'png', $transparent_color = '#ffffff') { - return $this->apply('create_new', array('width' => $width, 'height' => $height, 'extension' => $extension, 'transparent_color' => $transparent_color)); + return $this->apply('create_new', ['width' => $width, 'height' => $height, 'extension' => $extension, 'transparent_color' => $transparent_color]); } /** * {@inheritdoc} */ public function convert($extension) { - return $this->apply('convert', array('extension' => $extension)); + return $this->apply('convert', ['extension' => $extension]); } /** * {@inheritdoc} */ public function crop($x, $y, $width, $height = NULL) { - return $this->apply('crop', array('x' => $x, 'y' => $y, 'width' => $width, 'height' => $height)); + return $this->apply('crop', ['x' => $x, 'y' => $y, 'width' => $width, 'height' => $height]); } /** * {@inheritdoc} */ public function desaturate() { - return $this->apply('desaturate', array()); + return $this->apply('desaturate', []); } /** * {@inheritdoc} */ public function resize($width, $height) { - return $this->apply('resize', array('width' => $width, 'height' => $height)); + return $this->apply('resize', ['width' => $width, 'height' => $height]); } /** * {@inheritdoc} */ public function rotate($degrees, $background = NULL) { - return $this->apply('rotate', array('degrees' => $degrees, 'background' => $background)); + return $this->apply('rotate', ['degrees' => $degrees, 'background' => $background]); } /** * {@inheritdoc} */ public function scaleAndCrop($width, $height) { - return $this->apply('scale_and_crop', array('width' => $width, 'height' => $height)); + return $this->apply('scale_and_crop', ['width' => $width, 'height' => $height]); } /** * {@inheritdoc} */ public function scale($width, $height = NULL, $upscale = FALSE) { - return $this->apply('scale', array('width' => $width, 'height' => $height, 'upscale' => $upscale)); + return $this->apply('scale', ['width' => $width, 'height' => $height, 'upscale' => $upscale]); } /** diff --git a/core/lib/Drupal/Core/Image/ImageInterface.php b/core/lib/Drupal/Core/Image/ImageInterface.php index 9e112c6..29d092a 100644 --- a/core/lib/Drupal/Core/Image/ImageInterface.php +++ b/core/lib/Drupal/Core/Image/ImageInterface.php @@ -91,7 +91,7 @@ public function getToolkitId(); * @return bool * TRUE on success, FALSE on failure. */ - public function apply($operation, array $arguments = array()); + public function apply($operation, array $arguments = []); /** * Closes the image and saves the changes to a file. diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php index 0c7eb7d..72f3d29 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php @@ -100,7 +100,7 @@ public function getSource() { * {@inheritdoc} */ public function getRequirements() { - return array(); + return []; } /** @@ -119,17 +119,17 @@ protected function getToolkitOperation($operation) { /** * {@inheritdoc} */ - public function apply($operation, array $arguments = array()) { + public function apply($operation, array $arguments = []) { try { // Get the plugin to use for the operation and apply the operation. return $this->getToolkitOperation($operation)->apply($arguments); } catch (PluginNotFoundException $e) { - $this->logger->error("The selected image handling toolkit '@toolkit' can not process operation '@operation'.", array('@toolkit' => $this->getPluginId(), '@operation' => $operation)); + $this->logger->error("The selected image handling toolkit '@toolkit' can not process operation '@operation'.", ['@toolkit' => $this->getPluginId(), '@operation' => $operation]); return FALSE; } catch (\InvalidArgumentException $e) { - $this->logger->warning($e->getMessage(), array()); + $this->logger->warning($e->getMessage(), []); return FALSE; } } diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php index f841315..51867f4 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitInterface.php @@ -169,6 +169,6 @@ public static function getSupportedExtensions(); * @return bool * TRUE if the operation was performed successfully, FALSE otherwise. */ - public function apply($operation, array $arguments = array()); + public function apply($operation, array $arguments = []); } diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php index 1c63807..d533647 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitManager.php @@ -87,7 +87,7 @@ public function getAvailableToolkits() { // Use plugin system to get list of available toolkits. $toolkits = $this->getDefinitions(); - $output = array(); + $output = []; foreach ($toolkits as $id => $definition) { // Only allow modules that aren't marked as unavailable. if (call_user_func($definition['class'] . '::isAvailable')) { diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php index af1b2c9..401b90c 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationBase.php @@ -103,7 +103,7 @@ protected function getToolkit() { */ protected function prepareArguments(array $arguments) { foreach ($this->arguments() as $id => $argument) { - $argument += array('required' => TRUE); + $argument += ['required' => TRUE]; // Check if the argument is required and, if so, has been provided. if ($argument['required']) { if (!array_key_exists($id, $arguments)) { diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php index b3a3e75..5fc434c 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php @@ -91,7 +91,7 @@ function ($definition) use ($toolkit_id, $operation) { return $this->getToolkitOperationPluginId($base_toolkit, $operation); } - $message = SafeMarkup::format("No image operation plugin for '@toolkit' toolkit and '@operation' operation.", array('@toolkit' => $toolkit_id, '@operation' => $operation)); + $message = SafeMarkup::format("No image operation plugin for '@toolkit' toolkit and '@operation' operation.", ['@toolkit' => $toolkit_id, '@operation' => $operation]); throw new PluginNotFoundException($toolkit_id . '.' . $operation, $message); } else { @@ -106,7 +106,7 @@ function ($definition) use ($toolkit_id, $operation) { /** * {@inheritdoc} */ - public function createInstance($plugin_id, array $configuration = array(), ImageToolkitInterface $toolkit = NULL) { + public function createInstance($plugin_id, array $configuration = [], ImageToolkitInterface $toolkit = NULL) { $plugin_definition = $this->getDefinition($plugin_id); $plugin_class = DefaultFactory::getPluginClass($plugin_id, $plugin_definition); return new $plugin_class($configuration, $plugin_id, $plugin_definition, $toolkit, $this->logger); @@ -117,7 +117,7 @@ public function createInstance($plugin_id, array $configuration = array(), Image */ public function getToolkitOperation(ImageToolkitInterface $toolkit, $operation) { $plugin_id = $this->getToolkitOperationPluginId($toolkit, $operation); - return $this->createInstance($plugin_id, array(), $toolkit); + return $this->createInstance($plugin_id, [], $toolkit); } } diff --git a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php index ed0cfac..ca00d0b 100644 --- a/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php +++ b/core/lib/Drupal/Core/Installer/Exception/AlreadyInstalledException.php @@ -23,10 +23,10 @@ public function __construct(TranslationInterface $string_translation) {
  • To start over, you must empty your existing database and copy default.settings.php over settings.php.
  • To upgrade an existing installation, proceed to the update script.
  • View your existing site.
  • -', array( +', [ ':base-url' => $GLOBALS['base_url'], ':update-url' => $GLOBALS['base_path'] . 'update.php', - )); + ]); parent::__construct($message, $title); } diff --git a/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php b/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php index 9342f5c..686b1a2 100644 --- a/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SelectLanguageForm.php @@ -31,11 +31,11 @@ public function buildForm(array $form, FormStateInterface $form_state, $install_ $files = $install_state['translations']; } else { - $files = array(); + $files = []; } $standard_languages = LanguageManager::getStandardLanguageList(); - $select_options = array(); - $browser_options = array(); + $select_options = []; + $browser_options = []; $form['#title'] = 'Choose language'; @@ -57,32 +57,32 @@ public function buildForm(array $form, FormStateInterface $form_state, $install_ asort($select_options); $request = Request::createFromGlobals(); $browser_langcode = UserAgent::getBestMatchingLangcode($request->server->get('HTTP_ACCEPT_LANGUAGE'), $browser_options); - $form['langcode'] = array( + $form['langcode'] = [ '#type' => 'select', '#title' => 'Choose language', '#title_display' => 'invisible', '#options' => $select_options, // Use the browser detected language as default or English if nothing found. '#default_value' => !empty($browser_langcode) ? $browser_langcode : 'en', - ); - $link_to_english = install_full_redirect_url(array('parameters' => array('langcode' => 'en'))); - $form['help'] = array( + ]; + $link_to_english = install_full_redirect_url(['parameters' => ['langcode' => 'en']]); + $form['help'] = [ '#type' => 'item', // #markup is XSS admin filtered which ensures unsafe protocols will be // removed from the url. '#markup' => '

    Translations will be downloaded from the Drupal Translation website. If you do not want this, select English.

    ', - '#states' => array( - 'invisible' => array( - 'select[name="langcode"]' => array('value' => 'en'), - ), - ), - ); - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( + '#states' => [ + 'invisible' => [ + 'select[name="langcode"]' => ['value' => 'en'], + ], + ], + ]; + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => 'Save and continue', '#button_type' => 'primary', - ); + ]; return $form; } diff --git a/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php b/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php index 7ccdf27..679e6db 100644 --- a/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php @@ -23,8 +23,8 @@ public function getFormId() { public function buildForm(array $form, FormStateInterface $form_state, $install_state = NULL) { $form['#title'] = $this->t('Select an installation profile'); - $profiles = array(); - $names = array(); + $profiles = []; + $names = []; foreach ($install_state['profiles'] as $profile) { /** @var $profile \Drupal\Core\Extension\Extension */ $details = install_profile_info($profile->getName()); @@ -49,34 +49,34 @@ public function buildForm(array $form, FormStateInterface $form_state, $install_ // any non-core profiles rather than including it with them alphabetically, // since the other profiles might be intended to group together in a // particular way. - $names = array('minimal' => $names['minimal']) + $names; + $names = ['minimal' => $names['minimal']] + $names; } if (isset($names['standard'])) { // If the default ("Standard") core profile is present, put it at the very // top of the list. This profile will have its radio button pre-selected, // so we want it to always appear at the top. - $names = array('standard' => $names['standard']) + $names; + $names = ['standard' => $names['standard']] + $names; } // The profile name and description are extracted for translation from the // .info file, so we can use $this->t() on them even though they are dynamic // data at this point. - $form['profile'] = array( + $form['profile'] = [ '#type' => 'radios', '#title' => $this->t('Select an installation profile'), '#title_display' => 'invisible', - '#options' => array_map(array($this, 't'), $names), + '#options' => array_map([$this, 't'], $names), '#default_value' => 'standard', - ); + ]; foreach (array_keys($names) as $profile_name) { $form['profile'][$profile_name]['#description'] = isset($profiles[$profile_name]['description']) ? $this->t($profiles[$profile_name]['description']) : ''; } - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Save and continue'), '#button_type' => 'primary', - ); + ]; return $form; } diff --git a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php index 6d5fe65..299a7db 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php @@ -132,7 +132,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { // successfully.) $post_params = $this->getRequest()->request->all(); if (empty($post_params) && (!drupal_verify_install_file($this->root . '/' . $settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE) || !drupal_verify_install_file($this->root . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) { - drupal_set_message(t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the online handbook.', array('%dir' => $settings_dir, '%file' => $settings_file, ':handbook_url' => 'https://www.drupal.org/server-permissions')), 'warning'); + drupal_set_message(t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the online handbook.', ['%dir' => $settings_dir, '%file' => $settings_file, ':handbook_url' => 'https://www.drupal.org/server-permissions']), 'warning'); } $form['#attached']['library'][] = 'system/drupal.system'; @@ -142,55 +142,55 @@ public function buildForm(array $form, FormStateInterface $form_state) { // work during installation. $form['#attached']['drupalSettings']['copyFieldValue']['edit-site-mail'] = ['edit-account-mail']; - $form['site_information'] = array( + $form['site_information'] = [ '#type' => 'fieldgroup', '#title' => $this->t('Site information'), - ); - $form['site_information']['site_name'] = array( + ]; + $form['site_information']['site_name'] = [ '#type' => 'textfield', '#title' => $this->t('Site name'), '#required' => TRUE, '#weight' => -20, - ); - $form['site_information']['site_mail'] = array( + ]; + $form['site_information']['site_mail'] = [ '#type' => 'email', '#title' => $this->t('Site email address'), '#default_value' => ini_get('sendmail_from'), '#description' => $this->t("Automated emails, such as registration information, will be sent from this address. Use an address ending in your site's domain to help prevent these emails from being flagged as spam."), '#required' => TRUE, '#weight' => -15, - ); + ]; - $form['admin_account'] = array( + $form['admin_account'] = [ '#type' => 'fieldgroup', '#title' => $this->t('Site maintenance account'), - ); - $form['admin_account']['account']['name'] = array( + ]; + $form['admin_account']['account']['name'] = [ '#type' => 'textfield', '#title' => $this->t('Username'), '#maxlength' => USERNAME_MAX_LENGTH, '#description' => $this->t("Several special characters are allowed, including space, period (.), hyphen (-), apostrophe ('), underscore (_), and the @ sign."), '#required' => TRUE, - '#attributes' => array('class' => array('username')), - ); - $form['admin_account']['account']['pass'] = array( + '#attributes' => ['class' => ['username']], + ]; + $form['admin_account']['account']['pass'] = [ '#type' => 'password_confirm', '#required' => TRUE, '#size' => 25, - ); + ]; $form['admin_account']['account']['#tree'] = TRUE; - $form['admin_account']['account']['mail'] = array( + $form['admin_account']['account']['mail'] = [ '#type' => 'email', '#title' => $this->t('Email address'), '#required' => TRUE, - ); + ]; - $form['regional_settings'] = array( + $form['regional_settings'] = [ '#type' => 'fieldgroup', '#title' => $this->t('Regional settings'), - ); + ]; $countries = $this->countryManager->getList(); - $form['regional_settings']['site_default_country'] = array( + $form['regional_settings']['site_default_country'] = [ '#type' => 'select', '#title' => $this->t('Default country'), '#empty_value' => '', @@ -198,8 +198,8 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#options' => $countries, '#description' => $this->t('Select the default country for the site.'), '#weight' => 0, - ); - $form['regional_settings']['date_default_timezone'] = array( + ]; + $form['regional_settings']['date_default_timezone'] = [ '#type' => 'select', '#title' => $this->t('Default time zone'), // Use system timezone if set, but avoid throwing a warning in PHP >=5.4 @@ -207,39 +207,39 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#options' => system_time_zones(), '#description' => $this->t('By default, dates in this site will be displayed in the chosen time zone.'), '#weight' => 5, - '#attributes' => array('class' => array('timezone-detect')), - ); + '#attributes' => ['class' => ['timezone-detect']], + ]; - $form['update_notifications'] = array( + $form['update_notifications'] = [ '#type' => 'fieldgroup', '#title' => $this->t('Update notifications'), - ); - $form['update_notifications']['update_status_module'] = array( + ]; + $form['update_notifications']['update_status_module'] = [ '#type' => 'checkboxes', '#title' => $this->t('Update notifications'), - '#options' => array( + '#options' => [ 1 => $this->t('Check for updates automatically'), 2 => $this->t('Receive email notifications'), - ), - '#default_value' => array(1, 2), - '#description' => $this->t('The system will notify you when updates and important security releases are available for installed components. Anonymous information about your site is sent to Drupal.org.', array(':drupal' => 'https://www.drupal.org')), + ], + '#default_value' => [1, 2], + '#description' => $this->t('The system will notify you when updates and important security releases are available for installed components. Anonymous information about your site is sent to Drupal.org.', [':drupal' => 'https://www.drupal.org']), '#weight' => 15, - ); - $form['update_notifications']['update_status_module'][2] = array( - '#states' => array( - 'visible' => array( - 'input[name="update_status_module[1]"]' => array('checked' => TRUE), - ), - ), - ); + ]; + $form['update_notifications']['update_status_module'][2] = [ + '#states' => [ + 'visible' => [ + 'input[name="update_status_module[1]"]' => ['checked' => TRUE], + ], + ], + ]; - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Save and continue'), '#weight' => 15, '#button_type' => 'primary', - ); + ]; return $form; } @@ -248,7 +248,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { - if ($error = user_validate_name($form_state->getValue(array('account', 'name')))) { + if ($error = user_validate_name($form_state->getValue(['account', 'name']))) { $form_state->setErrorByName('account][name', $error); } } @@ -272,14 +272,14 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // Enable update.module if this option was selected. $update_status_module = $form_state->getValue('update_status_module'); if ($update_status_module[1]) { - $this->moduleInstaller->install(array('file', 'update'), FALSE); + $this->moduleInstaller->install(['file', 'update'], FALSE); // Add the site maintenance account's email address to the list of // addresses to be notified when updates are available, if selected. if ($update_status_module[2]) { // Reset the configuration factory so it is updated with the new module. $this->resetConfigFactory(); - $this->config('update.settings')->set('notification.emails', array($account_values['mail']))->save(TRUE); + $this->config('update.settings')->set('notification.emails', [$account_values['mail']])->save(TRUE); } } diff --git a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php index c6a3840..0a75748 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteSettingsForm.php @@ -97,15 +97,15 @@ public function buildForm(array $form, FormStateInterface $form_state) { // when JavaScript is enabled (see below). else { $default_driver = current($drivers_keys); - $default_options = array(); + $default_options = []; } - $form['driver'] = array( + $form['driver'] = [ '#type' => 'radios', '#title' => $this->t('Database type'), '#required' => TRUE, '#default_value' => $default_driver, - ); + ]; if (count($drivers) == 1) { $form['driver']['#disabled'] = TRUE; } @@ -115,31 +115,31 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['driver']['#options'][$key] = $driver->name(); $form['settings'][$key] = $driver->getFormOptions($default_options); - $form['settings'][$key]['#prefix'] = '

    ' . $this->t('@driver_name settings', array('@driver_name' => $driver->name())) . '

    '; + $form['settings'][$key]['#prefix'] = '

    ' . $this->t('@driver_name settings', ['@driver_name' => $driver->name()]) . '

    '; $form['settings'][$key]['#type'] = 'container'; $form['settings'][$key]['#tree'] = TRUE; - $form['settings'][$key]['advanced_options']['#parents'] = array($key); - $form['settings'][$key]['#states'] = array( - 'visible' => array( - ':input[name=driver]' => array('value' => $key), - ) - ); + $form['settings'][$key]['advanced_options']['#parents'] = [$key]; + $form['settings'][$key]['#states'] = [ + 'visible' => [ + ':input[name=driver]' => ['value' => $key], + ] + ]; } - $form['actions'] = array('#type' => 'actions'); - $form['actions']['save'] = array( + $form['actions'] = ['#type' => 'actions']; + $form['actions']['save'] = [ '#type' => 'submit', '#value' => $this->t('Save and continue'), '#button_type' => 'primary', - '#limit_validation_errors' => array( - array('driver'), - array($default_driver), - ), - '#submit' => array('::submitForm'), - ); + '#limit_validation_errors' => [ + ['driver'], + [$default_driver], + ], + '#submit' => ['::submitForm'], + ]; - $form['errors'] = array(); - $form['settings_file'] = array('#type' => 'value', '#value' => $settings_file); + $form['errors'] = []; + $form['settings_file'] = ['#type' => 'value', '#value' => $settings_file]; return $form; } @@ -213,21 +213,21 @@ public function submitForm(array &$form, FormStateInterface $form_state) { global $install_state; // Update global settings array and save. - $settings = array(); + $settings = []; $database = $form_state->get('database'); - $settings['databases']['default']['default'] = (object) array( + $settings['databases']['default']['default'] = (object) [ 'value' => $database, 'required' => TRUE, - ); - $settings['settings']['hash_salt'] = (object) array( + ]; + $settings['settings']['hash_salt'] = (object) [ 'value' => Crypt::randomBytesBase64(55), 'required' => TRUE, - ); + ]; // Remember the profile which was used. - $settings['settings']['install_profile'] = (object) array( + $settings['settings']['install_profile'] = (object) [ 'value' => $install_state['parameters']['profile'], 'required' => TRUE, - ); + ]; drupal_rewrite_settings($settings); diff --git a/core/lib/Drupal/Core/Installer/InstallerRouteBuilder.php b/core/lib/Drupal/Core/Installer/InstallerRouteBuilder.php index c2ec5ed..a432f23 100644 --- a/core/lib/Drupal/Core/Installer/InstallerRouteBuilder.php +++ b/core/lib/Drupal/Core/Installer/InstallerRouteBuilder.php @@ -17,7 +17,7 @@ class InstallerRouteBuilder extends RouteBuilder { * @todo Convert installer steps into routes; add an installer.routing.yml. */ protected function getRouteDefinitions() { - return array(); + return []; } } diff --git a/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php b/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php index 1ace991..4834149 100644 --- a/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php +++ b/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php @@ -28,8 +28,8 @@ public function register(ContainerBuilder $container) { // Replace services with in-memory implementations. $definition = $container->getDefinition('cache_factory'); $definition->setClass('Drupal\Core\Cache\MemoryBackendFactory'); - $definition->setArguments(array()); - $definition->setMethodCalls(array()); + $definition->setArguments([]); + $definition->setMethodCalls([]); $container ->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueMemoryFactory'); $container diff --git a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php index aca4f31..bd96df2 100644 --- a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php +++ b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php @@ -61,19 +61,19 @@ public function __construct($collection, SerializationInterface $serializer, Con * {@inheritdoc} */ public function has($key) { - return (bool) $this->connection->query('SELECT 1 FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :key', array( + return (bool) $this->connection->query('SELECT 1 FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :key', [ ':collection' => $this->collection, ':key' => $key, - ))->fetchField(); + ])->fetchField(); } /** * {@inheritdoc} */ public function getMultiple(array $keys) { - $values = array(); + $values = []; try { - $result = $this->connection->query('SELECT name, value FROM {' . $this->connection->escapeTable($this->table) . '} WHERE name IN ( :keys[] ) AND collection = :collection', array(':keys[]' => $keys, ':collection' => $this->collection))->fetchAllAssoc('name'); + $result = $this->connection->query('SELECT name, value FROM {' . $this->connection->escapeTable($this->table) . '} WHERE name IN ( :keys[] ) AND collection = :collection', [':keys[]' => $keys, ':collection' => $this->collection])->fetchAllAssoc('name'); foreach ($keys as $key) { if (isset($result[$key])) { $values[$key] = $this->serializer->decode($result[$key]->value); @@ -92,8 +92,8 @@ public function getMultiple(array $keys) { * {@inheritdoc} */ public function getAll() { - $result = $this->connection->query('SELECT name, value FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection', array(':collection' => $this->collection)); - $values = array(); + $result = $this->connection->query('SELECT name, value FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection', [':collection' => $this->collection]); + $values = []; foreach ($result as $item) { if ($item) { @@ -108,11 +108,11 @@ public function getAll() { */ public function set($key, $value) { $this->connection->merge($this->table) - ->keys(array( + ->keys([ 'name' => $key, 'collection' => $this->collection, - )) - ->fields(array('value' => $this->serializer->encode($value))) + ]) + ->fields(['value' => $this->serializer->encode($value)]) ->execute(); } @@ -121,11 +121,11 @@ public function set($key, $value) { */ public function setIfNotExists($key, $value) { $result = $this->connection->merge($this->table) - ->insertFields(array( + ->insertFields([ 'collection' => $this->collection, 'name' => $key, 'value' => $this->serializer->encode($value), - )) + ]) ->condition('collection', $this->collection) ->condition('name', $key) ->execute(); @@ -137,7 +137,7 @@ public function setIfNotExists($key, $value) { */ public function rename($key, $new_key) { $this->connection->update($this->table) - ->fields(array('name' => $new_key)) + ->fields(['name' => $new_key]) ->condition('collection', $this->collection) ->condition('name', $key) ->execute(); diff --git a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php index 9f3b428..8e487d1 100644 --- a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php +++ b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorageExpirable.php @@ -34,11 +34,11 @@ public function __construct($collection, SerializationInterface $serializer, Con * {@inheritdoc} */ public function has($key) { - return (bool) $this->connection->query('SELECT 1 FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :key AND expire > :now', array( + return (bool) $this->connection->query('SELECT 1 FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :key AND expire > :now', [ ':collection' => $this->collection, ':key' => $key, ':now' => REQUEST_TIME, - ))->fetchField(); + ])->fetchField(); } /** @@ -47,12 +47,12 @@ public function has($key) { public function getMultiple(array $keys) { $values = $this->connection->query( 'SELECT name, value FROM {' . $this->connection->escapeTable($this->table) . '} WHERE expire > :now AND name IN ( :keys[] ) AND collection = :collection', - array( + [ ':now' => REQUEST_TIME, ':keys[]' => $keys, ':collection' => $this->collection, - ))->fetchAllKeyed(); - return array_map(array($this->serializer, 'decode'), $values); + ])->fetchAllKeyed(); + return array_map([$this->serializer, 'decode'], $values); } /** @@ -61,11 +61,11 @@ public function getMultiple(array $keys) { public function getAll() { $values = $this->connection->query( 'SELECT name, value FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND expire > :now', - array( + [ ':collection' => $this->collection, ':now' => REQUEST_TIME - ))->fetchAllKeyed(); - return array_map(array($this->serializer, 'decode'), $values); + ])->fetchAllKeyed(); + return array_map([$this->serializer, 'decode'], $values); } /** @@ -73,14 +73,14 @@ public function getAll() { */ function setWithExpire($key, $value, $expire) { $this->connection->merge($this->table) - ->keys(array( + ->keys([ 'name' => $key, 'collection' => $this->collection, - )) - ->fields(array( + ]) + ->fields([ 'value' => $this->serializer->encode($value), 'expire' => REQUEST_TIME + $expire, - )) + ]) ->execute(); } @@ -89,12 +89,12 @@ function setWithExpire($key, $value, $expire) { */ function setWithExpireIfNotExists($key, $value, $expire) { $result = $this->connection->merge($this->table) - ->insertFields(array( + ->insertFields([ 'collection' => $this->collection, 'name' => $key, 'value' => $this->serializer->encode($value), 'expire' => REQUEST_TIME + $expire, - )) + ]) ->condition('collection', $this->collection) ->condition('name', $key) ->execute(); diff --git a/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php b/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php index 5670fe5..7815b8c 100644 --- a/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php +++ b/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php @@ -15,7 +15,7 @@ class KeyValueDatabaseExpirableFactory implements KeyValueExpirableFactoryInterf * * @var \Drupal\Core\KeyValueStore\DatabaseStorageExpirable[] */ - protected $storages = array(); + protected $storages = []; /** * The serialization class to use. diff --git a/core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php b/core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php index 9f6d28c..0801ca1 100644 --- a/core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php +++ b/core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php @@ -37,7 +37,7 @@ class KeyValueFactory implements KeyValueFactoryInterface { * * @var array */ - protected $stores = array(); + protected $stores = []; /** * var \Symfony\Component\DependencyInjection\ContainerInterface @@ -50,7 +50,7 @@ class KeyValueFactory implements KeyValueFactoryInterface { * @param array $options * (optional) Collection-specific storage override options. */ - function __construct(ContainerInterface $container, array $options = array()) { + function __construct(ContainerInterface $container, array $options = []) { $this->container = $container; $this->options = $options; } diff --git a/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php b/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php index f172026..701e2bd 100644 --- a/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php +++ b/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php @@ -12,7 +12,7 @@ class KeyValueMemoryFactory implements KeyValueFactoryInterface { * * @var array */ - protected $collections = array(); + protected $collections = []; /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php b/core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php index ea9e056..d6a6ca9 100644 --- a/core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php +++ b/core/lib/Drupal/Core/KeyValueStore/MemoryStorage.php @@ -12,7 +12,7 @@ class MemoryStorage extends StorageBase { * * @var array */ - protected $data = array(); + protected $data = []; /** * {@inheritdoc} @@ -95,7 +95,7 @@ public function deleteMultiple(array $keys) { * {@inheritdoc} */ public function deleteAll() { - $this->data = array(); + $this->data = []; } } diff --git a/core/lib/Drupal/Core/KeyValueStore/NullStorageExpirable.php b/core/lib/Drupal/Core/KeyValueStore/NullStorageExpirable.php index 8e7ab53..5ea8cbc 100644 --- a/core/lib/Drupal/Core/KeyValueStore/NullStorageExpirable.php +++ b/core/lib/Drupal/Core/KeyValueStore/NullStorageExpirable.php @@ -12,7 +12,7 @@ class NullStorageExpirable implements KeyValueStoreExpirableInterface { * * @var array */ - protected $data = array(); + protected $data = []; /** * The name of the collection holding key and value pairs. @@ -46,14 +46,14 @@ public function get($key, $default = NULL) { * {@inheritdoc} */ public function getMultiple(array $keys) { - return array(); + return []; } /** * {@inheritdoc} */ public function getAll() { - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/KeyValueStore/StorageBase.php b/core/lib/Drupal/Core/KeyValueStore/StorageBase.php index ecdd08c..ad5e3b4 100644 --- a/core/lib/Drupal/Core/KeyValueStore/StorageBase.php +++ b/core/lib/Drupal/Core/KeyValueStore/StorageBase.php @@ -32,7 +32,7 @@ public function getCollectionName() { * {@inheritdoc} */ public function get($key, $default = NULL) { - $values = $this->getMultiple(array($key)); + $values = $this->getMultiple([$key]); return isset($values[$key]) ? $values[$key] : $default; } @@ -49,7 +49,7 @@ public function setMultiple(array $data) { * {@inheritdoc} */ public function delete($key) { - $this->deleteMultiple(array($key)); + $this->deleteMultiple([$key]); } } diff --git a/core/lib/Drupal/Core/Language/Language.php b/core/lib/Drupal/Core/Language/Language.php index abaad81..5c4068d 100644 --- a/core/lib/Drupal/Core/Language/Language.php +++ b/core/lib/Drupal/Core/Language/Language.php @@ -16,13 +16,13 @@ class Language implements LanguageInterface { * * @var array */ - public static $defaultValues = array( + public static $defaultValues = [ 'id' => 'en', 'name' => 'English', 'direction' => self::DIRECTION_LTR, 'weight' => 0, 'locked' => FALSE, - ); + ]; // Properties within the Language are set up as the default language. @@ -74,7 +74,7 @@ class Language implements LanguageInterface { * An array of property values, keyed by property name, used to construct * the language. */ - public function __construct(array $values = array()) { + public function __construct(array $values = []) { // Set all the provided properties for the language. foreach ($values as $key => $value) { if (property_exists($this, $key)) { diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php index 9016d1e..c269c2b 100644 --- a/core/lib/Drupal/Core/Language/LanguageManager.php +++ b/core/lib/Drupal/Core/Language/LanguageManager.php @@ -23,7 +23,7 @@ class LanguageManager implements LanguageManagerInterface { * * @see \Drupal\Core\Language\LanguageManager::getLanguages() */ - protected $languages = array(); + protected $languages = []; /** * The default language object. @@ -53,7 +53,7 @@ public function isMultilingual() { * {@inheritdoc} */ public function getLanguageTypes() { - return array(LanguageInterface::TYPE_INTERFACE, LanguageInterface::TYPE_CONTENT, LanguageInterface::TYPE_URL); + return [LanguageInterface::TYPE_INTERFACE, LanguageInterface::TYPE_CONTENT, LanguageInterface::TYPE_URL]; } /** @@ -77,21 +77,21 @@ public function getLanguageTypes() { * hook_language_types_info(). */ public function getDefinedLanguageTypesInfo() { - $this->definedLanguageTypesInfo = array( - LanguageInterface::TYPE_INTERFACE => array( + $this->definedLanguageTypesInfo = [ + LanguageInterface::TYPE_INTERFACE => [ 'name' => new TranslatableMarkup('Interface text'), 'description' => new TranslatableMarkup('Order of language detection methods for interface text. If a translation of interface text is available in the detected language, it will be displayed.'), 'locked' => TRUE, - ), - LanguageInterface::TYPE_CONTENT => array( + ], + LanguageInterface::TYPE_CONTENT => [ 'name' => new TranslatableMarkup('Content'), 'description' => new TranslatableMarkup('Order of language detection methods for content. If a version of content is available in the detected language, it will be displayed.'), 'locked' => TRUE, - ), - LanguageInterface::TYPE_URL => array( + ], + LanguageInterface::TYPE_URL => [ 'locked' => TRUE, - ), - ); + ], + ]; return $this->definedLanguageTypesInfo; } @@ -127,7 +127,7 @@ public function getLanguages($flags = LanguageInterface::STATE_CONFIGURABLE) { // The default language and locked languages comprise the full language // list. $default = $this->getDefaultLanguage(); - $languages = array($default->getId() => $default); + $languages = [$default->getId() => $default]; $languages += $this->getDefaultLockedLanguages($default->getWeight()); // Filter the full list of languages based on the value of $flags. @@ -165,33 +165,33 @@ public function getLanguageName($langcode) { if (empty($langcode)) { return new TranslatableMarkup('Unknown'); } - return new TranslatableMarkup('Unknown (@langcode)', array('@langcode' => $langcode)); + return new TranslatableMarkup('Unknown (@langcode)', ['@langcode' => $langcode]); } /** * {@inheritdoc} */ public function getDefaultLockedLanguages($weight = 0) { - $languages = array(); + $languages = []; - $locked_language = array( + $locked_language = [ 'default' => FALSE, 'locked' => TRUE, 'direction' => LanguageInterface::DIRECTION_LTR, - ); + ]; // This is called very early while initializing the language system. Prevent // early t() calls by using the TranslatableMarkup. - $languages[LanguageInterface::LANGCODE_NOT_SPECIFIED] = new Language(array( + $languages[LanguageInterface::LANGCODE_NOT_SPECIFIED] = new Language([ 'id' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'name' => new TranslatableMarkup('Not specified'), 'weight' => ++$weight, - ) + $locked_language); + ] + $locked_language); - $languages[LanguageInterface::LANGCODE_NOT_APPLICABLE] = new Language(array( + $languages[LanguageInterface::LANGCODE_NOT_APPLICABLE] = new Language([ 'id' => LanguageInterface::LANGCODE_NOT_APPLICABLE, 'name' => new TranslatableMarkup('Not applicable'), 'weight' => ++$weight, - ) + $locked_language); + ] + $locked_language); return $languages; } @@ -207,15 +207,15 @@ public function isLanguageLocked($langcode) { /** * {@inheritdoc} */ - public function getFallbackCandidates(array $context = array()) { - return array(LanguageInterface::LANGCODE_DEFAULT); + public function getFallbackCandidates(array $context = []) { + return [LanguageInterface::LANGCODE_DEFAULT]; } /** * {@inheritdoc} */ public function getLanguageSwitchLinks($type, Url $url) { - return array(); + return []; } /** @@ -229,103 +229,103 @@ public static function getStandardLanguageList() { // The "Left-to-right marker" comments and the enclosed UTF-8 markers are to // make otherwise strange looking PHP syntax natural (to not be displayed in // right to left). See https://www.drupal.org/node/128866#comment-528929. - return array( - 'af' => array('Afrikaans', 'Afrikaans'), - 'am' => array('Amharic', 'አማርኛ'), - 'ar' => array('Arabic', /* Left-to-right marker "‭" */ 'العربية', LanguageInterface::DIRECTION_RTL), - 'ast' => array('Asturian', 'Asturianu'), - 'az' => array('Azerbaijani', 'Azərbaycanca'), - 'be' => array('Belarusian', 'Беларуская'), - 'bg' => array('Bulgarian', 'Български'), - 'bn' => array('Bengali', 'বাংলা'), - 'bo' => array('Tibetan', 'བོད་སྐད་'), - 'bs' => array('Bosnian', 'Bosanski'), - 'ca' => array('Catalan', 'Català'), - 'cs' => array('Czech', 'Čeština'), - 'cy' => array('Welsh', 'Cymraeg'), - 'da' => array('Danish', 'Dansk'), - 'de' => array('German', 'Deutsch'), - 'dz' => array('Dzongkha', 'རྫོང་ཁ'), - 'el' => array('Greek', 'Ελληνικά'), - 'en' => array('English', 'English'), - 'en-x-simple' => array('Simple English', 'Simple English'), - 'eo' => array('Esperanto', 'Esperanto'), - 'es' => array('Spanish', 'Español'), - 'et' => array('Estonian', 'Eesti'), - 'eu' => array('Basque', 'Euskera'), - 'fa' => array('Persian, Farsi', /* Left-to-right marker "‭" */ 'فارسی', LanguageInterface::DIRECTION_RTL), - 'fi' => array('Finnish', 'Suomi'), - 'fil' => array('Filipino', 'Filipino'), - 'fo' => array('Faeroese', 'Føroyskt'), - 'fr' => array('French', 'Français'), - 'fy' => array('Frisian, Western', 'Frysk'), - 'ga' => array('Irish', 'Gaeilge'), - 'gd' => array('Scots Gaelic', 'Gàidhlig'), - 'gl' => array('Galician', 'Galego'), - 'gsw-berne' => array('Swiss German', 'Schwyzerdütsch'), - 'gu' => array('Gujarati', 'ગુજરાતી'), - 'he' => array('Hebrew', /* Left-to-right marker "‭" */ 'עברית', LanguageInterface::DIRECTION_RTL), - 'hi' => array('Hindi', 'हिन्दी'), - 'hr' => array('Croatian', 'Hrvatski'), - 'ht' => array('Haitian Creole', 'Kreyòl ayisyen'), - 'hu' => array('Hungarian', 'Magyar'), - 'hy' => array('Armenian', 'Հայերեն'), - 'id' => array('Indonesian', 'Bahasa Indonesia'), - 'is' => array('Icelandic', 'Íslenska'), - 'it' => array('Italian', 'Italiano'), - 'ja' => array('Japanese', '日本語'), - 'jv' => array('Javanese', 'Basa Java'), - 'ka' => array('Georgian', 'ქართული ენა'), - 'kk' => array('Kazakh', 'Қазақ'), - 'km' => array('Khmer', 'ភាសាខ្មែរ'), - 'kn' => array('Kannada', 'ಕನ್ನಡ'), - 'ko' => array('Korean', '한국어'), - 'ku' => array('Kurdish', 'Kurdî'), - 'ky' => array('Kyrgyz', 'Кыргызча'), - 'lo' => array('Lao', 'ພາສາລາວ'), - 'lt' => array('Lithuanian', 'Lietuvių'), - 'lv' => array('Latvian', 'Latviešu'), - 'mg' => array('Malagasy', 'Malagasy'), - 'mk' => array('Macedonian', 'Македонски'), - 'ml' => array('Malayalam', 'മലയാളം'), - 'mn' => array('Mongolian', 'монгол'), - 'mr' => array('Marathi', 'मराठी'), - 'ms' => array('Bahasa Malaysia', 'بهاس ملايو'), - 'my' => array('Burmese', 'ဗမာစကား'), - 'ne' => array('Nepali', 'नेपाली'), - 'nl' => array('Dutch', 'Nederlands'), - 'nb' => array('Norwegian Bokmål', 'Norsk, bokmål'), - 'nn' => array('Norwegian Nynorsk', 'Norsk, nynorsk'), - 'oc' => array('Occitan', 'Occitan'), - 'pa' => array('Punjabi', 'ਪੰਜਾਬੀ'), - 'pl' => array('Polish', 'Polski'), - 'pt-pt' => array('Portuguese, Portugal', 'Português, Portugal'), - 'pt-br' => array('Portuguese, Brazil', 'Português, Brasil'), - 'ro' => array('Romanian', 'Română'), - 'ru' => array('Russian', 'Русский'), - 'sco' => array('Scots', 'Scots'), - 'se' => array('Northern Sami', 'Sámi'), - 'si' => array('Sinhala', 'සිංහල'), - 'sk' => array('Slovak', 'Slovenčina'), - 'sl' => array('Slovenian', 'Slovenščina'), - 'sq' => array('Albanian', 'Shqip'), - 'sr' => array('Serbian', 'Српски'), - 'sv' => array('Swedish', 'Svenska'), - 'sw' => array('Swahili', 'Kiswahili'), - 'ta' => array('Tamil', 'தமிழ்'), - 'ta-lk' => array('Tamil, Sri Lanka', 'தமிழ், இலங்கை'), - 'te' => array('Telugu', 'తెలుగు'), - 'th' => array('Thai', 'ภาษาไทย'), - 'tr' => array('Turkish', 'Türkçe'), - 'tyv' => array('Tuvan', 'Тыва дыл'), - 'ug' => array('Uyghur', 'Уйғур'), - 'uk' => array('Ukrainian', 'Українська'), - 'ur' => array('Urdu', /* Left-to-right marker "‭" */ 'اردو', LanguageInterface::DIRECTION_RTL), - 'vi' => array('Vietnamese', 'Tiếng Việt'), - 'xx-lolspeak' => array('Lolspeak', 'Lolspeak'), - 'zh-hans' => array('Chinese, Simplified', '简体中文'), - 'zh-hant' => array('Chinese, Traditional', '繁體中文'), - ); + return [ + 'af' => ['Afrikaans', 'Afrikaans'], + 'am' => ['Amharic', 'አማርኛ'], + 'ar' => ['Arabic', /* Left-to-right marker "‭" */ 'العربية', LanguageInterface::DIRECTION_RTL], + 'ast' => ['Asturian', 'Asturianu'], + 'az' => ['Azerbaijani', 'Azərbaycanca'], + 'be' => ['Belarusian', 'Беларуская'], + 'bg' => ['Bulgarian', 'Български'], + 'bn' => ['Bengali', 'বাংলা'], + 'bo' => ['Tibetan', 'བོད་སྐད་'], + 'bs' => ['Bosnian', 'Bosanski'], + 'ca' => ['Catalan', 'Català'], + 'cs' => ['Czech', 'Čeština'], + 'cy' => ['Welsh', 'Cymraeg'], + 'da' => ['Danish', 'Dansk'], + 'de' => ['German', 'Deutsch'], + 'dz' => ['Dzongkha', 'རྫོང་ཁ'], + 'el' => ['Greek', 'Ελληνικά'], + 'en' => ['English', 'English'], + 'en-x-simple' => ['Simple English', 'Simple English'], + 'eo' => ['Esperanto', 'Esperanto'], + 'es' => ['Spanish', 'Español'], + 'et' => ['Estonian', 'Eesti'], + 'eu' => ['Basque', 'Euskera'], + 'fa' => ['Persian, Farsi', /* Left-to-right marker "‭" */ 'فارسی', LanguageInterface::DIRECTION_RTL], + 'fi' => ['Finnish', 'Suomi'], + 'fil' => ['Filipino', 'Filipino'], + 'fo' => ['Faeroese', 'Føroyskt'], + 'fr' => ['French', 'Français'], + 'fy' => ['Frisian, Western', 'Frysk'], + 'ga' => ['Irish', 'Gaeilge'], + 'gd' => ['Scots Gaelic', 'Gàidhlig'], + 'gl' => ['Galician', 'Galego'], + 'gsw-berne' => ['Swiss German', 'Schwyzerdütsch'], + 'gu' => ['Gujarati', 'ગુજરાતી'], + 'he' => ['Hebrew', /* Left-to-right marker "‭" */ 'עברית', LanguageInterface::DIRECTION_RTL], + 'hi' => ['Hindi', 'हिन्दी'], + 'hr' => ['Croatian', 'Hrvatski'], + 'ht' => ['Haitian Creole', 'Kreyòl ayisyen'], + 'hu' => ['Hungarian', 'Magyar'], + 'hy' => ['Armenian', 'Հայերեն'], + 'id' => ['Indonesian', 'Bahasa Indonesia'], + 'is' => ['Icelandic', 'Íslenska'], + 'it' => ['Italian', 'Italiano'], + 'ja' => ['Japanese', '日本語'], + 'jv' => ['Javanese', 'Basa Java'], + 'ka' => ['Georgian', 'ქართული ენა'], + 'kk' => ['Kazakh', 'Қазақ'], + 'km' => ['Khmer', 'ភាសាខ្មែរ'], + 'kn' => ['Kannada', 'ಕನ್ನಡ'], + 'ko' => ['Korean', '한국어'], + 'ku' => ['Kurdish', 'Kurdî'], + 'ky' => ['Kyrgyz', 'Кыргызча'], + 'lo' => ['Lao', 'ພາສາລາວ'], + 'lt' => ['Lithuanian', 'Lietuvių'], + 'lv' => ['Latvian', 'Latviešu'], + 'mg' => ['Malagasy', 'Malagasy'], + 'mk' => ['Macedonian', 'Македонски'], + 'ml' => ['Malayalam', 'മലയാളം'], + 'mn' => ['Mongolian', 'монгол'], + 'mr' => ['Marathi', 'मराठी'], + 'ms' => ['Bahasa Malaysia', 'بهاس ملايو'], + 'my' => ['Burmese', 'ဗမာစကား'], + 'ne' => ['Nepali', 'नेपाली'], + 'nl' => ['Dutch', 'Nederlands'], + 'nb' => ['Norwegian Bokmål', 'Norsk, bokmål'], + 'nn' => ['Norwegian Nynorsk', 'Norsk, nynorsk'], + 'oc' => ['Occitan', 'Occitan'], + 'pa' => ['Punjabi', 'ਪੰਜਾਬੀ'], + 'pl' => ['Polish', 'Polski'], + 'pt-pt' => ['Portuguese, Portugal', 'Português, Portugal'], + 'pt-br' => ['Portuguese, Brazil', 'Português, Brasil'], + 'ro' => ['Romanian', 'Română'], + 'ru' => ['Russian', 'Русский'], + 'sco' => ['Scots', 'Scots'], + 'se' => ['Northern Sami', 'Sámi'], + 'si' => ['Sinhala', 'සිංහල'], + 'sk' => ['Slovak', 'Slovenčina'], + 'sl' => ['Slovenian', 'Slovenščina'], + 'sq' => ['Albanian', 'Shqip'], + 'sr' => ['Serbian', 'Српски'], + 'sv' => ['Swedish', 'Svenska'], + 'sw' => ['Swahili', 'Kiswahili'], + 'ta' => ['Tamil', 'தமிழ்'], + 'ta-lk' => ['Tamil, Sri Lanka', 'தமிழ், இலங்கை'], + 'te' => ['Telugu', 'తెలుగు'], + 'th' => ['Thai', 'ภาษาไทย'], + 'tr' => ['Turkish', 'Türkçe'], + 'tyv' => ['Tuvan', 'Тыва дыл'], + 'ug' => ['Uyghur', 'Уйғур'], + 'uk' => ['Ukrainian', 'Українська'], + 'ur' => ['Urdu', /* Left-to-right marker "‭" */ 'اردو', LanguageInterface::DIRECTION_RTL], + 'vi' => ['Vietnamese', 'Tiếng Việt'], + 'xx-lolspeak' => ['Lolspeak', 'Lolspeak'], + 'zh-hans' => ['Chinese, Simplified', '简体中文'], + 'zh-hant' => ['Chinese, Traditional', '繁體中文'], + ]; } /** @@ -391,7 +391,7 @@ protected function filterLanguages(array $languages, $flags = LanguageInterface: return $languages; } - $filtered_languages = array(); + $filtered_languages = []; // Add the site's default language if requested. if ($flags & LanguageInterface::STATE_SITE_DEFAULT) { @@ -399,13 +399,13 @@ protected function filterLanguages(array $languages, $flags = LanguageInterface: // default language only for runtime. $defaultLanguage = $this->getDefaultLanguage(); $default = new Language( - array( + [ 'id' => $defaultLanguage->getId(), 'name' => new TranslatableMarkup("Site's default language (@lang_name)", - array('@lang_name' => $defaultLanguage->getName())), + ['@lang_name' => $defaultLanguage->getName()]), 'direction' => $defaultLanguage->getDirection(), 'weight' => $defaultLanguage->getWeight(), - ) + ] ); $filtered_languages[LanguageInterface::LANGCODE_SITE_DEFAULT] = $default; } diff --git a/core/lib/Drupal/Core/Language/LanguageManagerInterface.php b/core/lib/Drupal/Core/Language/LanguageManagerInterface.php index be0188d..eaefd18 100644 --- a/core/lib/Drupal/Core/Language/LanguageManagerInterface.php +++ b/core/lib/Drupal/Core/Language/LanguageManagerInterface.php @@ -161,7 +161,7 @@ public function isLanguageLocked($langcode); * An array of language codes sorted by priority: first values should be * tried first. */ - public function getFallbackCandidates(array $context = array()); + public function getFallbackCandidates(array $context = []); /** * Returns the language switch links for the given language type. diff --git a/core/lib/Drupal/Core/Link.php b/core/lib/Drupal/Core/Link.php index 6810fb0..ee7eb50 100644 --- a/core/lib/Drupal/Core/Link.php +++ b/core/lib/Drupal/Core/Link.php @@ -70,7 +70,7 @@ public function __construct($text, Url $url) { * * @return static */ - public static function createFromRoute($text, $route_name, $route_parameters = array(), $options = array()) { + public static function createFromRoute($text, $route_name, $route_parameters = [], $options = []) { return new static($text, new Url($route_name, $route_parameters, $options)); } diff --git a/core/lib/Drupal/Core/Locale/CountryManager.php b/core/lib/Drupal/Core/Locale/CountryManager.php index 451758e..adc110c 100644 --- a/core/lib/Drupal/Core/Locale/CountryManager.php +++ b/core/lib/Drupal/Core/Locale/CountryManager.php @@ -37,7 +37,7 @@ public function __construct(ModuleHandlerInterface $module_handler) { * An array of country code => country name pairs. */ public static function getStandardList() { - $countries = array( + $countries = [ 'AC' => t('Ascension Island'), 'AD' => t('Andorra'), 'AE' => t('United Arab Emirates'), @@ -296,7 +296,7 @@ public static function getStandardList() { 'ZA' => t('South Africa'), 'ZM' => t('Zambia'), 'ZW' => t('Zimbabwe'), - ); + ]; // Sort the list. natcasesort($countries); diff --git a/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php b/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php index d095028..91077e7 100644 --- a/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php +++ b/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php @@ -34,7 +34,7 @@ class DatabaseLockBackend extends LockBackendAbstract { public function __construct(Connection $database) { // __destruct() is causing problems with garbage collections, register a // shutdown function instead. - drupal_register_shutdown_function(array($this, 'releaseAll')); + drupal_register_shutdown_function([$this, 'releaseAll']); $this->database = $database; } @@ -48,7 +48,7 @@ public function acquire($name, $timeout = 30.0) { if (isset($this->locks[$name])) { // Try to extend the expiration of a lock we already acquired. $success = (bool) $this->database->update('semaphore') - ->fields(array('expire' => $expire)) + ->fields(['expire' => $expire]) ->condition('name', $name) ->condition('value', $this->getLockId()) ->execute(); @@ -66,11 +66,11 @@ public function acquire($name, $timeout = 30.0) { do { try { $this->database->insert('semaphore') - ->fields(array( + ->fields([ 'name' => $name, 'value' => $this->getLockId(), 'expire' => $expire, - )) + ]) ->execute(); // We track all acquired locks in the global variable. $this->locks[$name] = TRUE; @@ -107,7 +107,7 @@ public function acquire($name, $timeout = 30.0) { */ public function lockMayBeAvailable($name) { try { - $lock = $this->database->query('SELECT expire, value FROM {semaphore} WHERE name = :name', array(':name' => $name))->fetchAssoc(); + $lock = $this->database->query('SELECT expire, value FROM {semaphore} WHERE name = :name', [':name' => $name])->fetchAssoc(); } catch (\Exception $e) { $this->catchException($e); @@ -154,7 +154,7 @@ public function release($name) { public function releaseAll($lock_id = NULL) { // Only attempt to release locks if any were acquired. if (!empty($this->locks)) { - $this->locks = array(); + $this->locks = []; if (empty($lock_id)) { $lock_id = $this->getLockId(); } diff --git a/core/lib/Drupal/Core/Lock/LockBackendAbstract.php b/core/lib/Drupal/Core/Lock/LockBackendAbstract.php index 32322d4..41ee27c 100644 --- a/core/lib/Drupal/Core/Lock/LockBackendAbstract.php +++ b/core/lib/Drupal/Core/Lock/LockBackendAbstract.php @@ -21,7 +21,7 @@ * * @var array */ - protected $locks = array(); + protected $locks = []; /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/Logger/LogMessageParser.php b/core/lib/Drupal/Core/Logger/LogMessageParser.php index 3ce39bb..8a67df1 100644 --- a/core/lib/Drupal/Core/Logger/LogMessageParser.php +++ b/core/lib/Drupal/Core/Logger/LogMessageParser.php @@ -11,7 +11,7 @@ class LogMessageParser implements LogMessageParserInterface { * {@inheritdoc} */ public function parseMessagePlaceholders(&$message, array &$context) { - $variables = array(); + $variables = []; $has_psr3 = FALSE; if (($start = strpos($message, '{')) !== FALSE && strpos($message, '}') > $start) { $has_psr3 = TRUE; diff --git a/core/lib/Drupal/Core/Logger/LoggerChannel.php b/core/lib/Drupal/Core/Logger/LoggerChannel.php index 9253a24..51141f7 100644 --- a/core/lib/Drupal/Core/Logger/LoggerChannel.php +++ b/core/lib/Drupal/Core/Logger/LoggerChannel.php @@ -46,7 +46,7 @@ class LoggerChannel implements LoggerChannelInterface { * * @var array */ - protected $levelTranslation = array( + protected $levelTranslation = [ LogLevel::EMERGENCY => RfcLogLevel::EMERGENCY, LogLevel::ALERT => RfcLogLevel::ALERT, LogLevel::CRITICAL => RfcLogLevel::CRITICAL, @@ -55,14 +55,14 @@ class LoggerChannel implements LoggerChannelInterface { LogLevel::NOTICE => RfcLogLevel::NOTICE, LogLevel::INFO => RfcLogLevel::INFO, LogLevel::DEBUG => RfcLogLevel::DEBUG, - ); + ]; /** * An array of arrays of \Psr\Log\LoggerInterface keyed by priority. * * @var array */ - protected $loggers = array(); + protected $loggers = []; /** * The request stack object. @@ -91,14 +91,14 @@ public function __construct($channel) { /** * {@inheritdoc} */ - public function log($level, $message, array $context = array()) { + public function log($level, $message, array $context = []) { if ($this->callDepth == self::MAX_CALL_DEPTH) { return; } $this->callDepth++; // Merge in defaults. - $context += array( + $context += [ 'channel' => $this->channel, 'link' => '', 'user' => NULL, @@ -107,7 +107,7 @@ public function log($level, $message, array $context = array()) { 'referer' => '', 'ip' => '', 'timestamp' => time(), - ); + ]; // Some context values are only available when in a request context. if ($this->requestStack && $request = $this->requestStack->getCurrentRequest()) { $context['request_uri'] = $request->getUri(); @@ -174,7 +174,7 @@ public function addLogger(LoggerInterface $logger, $priority = 0) { * An array of sorted loggers by priority. */ protected function sortLoggers() { - $sorted = array(); + $sorted = []; krsort($this->loggers); foreach ($this->loggers as $loggers) { diff --git a/core/lib/Drupal/Core/Logger/LoggerChannelFactory.php b/core/lib/Drupal/Core/Logger/LoggerChannelFactory.php index 2fa5531..6c487d1 100644 --- a/core/lib/Drupal/Core/Logger/LoggerChannelFactory.php +++ b/core/lib/Drupal/Core/Logger/LoggerChannelFactory.php @@ -17,14 +17,14 @@ class LoggerChannelFactory implements LoggerChannelFactoryInterface, ContainerAw * * @var \Drupal\Core\Logger\LoggerChannelInterface[] */ - protected $channels = array(); + protected $channels = []; /** * An array of arrays of \Psr\Log\LoggerInterface keyed by priority. * * @var array */ - protected $loggers = array(); + protected $loggers = []; /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/Logger/RfcLoggerTrait.php b/core/lib/Drupal/Core/Logger/RfcLoggerTrait.php index c05d733..0152efe 100644 --- a/core/lib/Drupal/Core/Logger/RfcLoggerTrait.php +++ b/core/lib/Drupal/Core/Logger/RfcLoggerTrait.php @@ -17,62 +17,62 @@ /** * {@inheritdoc} */ - public function emergency($message, array $context = array()) { + public function emergency($message, array $context = []) { $this->log(RfcLogLevel::EMERGENCY, $message, $context); } /** * {@inheritdoc} */ - public function alert($message, array $context = array()) { + public function alert($message, array $context = []) { $this->log(RfcLogLevel::ALERT, $message, $context); } /** * {@inheritdoc} */ - public function critical($message, array $context = array()) { + public function critical($message, array $context = []) { $this->log(RfcLogLevel::CRITICAL, $message, $context); } /** * {@inheritdoc} */ - public function error($message, array $context = array()) { + public function error($message, array $context = []) { $this->log(RfcLogLevel::ERROR, $message, $context); } /** * {@inheritdoc} */ - public function warning($message, array $context = array()) { + public function warning($message, array $context = []) { $this->log(RfcLogLevel::WARNING, $message, $context); } /** * {@inheritdoc} */ - public function notice($message, array $context = array()) { + public function notice($message, array $context = []) { $this->log(RfcLogLevel::NOTICE, $message, $context); } /** * {@inheritdoc} */ - public function info($message, array $context = array()) { + public function info($message, array $context = []) { $this->log(RfcLogLevel::INFO, $message, $context); } /** * {@inheritdoc} */ - public function debug($message, array $context = array()) { + public function debug($message, array $context = []) { $this->log(RfcLogLevel::DEBUG, $message, $context); } /** * {@inheritdoc} */ - abstract public function log($level, $message, array $context = array()); + abstract public function log($level, $message, array $context = []); } diff --git a/core/lib/Drupal/Core/Mail/MailFormatHelper.php b/core/lib/Drupal/Core/Mail/MailFormatHelper.php index 080b326..0714862 100644 --- a/core/lib/Drupal/Core/Mail/MailFormatHelper.php +++ b/core/lib/Drupal/Core/Mail/MailFormatHelper.php @@ -17,7 +17,7 @@ class MailFormatHelper { * * @var array */ - protected static $urls = array(); + protected static $urls = []; /** * Quoted regex expression based on base path. @@ -31,7 +31,7 @@ class MailFormatHelper { * * @var array */ - protected static $supportedTags = array(); + protected static $supportedTags = []; /** * Performs format=flowed soft wrapping for mail (RFC 3676). @@ -63,12 +63,12 @@ public static function wrapMail($text, $indent = '') { $text = preg_replace('/(?(? $soft, 'length' => strlen($indent))); + array_walk($lines, '\Drupal\Core\Mail\MailFormatHelper::wrapMailLine', ['soft' => $soft, 'length' => strlen($indent)]); $text = implode("\n", $lines); } else { // Wrap this line. - static::wrapMailLine($text, 0, array('soft' => $soft, 'length' => strlen($indent))); + static::wrapMailLine($text, 0, ['soft' => $soft, 'length' => strlen($indent)]); } // Empty lines with nothing but spaces. $text = preg_replace('/^ +\n/m', "\n", $text); @@ -104,9 +104,9 @@ public static function wrapMail($text, $indent = '') { public static function htmlToText($string, $allowed_tags = NULL) { // Cache list of supported tags. if (empty(static::$supportedTags)) { - static::$supportedTags = array('a', 'em', 'i', 'strong', 'b', 'br', 'p', + static::$supportedTags = ['a', 'em', 'i', 'strong', 'b', 'br', 'p', 'blockquote', 'ul', 'ol', 'li', 'dl', 'dt', 'dd', 'h1', 'h2', 'h3', - 'h4', 'h5', 'h6', 'hr'); + 'h4', 'h5', 'h6', 'hr']; } // Make sure only supported tags are kept. @@ -146,9 +146,9 @@ public static function htmlToText($string, $allowed_tags = NULL) { $casing = NULL; $output = ''; // All current indentation string chunks. - $indent = array(); + $indent = []; // Array of counters for opened lists. - $lists = array(); + $lists = []; foreach ($split as $value) { // Holds a string ready to be formatted and output. $chunk = NULL; @@ -302,12 +302,12 @@ public static function htmlToText($string, $allowed_tags = NULL) { */ protected static function wrapMailLine(&$line, $key, $values) { $line_is_mime_header = FALSE; - $mime_headers = array( + $mime_headers = [ 'Content-Type', 'Content-Transfer-Encoding', 'Content-Disposition', 'Content-Description', - ); + ]; // Do not break MIME headers which could be longer than 77 characters. foreach ($mime_headers as $header) { @@ -336,7 +336,7 @@ protected static function htmlToMailUrls($match = NULL, $reset = FALSE) { if ($reset) { // Reset internal URL list. - static::$urls = array(); + static::$urls = []; } else { if (empty(static::$regexp)) { diff --git a/core/lib/Drupal/Core/Mail/MailManager.php b/core/lib/Drupal/Core/Mail/MailManager.php index 2abba6b..6de2dd8 100644 --- a/core/lib/Drupal/Core/Mail/MailManager.php +++ b/core/lib/Drupal/Core/Mail/MailManager.php @@ -50,7 +50,7 @@ class MailManager extends DefaultPluginManager implements MailManagerInterface { * * @var array */ - protected $instances = array(); + protected $instances = []; /** * Constructs the MailManager object. @@ -163,7 +163,7 @@ public function getInstance(array $options) { /** * {@inheritdoc} */ - public function mail($module, $key, $to, $langcode, $params = array(), $reply = NULL, $send = TRUE) { + public function mail($module, $key, $to, $langcode, $params = [], $reply = NULL, $send = TRUE) { // Mailing can invoke rendering (e.g., generating URLs, replacing tokens), // but e-mails are not HTTP responses: they're not cached, they don't have // attachments. Therefore we perform mailing inside its own render context, @@ -215,7 +215,7 @@ public function mail($module, $key, $to, $langcode, $params = array(), $reply = * * @see \Drupal\Core\Mail\MailManagerInterface::mail() */ - public function doMail($module, $key, $to, $langcode, $params = array(), $reply = NULL, $send = TRUE) { + public function doMail($module, $key, $to, $langcode, $params = [], $reply = NULL, $send = TRUE) { $site_config = $this->configFactory->get('system.site'); $site_mail = $site_config->get('mail'); if (empty($site_mail)) { @@ -223,7 +223,7 @@ public function doMail($module, $key, $to, $langcode, $params = array(), $reply } // Bundle up the variables into a structured array for altering. - $message = array( + $message = [ 'id' => $module . '_' . $key, 'module' => $module, 'key' => $key, @@ -234,16 +234,16 @@ public function doMail($module, $key, $to, $langcode, $params = array(), $reply 'params' => $params, 'send' => TRUE, 'subject' => '', - 'body' => array(), - ); + 'body' => [], + ]; // Build the default headers. - $headers = array( + $headers = [ 'MIME-Version' => '1.0', 'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes', 'Content-Transfer-Encoding' => '8Bit', 'X-Mailer' => 'Drupal', - ); + ]; // To prevent email from looking like spam, the addresses in the Sender and // Return-Path headers should have a domain authorized to use the // originating SMTP server. @@ -267,7 +267,7 @@ public function doMail($module, $key, $to, $langcode, $params = array(), $reply $this->moduleHandler->alter('mail', $message); // Retrieve the responsible implementation for this message. - $system = $this->getInstance(array('module' => $module, 'key' => $key)); + $system = $this->getInstance(['module' => $module, 'key' => $key]); // Format the message body. $message = $system->format($message); @@ -292,11 +292,11 @@ public function doMail($module, $key, $to, $langcode, $params = array(), $reply // Log errors. if (!$message['result']) { $this->loggerFactory->get('mail') - ->error('Error sending email (from %from to %to with reply-to %reply).', array( + ->error('Error sending email (from %from to %to with reply-to %reply).', [ '%from' => $message['from'], '%to' => $message['to'], '%reply' => $message['reply-to'] ? $message['reply-to'] : $this->t('not set'), - )); + ]); drupal_set_message($this->t('Unable to send email. Contact the site administrator if the problem persists.'), 'error'); } } diff --git a/core/lib/Drupal/Core/Mail/MailManagerInterface.php b/core/lib/Drupal/Core/Mail/MailManagerInterface.php index cdf4c8a..0228fbc 100644 --- a/core/lib/Drupal/Core/Mail/MailManagerInterface.php +++ b/core/lib/Drupal/Core/Mail/MailManagerInterface.php @@ -119,6 +119,6 @@ * watchdog. (Success means nothing more than the message being accepted at * php-level, which still doesn't guarantee it to be delivered.) */ - public function mail($module, $key, $to, $langcode, $params = array(), $reply = NULL, $send = TRUE); + public function mail($module, $key, $to, $langcode, $params = [], $reply = NULL, $send = TRUE); } diff --git a/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php b/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php index 652c6b3..1fced2e 100644 --- a/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php +++ b/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php @@ -61,7 +61,7 @@ public function mail(array $message) { unset($message['headers']['Return-Path']); } } - $mimeheaders = array(); + $mimeheaders = []; foreach ($message['headers'] as $name => $value) { $mimeheaders[] = $name . ': ' . Unicode::mimeHeaderEncode($value); } diff --git a/core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php b/core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php index ede465e..607906f 100644 --- a/core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php +++ b/core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php @@ -21,7 +21,7 @@ class TestMailCollector extends PhpMail implements MailInterface { * {@inheritdoc} */ public function mail(array $message) { - $captured_emails = \Drupal::state()->get('system.test_mail_collector') ?: array(); + $captured_emails = \Drupal::state()->get('system.test_mail_collector') ?: []; $captured_emails[] = $message; \Drupal::state()->set('system.test_mail_collector', $captured_emails); diff --git a/core/lib/Drupal/Core/Menu/ContextualLinkManager.php b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php index 29803ad..d9883ef 100644 --- a/core/lib/Drupal/Core/Menu/ContextualLinkManager.php +++ b/core/lib/Drupal/Core/Menu/ContextualLinkManager.php @@ -27,7 +27,7 @@ class ContextualLinkManager extends DefaultPluginManager implements ContextualLi * * @var array */ - protected $defaults = array( + protected $defaults = [ // (required) The name of the route to link to. 'route_name' => '', // (required) The contextual links group. @@ -35,14 +35,14 @@ class ContextualLinkManager extends DefaultPluginManager implements ContextualLi // The static title text for the link. 'title' => '', // The default link options. - 'options' => array(), + 'options' => [], // The weight of the link. 'weight' => NULL, // Default class for contextual link implementations. 'class' => '\Drupal\Core\Menu\ContextualLinkDefault', // The plugin id. Set by the plugin system based on the top-level YAML key. 'id' => '', - ); + ]; /** * A controller resolver object. @@ -105,7 +105,7 @@ public function __construct(ControllerResolverInterface $controller_resolver, Mo $this->moduleHandler = $module_handler; $this->requestStack = $request_stack; $this->alterInfo('contextual_links_plugins'); - $this->setCacheBackend($cache_backend, 'contextual_links_plugins:' . $language_manager->getCurrentLanguage()->getId(), array('contextual_links_plugins')); + $this->setCacheBackend($cache_backend, 'contextual_links_plugins:' . $language_manager->getCurrentLanguage()->getId(), ['contextual_links_plugins']); } /** @@ -148,7 +148,7 @@ public function getContextualLinkPluginsByGroup($group_name) { $this->pluginsByGroup[$group_name] = $contextual_links; } else { - $contextual_links = array(); + $contextual_links = []; foreach ($this->getDefinitions() as $plugin_id => $plugin_definition) { if ($plugin_definition['group'] == $group_name) { $contextual_links[$plugin_id] = $plugin_definition; @@ -163,8 +163,8 @@ public function getContextualLinkPluginsByGroup($group_name) { /** * {@inheritdoc} */ - public function getContextualLinksArrayByGroup($group_name, array $route_parameters, array $metadata = array()) { - $links = array(); + public function getContextualLinksArrayByGroup($group_name, array $route_parameters, array $metadata = []) { + $links = []; $request = $this->requestStack->getCurrentRequest(); foreach ($this->getContextualLinkPluginsByGroup($group_name) as $plugin_id => $plugin_definition) { /** @var $plugin \Drupal\Core\Menu\ContextualLinkInterface */ @@ -176,14 +176,14 @@ public function getContextualLinksArrayByGroup($group_name, array $route_paramet continue; } - $links[$plugin_id] = array( + $links[$plugin_id] = [ 'route_name' => $route_name, 'route_parameters' => $route_parameters, 'title' => $plugin->getTitle($request), 'weight' => $plugin->getWeight(), 'localized_options' => $plugin->getOptions(), 'metadata' => $metadata, - ); + ]; } $this->moduleHandler->alter('contextual_links', $links, $group_name, $route_parameters); diff --git a/core/lib/Drupal/Core/Menu/ContextualLinkManagerInterface.php b/core/lib/Drupal/Core/Menu/ContextualLinkManagerInterface.php index 9e29436..12f0275 100644 --- a/core/lib/Drupal/Core/Menu/ContextualLinkManagerInterface.php +++ b/core/lib/Drupal/Core/Menu/ContextualLinkManagerInterface.php @@ -41,6 +41,6 @@ public function getContextualLinkPluginsByGroup($group_name); * to the link generator. * - metadata: The array of additional metadata that was passed in. */ - public function getContextualLinksArrayByGroup($group_name, array $route_parameters, array $metadata = array()); + public function getContextualLinksArrayByGroup($group_name, array $route_parameters, array $metadata = []); } diff --git a/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php b/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php index 43c4468..47b1cfd 100644 --- a/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php +++ b/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php @@ -129,7 +129,7 @@ public function checkAccess(array $tree) { * The manipulated menu link tree. */ public function checkNodeAccess(array $tree) { - $node_links = array(); + $node_links = []; $this->collectNodeLinks($tree, $node_links); if ($node_links) { $nids = array_keys($node_links); @@ -224,7 +224,7 @@ protected function menuLinkCheckAccess(MenuLinkInterface $instance) { * The manipulated menu link tree. */ public function generateIndexAndSort(array $tree) { - $new_tree = array(); + $new_tree = []; foreach ($tree as $key => $v) { if ($tree[$key]->subtree) { $tree[$key]->subtree = $this->generateIndexAndSort($tree[$key]->subtree); @@ -254,7 +254,7 @@ public function flatten(array $tree) { if ($tree[$key]->subtree) { $tree += $this->flatten($tree[$key]->subtree); } - $tree[$key]->subtree = array(); + $tree[$key]->subtree = []; } return $tree; } diff --git a/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php b/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php index e7c04e3..1703119 100644 --- a/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php +++ b/core/lib/Drupal/Core/Menu/Form/MenuLinkDefaultForm.php @@ -98,41 +98,41 @@ public function setMenuLinkInstance(MenuLinkInterface $menu_link) { * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form['#title'] = $this->t('Edit menu link %title', array('%title' => $this->menuLink->getTitle())); + $form['#title'] = $this->t('Edit menu link %title', ['%title' => $this->menuLink->getTitle()]); $provider = $this->menuLink->getProvider(); - $form['info'] = array( + $form['info'] = [ '#type' => 'item', - '#title' => $this->t('This link is provided by the @name module. The title and path cannot be edited.', array('@name' => $this->moduleHandler->getName($provider))), - ); - $form['id'] = array( + '#title' => $this->t('This link is provided by the @name module. The title and path cannot be edited.', ['@name' => $this->moduleHandler->getName($provider)]), + ]; + $form['id'] = [ '#type' => 'value', '#value' => $this->menuLink->getPluginId(), - ); - $link = array( + ]; + $link = [ '#type' => 'link', '#title' => $this->menuLink->getTitle(), '#url' => $this->menuLink->getUrlObject(), - ); - $form['path'] = array( + ]; + $form['path'] = [ 'link' => $link, '#type' => 'item', '#title' => $this->t('Link'), - ); + ]; - $form['enabled'] = array( + $form['enabled'] = [ '#type' => 'checkbox', '#title' => $this->t('Enable menu link'), '#description' => $this->t('Menu links that are not enabled will not be listed in any menu.'), '#default_value' => $this->menuLink->isEnabled(), - ); + ]; - $form['expanded'] = array( + $form['expanded'] = [ '#type' => 'checkbox', '#title' => t('Show as expanded'), '#description' => $this->t('If selected and this menu link has children, the menu will always appear expanded.'), '#default_value' => $this->menuLink->isExpanded(), - ); + ]; $menu_parent = $this->menuLink->getMenuName() . ':' . $this->menuLink->getParent(); $form['menu_parent'] = $this->menuParentSelector->parentSelectElement($menu_parent, $this->menuLink->getPluginId()); @@ -141,14 +141,14 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $form['menu_parent']['#attributes']['class'][] = 'menu-title-select'; $delta = max(abs($this->menuLink->getWeight()), 50); - $form['weight'] = array( + $form['weight'] = [ '#type' => 'number', '#min' => -$delta, '#max' => $delta, '#default_value' => $this->menuLink->getWeight(), '#title' => $this->t('Weight'), '#description' => $this->t('Link weight among links in the same menu at the same depth. In the menu, the links with high weight will sink and links with a low weight will be positioned nearer the top.'), - ); + ]; return $form; } diff --git a/core/lib/Drupal/Core/Menu/LocalActionDefault.php b/core/lib/Drupal/Core/Menu/LocalActionDefault.php index faa20a8..a628b81 100644 --- a/core/lib/Drupal/Core/Menu/LocalActionDefault.php +++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php @@ -83,7 +83,7 @@ public function getWeight() { * {@inheritdoc} */ public function getRouteParameters(RouteMatchInterface $route_match) { - $parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : array(); + $parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : []; $route = $this->routeProvider->getRouteByName($this->getRouteName()); $variables = $route->compile()->getVariables(); diff --git a/core/lib/Drupal/Core/Menu/LocalActionManager.php b/core/lib/Drupal/Core/Menu/LocalActionManager.php index 924af7c..f262d47 100644 --- a/core/lib/Drupal/Core/Menu/LocalActionManager.php +++ b/core/lib/Drupal/Core/Menu/LocalActionManager.php @@ -28,7 +28,7 @@ class LocalActionManager extends DefaultPluginManager implements LocalActionMana * * @var array */ - protected $defaults = array( + protected $defaults = [ // The plugin id. Set by the plugin system based on the top-level YAML key. 'id' => NULL, // The static title for the local action. @@ -38,14 +38,14 @@ class LocalActionManager extends DefaultPluginManager implements LocalActionMana // (Required) the route name used to generate a link. 'route_name' => NULL, // Default route parameters for generating links. - 'route_parameters' => array(), + 'route_parameters' => [], // Associative array of link options. - 'options' => array(), + 'options' => [], // The route names where this local action appears. - 'appears_on' => array(), + 'appears_on' => [], // Default class for local action implementations. 'class' => 'Drupal\Core\Menu\LocalActionDefault', - ); + ]; /** * A controller resolver object. @@ -94,7 +94,7 @@ class LocalActionManager extends DefaultPluginManager implements LocalActionMana * * @var \Drupal\Core\Menu\LocalActionInterface[] */ - protected $instances = array(); + protected $instances = []; /** * Constructs a LocalActionManager object. @@ -130,7 +130,7 @@ public function __construct(ControllerResolverInterface $controller_resolver, Re $this->moduleHandler = $module_handler; $this->account = $account; $this->alterInfo('menu_local_actions'); - $this->setCacheBackend($cache_backend, 'local_action_plugins:' . $language_manager->getCurrentLanguage()->getId(), array('local_action')); + $this->setCacheBackend($cache_backend, 'local_action_plugins:' . $language_manager->getCurrentLanguage()->getId(), ['local_action']); } /** @@ -149,7 +149,7 @@ protected function getDiscovery() { * {@inheritdoc} */ public function getTitle(LocalActionInterface $local_action) { - $controller = array($local_action, 'getTitle'); + $controller = [$local_action, 'getTitle']; $arguments = $this->controllerResolver->getArguments($this->requestStack->getCurrentRequest(), $controller); return call_user_func_array($controller, $arguments); } @@ -159,8 +159,8 @@ public function getTitle(LocalActionInterface $local_action) { */ public function getActionsForRoute($route_appears) { if (!isset($this->instances[$route_appears])) { - $route_names = array(); - $this->instances[$route_appears] = array(); + $route_names = []; + $this->instances[$route_appears] = []; // @todo - optimize this lookup by compiling or caching. foreach ($this->getDefinitions() as $plugin_id => $action_info) { if (in_array($route_appears, $action_info['appears_on'])) { @@ -175,23 +175,23 @@ public function getActionsForRoute($route_appears) { $this->routeProvider->getRoutesByNames($route_names); } } - $links = array(); + $links = []; /** @var $plugin \Drupal\Core\Menu\LocalActionInterface */ foreach ($this->instances[$route_appears] as $plugin_id => $plugin) { $cacheability = new CacheableMetadata(); $route_name = $plugin->getRouteName(); $route_parameters = $plugin->getRouteParameters($this->routeMatch); $access = $this->accessManager->checkNamedRoute($route_name, $route_parameters, $this->account, TRUE); - $links[$plugin_id] = array( + $links[$plugin_id] = [ '#theme' => 'menu_local_action', - '#link' => array( + '#link' => [ 'title' => $this->getTitle($plugin), 'url' => Url::fromRoute($route_name, $route_parameters), 'localized_options' => $plugin->getOptions($this->routeMatch), - ), + ], '#access' => $access, '#weight' => $plugin->getWeight(), - ); + ]; $cacheability->addCacheableDependency($access)->addCacheableDependency($plugin); $cacheability->applyTo($links[$plugin_id]); } diff --git a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php index 38534b1..30fba4f 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php @@ -41,7 +41,7 @@ public function getRouteName() { * {@inheritdoc} */ public function getRouteParameters(RouteMatchInterface $route_match) { - $parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : array(); + $parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : []; $route = $this->routeProvider()->getRouteByName($this->getRouteName()); $variables = $route->compile()->getVariables(); diff --git a/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php index ec1df5c..17ee4de 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskManager.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php @@ -29,11 +29,11 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI /** * {@inheritdoc} */ - protected $defaults = array( + protected $defaults = [ // (required) The name of the route this task links to. 'route_name' => '', // Parameters for route variables when generating a link. - 'route_parameters' => array(), + 'route_parameters' => [], // The static title for the local task. 'title' => '', // The route name where the root tab appears. @@ -43,12 +43,12 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI // The weight of the tab. 'weight' => NULL, // The default link options. - 'options' => array(), + 'options' => [], // Default class for local task implementations. 'class' => 'Drupal\Core\Menu\LocalTaskDefault', // The plugin id. Set by the plugin system based on the top-level YAML key. 'id' => '', - ); + ]; /** * A controller resolver object. @@ -76,7 +76,7 @@ class LocalTaskManager extends DefaultPluginManager implements LocalTaskManagerI * * @var array */ - protected $instances = array(); + protected $instances = []; /** * The local task render arrays for the current route. @@ -138,7 +138,7 @@ public function __construct(ControllerResolverInterface $controller_resolver, Re $this->account = $account; $this->moduleHandler = $module_handler; $this->alterInfo('local_tasks'); - $this->setCacheBackend($cache, 'local_task_plugins:' . $language_manager->getCurrentLanguage()->getId(), array('local_task')); + $this->setCacheBackend($cache, 'local_task_plugins:' . $language_manager->getCurrentLanguage()->getId(), ['local_task']); } /** @@ -168,7 +168,7 @@ public function processDefinition(&$definition, $plugin_id) { * {@inheritdoc} */ public function getTitle(LocalTaskInterface $local_task) { - $controller = array($local_task, 'getTitle'); + $controller = [$local_task, 'getTitle']; $request = $this->requestStack->getCurrentRequest(); $arguments = $this->controllerResolver->getArguments($request, $controller); return call_user_func_array($controller, $arguments); @@ -196,7 +196,7 @@ public function getDefinitions() { */ public function getLocalTasksForRoute($route_name) { if (!isset($this->instances[$route_name])) { - $this->instances[$route_name] = array(); + $this->instances[$route_name] = []; if ($cache = $this->cacheBackend->get($this->cacheKey . ':' . $route_name)) { $base_routes = $cache->data['base_routes']; $parents = $cache->data['parents']; @@ -206,9 +206,9 @@ public function getLocalTasksForRoute($route_name) { $definitions = $this->getDefinitions(); // We build the hierarchy by finding all tabs that should // appear on the current route. - $base_routes = array(); - $parents = array(); - $children = array(); + $base_routes = []; + $parents = []; + $children = []; foreach ($definitions as $plugin_id => $task_info) { // Fill in the base_route from the parent to insure consistency. if (!empty($task_info['parent_id']) && !empty($definitions[$task_info['parent_id']])) { @@ -242,11 +242,11 @@ public function getLocalTasksForRoute($route_name) { } } } - $data = array( + $data = [ 'base_routes' => $base_routes, 'parents' => $parents, 'children' => $children, - ); + ]; $this->cacheBackend->set($this->cacheKey . ':' . $route_name, $data, Cache::PERMANENT, $this->cacheTags); } // Create a plugin instance for each element of the hierarchy. @@ -288,10 +288,10 @@ public function getLocalTasksForRoute($route_name) { */ public function getTasksBuild($current_route_name, RefinableCacheableDependencyInterface &$cacheability) { $tree = $this->getLocalTasksForRoute($current_route_name); - $build = array(); + $build = []; // Collect all route names. - $route_names = array(); + $route_names = []; foreach ($tree as $instances) { foreach ($instances as $child) { $route_names[] = $child->getRouteName(); diff --git a/core/lib/Drupal/Core/Menu/MenuActiveTrail.php b/core/lib/Drupal/Core/Menu/MenuActiveTrail.php index b99a0e4..353a814 100644 --- a/core/lib/Drupal/Core/Menu/MenuActiveTrail.php +++ b/core/lib/Drupal/Core/Menu/MenuActiveTrail.php @@ -98,7 +98,7 @@ public function getActiveTrailIds($menu_name) { protected function doGetActiveTrailIds($menu_name) { // Parent ids; used both as key and value to ensure uniqueness. // We always want all the top-level links with parent == ''. - $active_trail = array('' => ''); + $active_trail = ['' => '']; // If a link in the given menu indeed matches the route, then use it to // complete the active trail. diff --git a/core/lib/Drupal/Core/Menu/MenuLinkBase.php b/core/lib/Drupal/Core/Menu/MenuLinkBase.php index 760ced2..c61b5db 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkBase.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkBase.php @@ -19,7 +19,7 @@ * * @var array */ - protected $overrideAllowed = array(); + protected $overrideAllowed = []; /** * {@inheritdoc} @@ -92,14 +92,14 @@ public function isDeletable() { * {@inheritdoc} */ public function getOptions() { - return $this->pluginDefinition['options'] ?: array(); + return $this->pluginDefinition['options'] ?: []; } /** * {@inheritdoc} */ public function getMetaData() { - return $this->pluginDefinition['metadata'] ?: array(); + return $this->pluginDefinition['metadata'] ?: []; } /** @@ -113,7 +113,7 @@ public function getRouteName() { * {@inheritdoc} */ public function getRouteParameters() { - return isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : array(); + return isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : []; } /** diff --git a/core/lib/Drupal/Core/Menu/MenuLinkDefault.php b/core/lib/Drupal/Core/Menu/MenuLinkDefault.php index 0dda7e1..80a02cd 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkDefault.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkDefault.php @@ -13,13 +13,13 @@ class MenuLinkDefault extends MenuLinkBase implements ContainerFactoryPluginInte /** * {@inheritdoc} */ - protected $overrideAllowed = array( + protected $overrideAllowed = [ 'menu_name' => 1, 'parent' => 1, 'weight' => 1, 'expanded' => 1, 'enabled' => 1, - ); + ]; /** * The static menu link service used to store updates to weight/parent etc. diff --git a/core/lib/Drupal/Core/Menu/MenuLinkManager.php b/core/lib/Drupal/Core/Menu/MenuLinkManager.php index 15b2e4d..e9cd165 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkManager.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkManager.php @@ -26,13 +26,13 @@ class MenuLinkManager implements MenuLinkManagerInterface { * * @var array */ - protected $defaults = array( + protected $defaults = [ // (required) The name of the menu for this link. 'menu_name' => 'tools', // (required) The name of the route this links to, unless it's external. 'route_name' => '', // Parameters for route variables when generating a link. - 'route_parameters' => array(), + 'route_parameters' => [], // The external URL if this link has one (required if route_name is empty). 'url' => '', // The static title for the menu link. If this came from a YAML definition @@ -46,18 +46,18 @@ class MenuLinkManager implements MenuLinkManagerInterface { // The weight of the link. 'weight' => 0, // The default link options. - 'options' => array(), + 'options' => [], 'expanded' => 0, 'enabled' => 1, // The name of the module providing this link. 'provider' => '', - 'metadata' => array(), + 'metadata' => [], // Default class for local task implementations. 'class' => 'Drupal\Core\Menu\MenuLinkDefault', 'form_class' => 'Drupal\Core\Menu\Form\MenuLinkDefaultForm', // The plugin ID. Set by the plugin system based on the top-level YAML key. 'id' => '', - ); + ]; /** * The object that discovers plugins managed by this manager. @@ -231,7 +231,7 @@ public function hasDefinition($plugin_id) { * @throws \Drupal\Component\Plugin\Exception\PluginException * If the instance cannot be created, such as if the ID is invalid. */ - public function createInstance($plugin_id, array $configuration = array()) { + public function createInstance($plugin_id, array $configuration = []) { return $this->getFactory()->createInstance($plugin_id, $configuration); } @@ -248,7 +248,7 @@ public function getInstance(array $options) { * {@inheritdoc} */ public function deleteLinksInMenu($menu_name) { - foreach ($this->treeStorage->loadByProperties(array('menu_name' => $menu_name)) as $plugin_id => $definition) { + foreach ($this->treeStorage->loadByProperties(['menu_name' => $menu_name]) as $plugin_id => $definition) { $instance = $this->createInstance($plugin_id); if ($instance->isDeletable()) { $this->deleteInstance($instance, TRUE); @@ -333,8 +333,8 @@ public function getChildIds($id) { /** * {@inheritdoc} */ - public function loadLinksByRoute($route_name, array $route_parameters = array(), $menu_name = NULL) { - $instances = array(); + public function loadLinksByRoute($route_name, array $route_parameters = [], $menu_name = NULL) { + $instances = []; $loaded = $this->treeStorage->loadByRoute($route_name, $route_parameters, $menu_name); foreach ($loaded as $plugin_id => $definition) { $instances[$plugin_id] = $this->createInstance($plugin_id); diff --git a/core/lib/Drupal/Core/Menu/MenuLinkManagerInterface.php b/core/lib/Drupal/Core/Menu/MenuLinkManagerInterface.php index c64c47f..d415570 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkManagerInterface.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkManagerInterface.php @@ -72,7 +72,7 @@ public function removeDefinition($id, $persist = TRUE); * @return \Drupal\Core\Menu\MenuLinkInterface[] * An array of instances keyed by plugin ID. */ - public function loadLinksByRoute($route_name, array $route_parameters = array(), $menu_name = NULL); + public function loadLinksByRoute($route_name, array $route_parameters = [], $menu_name = NULL); /** * Adds a new menu link definition to the menu tree storage. diff --git a/core/lib/Drupal/Core/Menu/MenuLinkTree.php b/core/lib/Drupal/Core/Menu/MenuLinkTree.php index 72e8ee9..8dd4c51 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkTree.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkTree.php @@ -107,7 +107,7 @@ public function load($menu_name, MenuTreeParameters $parameters) { * An array containing the elements of a menu tree. */ protected function createInstances(array $data_tree) { - $tree = array(); + $tree = []; foreach ($data_tree as $key => $element) { $subtree = $this->createInstances($element['subtree']); // Build a MenuLinkTreeElement out of the menu tree link definition: @@ -202,7 +202,7 @@ public function build(array $tree) { * @throws \DomainException */ protected function buildItems(array $tree, CacheableMetadata &$tree_access_cacheability, CacheableMetadata &$tree_link_cacheability) { - $items = array(); + $items = []; foreach ($tree as $data) { /** @var \Drupal\Core\Menu\MenuLinkInterface $link */ @@ -262,7 +262,7 @@ protected function buildItems(array $tree, CacheableMetadata &$tree_access_cache $element['title'] = $link->getTitle(); $element['url'] = $link->getUrlObject(); $element['url']->setOption('set_active_class', TRUE); - $element['below'] = $data->subtree ? $this->buildItems($data->subtree, $tree_access_cacheability, $tree_link_cacheability) : array(); + $element['below'] = $data->subtree ? $this->buildItems($data->subtree, $tree_access_cacheability, $tree_link_cacheability) : []; if (isset($data->options)) { $element['url']->setOptions(NestedArray::mergeDeep($element['url']->getOptions(), $data->options)); } diff --git a/core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php b/core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php index 1327c78..d4bd2b7 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkTreeElement.php @@ -79,7 +79,7 @@ class MenuLinkTreeElement { * \Drupal\Core\Menu\MenuLinkInterface::getOptions(), to allow menu link tree * manipulators to add or override link options. */ - public $options = array(); + public $options = []; /** * Constructs a new \Drupal\Core\Menu\MenuLinkTreeElement. diff --git a/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php b/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php index b112104..8add3b0 100644 --- a/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php +++ b/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php @@ -54,7 +54,7 @@ public function getParentSelectOptions($id = '', array $menus = NULL, CacheableM $menus = $this->getMenuOptions(); } - $options = array(); + $options = []; $depth_limit = $this->getParentDepthLimit($id); foreach ($menus as $menu_name => $menu_title) { $options[$menu_name . ':'] = '<' . $menu_title . '>'; @@ -62,11 +62,11 @@ public function getParentSelectOptions($id = '', array $menus = NULL, CacheableM $parameters = new MenuTreeParameters(); $parameters->setMaxDepth($depth_limit); $tree = $this->menuLinkTree->load($menu_name, $parameters); - $manipulators = array( - array('callable' => 'menu.default_tree_manipulators:checkNodeAccess'), - array('callable' => 'menu.default_tree_manipulators:checkAccess'), - array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'), - ); + $manipulators = [ + ['callable' => 'menu.default_tree_manipulators:checkNodeAccess'], + ['callable' => 'menu.default_tree_manipulators:checkAccess'], + ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'], + ]; $tree = $this->menuLinkTree->transform($tree, $manipulators); $this->parentSelectOptionsTreeWalk($tree, $menu_name, '--', $options, $id, $depth_limit, $cacheability); } @@ -81,10 +81,10 @@ public function parentSelectElement($menu_parent, $id = '', array $menus = NULL) $options = $this->getParentSelectOptions($id, $menus, $options_cacheability); // If no options were found, there is nothing to select. if ($options) { - $element = array( + $element = [ '#type' => 'select', '#options' => $options, - ); + ]; if (!isset($options[$menu_parent])) { // The requested menu parent cannot be found in the menu anymore. Try // setting it to the top level in the current menu. @@ -93,12 +93,12 @@ public function parentSelectElement($menu_parent, $id = '', array $menus = NULL) } if (isset($options[$menu_parent])) { // Only provide the default value if it is valid among the options. - $element += array('#default_value' => $menu_parent); + $element += ['#default_value' => $menu_parent]; } $options_cacheability->applyTo($element); return $element; } - return array(); + return []; } /** @@ -183,7 +183,7 @@ protected function parentSelectOptionsTreeWalk(array $tree, $menu_name, $indent, */ protected function getMenuOptions(array $menu_names = NULL) { $menus = $this->entityManager->getStorage('menu')->loadMultiple($menu_names); - $options = array(); + $options = []; /** @var \Drupal\system\MenuInterface[] $menus */ foreach ($menus as $menu) { $options[$menu->id()] = $menu->label(); diff --git a/core/lib/Drupal/Core/Menu/MenuTreeParameters.php b/core/lib/Drupal/Core/Menu/MenuTreeParameters.php index cb21073..702dcb4 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeParameters.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeParameters.php @@ -50,7 +50,7 @@ class MenuTreeParameters { * * @var string[] */ - public $expandedParents = array(); + public $expandedParents = []; /** * The IDs from the currently active menu link to the root of the whole tree. @@ -62,7 +62,7 @@ class MenuTreeParameters { * * @var string[] */ - public $activeTrail = array(); + public $activeTrail = []; /** * The conditions used to restrict which links are loaded. @@ -71,7 +71,7 @@ class MenuTreeParameters { * * @var array */ - public $conditions = array(); + public $conditions = []; /** * Sets a root for menu tree loading. @@ -170,7 +170,7 @@ public function addCondition($definition_field, $value, $operator = NULL) { $this->conditions[$definition_field] = $value; } else { - $this->conditions[$definition_field] = array($value, $operator); + $this->conditions[$definition_field] = [$value, $operator]; } return $this; } diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index e2181cf..7bba137 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -55,7 +55,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface { * * @var array */ - protected $options = array(); + protected $options = []; /** * Stores definitions that have already been loaded for better performance. @@ -64,7 +64,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface { * * @var array */ - protected $definitions = array(); + protected $definitions = []; /** * List of serialized fields. @@ -83,7 +83,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface { * * @var array */ - protected $definitionFields = array( + protected $definitionFields = [ 'menu_name', 'route_name', 'route_parameters', @@ -100,7 +100,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface { 'class', 'form_class', 'id', - ); + ]; /** * Constructs a new \Drupal\Core\Menu\MenuTreeStorage. @@ -116,7 +116,7 @@ class MenuTreeStorage implements MenuTreeStorageInterface { * @param array $options * (optional) Any additional database connection options to use in queries. */ - public function __construct(Connection $connection, CacheBackendInterface $menu_cache_backend, CacheTagsInvalidatorInterface $cache_tags_invalidator, $table, array $options = array()) { + public function __construct(Connection $connection, CacheBackendInterface $menu_cache_backend, CacheTagsInvalidatorInterface $cache_tags_invalidator, $table, array $options = []) { $this->connection = $connection; $this->menuCacheBackend = $menu_cache_backend; $this->cacheTagsInvalidator = $cache_tags_invalidator; @@ -135,16 +135,16 @@ public function maxDepth() { * {@inheritdoc} */ public function resetDefinitions() { - $this->definitions = array(); + $this->definitions = []; } /** * {@inheritdoc} */ public function rebuild(array $definitions) { - $links = array(); - $children = array(); - $top_links = array(); + $links = []; + $children = []; + $top_links = []; // Fetch the list of existing menus, in case some are not longer populated // after the rebuild. $before_menus = $this->getMenuNames(); @@ -214,7 +214,7 @@ protected function purgeMultiple(array $ids) { $loaded = $this->loadFullMultiple($ids); foreach ($loaded as $id => $link) { if ($link['has_children']) { - $children = $this->loadByProperties(array('parent' => $id)); + $children = $this->loadByProperties(['parent' => $id]); foreach ($children as $child) { $child['parent'] = $link['parent']; $this->save($child); @@ -286,7 +286,7 @@ protected function doSave(array $link) { // @todo Should we just return here if the link values match the original // values completely? // https://www.drupal.org/node/2302137 - $affected_menus = array(); + $affected_menus = []; $transaction = $this->connection->startTransaction(); try { @@ -297,9 +297,9 @@ protected function doSave(array $link) { } else { // Generate a new mlid. - $options = array('return' => Database::RETURN_INSERT_ID) + $this->options; + $options = ['return' => Database::RETURN_INSERT_ID] + $this->options; $link['mlid'] = $this->connection->insert($this->table, $options) - ->fields(array('id' => $link['id'], 'menu_name' => $link['menu_name'])) + ->fields(['id' => $link['id'], 'menu_name' => $link['menu_name']]) ->execute(); } $fields = $this->preSave($link, $original); @@ -401,7 +401,7 @@ public function delete($id) { // It's possible the link is already deleted. if ($item) { $parent = $item['parent']; - $children = $this->loadByProperties(array('parent' => $id)); + $children = $this->loadByProperties(['parent' => $id]); foreach ($children as $child) { $child['parent'] = $parent; $this->save($child); @@ -512,18 +512,18 @@ protected function setParents(array &$fields, $parent, array $original) { protected function moveChildren($fields, $original) { $query = $this->connection->update($this->table, $this->options); - $query->fields(array('menu_name' => $fields['menu_name'])); + $query->fields(['menu_name' => $fields['menu_name']]); - $expressions = array(); + $expressions = []; for ($i = 1; $i <= $fields['depth']; $i++) { - $expressions[] = array("p$i", ":p_$i", array(":p_$i" => $fields["p$i"])); + $expressions[] = ["p$i", ":p_$i", [":p_$i" => $fields["p$i"]]]; } $j = $original['depth'] + 1; while ($i <= $this->maxDepth() && $j <= $this->maxDepth()) { - $expressions[] = array('p' . $i++, 'p' . $j++, array()); + $expressions[] = ['p' . $i++, 'p' . $j++, []]; } while ($i <= $this->maxDepth()) { - $expressions[] = array('p' . $i++, 0, array()); + $expressions[] = ['p' . $i++, 0, []]; } $shift = $fields['depth'] - $original['depth']; @@ -538,7 +538,7 @@ protected function moveChildren($fields, $original) { $query->expression($expression[0], $expression[1], $expression[2]); } - $query->expression('depth', 'depth + :depth', array(':depth' => $shift)); + $query->expression('depth', 'depth + :depth', [':depth' => $shift]); $query->condition('menu_name', $original['menu_name']); for ($i = 1; $i <= $this->maxDepth() && $original["p$i"]; $i++) { @@ -569,7 +569,7 @@ protected function findParent($link, $original) { } // If we have a parent link ID, try to use that. - $candidates = array(); + $candidates = []; if (isset($link['parent'])) { $candidates[] = $link['parent']; } @@ -607,7 +607,7 @@ protected function updateParentalStatus(array $link) { $parent_has_children = ((bool) $query->execute()->fetchField()) ? 1 : 0; $this->connection->update($this->table, $this->options) - ->fields(array('has_children' => $parent_has_children)) + ->fields(['has_children' => $parent_has_children]) ->condition('id', $link['parent']) ->execute(); } @@ -660,7 +660,7 @@ public function loadByProperties(array $properties) { /** * {@inheritdoc} */ - public function loadByRoute($route_name, array $route_parameters = array(), $menu_name = NULL) { + public function loadByRoute($route_name, array $route_parameters = [], $menu_name = NULL) { // Sort the route parameters so that the query string will be the same. asort($route_parameters); // Since this will be urlencoded, it's safe to store and match against a @@ -711,7 +711,7 @@ public function load($id) { if (isset($this->definitions[$id])) { return $this->definitions[$id]; } - $loaded = $this->loadMultiple(array($id)); + $loaded = $this->loadMultiple([$id]); return isset($loaded[$id]) ? $loaded[$id] : FALSE; } @@ -725,8 +725,8 @@ public function load($id) { * The loaded menu link definition or an empty array if not be found. */ protected function loadFull($id) { - $loaded = $this->loadFullMultiple(array($id)); - return isset($loaded[$id]) ? $loaded[$id] : array(); + $loaded = $this->loadFullMultiple([$id]); + return isset($loaded[$id]) ? $loaded[$id] : []; } /** @@ -761,20 +761,20 @@ public function getRootPathIds($id) { // @todo Consider making this dynamic based on static::MAX_DEPTH or from the // schema if that is generated using static::MAX_DEPTH. // https://www.drupal.org/node/2302043 - $subquery->fields($this->table, array('p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9')); + $subquery->fields($this->table, ['p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9']); $subquery->condition('id', $id); $result = current($subquery->execute()->fetchAll(\PDO::FETCH_ASSOC)); $ids = array_filter($result); if ($ids) { $query = $this->connection->select($this->table, $this->options); - $query->fields($this->table, array('id')); + $query->fields($this->table, ['id']); $query->orderBy('depth', 'DESC'); $query->condition('mlid', $ids, 'IN'); // @todo Cache this result in memory if we find it is being used more // than once per page load. https://www.drupal.org/node/2302185 return $this->safeExecuteSelect($query)->fetchAllKeyed(0, 0); } - return array(); + return []; } /** @@ -785,7 +785,7 @@ public function getExpanded($menu_name, array $parents) { // expanded links? https://www.drupal.org/node/2302187 do { $query = $this->connection->select($this->table, $this->options); - $query->fields($this->table, array('id')); + $query->fields($this->table, ['id']); $query->condition('menu_name', $menu_name); $query->condition('expanded', 1); $query->condition('has_children', 1); @@ -843,7 +843,7 @@ public function loadTreeData($menu_name, MenuTreeParameters $parameters) { else { $links = $this->loadLinks($menu_name, $parameters); $data['tree'] = $this->doBuildTreeData($links, $parameters->activeTrail, $parameters->minDepth); - $data['definitions'] = array(); + $data['definitions'] = []; $data['route_names'] = $this->collectRoutesAndDefinitions($data['tree'], $data['definitions']); $this->menuCacheBackend->set($tree_cid, $data, Cache::PERMANENT, ['config:system.menu.' . $menu_name]); // The definitions were already added to $this->definitions in @@ -880,7 +880,7 @@ protected function loadLinks($menu_name, MenuTreeParameters $parameters) { // If the custom root does not exist, we cannot load the links below it. if (!$root) { - return array(); + return []; } // When specifying a custom root, we only want to find links whose @@ -986,7 +986,7 @@ protected function collectRoutesAndDefinitions(array $tree, array &$definitions) * The collected route names. */ protected function doCollectRoutesAndDefinitions(array $tree, array &$definitions) { - $route_names = array(); + $route_names = []; foreach (array_keys($tree) as $id) { $definitions[$id] = $this->definitions[$id]; if (!empty($definition['route_name'])) { @@ -1003,7 +1003,7 @@ protected function doCollectRoutesAndDefinitions(array $tree, array &$definition * {@inheritdoc} */ public function loadSubtreeData($id, $max_relative_depth = NULL) { - $tree = array(); + $tree = []; $root = $this->loadFull($id); if (!$root) { return $tree; @@ -1051,10 +1051,10 @@ public function countMenuLinks($menu_name = NULL) { public function getAllChildIds($id) { $root = $this->loadFull($id); if (!$root) { - return array(); + return []; } $query = $this->connection->select($this->table, $this->options); - $query->fields($this->table, array('id')); + $query->fields($this->table, ['id']); $query->condition('menu_name', $root['menu_name']); for ($i = 1; $i <= $root['depth']; $i++) { $query->condition("p$i", $root["p$i"]); @@ -1080,7 +1080,7 @@ public function loadAllChildren($id, $max_relative_depth = NULL) { /** * Prepares the data for calling $this->treeDataRecursive(). */ - protected function doBuildTreeData(array $links, array $parents = array(), $depth = 1) { + protected function doBuildTreeData(array $links, array $parents = [], $depth = 1) { // Reverse the array so we can use the more efficient array_pop() function. $links = array_reverse($links); return $this->treeDataRecursive($links, $parents, $depth); @@ -1109,17 +1109,17 @@ protected function doBuildTreeData(array $links, array $parents = array(), $dept * @see \Drupal\Core\Menu\MenuTreeStorage::loadTreeData() */ protected function treeDataRecursive(array &$links, array $parents, $depth) { - $tree = array(); + $tree = []; while ($tree_link_definition = array_pop($links)) { - $tree[$tree_link_definition['id']] = array( + $tree[$tree_link_definition['id']] = [ 'definition' => $this->prepareLink($tree_link_definition, TRUE), 'has_children' => $tree_link_definition['has_children'], // We need to determine if we're on the path to root so we can later // build the correct active trail. 'in_active_trail' => in_array($tree_link_definition['id'], $parents), - 'subtree' => array(), + 'subtree' => [], 'depth' => $tree_link_definition['depth'], - ); + ]; // Look ahead to the next link, but leave it on the array so it's // available to other recursive function calls if we return or build a // sub-tree. @@ -1202,211 +1202,211 @@ protected function definitionFields() { * The schema API definition for the SQL storage table. */ protected static function schemaDefinition() { - $schema = array( + $schema = [ 'description' => 'Contains the menu tree hierarchy.', - 'fields' => array( - 'menu_name' => array( + 'fields' => [ + 'menu_name' => [ 'description' => "The menu name. All links with the same menu name (such as 'tools') are part of the same menu.", 'type' => 'varchar_ascii', 'length' => 32, 'not null' => TRUE, 'default' => '', - ), - 'mlid' => array( + ], + 'mlid' => [ 'description' => 'The menu link ID (mlid) is the integer primary key.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'description' => 'Unique machine name: the plugin ID.', 'type' => 'varchar_ascii', 'length' => 255, 'not null' => TRUE, - ), - 'parent' => array( + ], + 'parent' => [ 'description' => 'The plugin ID for the parent of this link.', 'type' => 'varchar_ascii', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), - 'route_name' => array( + ], + 'route_name' => [ 'description' => 'The machine name of a defined Symfony Route this menu item represents.', 'type' => 'varchar_ascii', 'length' => 255, - ), - 'route_param_key' => array( + ], + 'route_param_key' => [ 'description' => 'An encoded string of route parameters for loading by route.', 'type' => 'varchar', 'length' => 255, - ), - 'route_parameters' => array( + ], + 'route_parameters' => [ 'description' => 'Serialized array of route parameters of this menu link.', 'type' => 'blob', 'size' => 'big', 'not null' => FALSE, 'serialize' => TRUE, - ), - 'url' => array( + ], + 'url' => [ 'description' => 'The external path this link points to (when not using a route).', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), - 'title' => array( + ], + 'title' => [ 'description' => 'The serialized title for the link. May be a TranslatableMarkup.', 'type' => 'blob', 'size' => 'big', 'not null' => FALSE, 'serialize' => TRUE, - ), - 'description' => array( + ], + 'description' => [ 'description' => 'The serialized description of this link - used for admin pages and title attribute. May be a TranslatableMarkup.', 'type' => 'blob', 'size' => 'big', 'not null' => FALSE, 'serialize' => TRUE, - ), - 'class' => array( + ], + 'class' => [ 'description' => 'The class for this link plugin.', 'type' => 'text', 'not null' => FALSE, - ), - 'options' => array( + ], + 'options' => [ 'description' => 'A serialized array of URL options, such as a query string or HTML attributes.', 'type' => 'blob', 'size' => 'big', 'not null' => FALSE, 'serialize' => TRUE, - ), - 'provider' => array( + ], + 'provider' => [ 'description' => 'The name of the module that generated this link.', 'type' => 'varchar_ascii', 'length' => DRUPAL_EXTENSION_NAME_MAX_LENGTH, 'not null' => TRUE, 'default' => 'system', - ), - 'enabled' => array( + ], + 'enabled' => [ 'description' => 'A flag for whether the link should be rendered in menus. (0 = a disabled menu item that may be shown on admin screens, 1 = a normal, visible link)', 'type' => 'int', 'not null' => TRUE, 'default' => 1, 'size' => 'small', - ), - 'discovered' => array( + ], + 'discovered' => [ 'description' => 'A flag for whether the link was discovered, so can be purged on rebuild', 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small', - ), - 'expanded' => array( + ], + 'expanded' => [ 'description' => 'Flag for whether this link should be rendered as expanded in menus - expanded links always have their child links displayed, instead of only when the link is in the active trail (1 = expanded, 0 = not expanded)', 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small', - ), - 'weight' => array( + ], + 'weight' => [ 'description' => 'Link weight among links in the same menu at the same depth.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, - ), - 'metadata' => array( + ], + 'metadata' => [ 'description' => 'A serialized array of data that may be used by the plugin instance.', 'type' => 'blob', 'size' => 'big', 'not null' => FALSE, 'serialize' => TRUE, - ), - 'has_children' => array( + ], + 'has_children' => [ 'description' => 'Flag indicating whether any enabled links have this link as a parent (1 = enabled children exist, 0 = no enabled children).', 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small', - ), - 'depth' => array( + ], + 'depth' => [ 'description' => 'The depth relative to the top level. A link with empty parent will have depth == 1.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small', - ), - 'p1' => array( + ], + 'p1' => [ 'description' => 'The first mlid in the materialized path. If N = depth, then pN must equal the mlid. If depth > 1 then p(N-1) must equal the parent link mlid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p2' => array( + ], + 'p2' => [ 'description' => 'The second mlid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p3' => array( + ], + 'p3' => [ 'description' => 'The third mlid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p4' => array( + ], + 'p4' => [ 'description' => 'The fourth mlid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p5' => array( + ], + 'p5' => [ 'description' => 'The fifth mlid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p6' => array( + ], + 'p6' => [ 'description' => 'The sixth mlid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p7' => array( + ], + 'p7' => [ 'description' => 'The seventh mlid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p8' => array( + ], + 'p8' => [ 'description' => 'The eighth mlid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p9' => array( + ], + 'p9' => [ 'description' => 'The ninth mlid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'form_class' => array( + ], + 'form_class' => [ 'description' => 'meh', 'type' => 'varchar', 'length' => 255, - ), - ), - 'indexes' => array( - 'menu_parents' => array( + ], + ], + 'indexes' => [ + 'menu_parents' => [ 'menu_name', 'p1', 'p2', @@ -1417,24 +1417,24 @@ protected static function schemaDefinition() { 'p7', 'p8', 'p9', - ), + ], // @todo Test this index for effectiveness. // https://www.drupal.org/node/2302197 - 'menu_parent_expand_child' => array( + 'menu_parent_expand_child' => [ 'menu_name', 'expanded', 'has_children', - array('parent', 16), - ), - 'route_values' => array( - array('route_name', 32), - array('route_param_key', 16), - ), - ), - 'primary key' => array('mlid'), - 'unique keys' => array( - 'id' => array('id'), - ), - ); + ['parent', 16], + ], + 'route_values' => [ + ['route_name', 32], + ['route_param_key', 16], + ], + ], + 'primary key' => ['mlid'], + 'unique keys' => [ + 'id' => ['id'], + ], + ]; return $schema; } @@ -1459,7 +1459,7 @@ protected function findNoLongerExistingLinks(array $definitions) { $result = $query->execute()->fetchCol(); } else { - $result = array(); + $result = []; } return $result; } diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php b/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php index 4ee308b..51d74f4 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php @@ -86,7 +86,7 @@ public function loadByProperties(array $properties); * @return array * An array of menu link definitions keyed by ID and ordered by depth. */ - public function loadByRoute($route_name, array $route_parameters = array(), $menu_name = NULL); + public function loadByRoute($route_name, array $route_parameters = [], $menu_name = NULL); /** * Saves a plugin definition to the storage. diff --git a/core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php b/core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php index a2d7591..07b7526 100644 --- a/core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php +++ b/core/lib/Drupal/Core/Menu/StaticMenuLinkOverrides.php @@ -73,7 +73,7 @@ public function reload() { public function loadOverride($id) { $all_overrides = $this->getConfig()->get('definitions'); $id = static::encodeId($id); - return $id && isset($all_overrides[$id]) ? $all_overrides[$id] : array(); + return $id && isset($all_overrides[$id]) ? $all_overrides[$id] : []; } /** @@ -99,16 +99,16 @@ public function deleteMultipleOverrides(array $ids) { * {@inheritdoc} */ public function deleteOverride($id) { - return $this->deleteMultipleOverrides(array($id)); + return $this->deleteMultipleOverrides([$id]); } /** * {@inheritdoc} */ public function loadMultipleOverrides(array $ids) { - $result = array(); + $result = []; if ($ids) { - $all_overrides = $this->getConfig()->get('definitions') ?: array(); + $all_overrides = $this->getConfig()->get('definitions') ?: []; foreach ($ids as $id) { $encoded_id = static::encodeId($id); if (isset($all_overrides[$encoded_id])) { @@ -124,13 +124,13 @@ public function loadMultipleOverrides(array $ids) { */ public function saveOverride($id, array $definition) { // Only allow to override a specific subset of the keys. - $expected = array( + $expected = [ 'menu_name' => '', 'parent' => '', 'weight' => 0, 'expanded' => FALSE, 'enabled' => FALSE, - ); + ]; // Filter the overrides to only those that are expected. $definition = array_intersect_key($definition, $expected); // Ensure all values are set. @@ -173,7 +173,7 @@ public function getCacheTags() { * The menu plugin ID with double underscore instead of dots. */ protected static function encodeId($id) { - return strtr($id, array('.' => '__', '__' => '___')); + return strtr($id, ['.' => '__', '__' => '___']); } } diff --git a/core/lib/Drupal/Core/Menu/menu.api.php b/core/lib/Drupal/Core/Menu/menu.api.php index af33b32..858281b 100644 --- a/core/lib/Drupal/Core/Menu/menu.api.php +++ b/core/lib/Drupal/Core/Menu/menu.api.php @@ -268,12 +268,12 @@ function hook_menu_links_discovered_alter(&$links) { $links['user.logout']['title'] = new \Drupal\Core\StringTranslation\TranslatableMarkup('Logout'); // Conditionally add an additional link with a title that's not translated. if (\Drupal::moduleHandler()->moduleExists('search')) { - $links['menu.api.search'] = array( + $links['menu.api.search'] = [ 'title' => \Drupal::config('system.site')->get('name'), 'route_name' => 'menu.api.search', 'description' => new \Drupal\Core\StringTranslation\TranslatableMarkup('View popular search phrases for this site.'), 'parent' => 'system.admin_reports', - ); + ]; } } @@ -307,18 +307,18 @@ function hook_menu_links_discovered_alter(&$links) { function hook_menu_local_tasks_alter(&$data, $route_name) { // Add a tab linking to node/add to all pages. - $data['tabs'][0]['node.add_page'] = array( + $data['tabs'][0]['node.add_page'] = [ '#theme' => 'menu_local_task', - '#link' => array( + '#link' => [ 'title' => t('Example tab'), 'url' => Url::fromRoute('node.add_page'), - 'localized_options' => array( - 'attributes' => array( + 'localized_options' => [ + 'attributes' => [ 'title' => t('Add content'), - ), - ), - ), - ); + ], + ], + ], + ]; } /** @@ -390,7 +390,7 @@ function hook_contextual_links_alter(array &$links, $group, array $route_paramet // Dynamically use the menu name for the title of the menu_edit contextual // link. $menu = \Drupal::entityManager()->getStorage('menu')->load($route_parameters['menu']); - $links['menu_edit']['title'] = t('Edit menu: @label', array('@label' => $menu->label())); + $links['menu_edit']['title'] = t('Edit menu: @label', ['@label' => $menu->label()]); } } diff --git a/core/lib/Drupal/Core/ParamConverter/EntityConverter.php b/core/lib/Drupal/Core/ParamConverter/EntityConverter.php index 573cd49..67f6a89 100644 --- a/core/lib/Drupal/Core/ParamConverter/EntityConverter.php +++ b/core/lib/Drupal/Core/ParamConverter/EntityConverter.php @@ -65,7 +65,7 @@ public function convert($value, $definition, $name, array $defaults) { // If the entity type is translatable, ensure we return the proper // translation object for the current context. if ($entity instanceof EntityInterface && $entity instanceof TranslatableInterface) { - $entity = $this->entityManager->getTranslationFromContext($entity, NULL, array('operation' => 'entity_upcast')); + $entity = $this->entityManager->getTranslationFromContext($entity, NULL, ['operation' => 'entity_upcast']); } return $entity; } diff --git a/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php b/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php index d54bd7f..cad7609 100644 --- a/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php +++ b/core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php @@ -18,7 +18,7 @@ class ParamConverterManager implements ParamConverterManagerInterface { * * @var array */ - protected $converters = array(); + protected $converters = []; /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/Path/AliasManager.php b/core/lib/Drupal/Core/Path/AliasManager.php index 0368d43..56b66be 100644 --- a/core/lib/Drupal/Core/Path/AliasManager.php +++ b/core/lib/Drupal/Core/Path/AliasManager.php @@ -52,14 +52,14 @@ class AliasManager implements AliasManagerInterface, CacheDecoratorInterface { * * @var array */ - protected $lookupMap = array(); + protected $lookupMap = []; /** * Holds an array of aliases for which no path was found. * * @var array */ - protected $noPath = array(); + protected $noPath = []; /** * Holds the array of whitelisted path aliases. @@ -73,14 +73,14 @@ class AliasManager implements AliasManagerInterface, CacheDecoratorInterface { * * @var array */ - protected $noAlias = array(); + protected $noAlias = []; /** * Whether preloaded path lookups has already been loaded. * * @var array */ - protected $langcodePreloaded = array(); + protected $langcodePreloaded = []; /** * Holds an array of previously looked up paths for the current request path. @@ -132,7 +132,7 @@ public function writeCache() { if ($this->cacheNeedsWriting && !empty($this->cacheKey)) { // Start with the preloaded path lookups, so that cached entries for other // languages will not be lost. - $path_lookups = $this->preloadedPathLookups ?: array(); + $path_lookups = $this->preloadedPathLookups ?: []; foreach ($this->lookupMap as $langcode => $lookups) { $path_lookups[$langcode] = array_keys($lookups); if (!empty($this->noAlias[$langcode])) { @@ -202,12 +202,12 @@ public function getAliasByPath($path, $langcode = NULL) { // paths for the page from cache. if (empty($this->langcodePreloaded[$langcode])) { $this->langcodePreloaded[$langcode] = TRUE; - $this->lookupMap[$langcode] = array(); + $this->lookupMap[$langcode] = []; // Load the cached paths that should be used for preloading. This only // happens if a cache key has been set. if ($this->preloadedPathLookups === FALSE) { - $this->preloadedPathLookups = array(); + $this->preloadedPathLookups = []; if ($this->cacheKey) { if ($cached = $this->cache->get($this->cacheKey)) { $this->preloadedPathLookups = $cached->data; @@ -258,12 +258,12 @@ public function cacheClear($source = NULL) { } } else { - $this->lookupMap = array(); + $this->lookupMap = []; } - $this->noPath = array(); - $this->noAlias = array(); - $this->langcodePreloaded = array(); - $this->preloadedPathLookups = array(); + $this->noPath = []; + $this->noAlias = []; + $this->langcodePreloaded = []; + $this->preloadedPathLookups = []; $this->cache->delete($this->cacheKey); $this->pathAliasWhitelistRebuild($source); } diff --git a/core/lib/Drupal/Core/Path/AliasStorage.php b/core/lib/Drupal/Core/Path/AliasStorage.php index 5379eda..4f38012 100644 --- a/core/lib/Drupal/Core/Path/AliasStorage.php +++ b/core/lib/Drupal/Core/Path/AliasStorage.php @@ -63,11 +63,11 @@ public function save($source, $alias, $langcode = LanguageInterface::LANGCODE_NO throw new \InvalidArgumentException(sprintf('Alias path %s has to start with a slash.', $alias)); } - $fields = array( + $fields = [ 'source' => $source, 'alias' => $alias, 'langcode' => $langcode, - ); + ]; // Insert or update the alias. if (empty($pid)) { @@ -99,7 +99,7 @@ public function save($source, $alias, $langcode = LanguageInterface::LANGCODE_NO // Fetch the current values so that an update hook can identify what // exactly changed. try { - $original = $this->connection->query('SELECT source, alias, langcode FROM {url_alias} WHERE pid = :pid', array(':pid' => $pid)) + $original = $this->connection->query('SELECT source, alias, langcode FROM {url_alias} WHERE pid = :pid', [':pid' => $pid]) ->fetchAssoc(); } catch (\Exception $e) { @@ -116,7 +116,7 @@ public function save($source, $alias, $langcode = LanguageInterface::LANGCODE_NO } if ($pid) { // @todo Switch to using an event for this instead of a hook. - $this->moduleHandler->invokeAll('path_' . $operation, array($fields)); + $this->moduleHandler->invokeAll('path_' . $operation, [$fields]); Cache::invalidateTags(['route_match']); return $fields; } @@ -174,7 +174,7 @@ public function delete($conditions) { $deleted = FALSE; } // @todo Switch to using an event for this instead of a hook. - $this->moduleHandler->invokeAll('path_delete', array($path)); + $this->moduleHandler->invokeAll('path_delete', [$path]); Cache::invalidateTags(['route_match']); return $deleted; } @@ -313,7 +313,7 @@ public function aliasExists($alias, $langcode, $source = NULL) { */ public function languageAliasExists() { try { - return (bool) $this->connection->queryRange('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED))->fetchField(); + return (bool) $this->connection->queryRange('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, [':langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED])->fetchField(); } catch (\Exception $e) { $this->catchException($e); diff --git a/core/lib/Drupal/Core/Path/PathMatcher.php b/core/lib/Drupal/Core/Path/PathMatcher.php index 2b616c2..cc4f2cc 100644 --- a/core/lib/Drupal/Core/Path/PathMatcher.php +++ b/core/lib/Drupal/Core/Path/PathMatcher.php @@ -66,19 +66,19 @@ public function matchPath($path, $patterns) { if (!isset($this->regexes[$patterns])) { // Convert path settings to a regular expression. - $to_replace = array( + $to_replace = [ // Replace newlines with a logical 'or'. '/(\r\n?|\n)/', // Quote asterisks. '/\\\\\*/', // Quote keyword. '/(^|\|)\\\\($|\|)/', - ); - $replacements = array( + ]; + $replacements = [ '|', '.*', '\1' . preg_quote($this->getFrontPagePath(), '/') . '\2', - ); + ]; $patterns_quoted = preg_quote($patterns, '/'); $this->regexes[$patterns] = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/'; } diff --git a/core/lib/Drupal/Core/PathProcessor/NullPathProcessorManager.php b/core/lib/Drupal/Core/PathProcessor/NullPathProcessorManager.php index 3718663..9e6d3da 100644 --- a/core/lib/Drupal/Core/PathProcessor/NullPathProcessorManager.php +++ b/core/lib/Drupal/Core/PathProcessor/NullPathProcessorManager.php @@ -22,7 +22,7 @@ public function processInbound($path, Request $request) { /** * {@inheritdoc} */ - public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { + public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { return $path; } diff --git a/core/lib/Drupal/Core/PathProcessor/OutboundPathProcessorInterface.php b/core/lib/Drupal/Core/PathProcessor/OutboundPathProcessorInterface.php index db7d896..a5e6570 100644 --- a/core/lib/Drupal/Core/PathProcessor/OutboundPathProcessorInterface.php +++ b/core/lib/Drupal/Core/PathProcessor/OutboundPathProcessorInterface.php @@ -45,6 +45,6 @@ * @return string * The processed path. */ - public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL); + public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL); } diff --git a/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php b/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php index a067b3d..b85737f 100644 --- a/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php +++ b/core/lib/Drupal/Core/PathProcessor/PathProcessorAlias.php @@ -39,7 +39,7 @@ public function processInbound($path, Request $request) { /** * {@inheritdoc} */ - public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { + public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { if (empty($options['alias'])) { $langcode = isset($options['language']) ? $options['language']->getId() : NULL; $path = $this->aliasManager->getAliasByPath($path, $langcode); diff --git a/core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php b/core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php index a800842..94ff118 100644 --- a/core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php +++ b/core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php @@ -49,7 +49,7 @@ public function processInbound($path, Request $request) { /** * {@inheritdoc} */ - public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { + public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { // The special path '' links to the default front page. if ($path === '/') { $path = '/'; diff --git a/core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php b/core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php index f1987f8..2a3181e 100644 --- a/core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php +++ b/core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php @@ -20,7 +20,7 @@ class PathProcessorManager implements InboundPathProcessorInterface, OutboundPat * An array whose keys are priorities and whose values are arrays of path * processor objects. */ - protected $inboundProcessors = array(); + protected $inboundProcessors = []; /** * Holds the array of inbound processors, sorted by priority. @@ -28,7 +28,7 @@ class PathProcessorManager implements InboundPathProcessorInterface, OutboundPat * @var array * An array of path processor objects. */ - protected $sortedInbound = array(); + protected $sortedInbound = []; /** @@ -38,7 +38,7 @@ class PathProcessorManager implements InboundPathProcessorInterface, OutboundPat * An array whose keys are priorities and whose values are arrays of path * processor objects. */ - protected $outboundProcessors = array(); + protected $outboundProcessors = []; /** * Holds the array of outbound processors, sorted by priority. @@ -46,7 +46,7 @@ class PathProcessorManager implements InboundPathProcessorInterface, OutboundPat * @var array * An array of path processor objects. */ - protected $sortedOutbound = array(); + protected $sortedOutbound = []; /** * Adds an inbound processor object to the $inboundProcessors property. @@ -58,7 +58,7 @@ class PathProcessorManager implements InboundPathProcessorInterface, OutboundPat */ public function addInbound(InboundPathProcessorInterface $processor, $priority = 0) { $this->inboundProcessors[$priority][] = $processor; - $this->sortedInbound = array(); + $this->sortedInbound = []; } /** @@ -97,13 +97,13 @@ protected function getInbound() { */ public function addOutbound(OutboundPathProcessorInterface $processor, $priority = 0) { $this->outboundProcessors[$priority][] = $processor; - $this->sortedOutbound = array(); + $this->sortedOutbound = []; } /** * {@inheritdoc} */ - public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { + public function processOutbound($path, &$options = [], Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) { $processors = $this->getOutbound(); foreach ($processors as $processor) { $path = $processor->processOutbound($path, $options, $request, $bubbleable_metadata); @@ -132,7 +132,7 @@ protected function getOutbound() { * The processor type to sort, e.g. 'inboundProcessors'. */ protected function sortProcessors($type) { - $sorted = array(); + $sorted = []; krsort($this->{$type}); foreach ($this->{$type} as $processors) { diff --git a/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php b/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php index e76e27f..17f889e 100644 --- a/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php +++ b/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php @@ -29,7 +29,7 @@ class PhpStorageFactory { * An instantiated storage for the specified name. */ static function get($name) { - $configuration = array(); + $configuration = []; $overrides = Settings::get('php_storage'); if (isset($overrides[$name])) { $configuration = $overrides[$name]; diff --git a/core/lib/Drupal/Core/Plugin/CachedDiscoveryClearer.php b/core/lib/Drupal/Core/Plugin/CachedDiscoveryClearer.php index 3689df5..80c0ada 100644 --- a/core/lib/Drupal/Core/Plugin/CachedDiscoveryClearer.php +++ b/core/lib/Drupal/Core/Plugin/CachedDiscoveryClearer.php @@ -14,7 +14,7 @@ class CachedDiscoveryClearer implements CachedDiscoveryClearerInterface { * * @var \Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface[] */ - protected $cachedDiscoveries = array(); + protected $cachedDiscoveries = []; /** * {@inheritdoc} diff --git a/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php b/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php index 1426562..52d153c 100644 --- a/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php +++ b/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php @@ -105,7 +105,7 @@ public function getSortedDefinitions(array $definitions = NULL, $label_key = 'la public function getGroupedDefinitions(array $definitions = NULL, $label_key = 'label') { /** @var \Drupal\Core\Plugin\CategorizingPluginManagerTrait|\Drupal\Component\Plugin\PluginManagerInterface $this */ $definitions = $this->getSortedDefinitions(isset($definitions) ? $definitions : $this->getDefinitions(), $label_key); - $grouped_definitions = array(); + $grouped_definitions = []; foreach ($definitions as $id => $definition) { $grouped_definitions[(string) $definition['category']][$id] = $definition; } diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerInterface.php b/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerInterface.php index a53de3f..5c29411 100644 --- a/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerInterface.php +++ b/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerInterface.php @@ -21,6 +21,6 @@ * @return array * An array of plugin definitions. */ - public function getDefinitionsForContexts(array $contexts = array()); + public function getDefinitionsForContexts(array $contexts = []); } diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerTrait.php b/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerTrait.php index fadaebd..afe2aa5 100644 --- a/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerTrait.php +++ b/core/lib/Drupal/Core/Plugin/Context/ContextAwarePluginManagerTrait.php @@ -19,7 +19,7 @@ protected function contextHandler() { /** * See \Drupal\Core\Plugin\Context\ContextAwarePluginManagerInterface::getDefinitionsForContexts(). */ - public function getDefinitionsForContexts(array $contexts = array()) { + public function getDefinitionsForContexts(array $contexts = []) { return $this->contextHandler()->filterPluginDefinitionsByContexts($contexts, $this->getDefinitions()); } diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php index 50d8db6..2a13d36 100644 --- a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php +++ b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php @@ -66,7 +66,7 @@ public function getMatchingContexts(array $contexts, ContextDefinitionInterface /** * {@inheritdoc} */ - public function applyContextMapping(ContextAwarePluginInterface $plugin, $contexts, $mappings = array()) { + public function applyContextMapping(ContextAwarePluginInterface $plugin, $contexts, $mappings = []) { /** @var $contexts \Drupal\Core\Plugin\Context\ContextInterface[] */ $mappings += $plugin->getContextMapping(); // Loop through each of the expected contexts. diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php b/core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php index 2a219e9..a0d5703 100644 --- a/core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php +++ b/core/lib/Drupal/Core/Plugin/Context/ContextHandlerInterface.php @@ -75,6 +75,6 @@ public function getMatchingContexts(array $contexts, ContextDefinitionInterface * @throws \Drupal\Component\Plugin\Exception\ContextException * Thrown when a context assignment was not satisfied. */ - public function applyContextMapping(ContextAwarePluginInterface $plugin, $contexts, $mappings = array()); + public function applyContextMapping(ContextAwarePluginInterface $plugin, $contexts, $mappings = []); } diff --git a/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php b/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php index a5ef4cf..31ff649 100644 --- a/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php +++ b/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php @@ -12,7 +12,7 @@ * * @see \Drupal\Core\StringTranslation\StringTranslationTrait */ - abstract protected function t($string, array $args = array(), array $options = array()); + abstract protected function t($string, array $args = [], array $options = []); /** * Wraps the context handler. diff --git a/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php b/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php index 1928bfb..3c48892 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php +++ b/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php @@ -33,7 +33,7 @@ class DefaultLazyPluginCollection extends LazyPluginCollection { * An associative array containing the initial configuration for each plugin * in the collection, keyed by plugin instance ID. */ - protected $configurations = array(); + protected $configurations = []; /** * The key within the plugin configuration that contains the plugin ID. @@ -47,7 +47,7 @@ class DefaultLazyPluginCollection extends LazyPluginCollection { * * @var array */ - protected $originalOrder = array(); + protected $originalOrder = []; /** * Constructs a new DefaultLazyPluginCollection object. @@ -58,7 +58,7 @@ class DefaultLazyPluginCollection extends LazyPluginCollection { * (optional) An associative array containing the initial configuration for * each plugin in the collection, keyed by plugin instance ID. */ - public function __construct(PluginManagerInterface $manager, array $configurations = array()) { + public function __construct(PluginManagerInterface $manager, array $configurations = []) { $this->manager = $manager; $this->configurations = $configurations; @@ -74,7 +74,7 @@ public function __construct(PluginManagerInterface $manager, array $configuratio * {@inheritdoc} */ protected function initializePlugin($instance_id) { - $configuration = isset($this->configurations[$instance_id]) ? $this->configurations[$instance_id] : array(); + $configuration = isset($this->configurations[$instance_id]) ? $this->configurations[$instance_id] : []; if (!isset($configuration[$this->pluginKey])) { throw new PluginNotFoundException($instance_id); } @@ -87,7 +87,7 @@ protected function initializePlugin($instance_id) { * @return $this */ public function sort() { - uasort($this->instanceIDs, array($this, 'sortHelper')); + uasort($this->instanceIDs, [$this, 'sortHelper']); return $this; } @@ -104,7 +104,7 @@ public function sortHelper($aID, $bID) { * {@inheritdoc} */ public function getConfiguration() { - $instances = array(); + $instances = []; // Store the current order of the instances. $current_order = $this->instanceIDs; // Reorder the instances to match the original order, adding new instances diff --git a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php index fa706a4..99133ab 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -148,7 +148,7 @@ public function __construct($subdir, \Traversable $namespaces, ModuleHandlerInte * clearCachedDefinitions() method. Only use cache tags when cached plugin * definitions should be cleared along with other, related cache entries. */ - public function setCacheBackend(CacheBackendInterface $cache_backend, $cache_key, array $cache_tags = array()) { + public function setCacheBackend(CacheBackendInterface $cache_backend, $cache_key, array $cache_tags = []) { assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($cache_tags)', 'Cache Tags must be strings.'); $this->cacheBackend = $cache_backend; $this->cacheKey = $cache_key; @@ -296,7 +296,7 @@ protected function findDefinitions() { if (is_object($plugin_definition) && !($plugin_definition = (array) $plugin_definition)) { continue; } - if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array('core', 'component')) && !$this->providerExists($plugin_definition['provider'])) { + if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], ['core', 'component']) && !$this->providerExists($plugin_definition['provider'])) { unset($definitions[$plugin_id]); } } diff --git a/core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php b/core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php index bbcb0f2..519e93d 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php +++ b/core/lib/Drupal/Core/Plugin/DefaultSingleLazyPluginCollection.php @@ -54,7 +54,7 @@ public function __construct(PluginManagerInterface $manager, $instance_id, array $this->manager = $manager; $this->instanceId = $instance_id; // This is still needed by the parent LazyPluginCollection class. - $this->instanceIDs = array($instance_id => $instance_id); + $this->instanceIDs = [$instance_id => $instance_id]; $this->configuration = $configuration; } diff --git a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php index 770308d..bbcc858 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/AnnotatedClassDiscovery.php @@ -61,7 +61,7 @@ function __construct($subdir, \Traversable $root_namespaces, $plugin_definition_ $this->namespaceSuffix = str_replace('/', '\\', $subdir); } $this->rootNamespacesIterator = $root_namespaces; - $plugin_namespaces = array(); + $plugin_namespaces = []; parent::__construct($plugin_namespaces, $plugin_definition_annotation_name, $annotation_namespaces); } @@ -113,7 +113,7 @@ protected function getProviderFromNamespace($namespace) { * {@inheritdoc} */ protected function getPluginNamespaces() { - $plugin_namespaces = array(); + $plugin_namespaces = []; if ($this->namespaceSuffix) { foreach ($this->rootNamespacesIterator as $namespace => $dirs) { // Append the namespace suffix to the base namespace, to obtain the diff --git a/core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php index 24f5cae..e366bcb 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/HookDiscovery.php @@ -45,7 +45,7 @@ function __construct(ModuleHandlerInterface $module_handler, $hook) { * {@inheritdoc} */ public function getDefinitions() { - $definitions = array(); + $definitions = []; foreach ($this->moduleHandler->getImplementations($this->hook) as $module) { $result = $this->moduleHandler->invoke($module, $this->hook); foreach ($result as $plugin_id => $definition) { diff --git a/core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php index af250d9..6501ce0 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/InfoHookDecorator.php @@ -55,7 +55,7 @@ public function getDefinitions() { * Passes through all unknown calls onto the decorated object. */ public function __call($method, $args) { - return call_user_func_array(array($this->decorated, $method), $args); + return call_user_func_array([$this->decorated, $method], $args); } } diff --git a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php index c149c10..af5630c 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php @@ -75,7 +75,7 @@ public function getDefinitions() { $plugins = $this->discovery->findAll(); // Flatten definitions into what's expected from plugins. - $definitions = array(); + $definitions = []; foreach ($plugins as $provider => $list) { foreach ($list as $id => $definition) { // Add TranslatableMarkup. @@ -92,10 +92,10 @@ public function getDefinitions() { } } // Add ID and provider. - $definitions[$id] = $definition + array( + $definitions[$id] = $definition + [ 'provider' => $provider, 'id' => $id, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php index a061f4b..e415c5b 100644 --- a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php +++ b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php @@ -47,7 +47,7 @@ public function getDefinitions() { * Passes through all unknown calls onto the decorated object. */ public function __call($method, $args) { - return call_user_func_array(array($this->decorated, $method), $args); + return call_user_func_array([$this->decorated, $method], $args); } } diff --git a/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php b/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php index 7658b42..7aefa59 100644 --- a/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php +++ b/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php @@ -12,7 +12,7 @@ class ContainerFactory extends DefaultFactory { /** * {@inheritdoc} */ - public function createInstance($plugin_id, array $configuration = array()) { + public function createInstance($plugin_id, array $configuration = []) { $plugin_definition = $this->discovery->getDefinition($plugin_id); $plugin_class = static::getPluginClass($plugin_id, $plugin_definition, $this->interface); diff --git a/core/lib/Drupal/Core/Plugin/PluginManagerPass.php b/core/lib/Drupal/Core/Plugin/PluginManagerPass.php index dcacf7b..9d4a483 100644 --- a/core/lib/Drupal/Core/Plugin/PluginManagerPass.php +++ b/core/lib/Drupal/Core/Plugin/PluginManagerPass.php @@ -19,7 +19,7 @@ public function process(ContainerBuilder $container) { foreach ($container->getDefinitions() as $service_id => $definition) { if (strpos($service_id, 'plugin.manager.') === 0 || $definition->hasTag('plugin_manager_cache_clear')) { if (is_subclass_of($definition->getClass(), '\Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface')) { - $cache_clearer_definition->addMethodCall('addCachedDiscovery', array(new Reference($service_id))); + $cache_clearer_definition->addMethodCall('addCachedDiscovery', [new Reference($service_id)]); } } } diff --git a/core/lib/Drupal/Core/Queue/Batch.php b/core/lib/Drupal/Core/Queue/Batch.php index a7827a9..1be96d8 100644 --- a/core/lib/Drupal/Core/Queue/Batch.php +++ b/core/lib/Drupal/Core/Queue/Batch.php @@ -26,7 +26,7 @@ class Batch extends DatabaseQueue { */ public function claimItem($lease_time = 0) { try { - $item = $this->connection->queryRange('SELECT data, item_id FROM {queue} q WHERE name = :name ORDER BY item_id ASC', 0, 1, array(':name' => $this->name))->fetchObject(); + $item = $this->connection->queryRange('SELECT data, item_id FROM {queue} q WHERE name = :name ORDER BY item_id ASC', 0, 1, [':name' => $this->name])->fetchObject(); if ($item) { $item->data = unserialize($item->data); return $item; @@ -48,9 +48,9 @@ public function claimItem($lease_time = 0) { * An array of queue items. */ public function getAllItems() { - $result = array(); + $result = []; try { - $items = $this->connection->query('SELECT data FROM {queue} q WHERE name = :name ORDER BY item_id ASC', array(':name' => $this->name))->fetchAll(); + $items = $this->connection->query('SELECT data FROM {queue} q WHERE name = :name ORDER BY item_id ASC', [':name' => $this->name])->fetchAll(); foreach ($items as $item) { $result[] = unserialize($item->data); } diff --git a/core/lib/Drupal/Core/Queue/BatchMemory.php b/core/lib/Drupal/Core/Queue/BatchMemory.php index 8245308..bf4ba55 100644 --- a/core/lib/Drupal/Core/Queue/BatchMemory.php +++ b/core/lib/Drupal/Core/Queue/BatchMemory.php @@ -40,7 +40,7 @@ public function claimItem($lease_time = 0) { * An array of queue items. */ public function getAllItems() { - $result = array(); + $result = []; foreach ($this->queue as $item) { $result[] = $item->data; } diff --git a/core/lib/Drupal/Core/Queue/DatabaseQueue.php b/core/lib/Drupal/Core/Queue/DatabaseQueue.php index eaa6757..710a99b 100644 --- a/core/lib/Drupal/Core/Queue/DatabaseQueue.php +++ b/core/lib/Drupal/Core/Queue/DatabaseQueue.php @@ -84,13 +84,13 @@ public function createItem($data) { */ protected function doCreateItem($data) { $query = $this->connection->insert(static::TABLE_NAME) - ->fields(array( + ->fields([ 'name' => $this->name, 'data' => serialize($data), // We cannot rely on REQUEST_TIME because many items might be created // by a single request which takes longer than 1 second. 'created' => time(), - )); + ]); // Return the new serial ID, or FALSE on failure. return $query->execute(); } @@ -100,7 +100,7 @@ protected function doCreateItem($data) { */ public function numberOfItems() { try { - return $this->connection->query('SELECT COUNT(item_id) FROM {' . static::TABLE_NAME . '} WHERE name = :name', array(':name' => $this->name)) + return $this->connection->query('SELECT COUNT(item_id) FROM {' . static::TABLE_NAME . '} WHERE name = :name', [':name' => $this->name]) ->fetchField(); } catch (\Exception $e) { @@ -120,7 +120,7 @@ public function claimItem($lease_time = 30) { // are no unclaimed items left. while (TRUE) { try { - $item = $this->connection->queryRange('SELECT data, created, item_id FROM {' . static::TABLE_NAME . '} q WHERE expire = 0 AND name = :name ORDER BY created, item_id ASC', 0, 1, array(':name' => $this->name))->fetchObject(); + $item = $this->connection->queryRange('SELECT data, created, item_id FROM {' . static::TABLE_NAME . '} q WHERE expire = 0 AND name = :name ORDER BY created, item_id ASC', 0, 1, [':name' => $this->name])->fetchObject(); } catch (\Exception $e) { $this->catchException($e); @@ -136,9 +136,9 @@ public function claimItem($lease_time = 30) { // time from the lease, and will tend to reset items before the lease // should really expire. $update = $this->connection->update(static::TABLE_NAME) - ->fields(array( + ->fields([ 'expire' => time() + $lease_time, - )) + ]) ->condition('item_id', $item->item_id) ->condition('expire', 0); // If there are affected rows, this update succeeded. @@ -160,9 +160,9 @@ public function claimItem($lease_time = 30) { public function releaseItem($item) { try { $update = $this->connection->update(static::TABLE_NAME) - ->fields(array( + ->fields([ 'expire' => 0, - )) + ]) ->condition('item_id', $item->item_id); return $update->execute(); } @@ -223,9 +223,9 @@ public function garbageCollection() { // Reset expired items in the default queue implementation table. If that's // not used, this will simply be a no-op. $this->connection->update(static::TABLE_NAME) - ->fields(array( + ->fields([ 'expire' => 0, - )) + ]) ->condition('expire', 0, '<>') ->condition('expire', REQUEST_TIME, '<') ->execute(); diff --git a/core/lib/Drupal/Core/Queue/Memory.php b/core/lib/Drupal/Core/Queue/Memory.php index b921d2c..2e4ac0f 100644 --- a/core/lib/Drupal/Core/Queue/Memory.php +++ b/core/lib/Drupal/Core/Queue/Memory.php @@ -33,7 +33,7 @@ class Memory implements QueueInterface { * An arbitrary string. The name of the queue to work with. */ public function __construct($name) { - $this->queue = array(); + $this->queue = []; $this->idSequence = 0; } @@ -100,7 +100,7 @@ public function createQueue() { * {@inheritdoc} */ public function deleteQueue() { - $this->queue = array(); + $this->queue = []; $this->idSequence = 0; } diff --git a/core/lib/Drupal/Core/Queue/QueueFactory.php b/core/lib/Drupal/Core/Queue/QueueFactory.php index db493d9..74126ef 100644 --- a/core/lib/Drupal/Core/Queue/QueueFactory.php +++ b/core/lib/Drupal/Core/Queue/QueueFactory.php @@ -18,7 +18,7 @@ class QueueFactory implements ContainerAwareInterface { * * @var array */ - protected $queues = array(); + protected $queues = []; /** * The settings object. diff --git a/core/lib/Drupal/Core/Render/BubbleableMetadata.php b/core/lib/Drupal/Core/Render/BubbleableMetadata.php index d1e43c9..33aa755 100644 --- a/core/lib/Drupal/Core/Render/BubbleableMetadata.php +++ b/core/lib/Drupal/Core/Render/BubbleableMetadata.php @@ -149,7 +149,7 @@ public static function mergeAttachments(array $a, array $b) { // correctly; adding the same settings multiple times needs to behave // idempotently. if (!empty($a['drupalSettings']) && !empty($b['drupalSettings'])) { - $drupalSettings = NestedArray::mergeDeepArray(array($a['drupalSettings'], $b['drupalSettings']), TRUE); + $drupalSettings = NestedArray::mergeDeepArray([$a['drupalSettings'], $b['drupalSettings']], TRUE); // No need for re-merging them. unset($a['drupalSettings']); unset($b['drupalSettings']); diff --git a/core/lib/Drupal/Core/Render/Element.php b/core/lib/Drupal/Core/Render/Element.php index c150519..e394a39 100644 --- a/core/lib/Drupal/Core/Render/Element.php +++ b/core/lib/Drupal/Core/Render/Element.php @@ -74,7 +74,7 @@ public static function children(array &$elements, $sort = FALSE) { // Filter out properties from the element, leaving only children. $count = count($elements); - $child_weights = array(); + $child_weights = []; $i = 0; $sortable = FALSE; foreach ($elements as $key => $value) { @@ -94,7 +94,7 @@ public static function children(array &$elements, $sort = FALSE) { // Only trigger an error if the value is not null. // @see https://www.drupal.org/node/1283892 elseif (isset($value)) { - trigger_error(SafeMarkup::format('"@key" is an invalid render array key', array('@key' => $key)), E_USER_ERROR); + trigger_error(SafeMarkup::format('"@key" is an invalid render array key', ['@key' => $key]), E_USER_ERROR); } } $i++; @@ -127,7 +127,7 @@ public static function children(array &$elements, $sort = FALSE) { * The array keys of the element's visible children. */ public static function getVisibleChildren(array $elements) { - $visible_children = array(); + $visible_children = []; foreach (static::children($elements) as $key) { $child = $elements[$key]; diff --git a/core/lib/Drupal/Core/Render/Element/Actions.php b/core/lib/Drupal/Core/Render/Element/Actions.php index 1f94466..ad85401 100644 --- a/core/lib/Drupal/Core/Render/Element/Actions.php +++ b/core/lib/Drupal/Core/Render/Element/Actions.php @@ -30,16 +30,16 @@ class Actions extends Container { */ public function getInfo() { $class = get_class($this); - return array( - '#process' => array( + return [ + '#process' => [ // @todo Move this to #pre_render. - array($class, 'preRenderActionsDropbutton'), - array($class, 'processActions'), - array($class, 'processContainer'), - ), + [$class, 'preRenderActionsDropbutton'], + [$class, 'processActions'], + [$class, 'processContainer'], + ], '#weight' => 100, - '#theme_wrappers' => array('container'), - ); + '#theme_wrappers' => ['container'], + ]; } /** @@ -86,23 +86,23 @@ public static function processActions(&$element, FormStateInterface $form_state, * into new #type 'dropbutton' elements. */ public static function preRenderActionsDropbutton(&$element, FormStateInterface $form_state, &$complete_form) { - $dropbuttons = array(); + $dropbuttons = []; foreach (Element::children($element, TRUE) as $key) { if (isset($element[$key]['#dropbutton'])) { $dropbutton = $element[$key]['#dropbutton']; // If there is no dropbutton for this button group yet, create one. if (!isset($dropbuttons[$dropbutton])) { - $dropbuttons[$dropbutton] = array( + $dropbuttons[$dropbutton] = [ '#type' => 'dropbutton', - ); + ]; } // Add this button to the corresponding dropbutton. // @todo Change #type 'dropbutton' to be based on item-list.html.twig // instead of links.html.twig to avoid this preemptive rendering. $button = \Drupal::service('renderer')->renderPlain($element[$key]); - $dropbuttons[$dropbutton]['#links'][$key] = array( + $dropbuttons[$dropbutton]['#links'][$key] = [ 'title' => $button, - ); + ]; } } // @todo For now, all dropbuttons appear first. Consider to invent a more diff --git a/core/lib/Drupal/Core/Render/Element/Ajax.php b/core/lib/Drupal/Core/Render/Element/Ajax.php index 672e4ca..d22d7ed 100644 --- a/core/lib/Drupal/Core/Render/Element/Ajax.php +++ b/core/lib/Drupal/Core/Render/Element/Ajax.php @@ -21,11 +21,11 @@ public function getInfo() { // an HTML page, so we don't provide defaults for #theme or #theme_wrappers. // However, modules can set these properties (for example, to provide an // HTML debugging page that displays rather than executes Ajax commands). - return array( + return [ '#header' => TRUE, - '#commands' => array(), + '#commands' => [], '#error' => NULL, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Render/Element/Button.php b/core/lib/Drupal/Core/Render/Element/Button.php index c5b84f0..63451ea 100644 --- a/core/lib/Drupal/Core/Render/Element/Button.php +++ b/core/lib/Drupal/Core/Render/Element/Button.php @@ -37,21 +37,21 @@ class Button extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#name' => 'op', '#is_button' => TRUE, '#executes_submit_callback' => FALSE, '#limit_validation_errors' => FALSE, - '#process' => array( - array($class, 'processButton'), - array($class, 'processAjaxForm'), - ), - '#pre_render' => array( - array($class, 'preRenderButton'), - ), - '#theme_wrappers' => array('input__submit'), - ); + '#process' => [ + [$class, 'processButton'], + [$class, 'processAjaxForm'], + ], + '#pre_render' => [ + [$class, 'preRenderButton'], + ], + '#theme_wrappers' => ['input__submit'], + ]; } /** @@ -81,7 +81,7 @@ public static function processButton(&$element, FormStateInterface $form_state, */ public static function preRenderButton($element) { $element['#attributes']['type'] = 'submit'; - Element::setAttributes($element, array('id', 'name', 'value')); + Element::setAttributes($element, ['id', 'name', 'value']); $element['#attributes']['class'][] = 'button'; if (!empty($element['#button_type'])) { diff --git a/core/lib/Drupal/Core/Render/Element/Checkbox.php b/core/lib/Drupal/Core/Render/Element/Checkbox.php index c9b8817..9092314 100644 --- a/core/lib/Drupal/Core/Render/Element/Checkbox.php +++ b/core/lib/Drupal/Core/Render/Element/Checkbox.php @@ -30,22 +30,22 @@ class Checkbox extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#return_value' => 1, - '#process' => array( - array($class, 'processCheckbox'), - array($class, 'processAjaxForm'), - array($class, 'processGroup'), - ), - '#pre_render' => array( - array($class, 'preRenderCheckbox'), - array($class, 'preRenderGroup'), - ), + '#process' => [ + [$class, 'processCheckbox'], + [$class, 'processAjaxForm'], + [$class, 'processGroup'], + ], + '#pre_render' => [ + [$class, 'preRenderCheckbox'], + [$class, 'preRenderGroup'], + ], '#theme' => 'input__checkbox', - '#theme_wrappers' => array('form_element'), + '#theme_wrappers' => ['form_element'], '#title_display' => 'after', - ); + ]; } /** @@ -93,13 +93,13 @@ public static function valueCallback(&$element, $input, FormStateInterface $form */ public static function preRenderCheckbox($element) { $element['#attributes']['type'] = 'checkbox'; - Element::setAttributes($element, array('id', 'name', '#return_value' => 'value')); + Element::setAttributes($element, ['id', 'name', '#return_value' => 'value']); // Unchecked checkbox has #value of integer 0. if (!empty($element['#checked'])) { $element['#attributes']['checked'] = 'checked'; } - static::setAttributes($element, array('form-checkbox')); + static::setAttributes($element, ['form-checkbox']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Checkboxes.php b/core/lib/Drupal/Core/Render/Element/Checkboxes.php index 78108b5..3663cd5 100644 --- a/core/lib/Drupal/Core/Render/Element/Checkboxes.php +++ b/core/lib/Drupal/Core/Render/Element/Checkboxes.php @@ -37,27 +37,27 @@ class Checkboxes extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, - '#process' => array( - array($class, 'processCheckboxes'), - ), - '#pre_render' => array( - array($class, 'preRenderCompositeFormElement'), - ), - '#theme_wrappers' => array('checkboxes'), - ); + '#process' => [ + [$class, 'processCheckboxes'], + ], + '#pre_render' => [ + [$class, 'preRenderCompositeFormElement'], + ], + '#theme_wrappers' => ['checkboxes'], + ]; } /** * Processes a checkboxes form element. */ public static function processCheckboxes(&$element, FormStateInterface $form_state, &$complete_form) { - $value = is_array($element['#value']) ? $element['#value'] : array(); + $value = is_array($element['#value']) ? $element['#value'] : []; $element['#tree'] = TRUE; if (count($element['#options']) > 0) { if (!isset($element['#default_value']) || $element['#default_value'] == 0) { - $element['#default_value'] = array(); + $element['#default_value'] = []; } $weight = 0; foreach ($element['#options'] as $key => $choice) { @@ -73,8 +73,8 @@ public static function processCheckboxes(&$element, FormStateInterface $form_sta // sub-elements. $weight += 0.001; - $element += array($key => array()); - $element[$key] += array( + $element += [$key => []]; + $element[$key] += [ '#type' => 'checkbox', '#title' => $choice, '#return_value' => $key, @@ -84,7 +84,7 @@ public static function processCheckboxes(&$element, FormStateInterface $form_sta // Errors should only be shown on the parent checkboxes element. '#error_no_message' => TRUE, '#weight' => $weight, - ); + ]; } } return $element; @@ -95,8 +95,8 @@ public static function processCheckboxes(&$element, FormStateInterface $form_sta */ public static function valueCallback(&$element, $input, FormStateInterface $form_state) { if ($input === FALSE) { - $value = array(); - $element += array('#default_value' => array()); + $value = []; + $element += ['#default_value' => []]; foreach ($element['#default_value'] as $key) { $value[$key] = $key; } @@ -118,7 +118,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form return array_combine($input, $input); } else { - return array(); + return []; } } diff --git a/core/lib/Drupal/Core/Render/Element/Color.php b/core/lib/Drupal/Core/Render/Element/Color.php index 0f0228c..716a076 100644 --- a/core/lib/Drupal/Core/Render/Element/Color.php +++ b/core/lib/Drupal/Core/Render/Element/Color.php @@ -30,20 +30,20 @@ class Color extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, - '#process' => array( - array($class, 'processAjaxForm'), - ), - '#element_validate' => array( - array($class, 'validateColor'), - ), - '#pre_render' => array( - array($class, 'preRenderColor'), - ), + '#process' => [ + [$class, 'processAjaxForm'], + ], + '#element_validate' => [ + [$class, 'validateColor'], + ], + '#pre_render' => [ + [$class, 'preRenderColor'], + ], '#theme' => 'input__color', - '#theme_wrappers' => array('form_element'), - ); + '#theme_wrappers' => ['form_element'], + ]; } /** @@ -63,7 +63,7 @@ public static function validateColor(&$element, FormStateInterface $form_state, $form_state->setValueForElement($element, ColorUtility::rgbToHex(ColorUtility::hexToRgb($value))); } catch (\InvalidArgumentException $e) { - $form_state->setError($element, t('%name must be a valid color.', array('%name' => empty($element['#title']) ? $element['#parents'][0] : $element['#title']))); + $form_state->setError($element, t('%name must be a valid color.', ['%name' => empty($element['#title']) ? $element['#parents'][0] : $element['#title']])); } } } @@ -80,8 +80,8 @@ public static function validateColor(&$element, FormStateInterface $form_state, */ public static function preRenderColor($element) { $element['#attributes']['type'] = 'color'; - Element::setAttributes($element, array('id', 'name', 'value')); - static::setAttributes($element, array('form-color')); + Element::setAttributes($element, ['id', 'name', 'value']); + static::setAttributes($element, ['form-color']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Container.php b/core/lib/Drupal/Core/Render/Element/Container.php index eb46f20..212000d 100644 --- a/core/lib/Drupal/Core/Render/Element/Container.php +++ b/core/lib/Drupal/Core/Render/Element/Container.php @@ -45,16 +45,16 @@ class Container extends RenderElement { */ public function getInfo() { $class = get_class($this); - return array( - '#process' => array( - array($class, 'processGroup'), - array($class, 'processContainer'), - ), - '#pre_render' => array( - array($class, 'preRenderGroup'), - ), - '#theme_wrappers' => array('container'), - ); + return [ + '#process' => [ + [$class, 'processGroup'], + [$class, 'processContainer'], + ], + '#pre_render' => [ + [$class, 'preRenderGroup'], + ], + '#theme_wrappers' => ['container'], + ]; } /** diff --git a/core/lib/Drupal/Core/Render/Element/Date.php b/core/lib/Drupal/Core/Render/Element/Date.php index dcee062..9a78ad5 100644 --- a/core/lib/Drupal/Core/Render/Element/Date.php +++ b/core/lib/Drupal/Core/Render/Element/Date.php @@ -87,8 +87,8 @@ public static function preRenderDate($element) { if (empty($element['#attributes']['type'])) { $element['#attributes']['type'] = 'date'; } - Element::setAttributes($element, array('id', 'name', 'type', 'min', 'max', 'step', 'value', 'size')); - static::setAttributes($element, array('form-' . $element['#attributes']['type'])); + Element::setAttributes($element, ['id', 'name', 'type', 'min', 'max', 'step', 'value', 'size']); + static::setAttributes($element, ['form-' . $element['#attributes']['type']]); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Details.php b/core/lib/Drupal/Core/Render/Element/Details.php index ae25d34..f9b1fc7 100644 --- a/core/lib/Drupal/Core/Render/Element/Details.php +++ b/core/lib/Drupal/Core/Render/Element/Details.php @@ -41,19 +41,19 @@ class Details extends RenderElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#open' => FALSE, '#value' => NULL, - '#process' => array( - array($class, 'processGroup'), - array($class, 'processAjaxForm'), - ), - '#pre_render' => array( - array($class, 'preRenderDetails'), - array($class, 'preRenderGroup'), - ), - '#theme_wrappers' => array('details'), - ); + '#process' => [ + [$class, 'processGroup'], + [$class, 'processAjaxForm'], + ], + '#pre_render' => [ + [$class, 'preRenderDetails'], + [$class, 'preRenderGroup'], + ], + '#theme_wrappers' => ['details'], + ]; } /** @@ -67,11 +67,11 @@ public function getInfo() { * The modified element. */ public static function preRenderDetails($element) { - Element::setAttributes($element, array('id')); + Element::setAttributes($element, ['id']); // The .js-form-wrapper class is required for #states to treat details like // containers. - static::setAttributes($element, array('js-form-wrapper', 'form-wrapper')); + static::setAttributes($element, ['js-form-wrapper', 'form-wrapper']); // Collapsible details. $element['#attached']['library'][] = 'core/drupal.collapse'; diff --git a/core/lib/Drupal/Core/Render/Element/Dropbutton.php b/core/lib/Drupal/Core/Render/Element/Dropbutton.php index 30f9755..682f5cc 100644 --- a/core/lib/Drupal/Core/Render/Element/Dropbutton.php +++ b/core/lib/Drupal/Core/Render/Element/Dropbutton.php @@ -46,12 +46,12 @@ class Dropbutton extends RenderElement { */ public function getInfo() { $class = get_class($this); - return array( - '#pre_render' => array( - array($class, 'preRenderDropbutton'), - ), + return [ + '#pre_render' => [ + [$class, 'preRenderDropbutton'], + ], '#theme' => 'links__dropbutton', - ); + ]; } /** @@ -61,7 +61,7 @@ public static function preRenderDropbutton($element) { $element['#attached']['library'][] = 'core/drupal.dropbutton'; $element['#attributes']['class'][] = 'dropbutton'; if (!isset($element['#theme_wrappers'])) { - $element['#theme_wrappers'] = array(); + $element['#theme_wrappers'] = []; } array_unshift($element['#theme_wrappers'], 'dropbutton_wrapper'); diff --git a/core/lib/Drupal/Core/Render/Element/ElementInterface.php b/core/lib/Drupal/Core/Render/Element/ElementInterface.php index 320a83d..12cb67d 100644 --- a/core/lib/Drupal/Core/Render/Element/ElementInterface.php +++ b/core/lib/Drupal/Core/Render/Element/ElementInterface.php @@ -47,6 +47,6 @@ public function getInfo(); * @param array $class * Array of new class names to be added. */ - public static function setAttributes(&$element, $class = array()); + public static function setAttributes(&$element, $class = []); } diff --git a/core/lib/Drupal/Core/Render/Element/Email.php b/core/lib/Drupal/Core/Render/Element/Email.php index 4b4da7b..283c577 100644 --- a/core/lib/Drupal/Core/Render/Element/Email.php +++ b/core/lib/Drupal/Core/Render/Element/Email.php @@ -42,25 +42,25 @@ class Email extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#size' => 60, '#maxlength' => self::EMAIL_MAX_LENGTH, '#autocomplete_route_name' => FALSE, - '#process' => array( - array($class, 'processAutocomplete'), - array($class, 'processAjaxForm'), - array($class, 'processPattern'), - ), - '#element_validate' => array( - array($class, 'validateEmail'), - ), - '#pre_render' => array( - array($class, 'preRenderEmail'), - ), + '#process' => [ + [$class, 'processAutocomplete'], + [$class, 'processAjaxForm'], + [$class, 'processPattern'], + ], + '#element_validate' => [ + [$class, 'validateEmail'], + ], + '#pre_render' => [ + [$class, 'preRenderEmail'], + ], '#theme' => 'input__email', - '#theme_wrappers' => array('form_element'), - ); + '#theme_wrappers' => ['form_element'], + ]; } /** @@ -73,7 +73,7 @@ public static function validateEmail(&$element, FormStateInterface $form_state, $form_state->setValueForElement($element, $value); if ($value !== '' && !\Drupal::service('email.validator')->isValid($value)) { - $form_state->setError($element, t('The email address %mail is not valid.', array('%mail' => $value))); + $form_state->setError($element, t('The email address %mail is not valid.', ['%mail' => $value])); } } @@ -90,8 +90,8 @@ public static function validateEmail(&$element, FormStateInterface $form_state, */ public static function preRenderEmail($element) { $element['#attributes']['type'] = 'email'; - Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder')); - static::setAttributes($element, array('form-email')); + Element::setAttributes($element, ['id', 'name', 'value', 'size', 'maxlength', 'placeholder']); + static::setAttributes($element, ['form-email']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Fieldgroup.php b/core/lib/Drupal/Core/Render/Element/Fieldgroup.php index a1bc1ee..6c73c35 100644 --- a/core/lib/Drupal/Core/Render/Element/Fieldgroup.php +++ b/core/lib/Drupal/Core/Render/Element/Fieldgroup.php @@ -19,9 +19,9 @@ class Fieldgroup extends Fieldset { public function getInfo() { - return array( - '#attributes' => array('class' => array('fieldgroup')), - ) + parent::getInfo(); + return [ + '#attributes' => ['class' => ['fieldgroup']], + ] + parent::getInfo(); } } diff --git a/core/lib/Drupal/Core/Render/Element/Fieldset.php b/core/lib/Drupal/Core/Render/Element/Fieldset.php index d8cb540..baed391 100644 --- a/core/lib/Drupal/Core/Render/Element/Fieldset.php +++ b/core/lib/Drupal/Core/Render/Element/Fieldset.php @@ -30,17 +30,17 @@ class Fieldset extends RenderElement { */ public function getInfo() { $class = get_class($this); - return array( - '#process' => array( - array($class, 'processGroup'), - array($class, 'processAjaxForm'), - ), - '#pre_render' => array( - array($class, 'preRenderGroup'), - ), + return [ + '#process' => [ + [$class, 'processGroup'], + [$class, 'processAjaxForm'], + ], + '#pre_render' => [ + [$class, 'preRenderGroup'], + ], '#value' => NULL, - '#theme_wrappers' => array('fieldset'), - ); + '#theme_wrappers' => ['fieldset'], + ]; } } diff --git a/core/lib/Drupal/Core/Render/Element/File.php b/core/lib/Drupal/Core/Render/Element/File.php index d37d5c7..07bd415 100644 --- a/core/lib/Drupal/Core/Render/Element/File.php +++ b/core/lib/Drupal/Core/Render/Element/File.php @@ -24,19 +24,19 @@ class File extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#multiple' => FALSE, - '#process' => array( - array($class, 'processFile'), - ), + '#process' => [ + [$class, 'processFile'], + ], '#size' => 60, - '#pre_render' => array( - array($class, 'preRenderFile'), - ), + '#pre_render' => [ + [$class, 'preRenderFile'], + ], '#theme' => 'input__file', - '#theme_wrappers' => array('form_element'), - ); + '#theme_wrappers' => ['form_element'], + ]; } /** @@ -44,7 +44,7 @@ public function getInfo() { */ public static function processFile(&$element, FormStateInterface $form_state, &$complete_form) { if ($element['#multiple']) { - $element['#attributes'] = array('multiple' => 'multiple'); + $element['#attributes'] = ['multiple' => 'multiple']; $element['#name'] .= '[]'; } return $element; @@ -66,8 +66,8 @@ public static function processFile(&$element, FormStateInterface $form_state, &$ */ public static function preRenderFile($element) { $element['#attributes']['type'] = 'file'; - Element::setAttributes($element, array('id', 'name', 'size')); - static::setAttributes($element, array('js-form-file', 'form-file')); + Element::setAttributes($element, ['id', 'name', 'size']); + static::setAttributes($element, ['js-form-file', 'form-file']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Form.php b/core/lib/Drupal/Core/Render/Element/Form.php index 61739ca..d81c254 100644 --- a/core/lib/Drupal/Core/Render/Element/Form.php +++ b/core/lib/Drupal/Core/Render/Element/Form.php @@ -13,10 +13,10 @@ class Form extends RenderElement { * {@inheritdoc} */ public function getInfo() { - return array( + return [ '#method' => 'post', - '#theme_wrappers' => array('form'), - ); + '#theme_wrappers' => ['form'], + ]; } } diff --git a/core/lib/Drupal/Core/Render/Element/FormElement.php b/core/lib/Drupal/Core/Render/Element/FormElement.php index 513f103..0168d2b 100644 --- a/core/lib/Drupal/Core/Render/Element/FormElement.php +++ b/core/lib/Drupal/Core/Render/Element/FormElement.php @@ -108,7 +108,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form public static function processPattern(&$element, FormStateInterface $form_state, &$complete_form) { if (isset($element['#pattern']) && !isset($element['#attributes']['pattern'])) { $element['#attributes']['pattern'] = $element['#pattern']; - $element['#element_validate'][] = array(get_called_class(), 'validatePattern'); + $element['#element_validate'][] = [get_called_class(), 'validatePattern']; } return $element; @@ -136,7 +136,7 @@ public static function validatePattern(&$element, FormStateInterface $form_state $pattern = '{^(?:' . $element['#pattern'] . ')$}'; if (!preg_match($pattern, $element['#value'])) { - $form_state->setError($element, t('%name field is not in the right format.', array('%name' => $element['#title']))); + $form_state->setError($element, t('%name field is not in the right format.', ['%name' => $element['#title']])); } } } @@ -178,7 +178,7 @@ public static function processAutocomplete(&$element, FormStateInterface $form_s $access = FALSE; if (!empty($element['#autocomplete_route_name'])) { - $parameters = isset($element['#autocomplete_route_parameters']) ? $element['#autocomplete_route_parameters'] : array(); + $parameters = isset($element['#autocomplete_route_parameters']) ? $element['#autocomplete_route_parameters'] : []; $url = Url::fromRoute($element['#autocomplete_route_name'], $parameters)->toString(TRUE); /** @var \Drupal\Core\Access\AccessManagerInterface $access_manager */ $access_manager = \Drupal::service('access_manager'); diff --git a/core/lib/Drupal/Core/Render/Element/Hidden.php b/core/lib/Drupal/Core/Render/Element/Hidden.php index 8e1f856..6fb62ff 100644 --- a/core/lib/Drupal/Core/Render/Element/Hidden.php +++ b/core/lib/Drupal/Core/Render/Element/Hidden.php @@ -31,16 +31,16 @@ class Hidden extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, - '#process' => array( - array($class, 'processAjaxForm'), - ), - '#pre_render' => array( - array($class, 'preRenderHidden'), - ), + '#process' => [ + [$class, 'processAjaxForm'], + ], + '#pre_render' => [ + [$class, 'preRenderHidden'], + ], '#theme' => 'input__hidden', - ); + ]; } /** @@ -55,7 +55,7 @@ public function getInfo() { */ public static function preRenderHidden($element) { $element['#attributes']['type'] = 'hidden'; - Element::setAttributes($element, array('name', 'value')); + Element::setAttributes($element, ['name', 'value']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Html.php b/core/lib/Drupal/Core/Render/Element/Html.php index 0a83d56..fb79b94 100644 --- a/core/lib/Drupal/Core/Render/Element/Html.php +++ b/core/lib/Drupal/Core/Render/Element/Html.php @@ -13,13 +13,13 @@ class Html extends RenderElement { * {@inheritdoc} */ public function getInfo() { - return array( + return [ '#theme' => 'html', // HTML5 Shiv - '#attached' => array( - 'library' => array('core/html5shiv'), - ), - ); + '#attached' => [ + 'library' => ['core/html5shiv'], + ], + ]; } } diff --git a/core/lib/Drupal/Core/Render/Element/HtmlTag.php b/core/lib/Drupal/Core/Render/Element/HtmlTag.php index 1d71350..0b9ac91 100644 --- a/core/lib/Drupal/Core/Render/Element/HtmlTag.php +++ b/core/lib/Drupal/Core/Render/Element/HtmlTag.php @@ -38,24 +38,24 @@ class HtmlTag extends RenderElement { * @see http://www.w3.org/TR/html5/syntax.html#syntax-start-tag * @see http://www.w3.org/TR/html5/syntax.html#void-elements */ - static protected $voidElements = array( + static protected $voidElements = [ 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr', - ); + ]; /** * {@inheritdoc} */ public function getInfo() { $class = get_class($this); - return array( - '#pre_render' => array( - array($class, 'preRenderConditionalComments'), - array($class, 'preRenderHtmlTag'), - ), - '#attributes' => array(), + return [ + '#pre_render' => [ + [$class, 'preRenderConditionalComments'], + [$class, 'preRenderHtmlTag'], + ], + '#attributes' => [], '#value' => NULL, - ); + ]; } /** @@ -132,11 +132,11 @@ public static function preRenderHtmlTag($element) { * added to '#prefix' and '#suffix'. */ public static function preRenderConditionalComments($element) { - $browsers = isset($element['#browsers']) ? $element['#browsers'] : array(); - $browsers += array( + $browsers = isset($element['#browsers']) ? $element['#browsers'] : []; + $browsers += [ 'IE' => TRUE, '!IE' => TRUE, - ); + ]; // If rendering in all browsers, no need for conditional comments. if ($browsers['IE'] === TRUE && $browsers['!IE']) { diff --git a/core/lib/Drupal/Core/Render/Element/ImageButton.php b/core/lib/Drupal/Core/Render/Element/ImageButton.php index a7d8be3..2404ba8 100644 --- a/core/lib/Drupal/Core/Render/Element/ImageButton.php +++ b/core/lib/Drupal/Core/Render/Element/ImageButton.php @@ -19,12 +19,12 @@ public function getInfo() { $info = parent::getInfo(); unset($info['name']); - return array( + return [ '#return_value' => TRUE, '#has_garbage_value' => TRUE, '#src' => NULL, - '#theme_wrappers' => array('input__image_button'), - ) + $info; + '#theme_wrappers' => ['input__image_button'], + ] + $info; } /** @@ -68,7 +68,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form */ public static function preRenderButton($element) { $element['#attributes']['type'] = 'image'; - Element::setAttributes($element, array('id', 'name', 'value')); + Element::setAttributes($element, ['id', 'name', 'value']); $element['#attributes']['src'] = file_url_transform_relative(file_create_url($element['#src'])); if (!empty($element['#title'])) { diff --git a/core/lib/Drupal/Core/Render/Element/InlineTemplate.php b/core/lib/Drupal/Core/Render/Element/InlineTemplate.php index 2fbdf43..0005ea2 100644 --- a/core/lib/Drupal/Core/Render/Element/InlineTemplate.php +++ b/core/lib/Drupal/Core/Render/Element/InlineTemplate.php @@ -30,13 +30,13 @@ class InlineTemplate extends RenderElement { */ public function getInfo() { $class = get_class($this); - return array( - '#pre_render' => array( - array($class, 'preRenderInlineTemplate'), - ), + return [ + '#pre_render' => [ + [$class, 'preRenderInlineTemplate'], + ], '#template' => '', - '#context' => array(), - ); + '#context' => [], + ]; } /** diff --git a/core/lib/Drupal/Core/Render/Element/Item.php b/core/lib/Drupal/Core/Render/Element/Item.php index b952da1..6c282b3 100644 --- a/core/lib/Drupal/Core/Render/Element/Item.php +++ b/core/lib/Drupal/Core/Render/Element/Item.php @@ -17,7 +17,7 @@ class Item extends FormElement { * {@inheritdoc} */ public function getInfo() { - return array( + return [ // Forms that show author fields to both anonymous and authenticated users // need to dynamically switch between #type 'textfield' and #type 'item' // to automatically take over the authenticated user's information. @@ -25,8 +25,8 @@ public function getInfo() { // assigned by Form API based on the #default_value or #value properties. '#input' => TRUE, '#markup' => '', - '#theme_wrappers' => array('form_element'), - ); + '#theme_wrappers' => ['form_element'], + ]; } } diff --git a/core/lib/Drupal/Core/Render/Element/Label.php b/core/lib/Drupal/Core/Render/Element/Label.php index 1dbaa70..28eb6a0 100644 --- a/core/lib/Drupal/Core/Render/Element/Label.php +++ b/core/lib/Drupal/Core/Render/Element/Label.php @@ -17,9 +17,9 @@ class Label extends RenderElement { * {@inheritdoc} */ public function getInfo() { - return array( + return [ '#theme' => 'form_element_label', - ); + ]; } } diff --git a/core/lib/Drupal/Core/Render/Element/LanguageSelect.php b/core/lib/Drupal/Core/Render/Element/LanguageSelect.php index 0e6011d..bd0a3c0 100644 --- a/core/lib/Drupal/Core/Render/Element/LanguageSelect.php +++ b/core/lib/Drupal/Core/Render/Element/LanguageSelect.php @@ -21,10 +21,10 @@ class LanguageSelect extends FormElement { * {@inheritdoc} */ public function getInfo() { - return array( + return [ '#input' => TRUE, '#default_value' => LanguageInterface::LANGCODE_NOT_SPECIFIED, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Render/Element/Link.php b/core/lib/Drupal/Core/Render/Element/Link.php index 535d9bb..1e405b6 100644 --- a/core/lib/Drupal/Core/Render/Element/Link.php +++ b/core/lib/Drupal/Core/Render/Element/Link.php @@ -33,11 +33,11 @@ class Link extends RenderElement { */ public function getInfo() { $class = get_class($this); - return array( - '#pre_render' => array( - array($class, 'preRenderLink'), - ), - ); + return [ + '#pre_render' => [ + [$class, 'preRenderLink'], + ], + ]; } /** @@ -58,12 +58,12 @@ public function getInfo() { public static function preRenderLink($element) { // By default, link options to pass to the link generator are normally set // in #options. - $element += array('#options' => array()); + $element += ['#options' => []]; // However, within the scope of renderable elements, #attributes is a valid // way to specify attributes, too. Take them into account, but do not override // attributes from #options. if (isset($element['#attributes'])) { - $element['#options'] += array('attributes' => array()); + $element['#options'] += ['attributes' => []]; $element['#options']['attributes'] += $element['#attributes']; } diff --git a/core/lib/Drupal/Core/Render/Element/MachineName.php b/core/lib/Drupal/Core/Render/Element/MachineName.php index c92d0e0..7bf31d0 100644 --- a/core/lib/Drupal/Core/Render/Element/MachineName.php +++ b/core/lib/Drupal/Core/Render/Element/MachineName.php @@ -75,27 +75,27 @@ class MachineName extends Textfield { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#default_value' => NULL, '#required' => TRUE, '#maxlength' => 64, '#size' => 60, '#autocomplete_route_name' => FALSE, - '#process' => array( - array($class, 'processMachineName'), - array($class, 'processAutocomplete'), - array($class, 'processAjaxForm'), - ), - '#element_validate' => array( - array($class, 'validateMachineName'), - ), - '#pre_render' => array( - array($class, 'preRenderTextfield'), - ), + '#process' => [ + [$class, 'processMachineName'], + [$class, 'processAutocomplete'], + [$class, 'processAjaxForm'], + ], + '#element_validate' => [ + [$class, 'validateMachineName'], + ], + '#pre_render' => [ + [$class, 'preRenderTextfield'], + ], '#theme' => 'input__textfield', - '#theme_wrappers' => array('form_element'), - ); + '#theme_wrappers' => ['form_element'], + ]; } /** @@ -128,19 +128,19 @@ public static function processMachineName(&$element, FormStateInterface $form_st $language = \Drupal::languageManager()->getCurrentLanguage(); // Apply default form element properties. - $element += array( + $element += [ '#title' => t('Machine-readable name'), '#description' => t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'), - '#machine_name' => array(), + '#machine_name' => [], '#field_prefix' => '', '#field_suffix' => '', '#suffix' => '', - ); + ]; // A form element that only wants to set one #machine_name property (usually // 'source' only) would leave all other properties undefined, if the defaults // were defined by an element plugin. Therefore, we apply the defaults here. - $element['#machine_name'] += array( - 'source' => array('label'), + $element['#machine_name'] += [ + 'source' => ['label'], 'target' => '#' . $element['#id'], 'label' => t('Machine name'), 'replace_pattern' => '[^a-z0-9_]+', @@ -148,14 +148,14 @@ public static function processMachineName(&$element, FormStateInterface $form_st 'standalone' => FALSE, 'field_prefix' => $element['#field_prefix'], 'field_suffix' => $element['#field_suffix'], - ); + ]; // By default, machine names are restricted to Latin alphanumeric characters. // So, default to LTR directionality. if (!isset($element['#attributes'])) { - $element['#attributes'] = array(); + $element['#attributes'] = []; } - $element['#attributes'] += array('dir' => LanguageInterface::DIRECTION_LTR); + $element['#attributes'] += ['dir' => LanguageInterface::DIRECTION_LTR]; // The source element defaults to array('name'), but may have been overridden. if (empty($element['#machine_name']['source'])) { @@ -180,10 +180,10 @@ public static function processMachineName(&$element, FormStateInterface $form_st else { // Append a field suffix to the source form element, which will contain // the live preview of the machine name. - $source += array('#field_suffix' => ''); + $source += ['#field_suffix' => '']; $source['#field_suffix'] = $source['#field_suffix'] . '  '; - $parents = array_merge($element['#machine_name']['source'], array('#field_suffix')); + $parents = array_merge($element['#machine_name']['source'], ['#field_suffix']); NestedArray::setValue($form_state->getCompleteForm(), $parents, $source['#field_suffix']); } diff --git a/core/lib/Drupal/Core/Render/Element/MoreLink.php b/core/lib/Drupal/Core/Render/Element/MoreLink.php index 7c042b2..596c660 100644 --- a/core/lib/Drupal/Core/Render/Element/MoreLink.php +++ b/core/lib/Drupal/Core/Render/Element/MoreLink.php @@ -27,14 +27,14 @@ class MoreLink extends Link { */ public function getInfo() { $info = parent::getInfo(); - return array( + return [ '#title' => $this->t('More'), - '#theme_wrappers' => array( - 'container' => array( - '#attributes' => array('class' => array('more-link')), - ), - ), - ) + $info; + '#theme_wrappers' => [ + 'container' => [ + '#attributes' => ['class' => ['more-link']], + ], + ], + ] + $info; } } diff --git a/core/lib/Drupal/Core/Render/Element/Number.php b/core/lib/Drupal/Core/Render/Element/Number.php index b2fbb11..561c133 100644 --- a/core/lib/Drupal/Core/Render/Element/Number.php +++ b/core/lib/Drupal/Core/Render/Element/Number.php @@ -37,21 +37,21 @@ class Number extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#step' => 1, - '#process' => array( - array($class, 'processAjaxForm'), - ), - '#element_validate' => array( - array($class, 'validateNumber'), - ), - '#pre_render' => array( - array($class, 'preRenderNumber'), - ), + '#process' => [ + [$class, 'processAjaxForm'], + ], + '#element_validate' => [ + [$class, 'validateNumber'], + ], + '#pre_render' => [ + [$class, 'preRenderNumber'], + ], '#theme' => 'input__number', - '#theme_wrappers' => array('form_element'), - ); + '#theme_wrappers' => ['form_element'], + ]; } /** @@ -69,18 +69,18 @@ public static function validateNumber(&$element, FormStateInterface $form_state, // Ensure the input is numeric. if (!is_numeric($value)) { - $form_state->setError($element, t('%name must be a number.', array('%name' => $name))); + $form_state->setError($element, t('%name must be a number.', ['%name' => $name])); return; } // Ensure that the input is greater than the #min property, if set. if (isset($element['#min']) && $value < $element['#min']) { - $form_state->setError($element, t('%name must be higher than or equal to %min.', array('%name' => $name, '%min' => $element['#min']))); + $form_state->setError($element, t('%name must be higher than or equal to %min.', ['%name' => $name, '%min' => $element['#min']])); } // Ensure that the input is less than the #max property, if set. if (isset($element['#max']) && $value > $element['#max']) { - $form_state->setError($element, t('%name must be lower than or equal to %max.', array('%name' => $name, '%max' => $element['#max']))); + $form_state->setError($element, t('%name must be lower than or equal to %max.', ['%name' => $name, '%max' => $element['#max']])); } if (isset($element['#step']) && strtolower($element['#step']) != 'any') { @@ -89,7 +89,7 @@ public static function validateNumber(&$element, FormStateInterface $form_state, $offset = isset($element['#min']) ? $element['#min'] : 0.0; if (!NumberUtility::validStep($value, $element['#step'], $offset)) { - $form_state->setError($element, t('%name is not a valid number.', array('%name' => $name))); + $form_state->setError($element, t('%name is not a valid number.', ['%name' => $name])); } } } @@ -107,8 +107,8 @@ public static function validateNumber(&$element, FormStateInterface $form_state, */ public static function preRenderNumber($element) { $element['#attributes']['type'] = 'number'; - Element::setAttributes($element, array('id', 'name', 'value', 'step', 'min', 'max', 'placeholder', 'size')); - static::setAttributes($element, array('form-number')); + Element::setAttributes($element, ['id', 'name', 'value', 'step', 'min', 'max', 'placeholder', 'size']); + static::setAttributes($element, ['form-number']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Operations.php b/core/lib/Drupal/Core/Render/Element/Operations.php index a0c9728..3a53cd7 100644 --- a/core/lib/Drupal/Core/Render/Element/Operations.php +++ b/core/lib/Drupal/Core/Render/Element/Operations.php @@ -19,9 +19,9 @@ class Operations extends Dropbutton { * {@inheritdoc} */ public function getInfo() { - return array( + return [ '#theme' => 'links__dropbutton__operations', - ) + parent::getInfo(); + ] + parent::getInfo(); } } diff --git a/core/lib/Drupal/Core/Render/Element/Page.php b/core/lib/Drupal/Core/Render/Element/Page.php index 7aeef85..c7a4e07 100644 --- a/core/lib/Drupal/Core/Render/Element/Page.php +++ b/core/lib/Drupal/Core/Render/Element/Page.php @@ -15,10 +15,10 @@ class Page extends RenderElement { * {@inheritdoc} */ public function getInfo() { - return array( + return [ '#theme' => 'page', '#title' => '', - ); + ]; } } diff --git a/core/lib/Drupal/Core/Render/Element/Password.php b/core/lib/Drupal/Core/Render/Element/Password.php index e16e8bb..87cc5c0 100644 --- a/core/lib/Drupal/Core/Render/Element/Password.php +++ b/core/lib/Drupal/Core/Render/Element/Password.php @@ -29,20 +29,20 @@ class Password extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#size' => 60, '#maxlength' => 128, - '#process' => array( - array($class, 'processAjaxForm'), - array($class, 'processPattern'), - ), - '#pre_render' => array( - array($class, 'preRenderPassword'), - ), + '#process' => [ + [$class, 'processAjaxForm'], + [$class, 'processPattern'], + ], + '#pre_render' => [ + [$class, 'preRenderPassword'], + ], '#theme' => 'input__password', - '#theme_wrappers' => array('form_element'), - ); + '#theme_wrappers' => ['form_element'], + ]; } /** @@ -58,8 +58,8 @@ public function getInfo() { */ public static function preRenderPassword($element) { $element['#attributes']['type'] = 'password'; - Element::setAttributes($element, array('id', 'name', 'size', 'maxlength', 'placeholder')); - static::setAttributes($element, array('form-text')); + Element::setAttributes($element, ['id', 'name', 'size', 'maxlength', 'placeholder']); + static::setAttributes($element, ['form-text']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php b/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php index 98b65ed..609b5e2 100644 --- a/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php +++ b/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php @@ -30,14 +30,14 @@ class PasswordConfirm extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#markup' => '', - '#process' => array( - array($class, 'processPasswordConfirm'), - ), - '#theme_wrappers' => array('form_element'), - ); + '#process' => [ + [$class, 'processPasswordConfirm'], + ], + '#theme_wrappers' => ['form_element'], + ]; } /** @@ -65,23 +65,23 @@ public static function valueCallback(&$element, $input, FormStateInterface $form * Expand a password_confirm field into two text boxes. */ public static function processPasswordConfirm(&$element, FormStateInterface $form_state, &$complete_form) { - $element['pass1'] = array( + $element['pass1'] = [ '#type' => 'password', '#title' => t('Password'), '#value' => empty($element['#value']) ? NULL : $element['#value']['pass1'], '#required' => $element['#required'], - '#attributes' => array('class' => array('password-field', 'js-password-field')), + '#attributes' => ['class' => ['password-field', 'js-password-field']], '#error_no_message' => TRUE, - ); - $element['pass2'] = array( + ]; + $element['pass2'] = [ '#type' => 'password', '#title' => t('Confirm password'), '#value' => empty($element['#value']) ? NULL : $element['#value']['pass2'], '#required' => $element['#required'], - '#attributes' => array('class' => array('password-confirm', 'js-password-confirm')), + '#attributes' => ['class' => ['password-confirm', 'js-password-confirm']], '#error_no_message' => TRUE, - ); - $element['#element_validate'] = array(array(get_called_class(), 'validatePasswordConfirm')); + ]; + $element['#element_validate'] = [[get_called_class(), 'validatePasswordConfirm']]; $element['#tree'] = TRUE; if (isset($element['#size'])) { diff --git a/core/lib/Drupal/Core/Render/Element/PathElement.php b/core/lib/Drupal/Core/Render/Element/PathElement.php index ee466ef..b08dbc7 100644 --- a/core/lib/Drupal/Core/Render/Element/PathElement.php +++ b/core/lib/Drupal/Core/Render/Element/PathElement.php @@ -38,9 +38,9 @@ public function getInfo() { $class = get_class($this); $info['#validate_path'] = TRUE; $info['#convert_path'] = self::CONVERT_ROUTE; - $info['#element_validate'] = array( - array($class, 'validateMatchedPath'), - ); + $info['#element_validate'] = [ + [$class, 'validateMatchedPath'], + ]; return $info; } @@ -73,10 +73,10 @@ public static function validateMatchedPath(&$element, FormStateInterface $form_s // We do the value conversion here whilst the Url object is in scope // after validation has occurred. if ($element['#convert_path'] == self::CONVERT_ROUTE) { - $form_state->setValueForElement($element, array( + $form_state->setValueForElement($element, [ 'route_name' => $url->getRouteName(), 'route_parameters' => $url->getRouteParameters(), - )); + ]); return; } elseif ($element['#convert_path'] == self::CONVERT_URL) { @@ -84,9 +84,9 @@ public static function validateMatchedPath(&$element, FormStateInterface $form_s return; } } - $form_state->setError($element, t('This path does not exist or you do not have permission to link to %path.', array( + $form_state->setError($element, t('This path does not exist or you do not have permission to link to %path.', [ '%path' => $element['#value'], - ))); + ])); } } diff --git a/core/lib/Drupal/Core/Render/Element/Radio.php b/core/lib/Drupal/Core/Render/Element/Radio.php index ae20284..8687a9d 100644 --- a/core/lib/Drupal/Core/Render/Element/Radio.php +++ b/core/lib/Drupal/Core/Render/Element/Radio.php @@ -22,19 +22,19 @@ class Radio extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#default_value' => NULL, - '#process' => array( - array($class, 'processAjaxForm'), - ), - '#pre_render' => array( - array($class, 'preRenderRadio'), - ), + '#process' => [ + [$class, 'processAjaxForm'], + ], + '#pre_render' => [ + [$class, 'preRenderRadio'], + ], '#theme' => 'input__radio', - '#theme_wrappers' => array('form_element'), + '#theme_wrappers' => ['form_element'], '#title_display' => 'after', - ); + ]; } /** @@ -52,12 +52,12 @@ public function getInfo() { */ public static function preRenderRadio($element) { $element['#attributes']['type'] = 'radio'; - Element::setAttributes($element, array('id', 'name', '#return_value' => 'value')); + Element::setAttributes($element, ['id', 'name', '#return_value' => 'value']); if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) { $element['#attributes']['checked'] = 'checked'; } - static::setAttributes($element, array('form-radio')); + static::setAttributes($element, ['form-radio']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Radios.php b/core/lib/Drupal/Core/Render/Element/Radios.php index e7179f4..2c9797a 100644 --- a/core/lib/Drupal/Core/Render/Element/Radios.php +++ b/core/lib/Drupal/Core/Render/Element/Radios.php @@ -37,16 +37,16 @@ class Radios extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, - '#process' => array( - array($class, 'processRadios'), - ), - '#theme_wrappers' => array('radios'), - '#pre_render' => array( - array($class, 'preRenderCompositeFormElement'), - ), - ); + '#process' => [ + [$class, 'processRadios'], + ], + '#theme_wrappers' => ['radios'], + '#pre_render' => [ + [$class, 'preRenderCompositeFormElement'], + ], + ]; } /** @@ -61,11 +61,11 @@ public static function processRadios(&$element, FormStateInterface $form_state, // sub-elements. $weight += 0.001; - $element += array($key => array()); + $element += [$key => []]; // Generate the parents as the autogenerator does, so we will have a // unique id for each radio button. - $parents_for_id = array_merge($element['#parents'], array($key)); - $element[$key] += array( + $parents_for_id = array_merge($element['#parents'], [$key]); + $element[$key] += [ '#type' => 'radio', '#title' => $choice, // The key is sanitized in Drupal\Core\Template\Attribute during output @@ -81,7 +81,7 @@ public static function processRadios(&$element, FormStateInterface $form_state, // Errors should only be shown on the parent radios element. '#error_no_message' => TRUE, '#weight' => $weight, - ); + ]; } } return $element; diff --git a/core/lib/Drupal/Core/Render/Element/Range.php b/core/lib/Drupal/Core/Render/Element/Range.php index a4eace6..9e665cf 100644 --- a/core/lib/Drupal/Core/Render/Element/Range.php +++ b/core/lib/Drupal/Core/Render/Element/Range.php @@ -35,14 +35,14 @@ class Range extends Number { public function getInfo() { $info = parent::getInfo(); $class = get_class($this); - return array( + return [ '#min' => 0, '#max' => 100, - '#pre_render' => array( - array($class, 'preRenderRange'), - ), + '#pre_render' => [ + [$class, 'preRenderRange'], + ], '#theme' => 'input__range', - ) + $info; + ] + $info; } /** @@ -58,8 +58,8 @@ public function getInfo() { */ public static function preRenderRange($element) { $element['#attributes']['type'] = 'range'; - Element::setAttributes($element, array('id', 'name', 'value', 'step', 'min', 'max')); - static::setAttributes($element, array('form-range')); + Element::setAttributes($element, ['id', 'name', 'value', 'step', 'min', 'max']); + static::setAttributes($element, ['form-range']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/RenderElement.php b/core/lib/Drupal/Core/Render/Element/RenderElement.php index 1f39e10..243a9af 100644 --- a/core/lib/Drupal/Core/Render/Element/RenderElement.php +++ b/core/lib/Drupal/Core/Render/Element/RenderElement.php @@ -126,10 +126,10 @@ /** * {@inheritdoc} */ - public static function setAttributes(&$element, $class = array()) { + public static function setAttributes(&$element, $class = []) { if (!empty($class)) { if (!isset($element['#attributes']['class'])) { - $element['#attributes']['class'] = array(); + $element['#attributes']['class'] = []; } $element['#attributes']['class'] = array_merge($element['#attributes']['class'], $class); } @@ -398,7 +398,7 @@ public static function preRenderAjaxForm($element) { // Convert a simple #ajax['progress'] string into an array. if (isset($settings['progress']) && is_string($settings['progress'])) { - $settings['progress'] = array('type' => $settings['progress']); + $settings['progress'] = ['type' => $settings['progress']]; } // Change progress path to a full URL. if (isset($settings['progress']['url']) && $settings['progress']['url'] instanceof Url) { diff --git a/core/lib/Drupal/Core/Render/Element/Search.php b/core/lib/Drupal/Core/Render/Element/Search.php index 45333c5..01db3b7 100644 --- a/core/lib/Drupal/Core/Render/Element/Search.php +++ b/core/lib/Drupal/Core/Render/Element/Search.php @@ -26,21 +26,21 @@ class Search extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_route_name' => FALSE, - '#process' => array( - array($class, 'processAutocomplete'), - array($class, 'processAjaxForm'), - ), - '#pre_render' => array( - array($class, 'preRenderSearch'), - ), + '#process' => [ + [$class, 'processAutocomplete'], + [$class, 'processAjaxForm'], + ], + '#pre_render' => [ + [$class, 'preRenderSearch'], + ], '#theme' => 'input__search', - '#theme_wrappers' => array('form_element'), - ); + '#theme_wrappers' => ['form_element'], + ]; } /** @@ -56,8 +56,8 @@ public function getInfo() { */ public static function preRenderSearch($element) { $element['#attributes']['type'] = 'search'; - Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder')); - static::setAttributes($element, array('form-search')); + Element::setAttributes($element, ['id', 'name', 'value', 'size', 'maxlength', 'placeholder']); + static::setAttributes($element, ['form-search']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Select.php b/core/lib/Drupal/Core/Render/Element/Select.php index f78dfa9..30b41de 100644 --- a/core/lib/Drupal/Core/Render/Element/Select.php +++ b/core/lib/Drupal/Core/Render/Element/Select.php @@ -42,20 +42,20 @@ class Select extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#multiple' => FALSE, - '#process' => array( - array($class, 'processSelect'), - array($class, 'processAjaxForm'), - ), - '#pre_render' => array( - array($class, 'preRenderSelect'), - ), + '#process' => [ + [$class, 'processSelect'], + [$class, 'processAjaxForm'], + ], + '#pre_render' => [ + [$class, 'preRenderSelect'], + ], '#theme' => 'select', - '#theme_wrappers' => array('form_element'), - '#options' => array(), - ); + '#theme_wrappers' => ['form_element'], + '#options' => [], + ]; } /** @@ -119,14 +119,14 @@ public static function processSelect(&$element, FormStateInterface $form_state, // make a choice. Also, if there's a value for #empty_value or // #empty_option, then add an option that represents emptiness. if (($required && !isset($element['#default_value'])) || isset($element['#empty_value']) || isset($element['#empty_option'])) { - $element += array( + $element += [ '#empty_value' => '', '#empty_option' => $required ? t('- Select -') : t('- None -'), - ); + ]; // The empty option is prepended to #options and purposively not merged // to prevent another option in #options mistakenly using the same value // as #empty_value. - $empty_option = array($element['#empty_value'] => $element['#empty_option']); + $empty_option = [$element['#empty_value'] => $element['#empty_option']]; $element['#options'] = $empty_option + $element['#options']; } } @@ -143,10 +143,10 @@ public static function valueCallback(&$element, $input, FormStateInterface $form // unselected. A disabled multi-select always submits NULL, and the // default value should be used. if (empty($element['#disabled'])) { - return (is_array($input)) ? array_combine($input, $input) : array(); + return (is_array($input)) ? array_combine($input, $input) : []; } else { - return (isset($element['#default_value']) && is_array($element['#default_value'])) ? $element['#default_value'] : array(); + return (isset($element['#default_value']) && is_array($element['#default_value'])) ? $element['#default_value'] : []; } } // Non-multiple select elements may have an empty option prepended to them @@ -168,8 +168,8 @@ public static function valueCallback(&$element, $input, FormStateInterface $form * Prepares a select render element. */ public static function preRenderSelect($element) { - Element::setAttributes($element, array('id', 'name', 'size')); - static::setAttributes($element, array('form-select')); + Element::setAttributes($element, ['id', 'name', 'size']); + static::setAttributes($element, ['form-select']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Submit.php b/core/lib/Drupal/Core/Render/Element/Submit.php index 4fa52bd..4ac7685 100644 --- a/core/lib/Drupal/Core/Render/Element/Submit.php +++ b/core/lib/Drupal/Core/Render/Element/Submit.php @@ -32,9 +32,9 @@ class Submit extends Button { * {@inheritdoc} */ public function getInfo() { - return array( + return [ '#executes_submit_callback' => TRUE, - ) + parent::getInfo(); + ] + parent::getInfo(); } } diff --git a/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php b/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php index 455113d..89f39a8 100644 --- a/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php +++ b/core/lib/Drupal/Core/Render/Element/SystemCompactLink.php @@ -24,17 +24,17 @@ class SystemCompactLink extends Link { */ public function getInfo() { $class = get_class($this); - return array( - '#pre_render' => array( - array($class, 'preRenderCompactLink'), - array($class, 'preRenderLink'), - ), - '#theme_wrappers' => array( - 'container' => array( - '#attributes' => array('class' => array('compact-link')), - ), - ), - ); + return [ + '#pre_render' => [ + [$class, 'preRenderCompactLink'], + [$class, 'preRenderLink'], + ], + '#theme_wrappers' => [ + 'container' => [ + '#attributes' => ['class' => ['compact-link']], + ], + ], + ]; } /** @@ -58,23 +58,23 @@ public function getInfo() { */ public static function preRenderCompactLink($element) { // By default, link options to pass to l() are normally set in #options. - $element += array('#options' => array()); + $element += ['#options' => []]; if (system_admin_compact_mode()) { $element['#title'] = t('Show descriptions'); - $element['#url'] = BaseUrl::fromRoute('system.admin_compact_page', array('mode' => 'off')); - $element['#options'] = array( - 'attributes' => array('title' => t('Expand layout to include descriptions.')), + $element['#url'] = BaseUrl::fromRoute('system.admin_compact_page', ['mode' => 'off']); + $element['#options'] = [ + 'attributes' => ['title' => t('Expand layout to include descriptions.')], 'query' => \Drupal::destination()->getAsArray() - ); + ]; } else { $element['#title'] = t('Hide descriptions'); - $element['#url'] = BaseUrl::fromRoute('system.admin_compact_page', array('mode' => 'on')); - $element['#options'] = array( - 'attributes' => array('title' => t('Compress layout by hiding descriptions.')), + $element['#url'] = BaseUrl::fromRoute('system.admin_compact_page', ['mode' => 'on']); + $element['#options'] = [ + 'attributes' => ['title' => t('Compress layout by hiding descriptions.')], 'query' => \Drupal::destination()->getAsArray(), - ); + ]; } $options = NestedArray::mergeDeep($element['#url']->getOptions(), $element['#options']); diff --git a/core/lib/Drupal/Core/Render/Element/Table.php b/core/lib/Drupal/Core/Render/Element/Table.php index 2da6ef9..614e54e 100644 --- a/core/lib/Drupal/Core/Render/Element/Table.php +++ b/core/lib/Drupal/Core/Render/Element/Table.php @@ -58,9 +58,9 @@ class Table extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( - '#header' => array(), - '#rows' => array(), + return [ + '#header' => [], + '#rows' => [], '#empty' => '', // Properties for tableselect support. '#input' => TRUE, @@ -70,24 +70,24 @@ public function getInfo() { '#responsive' => TRUE, '#multiple' => TRUE, '#js_select' => TRUE, - '#process' => array( - array($class, 'processTable'), - ), - '#element_validate' => array( - array($class, 'validateTable'), - ), + '#process' => [ + [$class, 'processTable'], + ], + '#element_validate' => [ + [$class, 'validateTable'], + ], // Properties for tabledrag support. // The value is a list of arrays that are passed to // drupal_attach_tabledrag(). Table::preRenderTable() prepends the HTML ID // of the table to each set of options. // @see drupal_attach_tabledrag() - '#tabledrag' => array(), + '#tabledrag' => [], // Render properties. - '#pre_render' => array( - array($class, 'preRenderTable'), - ), + '#pre_render' => [ + [$class, 'preRenderTable'], + ], '#theme' => 'table', - ); + ]; } /** @@ -101,12 +101,12 @@ public static function valueCallback(&$element, $input, FormStateInterface $form // #default_value property. // @todo D8: Remove this inconsistency. if ($input === FALSE) { - $element += array('#default_value' => array()); + $element += ['#default_value' => []]; $value = array_keys(array_filter($element['#default_value'])); return array_combine($value, $value); } else { - return is_array($input) ? array_combine($input, $input) : array(); + return is_array($input) ? array_combine($input, $input) : []; } } } @@ -128,7 +128,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form public static function processTable(&$element, FormStateInterface $form_state, &$complete_form) { if ($element['#tableselect']) { if ($element['#multiple']) { - $value = is_array($element['#value']) ? $element['#value'] : array(); + $value = is_array($element['#value']) ? $element['#value'] : []; } // Advanced selection behavior makes no sense for radios. else { @@ -138,7 +138,7 @@ public static function processTable(&$element, FormStateInterface $form_state, & // @todo D8: Rename into #select_all? if ($element['#js_select']) { $element['#attached']['library'][] = 'core/drupal.tableselect'; - array_unshift($element['#header'], array('class' => array('select-all'))); + array_unshift($element['#header'], ['class' => ['select-all']]); } // Add an empty header column for radio buttons or when a "Select all" // checkbox is not desired. @@ -147,7 +147,7 @@ public static function processTable(&$element, FormStateInterface $form_state, & } if (!isset($element['#default_value']) || $element['#default_value'] === 0) { - $element['#default_value'] = array(); + $element['#default_value'] = []; } // Create a checkbox or radio for each row in a way that the value of the // tableselect element behaves as if it had been of #type checkboxes or @@ -158,7 +158,7 @@ public static function processTable(&$element, FormStateInterface $form_state, & // Their values have to be located in child keys (#tree is ignored), // since Table::validateTable() has to be able to validate whether input // (for the parent #type 'table' element) has been submitted. - $element_parents = array_merge($element['#parents'], array($key)); + $element_parents = array_merge($element['#parents'], [$key]); // Since the #parents of the tableselect form element will equal the // #parents of the row element, prevent FormBuilder from auto-generating @@ -195,23 +195,23 @@ public static function processTable(&$element, FormStateInterface $form_state, & } } if (isset($title) && $title !== '') { - $title = t('Update @title', array('@title' => $title)); + $title = t('Update @title', ['@title' => $title]); } } // Prepend the select column to existing columns. - $row = array('select' => array()) + $row; - $row['select'] += array( + $row = ['select' => []] + $row; + $row['select'] += [ '#type' => $element['#multiple'] ? 'checkbox' : 'radio', '#id' => HtmlUtility::getUniqueId('edit-' . implode('-', $element_parents)), // @todo If rows happen to use numeric indexes instead of string keys, // this results in a first row with $key === 0, which is always FALSE. '#return_value' => $key, '#attributes' => $element['#attributes'], - '#wrapper_attributes' => array( - 'class' => array('table-select'), - ), - ); + '#wrapper_attributes' => [ + 'class' => ['table-select'], + ], + ]; if ($element['#multiple']) { $row['select']['#default_value'] = isset($value[$key]) ? $key : NULL; $row['select']['#parents'] = $element_parents; @@ -332,7 +332,7 @@ public static function validateTable(&$element, FormStateInterface $form_state, */ public static function preRenderTable($element) { foreach (Element::children($element) as $first) { - $row = array('data' => array()); + $row = ['data' => []]; // Apply attributes of first-level elements as table row attributes. if (isset($element[$first]['#attributes'])) { $row += $element[$first]['#attributes']; @@ -343,7 +343,7 @@ public static function preRenderTable($element) { foreach (Element::children($element[$first]) as $second) { // Assign the element by reference, so any potential changes to the // original element are taken over. - $column = array('data' => &$element[$first][$second]); + $column = ['data' => &$element[$first][$second]]; // Apply wrapper attributes of second-level elements as table cell // attributes. @@ -357,7 +357,7 @@ public static function preRenderTable($element) { } // Take over $element['#id'] as HTML ID attribute, if not already set. - Element::setAttributes($element, array('id')); + Element::setAttributes($element, ['id']); // Add sticky headers, if applicable. if (count($element['#header']) && $element['#sticky']) { diff --git a/core/lib/Drupal/Core/Render/Element/Tableselect.php b/core/lib/Drupal/Core/Render/Element/Tableselect.php index faa288e..a8f0e95 100644 --- a/core/lib/Drupal/Core/Render/Element/Tableselect.php +++ b/core/lib/Drupal/Core/Render/Element/Tableselect.php @@ -57,23 +57,23 @@ class Tableselect extends Table { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#js_select' => TRUE, '#multiple' => TRUE, '#responsive' => TRUE, '#sticky' => FALSE, - '#pre_render' => array( - array($class, 'preRenderTable'), - array($class, 'preRenderTableselect'), - ), - '#process' => array( - array($class, 'processTableselect'), - ), - '#options' => array(), + '#pre_render' => [ + [$class, 'preRenderTable'], + [$class, 'preRenderTableselect'], + ], + '#process' => [ + [$class, 'processTableselect'], + ], + '#options' => [], '#empty' => '', '#theme' => 'table__tableselect', - ); + ]; } /** @@ -87,8 +87,8 @@ public static function valueCallback(&$element, $input, FormStateInterface $form // keys of the #default_value property. This differs from the checkboxes // element which uses the array values. if ($input === FALSE) { - $value = array(); - $element += array('#default_value' => array()); + $value = []; + $element += ['#default_value' => []]; foreach ($element['#default_value'] as $key => $flag) { if ($flag) { $value[$key] = $key; @@ -97,7 +97,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form return $value; } else { - return is_array($input) ? array_combine($input, $input) : array(); + return is_array($input) ? array_combine($input, $input) : []; } } } @@ -147,14 +147,14 @@ public static function valueCallback(&$element, $input, FormStateInterface $form * The processed element. */ public static function preRenderTableselect($element) { - $rows = array(); + $rows = []; $header = $element['#header']; if (!empty($element['#options'])) { // Generate a table row for each selectable item in #options. foreach (Element::children($element) as $key) { - $row = array(); + $row = []; - $row['data'] = array(); + $row['data'] = []; if (isset($element['#options'][$key]['#attributes'])) { $row += $element['#options'][$key]['#attributes']; } @@ -187,7 +187,7 @@ public static function preRenderTableselect($element) { if ($element['#js_select']) { // Add a "Select all" checkbox. $element['#attached']['library'][] = 'core/drupal.tableselect'; - array_unshift($header, array('class' => array('select-all'))); + array_unshift($header, ['class' => ['select-all']]); } else { // Add an empty header when radio buttons are displayed or a "Select all" @@ -218,7 +218,7 @@ public static function preRenderTableselect($element) { */ public static function processTableselect(&$element, FormStateInterface $form_state, &$complete_form) { if ($element['#multiple']) { - $value = is_array($element['#value']) ? $element['#value'] : array(); + $value = is_array($element['#value']) ? $element['#value'] : []; } else { // Advanced selection behavior makes no sense for radios. @@ -229,7 +229,7 @@ public static function processTableselect(&$element, FormStateInterface $form_st if (count($element['#options']) > 0) { if (!isset($element['#default_value']) || $element['#default_value'] === 0) { - $element['#default_value'] = array(); + $element['#default_value'] = []; } // Create a checkbox or radio for each item in #options in such a way that @@ -242,12 +242,12 @@ public static function processTableselect(&$element, FormStateInterface $form_st $title = ''; if (isset($element['#options'][$key]['title']) && is_array($element['#options'][$key]['title'])) { if (!empty($element['#options'][$key]['title']['data']['#title'])) { - $title = new TranslatableMarkup('Update @title', array( + $title = new TranslatableMarkup('Update @title', [ '@title' => $element['#options'][$key]['title']['data']['#title'], - )); + ]); } } - $element[$key] = array( + $element[$key] = [ '#type' => 'checkbox', '#title' => $title, '#title_display' => 'invisible', @@ -255,13 +255,13 @@ public static function processTableselect(&$element, FormStateInterface $form_st '#default_value' => isset($value[$key]) ? $key : NULL, '#attributes' => $element['#attributes'], '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL, - ); + ]; } else { // Generate the parents as the autogenerator does, so we will have a // unique id for each radio button. - $parents_for_id = array_merge($element['#parents'], array($key)); - $element[$key] = array( + $parents_for_id = array_merge($element['#parents'], [$key]); + $element[$key] = [ '#type' => 'radio', '#title' => '', '#return_value' => $key, @@ -270,7 +270,7 @@ public static function processTableselect(&$element, FormStateInterface $form_st '#parents' => $element['#parents'], '#id' => HtmlUtility::getUniqueId('edit-' . implode('-', $parents_for_id)), '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL, - ); + ]; } if (isset($element['#options'][$key]['#weight'])) { $element[$key]['#weight'] = $element['#options'][$key]['#weight']; @@ -279,7 +279,7 @@ public static function processTableselect(&$element, FormStateInterface $form_st } } else { - $element['#value'] = array(); + $element['#value'] = []; } return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Tel.php b/core/lib/Drupal/Core/Render/Element/Tel.php index 02b071d..ec924ea 100644 --- a/core/lib/Drupal/Core/Render/Element/Tel.php +++ b/core/lib/Drupal/Core/Render/Element/Tel.php @@ -29,22 +29,22 @@ class Tel extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#size' => 30, '#maxlength' => 128, '#autocomplete_route_name' => FALSE, - '#process' => array( - array($class, 'processAutocomplete'), - array($class, 'processAjaxForm'), - array($class, 'processPattern'), - ), - '#pre_render' => array( - array($class, 'preRenderTel'), - ), + '#process' => [ + [$class, 'processAutocomplete'], + [$class, 'processAjaxForm'], + [$class, 'processPattern'], + ], + '#pre_render' => [ + [$class, 'preRenderTel'], + ], '#theme' => 'input__tel', - '#theme_wrappers' => array('form_element'), - ); + '#theme_wrappers' => ['form_element'], + ]; } /** @@ -60,8 +60,8 @@ public function getInfo() { */ public static function preRenderTel($element) { $element['#attributes']['type'] = 'tel'; - Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder')); - static::setAttributes($element, array('form-tel')); + Element::setAttributes($element, ['id', 'name', 'value', 'size', 'maxlength', 'placeholder']); + static::setAttributes($element, ['form-tel']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Textarea.php b/core/lib/Drupal/Core/Render/Element/Textarea.php index f9286ea..340bc11 100644 --- a/core/lib/Drupal/Core/Render/Element/Textarea.php +++ b/core/lib/Drupal/Core/Render/Element/Textarea.php @@ -33,21 +33,21 @@ class Textarea extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#cols' => 60, '#rows' => 5, '#resizable' => 'vertical', - '#process' => array( - array($class, 'processAjaxForm'), - array($class, 'processGroup'), - ), - '#pre_render' => array( - array($class, 'preRenderGroup'), - ), + '#process' => [ + [$class, 'processAjaxForm'], + [$class, 'processGroup'], + ], + '#pre_render' => [ + [$class, 'preRenderGroup'], + ], '#theme' => 'textarea', - '#theme_wrappers' => array('form_element'), - ); + '#theme_wrappers' => ['form_element'], + ]; } /** diff --git a/core/lib/Drupal/Core/Render/Element/Textfield.php b/core/lib/Drupal/Core/Render/Element/Textfield.php index 1cb35e8..0bdc294 100644 --- a/core/lib/Drupal/Core/Render/Element/Textfield.php +++ b/core/lib/Drupal/Core/Render/Element/Textfield.php @@ -47,24 +47,24 @@ class Textfield extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_route_name' => FALSE, - '#process' => array( - array($class, 'processAutocomplete'), - array($class, 'processAjaxForm'), - array($class, 'processPattern'), - array($class, 'processGroup'), - ), - '#pre_render' => array( - array($class, 'preRenderTextfield'), - array($class, 'preRenderGroup'), - ), + '#process' => [ + [$class, 'processAutocomplete'], + [$class, 'processAjaxForm'], + [$class, 'processPattern'], + [$class, 'processGroup'], + ], + '#pre_render' => [ + [$class, 'preRenderTextfield'], + [$class, 'preRenderGroup'], + ], '#theme' => 'input__textfield', - '#theme_wrappers' => array('form_element'), - ); + '#theme_wrappers' => ['form_element'], + ]; } /** @@ -77,7 +77,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form if (!is_scalar($input)) { $input = ''; } - return str_replace(array("\r", "\n"), '', $input); + return str_replace(["\r", "\n"], '', $input); } return NULL; } @@ -95,8 +95,8 @@ public static function valueCallback(&$element, $input, FormStateInterface $form */ public static function preRenderTextfield($element) { $element['#attributes']['type'] = 'text'; - Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder')); - static::setAttributes($element, array('form-text')); + Element::setAttributes($element, ['id', 'name', 'value', 'size', 'maxlength', 'placeholder']); + static::setAttributes($element, ['form-text']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Token.php b/core/lib/Drupal/Core/Render/Element/Token.php index 2f9e03a..aa24435 100644 --- a/core/lib/Drupal/Core/Render/Element/Token.php +++ b/core/lib/Drupal/Core/Render/Element/Token.php @@ -21,13 +21,13 @@ class Token extends Hidden { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, - '#pre_render' => array( - array($class, 'preRenderHidden'), - ), + '#pre_render' => [ + [$class, 'preRenderHidden'], + ], '#theme' => 'input__hidden', - ); + ]; } /** diff --git a/core/lib/Drupal/Core/Render/Element/Url.php b/core/lib/Drupal/Core/Render/Element/Url.php index 33d91ed..533e460 100644 --- a/core/lib/Drupal/Core/Render/Element/Url.php +++ b/core/lib/Drupal/Core/Render/Element/Url.php @@ -33,25 +33,25 @@ class Url extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#size' => 60, '#maxlength' => 255, '#autocomplete_route_name' => FALSE, - '#process' => array( - array($class, 'processAutocomplete'), - array($class, 'processAjaxForm'), - array($class, 'processPattern'), - ), - '#element_validate' => array( - array($class, 'validateUrl'), - ), - '#pre_render' => array( - array($class, 'preRenderUrl'), - ), + '#process' => [ + [$class, 'processAutocomplete'], + [$class, 'processAjaxForm'], + [$class, 'processPattern'], + ], + '#element_validate' => [ + [$class, 'validateUrl'], + ], + '#pre_render' => [ + [$class, 'preRenderUrl'], + ], '#theme' => 'input__url', - '#theme_wrappers' => array('form_element'), - ); + '#theme_wrappers' => ['form_element'], + ]; } /** @@ -64,7 +64,7 @@ public static function validateUrl(&$element, FormStateInterface $form_state, &$ $form_state->setValueForElement($element, $value); if ($value !== '' && !UrlHelper::isValid($value, TRUE)) { - $form_state->setError($element, t('The URL %url is not valid.', array('%url' => $value))); + $form_state->setError($element, t('The URL %url is not valid.', ['%url' => $value])); } } @@ -81,8 +81,8 @@ public static function validateUrl(&$element, FormStateInterface $form_state, &$ */ public static function preRenderUrl($element) { $element['#attributes']['type'] = 'url'; - Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder')); - static::setAttributes($element, array('form-url')); + Element::setAttributes($element, ['id', 'name', 'value', 'size', 'maxlength', 'placeholder']); + static::setAttributes($element, ['form-url']); return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Value.php b/core/lib/Drupal/Core/Render/Element/Value.php index 015b0bd..023bb1a 100644 --- a/core/lib/Drupal/Core/Render/Element/Value.php +++ b/core/lib/Drupal/Core/Render/Element/Value.php @@ -25,9 +25,9 @@ class Value extends FormElement { * {@inheritdoc} */ public function getInfo() { - return array( + return [ '#input' => TRUE, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Render/Element/VerticalTabs.php b/core/lib/Drupal/Core/Render/Element/VerticalTabs.php index 1d108aa..759723b 100644 --- a/core/lib/Drupal/Core/Render/Element/VerticalTabs.php +++ b/core/lib/Drupal/Core/Render/Element/VerticalTabs.php @@ -54,16 +54,16 @@ class VerticalTabs extends RenderElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#default_tab' => '', - '#process' => array( - array($class, 'processVerticalTabs'), - ), - '#pre_render' => array( - array($class, 'preRenderVerticalTabs'), - ), - '#theme_wrappers' => array('vertical_tabs', 'form_element'), - ); + '#process' => [ + [$class, 'processVerticalTabs'], + ], + '#pre_render' => [ + [$class, 'preRenderVerticalTabs'], + ], + '#theme_wrappers' => ['vertical_tabs', 'form_element'], + ]; } /** @@ -106,11 +106,11 @@ public static function processVerticalTabs(&$element, FormStateInterface $form_s // Inject a new details as child, so that form_process_details() processes // this details element like any other details. - $element['group'] = array( + $element['group'] = [ '#type' => 'details', - '#theme_wrappers' => array(), + '#theme_wrappers' => [], '#parents' => $element['#parents'], - ); + ]; // Add an invisible label for accessibility. if (!isset($element['#title'])) { @@ -128,11 +128,11 @@ public static function processVerticalTabs(&$element, FormStateInterface $form_s if ($form_state->hasValue($name . '__active_tab')) { $element['#default_tab'] = $form_state->getValue($name . '__active_tab'); } - $element[$name . '__active_tab'] = array( + $element[$name . '__active_tab'] = [ '#type' => 'hidden', '#default_value' => $element['#default_tab'], - '#attributes' => array('class' => array('vertical-tabs__active-tab')), - ); + '#attributes' => ['class' => ['vertical-tabs__active-tab']], + ]; // Clean up the active tab value so it's not accidentally stored in // settings forms. $form_state->addCleanValueKey($name . '__active_tab'); diff --git a/core/lib/Drupal/Core/Render/Element/Weight.php b/core/lib/Drupal/Core/Render/Element/Weight.php index a6ecbee..468290a 100644 --- a/core/lib/Drupal/Core/Render/Element/Weight.php +++ b/core/lib/Drupal/Core/Render/Element/Weight.php @@ -33,15 +33,15 @@ class Weight extends FormElement { */ public function getInfo() { $class = get_class($this); - return array( + return [ '#input' => TRUE, '#delta' => 10, '#default_value' => 0, - '#process' => array( - array($class, 'processWeight'), - array($class, 'processAjaxForm'), - ), - ); + '#process' => [ + [$class, 'processWeight'], + [$class, 'processAjaxForm'], + ], + ]; } /** @@ -55,7 +55,7 @@ public static function processWeight(&$element, FormStateInterface $form_state, $max_elements = \Drupal::config('system.site')->get('weight_select_max'); if ($element['#delta'] <= $max_elements) { $element['#type'] = 'select'; - $weights = array(); + $weights = []; for ($n = (-1 * $element['#delta']); $n <= $element['#delta']; $n++) { $weights[$n] = $n; } diff --git a/core/lib/Drupal/Core/Render/ElementInfoManager.php b/core/lib/Drupal/Core/Render/ElementInfoManager.php index 1754524..015e390 100644 --- a/core/lib/Drupal/Core/Render/ElementInfoManager.php +++ b/core/lib/Drupal/Core/Render/ElementInfoManager.php @@ -75,7 +75,7 @@ public function getInfo($type) { if (!isset($this->elementInfo[$theme_name])) { $this->elementInfo[$theme_name] = $this->buildInfo($theme_name); } - $info = isset($this->elementInfo[$theme_name][$type]) ? $this->elementInfo[$theme_name][$type] : array(); + $info = isset($this->elementInfo[$theme_name][$type]) ? $this->elementInfo[$theme_name][$type] : []; $info['#defaults_loaded'] = TRUE; return $info; } @@ -114,7 +114,7 @@ protected function buildInfo($theme_name) { // will receive input, and assign the value callback. if ($element instanceof FormElementInterface) { $element_info['#input'] = TRUE; - $element_info['#value_callback'] = array($definition['class'], 'valueCallback'); + $element_info['#value_callback'] = [$definition['class'], 'valueCallback']; } $info[$element_type] = $element_info; } @@ -136,7 +136,7 @@ protected function buildInfo($theme_name) { * * @return \Drupal\Core\Render\Element\ElementInterface */ - public function createInstance($plugin_id, array $configuration = array()) { + public function createInstance($plugin_id, array $configuration = []) { return parent::createInstance($plugin_id, $configuration); } diff --git a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php index 2f9aeb3..e0cd2bf 100644 --- a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php +++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php @@ -410,10 +410,10 @@ protected function processHtmlHeadLink(array $html_head_link) { $attributes = $item[0]; $should_add_header = isset($item[1]) ? $item[1] : FALSE; - $element = array( + $element = [ '#tag' => 'link', '#attributes' => $attributes, - ); + ]; $href = $attributes['href']; $attached['html_head'][] = [$element, 'html_head_link:' . $attributes['rel'] . ':' . $href]; diff --git a/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php b/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php index 0a1b993..2b2a2a5 100644 --- a/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/AjaxRenderer.php @@ -66,7 +66,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch // replace the element making the Ajax call. The default 'replaceWith' // behavior can be changed with #ajax['method']. $response->addCommand(new InsertCommand(NULL, $html)); - $status_messages = array('#type' => 'status_messages'); + $status_messages = ['#type' => 'status_messages']; $output = $this->drupalRenderRoot($status_messages); if (!empty($output)) { $response->addCommand(new PrependCommand(NULL, $output)); diff --git a/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php b/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php index c71604b..664063a 100644 --- a/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php @@ -50,7 +50,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch $title = isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject()); // Determine the dialog options and the target for the OpenDialogCommand. - $options = $request->request->get('dialogOptions', array()); + $options = $request->request->get('dialogOptions', []); $target = $this->determineTargetSelector($options, $route_match); $response->addCommand(new OpenDialogCommand($target, $title, $content, $options)); diff --git a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php index 54c40f6..c76a972 100644 --- a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php @@ -253,9 +253,9 @@ protected function prepare(array $main_content, Request $request, RouteMatchInte // Generate a #type => page render array using the page display variant, // the page display will build the content for the various page regions. - $page = array( + $page = [ '#type' => 'page', - ); + ]; $page += $page_display->build(); } diff --git a/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php b/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php index fcb38e2..60a4951 100644 --- a/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php @@ -31,7 +31,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch // Determine the title: use the title provided by the main content if any, // otherwise get it from the routing information. - $options = $request->request->get('dialogOptions', array()); + $options = $request->request->get('dialogOptions', []); $response->addCommand(new OpenModalDialogCommand($title, $content, $options)); return $response; diff --git a/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php b/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php index de52da2..6a5527b 100644 --- a/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php +++ b/core/lib/Drupal/Core/Render/MetadataBubblingUrlGenerator.php @@ -64,7 +64,7 @@ public function getContext() { /** * {@inheritdoc} */ - public function getPathFromRoute($name, $parameters = array()) { + public function getPathFromRoute($name, $parameters = []) { return $this->urlGenerator->getPathFromRoute($name, $parameters); } @@ -91,7 +91,7 @@ protected function bubble(GeneratedUrl $generated_url, array $options = []) { /** * {@inheritdoc} */ - public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) { + public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) { $options['absolute'] = is_bool($referenceType) ? $referenceType : $referenceType === self::ABSOLUTE_URL; $generated_url = $this->generateFromRoute($name, $parameters, $options, TRUE); $this->bubble($generated_url); @@ -101,7 +101,7 @@ public function generate($name, $parameters = array(), $referenceType = self::AB /** * {@inheritdoc} */ - public function generateFromRoute($name, $parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE) { + public function generateFromRoute($name, $parameters = [], $options = [], $collect_bubbleable_metadata = FALSE) { $generated_url = $this->urlGenerator->generateFromRoute($name, $parameters, $options, TRUE); if (!$collect_bubbleable_metadata) { $this->bubble($generated_url, $options); @@ -119,7 +119,7 @@ public function supports($name) { /** * {@inheritdoc} */ - public function getRouteDebugMessage($name, array $parameters = array()) { + public function getRouteDebugMessage($name, array $parameters = []) { return $this->urlGenerator->getRouteDebugMessage($name, $parameters); } diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php index 0bf1d63..c240012 100644 --- a/core/lib/Drupal/Core/Render/Renderer.php +++ b/core/lib/Drupal/Core/Render/Renderer.php @@ -383,9 +383,9 @@ protected function doRender(&$elements, $is_root_call = FALSE) { } // Defaults for bubbleable rendering metadata. - $elements['#cache']['tags'] = isset($elements['#cache']['tags']) ? $elements['#cache']['tags'] : array(); + $elements['#cache']['tags'] = isset($elements['#cache']['tags']) ? $elements['#cache']['tags'] : []; $elements['#cache']['max-age'] = isset($elements['#cache']['max-age']) ? $elements['#cache']['max-age'] : Cache::PERMANENT; - $elements['#attached'] = isset($elements['#attached']) ? $elements['#attached'] : array(); + $elements['#attached'] = isset($elements['#attached']) ? $elements['#attached'] : []; // Allow #pre_render to abort rendering. if (!empty($elements['#printed'])) { @@ -415,11 +415,11 @@ protected function doRender(&$elements, $is_root_call = FALSE) { $theme_is_implemented = isset($elements['#theme']); // Check the elements for insecure HTML and pass through sanitization. if (isset($elements)) { - $markup_keys = array( + $markup_keys = [ '#description', '#field_prefix', '#field_suffix', - ); + ]; foreach ($markup_keys as $key) { if (!empty($elements[$key]) && is_scalar($elements[$key])) { $elements[$key] = $this->xssFilterAdminIfUnsafe($elements[$key]); diff --git a/core/lib/Drupal/Core/Render/theme.api.php b/core/lib/Drupal/Core/Render/theme.api.php index 61cafc3..1fff8df 100644 --- a/core/lib/Drupal/Core/Render/theme.api.php +++ b/core/lib/Drupal/Core/Render/theme.api.php @@ -529,12 +529,12 @@ */ function hook_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) { // Add a checkbox to toggle the breadcrumb trail. - $form['toggle_breadcrumb'] = array( + $form['toggle_breadcrumb'] = [ '#type' => 'checkbox', '#title' => t('Display the breadcrumb'), '#default_value' => theme_get_setting('features.breadcrumb'), '#description' => t('Show a trail of links from the homepage to the current page.'), - ); + ]; } /** @@ -604,7 +604,7 @@ function hook_preprocess(&$variables, $hook) { function hook_preprocess_HOOK(&$variables) { // This example is from rdf_preprocess_image(). It adds an RDF attribute // to the image hook's variables. - $variables['attributes']['typeof'] = array('foaf:Image'); + $variables['attributes']['typeof'] = ['foaf:Image']; } /** @@ -631,7 +631,7 @@ function hook_preprocess_HOOK(&$variables) { * @see hook_theme_suggestions_HOOK_alter() */ function hook_theme_suggestions_HOOK(array $variables) { - $suggestions = array(); + $suggestions = []; $suggestions[] = 'node__' . $variables['elements']['#langcode']; @@ -963,10 +963,10 @@ function hook_library_info_alter(&$libraries, $extension) { // relative to the original extension, specify an absolute path (relative // to DRUPAL_ROOT / base_path()) to the new location. $new_path = '/' . drupal_get_path('module', 'farbtastic_update') . '/js'; - $new_js = array(); - $replacements = array( + $new_js = []; + $replacements = [ $old_path . '/farbtastic.js' => $new_path . '/farbtastic-2.0.js', - ); + ]; foreach ($libraries['jquery.farbtastic']['js'] as $source => $options) { if (isset($replacements[$source])) { $new_js[$replacements[$source]] = $options; @@ -1179,21 +1179,21 @@ function hook_page_bottom(array &$page_bottom) { * @see hook_theme_registry_alter() */ function hook_theme($existing, $type, $theme, $path) { - return array( - 'forum_display' => array( - 'variables' => array('forums' => NULL, 'topics' => NULL, 'parents' => NULL, 'tid' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL), - ), - 'forum_list' => array( - 'variables' => array('forums' => NULL, 'parents' => NULL, 'tid' => NULL), - ), - 'forum_icon' => array( - 'variables' => array('new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0), - ), - 'status_report' => array( + return [ + 'forum_display' => [ + 'variables' => ['forums' => NULL, 'topics' => NULL, 'parents' => NULL, 'tid' => NULL, 'sortby' => NULL, 'forum_per_page' => NULL], + ], + 'forum_list' => [ + 'variables' => ['forums' => NULL, 'parents' => NULL, 'tid' => NULL], + ], + 'forum_icon' => [ + 'variables' => ['new_posts' => NULL, 'num_posts' => 0, 'comment_mode' => 0, 'sticky' => 0], + ], + 'status_report' => [ 'render element' => 'requirements', 'file' => 'system.admin.inc', - ), - ); + ], + ]; } /** diff --git a/core/lib/Drupal/Core/RouteProcessor/RouteProcessorManager.php b/core/lib/Drupal/Core/RouteProcessor/RouteProcessorManager.php index 4e710ba..74a791d 100644 --- a/core/lib/Drupal/Core/RouteProcessor/RouteProcessorManager.php +++ b/core/lib/Drupal/Core/RouteProcessor/RouteProcessorManager.php @@ -20,7 +20,7 @@ class RouteProcessorManager implements OutboundRouteProcessorInterface { * An array whose keys are priorities and whose values are arrays of path * processor objects. */ - protected $outboundProcessors = array(); + protected $outboundProcessors = []; /** * Holds the array of outbound processors, sorted by priority. @@ -28,7 +28,7 @@ class RouteProcessorManager implements OutboundRouteProcessorInterface { * @var array * An array of path processor objects. */ - protected $sortedOutbound = array(); + protected $sortedOutbound = []; /** * Adds an outbound processor object to the $outboundProcessors property. @@ -40,7 +40,7 @@ class RouteProcessorManager implements OutboundRouteProcessorInterface { */ public function addOutbound(OutboundRouteProcessorInterface $processor, $priority = 0) { $this->outboundProcessors[$priority][] = $processor; - $this->sortedOutbound = array(); + $this->sortedOutbound = []; } /** @@ -71,7 +71,7 @@ protected function getOutbound() { * Sorts the processors according to priority. */ protected function sortProcessors() { - $sorted = array(); + $sorted = []; krsort($this->outboundProcessors); foreach ($this->outboundProcessors as $processors) { diff --git a/core/lib/Drupal/Core/Routing/AccessAwareRouter.php b/core/lib/Drupal/Core/Routing/AccessAwareRouter.php index 9346b0a..857e557 100644 --- a/core/lib/Drupal/Core/Routing/AccessAwareRouter.php +++ b/core/lib/Drupal/Core/Routing/AccessAwareRouter.php @@ -120,7 +120,7 @@ public function getRouteCollection() { /** * {@inheritdoc} */ - public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) { + public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) { return $this->chainRouter->generate($name, $parameters, $referenceType); } diff --git a/core/lib/Drupal/Core/Routing/CompiledRoute.php b/core/lib/Drupal/Core/Routing/CompiledRoute.php index 775d4ae..aa2025e 100644 --- a/core/lib/Drupal/Core/Routing/CompiledRoute.php +++ b/core/lib/Drupal/Core/Routing/CompiledRoute.php @@ -61,7 +61,7 @@ class CompiledRoute extends SymfonyCompiledRoute { * @param array $variables * An array of variables (variables defined in the path and in the host patterns) */ - public function __construct($fit, $pattern_outline, $num_parts, $staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = NULL, array $hostTokens = array(), array $hostVariables = array(), array $variables = array()) { + public function __construct($fit, $pattern_outline, $num_parts, $staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = NULL, array $hostTokens = [], array $hostVariables = [], array $variables = []) { parent::__construct($staticPrefix, $regex, $tokens, $pathVariables, $hostRegex, $hostTokens, $hostVariables, $variables); $this->fit = $fit; diff --git a/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php b/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php index e804f2e..09d6148 100644 --- a/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php +++ b/core/lib/Drupal/Core/Routing/Enhancer/ParamConversionEnhancer.php @@ -62,7 +62,7 @@ protected function copyRawVariables(array $defaults) { // Foreach will copy the values from the array it iterates. Even if they // are references, use it to break them. This avoids any scenarios where raw // variables also get replaced with converted values. - $raw_variables = array(); + $raw_variables = []; foreach (array_intersect_key($defaults, $variables) as $key => $value) { $raw_variables[$key] = $value; } @@ -85,7 +85,7 @@ public function onException(GetResponseForExceptionEvent $event) { * {@inheritdoc} */ public static function getSubscribedEvents() { - $events[KernelEvents::EXCEPTION][] = array('onException', 75); + $events[KernelEvents::EXCEPTION][] = ['onException', 75]; return $events; } diff --git a/core/lib/Drupal/Core/Routing/MatcherDumper.php b/core/lib/Drupal/Core/Routing/MatcherDumper.php index 467b02b..621df57 100644 --- a/core/lib/Drupal/Core/Routing/MatcherDumper.php +++ b/core/lib/Drupal/Core/Routing/MatcherDumper.php @@ -84,10 +84,10 @@ public function addRoutes(RouteCollection $routes) { * @param array $options * An array of options. */ - public function dump(array $options = array()) { + public function dump(array $options = []) { // Convert all of the routes into database records. // Accumulate the menu masks on top of any we found before. - $masks = array_flip($this->state->get('routing.menu_masks.' . $this->tableName, array())); + $masks = array_flip($this->state->get('routing.menu_masks.' . $this->tableName, [])); // Delete any old records first, then insert the new ones. That avoids // stale data. The transaction makes it atomic to avoid unstable router // states due to random failures. @@ -106,15 +106,15 @@ public function dump(array $options = array()) { // Split the routes into chunks to avoid big INSERT queries. $route_chunks = array_chunk($this->routes->all(), 50, TRUE); foreach ($route_chunks as $routes) { - $insert = $this->connection->insert($this->tableName)->fields(array( + $insert = $this->connection->insert($this->tableName)->fields([ 'name', 'fit', 'path', 'pattern_outline', 'number_parts', 'route', - )); - $names = array(); + ]); + $names = []; foreach ($routes as $name => $route) { /** @var \Symfony\Component\Routing\Route $route */ $route->setOption('compiler_class', '\Drupal\Core\Routing\RouteCompiler'); @@ -126,14 +126,14 @@ public function dump(array $options = array()) { // patterns we need to check in the RouteProvider. $masks[$compiled->getFit()] = 1; $names[] = $name; - $values = array( + $values = [ 'name' => $name, 'fit' => $compiled->getFit(), 'path' => $route->getPath(), 'pattern_outline' => $compiled->getPatternOutline(), 'number_parts' => $compiled->getNumParts(), 'route' => serialize($route), - ); + ]; $insert->values($values); } diff --git a/core/lib/Drupal/Core/Routing/NullGenerator.php b/core/lib/Drupal/Core/Routing/NullGenerator.php index d9bc9b0..2d48eea 100644 --- a/core/lib/Drupal/Core/Routing/NullGenerator.php +++ b/core/lib/Drupal/Core/Routing/NullGenerator.php @@ -52,7 +52,7 @@ protected function processRoute($name, Route $route, array &$parameters, Bubblea /** * {@inheritdoc} */ - protected function getInternalPathFromRoute($name, Route $route, $parameters = array(), $query_params = array()) { + protected function getInternalPathFromRoute($name, Route $route, $parameters = [], $query_params = []) { return $route->getPath(); } @@ -71,7 +71,7 @@ public function getContext() { /** * {@inheritdoc} */ - protected function processPath($path, &$options = array(), BubbleableMetadata $bubbleable_metadata = NULL) { + protected function processPath($path, &$options = [], BubbleableMetadata $bubbleable_metadata = NULL) { return $path; } diff --git a/core/lib/Drupal/Core/Routing/NullMatcherDumper.php b/core/lib/Drupal/Core/Routing/NullMatcherDumper.php index 938a426..3378e1b 100644 --- a/core/lib/Drupal/Core/Routing/NullMatcherDumper.php +++ b/core/lib/Drupal/Core/Routing/NullMatcherDumper.php @@ -39,7 +39,7 @@ public function addRoutes(RouteCollection $routes) { * @param array $options * An array of options. */ - public function dump(array $options = array()) { + public function dump(array $options = []) { // The dumper is reused for multiple providers, so reset the queued routes. $this->routes = NULL; } diff --git a/core/lib/Drupal/Core/Routing/RouteBuilder.php b/core/lib/Drupal/Core/Routing/RouteBuilder.php index 29da760..2a0720a 100644 --- a/core/lib/Drupal/Core/Routing/RouteBuilder.php +++ b/core/lib/Drupal/Core/Routing/RouteBuilder.php @@ -159,15 +159,15 @@ public function rebuild() { unset($routes['route_callbacks']); } foreach ($routes as $name => $route_info) { - $route_info += array( - 'defaults' => array(), - 'requirements' => array(), - 'options' => array(), + $route_info += [ + 'defaults' => [], + 'requirements' => [], + 'options' => [], 'host' => NULL, - 'schemes' => array(), - 'methods' => array(), + 'schemes' => [], + 'methods' => [], 'condition' => '', - ); + ]; $route = new Route($route_info['path'], $route_info['defaults'], $route_info['requirements'], $route_info['options'], $route_info['host'], $route_info['schemes'], $route_info['methods'], $route_info['condition']); $collection->add($name, $route); diff --git a/core/lib/Drupal/Core/Routing/RouteMatch.php b/core/lib/Drupal/Core/Routing/RouteMatch.php index 29ff5c6..5784b7f 100644 --- a/core/lib/Drupal/Core/Routing/RouteMatch.php +++ b/core/lib/Drupal/Core/Routing/RouteMatch.php @@ -52,7 +52,7 @@ class RouteMatch implements RouteMatchInterface { * @param array $raw_parameters * The raw $parameters array. */ - public function __construct($route_name, Route $route, array $parameters = array(), array $raw_parameters = array()) { + public function __construct($route_name, Route $route, array $parameters = [], array $raw_parameters = []) { $this->routeName = $route_name; $this->route = $route; @@ -77,7 +77,7 @@ public function __construct($route_name, Route $route, array $parameters = array */ public static function createFromRequest(Request $request) { if ($request->attributes->get(RouteObjectInterface::ROUTE_OBJECT)) { - $raw_variables = array(); + $raw_variables = []; if ($raw = $request->attributes->get('_raw_variables')) { $raw_variables = $raw->all(); } @@ -141,7 +141,7 @@ public function getRawParameters() { * Route parameter names as both the keys and values. */ protected function getParameterNames() { - $names = array(); + $names = []; if ($route = $this->getRouteObject()) { // Variables defined in path and host patterns are route parameters. $variables = $route->compile()->getVariables(); diff --git a/core/lib/Drupal/Core/Routing/RoutePreloader.php b/core/lib/Drupal/Core/Routing/RoutePreloader.php index 2d382bb..9e75cdf 100644 --- a/core/lib/Drupal/Core/Routing/RoutePreloader.php +++ b/core/lib/Drupal/Core/Routing/RoutePreloader.php @@ -38,7 +38,7 @@ class RoutePreloader implements EventSubscriberInterface { * * @var array */ - protected $nonAdminRoutesOnRebuild = array(); + protected $nonAdminRoutesOnRebuild = []; /** * The cache backend used to skip the state loading. @@ -114,7 +114,7 @@ public function onAlterRoutes(RouteBuildEvent $event) { */ public function onFinishedRoutes(Event $event) { $this->state->set('routing.non_admin_routes', $this->nonAdminRoutesOnRebuild); - $this->nonAdminRoutesOnRebuild = array(); + $this->nonAdminRoutesOnRebuild = []; } /** @@ -122,11 +122,11 @@ public function onFinishedRoutes(Event $event) { */ public static function getSubscribedEvents() { // Set a really low priority to catch as many as possible routes. - $events[RoutingEvents::ALTER] = array('onAlterRoutes', -1024); - $events[RoutingEvents::FINISHED] = array('onFinishedRoutes'); + $events[RoutingEvents::ALTER] = ['onAlterRoutes', -1024]; + $events[RoutingEvents::FINISHED] = ['onFinishedRoutes']; // Load the routes before the controller is executed (which happens after // the kernel request event). - $events[KernelEvents::REQUEST][] = array('onRequest'); + $events[KernelEvents::REQUEST][] = ['onRequest']; return $events; } diff --git a/core/lib/Drupal/Core/Routing/RouteProvider.php b/core/lib/Drupal/Core/Routing/RouteProvider.php index 53ed626..3dc5207 100644 --- a/core/lib/Drupal/Core/Routing/RouteProvider.php +++ b/core/lib/Drupal/Core/Routing/RouteProvider.php @@ -47,7 +47,7 @@ class RouteProvider implements PreloadableRouteProviderInterface, PagedRouteProv * * @var \Symfony\Component\Routing\Route[] */ - protected $routes = array(); + protected $routes = []; /** * A cache of already-loaded serialized routes, keyed by route name. @@ -182,7 +182,7 @@ public function getRouteCollectionForRequest(Request $request) { * Thrown if there is no route with that name in this repository. */ public function getRouteByName($name) { - $routes = $this->getRoutesByNames(array($name)); + $routes = $this->getRoutesByNames([$name]); if (empty($routes)) { throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name)); } @@ -207,7 +207,7 @@ public function preLoadRoutes($names) { } else { try { - $result = $this->connection->query('SELECT name, route FROM {' . $this->connection->escapeTable($this->tableName) . '} WHERE name IN ( :names[] )', array(':names[]' => $routes_to_load)); + $result = $this->connection->query('SELECT name, route FROM {' . $this->connection->escapeTable($this->tableName) . '} WHERE name IN ( :names[] )', [':names[]' => $routes_to_load]); $routes = $result->fetchAllKeyed(); $this->cache->set($cid, $routes, Cache::PERMANENT, ['routes']); @@ -249,14 +249,14 @@ public function getRoutesByNames($names) { */ protected function getCandidateOutlines(array $parts) { $number_parts = count($parts); - $ancestors = array(); + $ancestors = []; $length = $number_parts - 1; $end = (1 << $number_parts) - 1; // The highest possible mask is a 1 bit for every part of the path. We will // check every value down from there to generate a possible outline. if ($number_parts == 1) { - $masks = array(1); + $masks = [1]; } elseif ($number_parts <= 3 && $number_parts > 0) { // Optimization - don't query the state system for short paths. This also @@ -266,11 +266,11 @@ protected function getCandidateOutlines(array $parts) { } elseif ($number_parts <= 0) { // No path can match, short-circuit the process. - $masks = array(); + $masks = []; } else { // Get the actual patterns that exist out of state. - $masks = (array) $this->state->get('routing.menu_masks.' . $this->tableName, array()); + $masks = (array) $this->state->get('routing.menu_masks.' . $this->tableName, []); } // Only examine patterns that actually exist as router items (the masks). @@ -338,9 +338,9 @@ protected function getRoutesByPath($path) { // trailing wildcard parts as long as the pattern matches, since we // dump the route pattern without those optional parts. try { - $routes = $this->connection->query("SELECT name, route, fit FROM {" . $this->connection->escapeTable($this->tableName) . "} WHERE pattern_outline IN ( :patterns[] ) AND number_parts >= :count_parts", array( + $routes = $this->connection->query("SELECT name, route, fit FROM {" . $this->connection->escapeTable($this->tableName) . "} WHERE pattern_outline IN ( :patterns[] ) AND number_parts >= :count_parts", [ ':patterns[]' => $ancestors, ':count_parts' => count($parts), - )) + ]) ->fetchAll(\PDO::FETCH_ASSOC); } catch (\Exception $e) { @@ -348,7 +348,7 @@ protected function getRoutesByPath($path) { } // We sort by fit and name in PHP to avoid a SQL filesort. - usort($routes, array($this, 'routeProviderRouteCompare')); + usort($routes, [$this, 'routeProviderRouteCompare']); foreach ($routes as $row) { $collection->add($row['name'], unserialize($row['route'])); @@ -380,8 +380,8 @@ public function getAllRoutes() { * {@inheritdoc} */ public function reset() { - $this->routes = array(); - $this->serializedRoutes = array(); + $this->routes = []; + $this->serializedRoutes = []; $this->cacheTagInvalidator->invalidateTags(['routes']); } @@ -389,7 +389,7 @@ public function reset() { * {@inheritdoc} */ static function getSubscribedEvents() { - $events[RoutingEvents::FINISHED][] = array('reset'); + $events[RoutingEvents::FINISHED][] = ['reset']; return $events; } diff --git a/core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php b/core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php index e959c2a..625f7a3 100644 --- a/core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php +++ b/core/lib/Drupal/Core/Routing/TrustedRedirectResponse.php @@ -16,12 +16,12 @@ class TrustedRedirectResponse extends CacheableSecuredRedirectResponse { * * @var string[] */ - protected $trustedUrls = array(); + protected $trustedUrls = []; /** * {@inheritdoc} */ - public function __construct($url, $status = 302, $headers = array()) { + public function __construct($url, $status = 302, $headers = []) { $this->trustedUrls[$url] = TRUE; parent::__construct($url, $status, $headers); } diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php index ccf2b60..89c0fc8 100644 --- a/core/lib/Drupal/Core/Routing/UrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -117,7 +117,7 @@ public function isStrictRequirements() { /** * {@inheritdoc} */ - public function getPathFromRoute($name, $parameters = array()) { + public function getPathFromRoute($name, $parameters = []) { $route = $this->getRoute($name); $name = $this->getRouteDebugMessage($name); $this->processRoute($name, $route, $parameters); @@ -218,7 +218,7 @@ protected function doGenerate(array $variables, array $defaults, array $tokens, // so we need to encode them as they are not used for this purpose here // otherwise we would generate a URI that, when followed by a user agent // (e.g. browser), does not match this route - $url = strtr($url, array('/../' => '/%2E%2E/', '/./' => '/%2E/')); + $url = strtr($url, ['/../' => '/%2E%2E/', '/./' => '/%2E/']); if ('/..' === substr($url, -3)) { $url = substr($url, 0, -2) . '%2E%2E'; } @@ -253,7 +253,7 @@ protected function doGenerate(array $variables, array $defaults, array $tokens, * @return string * The url path corresponding to the route, without the base path. */ - protected function getInternalPathFromRoute($name, SymfonyRoute $route, $parameters = array(), $query_params = array()) { + protected function getInternalPathFromRoute($name, SymfonyRoute $route, $parameters = [], $query_params = []) { // The Route has a cache of its own and is not recompiled as long as it does // not get modified. $compiledRoute = $route->compile(); @@ -264,7 +264,7 @@ protected function getInternalPathFromRoute($name, SymfonyRoute $route, $paramet /** * {@inheritdoc} */ - public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) { + public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) { $options['absolute'] = is_bool($referenceType) ? $referenceType : $referenceType === self::ABSOLUTE_URL; return $this->generateFromRoute($name, $parameters, $options); } @@ -272,8 +272,8 @@ public function generate($name, $parameters = array(), $referenceType = self::AB /** * {@inheritdoc} */ - public function generateFromRoute($name, $parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE) { - $options += array('prefix' => ''); + public function generateFromRoute($name, $parameters = [], $options = [], $collect_bubbleable_metadata = FALSE) { + $options += ['prefix' => '']; $route = $this->getRoute($name); $generated_url = $collect_bubbleable_metadata ? new GeneratedUrl() : NULL; @@ -298,7 +298,7 @@ public function generateFromRoute($name, $parameters = array(), $options = array } $options += $route->getOption('default_url_options') ?: []; - $options += array('prefix' => '', 'path_processing' => TRUE); + $options += ['prefix' => '', 'path_processing' => TRUE]; $name = $this->getRouteDebugMessage($name); $this->processRoute($name, $route, $parameters, $generated_url); @@ -371,7 +371,7 @@ public function generateFromRoute($name, $parameters = array(), $options = array /** * Passes the path to a processor manager to allow alterations. */ - protected function processPath($path, &$options = array(), BubbleableMetadata $bubbleable_metadata = NULL) { + protected function processPath($path, &$options = [], BubbleableMetadata $bubbleable_metadata = NULL) { // Router-based paths may have a querystring on them. if ($query_pos = strpos($path, '?')) { // We don't need to do a strict check here because position 0 would mean we @@ -439,7 +439,7 @@ public function supports($name) { /** * {@inheritdoc} */ - public function getRouteDebugMessage($name, array $parameters = array()) { + public function getRouteDebugMessage($name, array $parameters = []) { if (is_scalar($name)) { return $name; } diff --git a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php index 70829cd..207006d 100644 --- a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php +++ b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php @@ -23,7 +23,7 @@ * @return string * The internal Drupal path corresponding to the route. */ - public function getPathFromRoute($name, $parameters = array()); + public function getPathFromRoute($name, $parameters = []); /** * Generates a URL or path for a specific route based on the given parameters. @@ -77,6 +77,6 @@ public function getPathFromRoute($name, $parameters = array()); * Should not be used in user code. * Use \Drupal\Core\Url instead. */ - public function generateFromRoute($name, $parameters = array(), $options = array(), $collect_bubbleable_metadata = FALSE); + public function generateFromRoute($name, $parameters = [], $options = [], $collect_bubbleable_metadata = FALSE); } diff --git a/core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php b/core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php index 98429d4..7854a0a 100644 --- a/core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php +++ b/core/lib/Drupal/Core/Routing/UrlGeneratorTrait.php @@ -38,7 +38,7 @@ * * @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute() */ - protected function url($route_name, $route_parameters = array(), $options = array()) { + protected function url($route_name, $route_parameters = [], $options = []) { return $this->getUrlGenerator()->generateFromRoute($route_name, $route_parameters, $options); } diff --git a/core/lib/Drupal/Core/Session/AccountSwitcher.php b/core/lib/Drupal/Core/Session/AccountSwitcher.php index cbebac4..3c2b3d8 100644 --- a/core/lib/Drupal/Core/Session/AccountSwitcher.php +++ b/core/lib/Drupal/Core/Session/AccountSwitcher.php @@ -16,14 +16,14 @@ class AccountSwitcher implements AccountSwitcherInterface { * * @var \Drupal\Core\Session\AccountInterface[] */ - protected $accountStack = array(); + protected $accountStack = []; /** * The current user service. * * @var \Drupal\Core\Session\AccountProxyInterface */ - protected $currentUser = array(); + protected $currentUser = []; /** * The write-safe session handler. diff --git a/core/lib/Drupal/Core/Session/SessionHandler.php b/core/lib/Drupal/Core/Session/SessionHandler.php index 50bb22f..4078d41 100644 --- a/core/lib/Drupal/Core/Session/SessionHandler.php +++ b/core/lib/Drupal/Core/Session/SessionHandler.php @@ -72,14 +72,14 @@ public function write($sid, $value) { // manually. try { $request = $this->requestStack->getCurrentRequest(); - $fields = array( + $fields = [ 'uid' => $request->getSession()->get('uid', 0), 'hostname' => $request->getClientIP(), 'session' => $value, 'timestamp' => REQUEST_TIME, - ); + ]; $this->connection->merge('sessions') - ->keys(array('sid' => Crypt::hashBase64($sid))) + ->keys(['sid' => Crypt::hashBase64($sid)]) ->fields($fields) ->execute(); return TRUE; diff --git a/core/lib/Drupal/Core/Session/SessionManager.php b/core/lib/Drupal/Core/Session/SessionManager.php index fcadf32..564ff65 100644 --- a/core/lib/Drupal/Core/Session/SessionManager.php +++ b/core/lib/Drupal/Core/Session/SessionManager.php @@ -83,7 +83,7 @@ class SessionManager extends NativeSessionStorage implements SessionManagerInter * @see \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage::setSaveHandler() */ public function __construct(RequestStack $request_stack, Connection $connection, MetadataBag $metadata_bag, SessionConfigurationInterface $session_configuration, $handler = NULL) { - $options = array(); + $options = []; $this->sessionConfiguration = $session_configuration; $this->requestStack = $request_stack; $this->connection = $connection; @@ -96,7 +96,7 @@ public function __construct(RequestStack $request_stack, Connection $connection, // https://www.drupal.org/node/2229145, when we will be using the Symfony // session object (which registers an attribute bag with the // manager upon instantiation). - $this->bags = array(); + $this->bags = []; } /** @@ -130,7 +130,7 @@ public function start() { $this->setId(Crypt::randomBytesBase64()); // Initialize the session global and attach the Symfony session bags. - $_SESSION = array(); + $_SESSION = []; $this->loadSession(); // NativeSessionStorage::loadSession() sets started to TRUE, reset it to @@ -304,7 +304,7 @@ protected function isSessionObsolete() { */ protected function getSessionDataMask() { if (empty($_SESSION)) { - return array(); + return []; } // Start out with a completely filled mask. @@ -329,7 +329,7 @@ protected function getSessionDataMask() { * The old session ID. The new session ID is $this->getId(). */ protected function migrateStoredSession($old_session_id) { - $fields = array('sid' => Crypt::hashBase64($this->getId())); + $fields = ['sid' => Crypt::hashBase64($this->getId())]; $this->connection->update('sessions') ->fields($fields) ->condition('sid', Crypt::hashBase64($old_session_id)) diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php index d4cdfe7..f25247d 100644 --- a/core/lib/Drupal/Core/Session/UserSession.php +++ b/core/lib/Drupal/Core/Session/UserSession.php @@ -23,7 +23,7 @@ class UserSession implements AccountInterface { * * @var array */ - protected $roles = array(AccountInterface::ANONYMOUS_ROLE); + protected $roles = [AccountInterface::ANONYMOUS_ROLE]; /** * The Unix timestamp when the user last accessed the site. @@ -73,7 +73,7 @@ class UserSession implements AccountInterface { * @param array $values * Array of initial values for the user session. */ - public function __construct(array $values = array()) { + public function __construct(array $values = []) { foreach ($values as $key => $value) { $this->$key = $value; } @@ -93,7 +93,7 @@ public function getRoles($exclude_locked_roles = FALSE) { $roles = $this->roles; if ($exclude_locked_roles) { - $roles = array_values(array_diff($roles, array(AccountInterface::ANONYMOUS_ROLE, AccountInterface::AUTHENTICATED_ROLE))); + $roles = array_values(array_diff($roles, [AccountInterface::ANONYMOUS_ROLE, AccountInterface::AUTHENTICATED_ROLE])); } return $roles; diff --git a/core/lib/Drupal/Core/Site/Settings.php b/core/lib/Drupal/Core/Site/Settings.php index 39a7e5a..c2e6e66 100644 --- a/core/lib/Drupal/Core/Site/Settings.php +++ b/core/lib/Drupal/Core/Site/Settings.php @@ -17,7 +17,7 @@ * * @var array */ - private $storage = array(); + private $storage = []; /** * Singleton instance. @@ -108,9 +108,9 @@ public static function getAll() { public static function initialize($app_root, $site_path, &$class_loader) { // Export these settings.php variables to the global namespace. global $config_directories, $config; - $settings = array(); - $config = array(); - $databases = array(); + $settings = []; + $config = []; + $databases = []; if (is_readable($app_root . '/' . $site_path . '/settings.php')) { require $app_root . '/' . $site_path . '/settings.php'; diff --git a/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php index 5208a2d..e3e4895 100644 --- a/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php +++ b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php @@ -73,7 +73,7 @@ public static function setSettingsOnRequest(Request $request, Settings $settings $forwarded_header = $settings->get('reverse_proxy_forwarded_header', 'FORWARDED'); $request::setTrustedHeaderName($request::HEADER_FORWARDED, $forwarded_header); - $proxies = $settings->get('reverse_proxy_addresses', array()); + $proxies = $settings->get('reverse_proxy_addresses', []); if (count($proxies) > 0) { $request::setTrustedProxies($proxies); } diff --git a/core/lib/Drupal/Core/State/State.php b/core/lib/Drupal/Core/State/State.php index a8ecb1e..0b70cbb 100644 --- a/core/lib/Drupal/Core/State/State.php +++ b/core/lib/Drupal/Core/State/State.php @@ -21,7 +21,7 @@ class State implements StateInterface { * * @var array */ - protected $cache = array(); + protected $cache = []; /** * Constructs a State object. @@ -37,7 +37,7 @@ function __construct(KeyValueFactoryInterface $key_value_factory) { * {@inheritdoc} */ public function get($key, $default = NULL) { - $values = $this->getMultiple(array($key)); + $values = $this->getMultiple([$key]); return isset($values[$key]) ? $values[$key] : $default; } @@ -45,8 +45,8 @@ public function get($key, $default = NULL) { * {@inheritdoc} */ public function getMultiple(array $keys) { - $values = array(); - $load = array(); + $values = []; + $load = []; foreach ($keys as $key) { // Check if we have a value in the cache. if (isset($this->cache[$key])) { @@ -98,7 +98,7 @@ public function setMultiple(array $data) { * {@inheritdoc} */ public function delete($key) { - $this->deleteMultiple(array($key)); + $this->deleteMultiple([$key]); } /** @@ -115,7 +115,7 @@ public function deleteMultiple(array $keys) { * {@inheritdoc} */ public function resetCache() { - $this->cache = array(); + $this->cache = []; } } diff --git a/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php b/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php index 55d896a..edcf4b7 100644 --- a/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/LocalReadOnlyStream.php @@ -26,7 +26,7 @@ public static function getType() { * {@inheritdoc} */ public function stream_open($uri, $mode, $options, &$opened_path) { - if (!in_array($mode, array('r', 'rb', 'rt'))) { + if (!in_array($mode, ['r', 'rb', 'rt'])) { if ($options & STREAM_REPORT_ERRORS) { trigger_error('stream_open() write modes not supported for read-only stream wrappers', E_USER_WARNING); } @@ -58,11 +58,11 @@ public function stream_open($uri, $mode, $options, &$opened_path) { */ public function stream_lock($operation) { // Disallow exclusive lock or non-blocking lock requests - if (in_array($operation, array(LOCK_EX, LOCK_EX | LOCK_NB))) { + if (in_array($operation, [LOCK_EX, LOCK_EX | LOCK_NB])) { trigger_error('stream_lock() exclusive lock operations not supported for read-only stream wrappers', E_USER_WARNING); return FALSE; } - if (in_array($operation, array(LOCK_SH, LOCK_UN, LOCK_SH | LOCK_NB))) { + if (in_array($operation, [LOCK_SH, LOCK_UN, LOCK_SH | LOCK_NB])) { return flock($this->handle, $operation); } diff --git a/core/lib/Drupal/Core/StreamWrapper/LocalStream.php b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php index 343b461..a6c8d2e 100644 --- a/core/lib/Drupal/Core/StreamWrapper/LocalStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php @@ -189,7 +189,7 @@ public function stream_open($uri, $mode, $options, &$opened_path) { * @see http://php.net/manual/streamwrapper.stream-lock.php */ public function stream_lock($operation) { - if (in_array($operation, array(LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB))) { + if (in_array($operation, [LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB])) { return flock($this->handle, $operation); } diff --git a/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php b/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php index 1b48910..e5538cc 100644 --- a/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php @@ -71,7 +71,7 @@ function getUri() { * @see http://php.net/manual/streamwrapper.stream-open.php */ public function stream_open($uri, $mode, $options, &$opened_path) { - if (!in_array($mode, array('r', 'rb', 'rt'))) { + if (!in_array($mode, ['r', 'rb', 'rt'])) { if ($options & STREAM_REPORT_ERRORS) { trigger_error('stream_open() write modes not supported for read-only stream wrappers', E_USER_WARNING); } @@ -111,11 +111,11 @@ public function stream_open($uri, $mode, $options, &$opened_path) { * @see http://php.net/manual/streamwrapper.stream-lock.php */ public function stream_lock($operation) { - if (in_array($operation, array(LOCK_EX, LOCK_EX | LOCK_NB))) { + if (in_array($operation, [LOCK_EX, LOCK_EX | LOCK_NB])) { trigger_error('stream_lock() exclusive lock operations not supported for read-only stream wrappers', E_USER_WARNING); return FALSE; } - if (in_array($operation, array(LOCK_SH, LOCK_UN, LOCK_SH | LOCK_NB))) { + if (in_array($operation, [LOCK_SH, LOCK_UN, LOCK_SH | LOCK_NB])) { return flock($this->handle, $operation); } diff --git a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php index 26b8eee..83310f6 100644 --- a/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php +++ b/core/lib/Drupal/Core/StreamWrapper/StreamWrapperManager.php @@ -23,7 +23,7 @@ class StreamWrapperManager implements ContainerAwareInterface, StreamWrapperMana * * @var array */ - protected $info = array(); + protected $info = []; /** * Contains collected stream wrappers. @@ -41,7 +41,7 @@ class StreamWrapperManager implements ContainerAwareInterface, StreamWrapperMana * * @var array */ - protected $wrappers = array(); + protected $wrappers = []; /** * {@inheritdoc} @@ -51,7 +51,7 @@ public function getWrappers($filter = StreamWrapperInterface::ALL) { return $this->wrappers[$filter]; } elseif (isset($this->wrappers[StreamWrapperInterface::ALL])) { - $this->wrappers[$filter] = array(); + $this->wrappers[$filter] = []; foreach ($this->wrappers[StreamWrapperInterface::ALL] as $scheme => $info) { // Bit-wise filter. if (($info['type'] & $filter) == $filter) { @@ -61,7 +61,7 @@ public function getWrappers($filter = StreamWrapperInterface::ALL) { return $this->wrappers[$filter]; } else { - return array(); + return []; } } @@ -69,7 +69,7 @@ public function getWrappers($filter = StreamWrapperInterface::ALL) { * {@inheritdoc} */ public function getNames($filter = StreamWrapperInterface::ALL) { - $names = array(); + $names = []; foreach (array_keys($this->getWrappers($filter)) as $scheme) { $names[$scheme] = $this->getViaScheme($scheme)->getName(); } @@ -81,7 +81,7 @@ public function getNames($filter = StreamWrapperInterface::ALL) { * {@inheritdoc} */ public function getDescriptions($filter = StreamWrapperInterface::ALL) { - $descriptions = array(); + $descriptions = []; foreach (array_keys($this->getWrappers($filter)) as $scheme) { $descriptions[$scheme] = $this->getViaScheme($scheme)->getDescription(); } @@ -149,11 +149,11 @@ protected function getWrapper($scheme, $uri) { * The scheme for which the wrapper should be registered. */ public function addStreamWrapper($service_id, $class, $scheme) { - $this->info[$scheme] = array( + $this->info[$scheme] = [ 'class' => $class, 'type' => $class::getType(), 'service_id' => $service_id, - ); + ]; } /** @@ -200,7 +200,7 @@ public function registerWrapper($scheme, $class, $type) { } // Pre-populate the static cache with the filters most typically used. - $info = array('type' => $type, 'class' => $class); + $info = ['type' => $type, 'class' => $class]; $this->wrappers[StreamWrapperInterface::ALL][$scheme] = $info; if (($type & StreamWrapperInterface::WRITE_VISIBLE) == StreamWrapperInterface::WRITE_VISIBLE) { diff --git a/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php b/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php index 89e602f..7cecf09 100644 --- a/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php +++ b/core/lib/Drupal/Core/StringTranslation/PluralTranslatableMarkup.php @@ -62,7 +62,7 @@ class PluralTranslatableMarkup extends TranslatableMarkup { */ public function __construct($count, $singular, $plural, array $args = [], array $options = [], TranslationInterface $string_translation = NULL) { $this->count = $count; - $translatable_string = implode(static::DELIMITER, array($singular, $plural)); + $translatable_string = implode(static::DELIMITER, [$singular, $plural]); parent::__construct($translatable_string, $args, $options, $string_translation); } diff --git a/core/lib/Drupal/Core/StringTranslation/StringTranslationTrait.php b/core/lib/Drupal/Core/StringTranslation/StringTranslationTrait.php index 63ff019..c435f79 100644 --- a/core/lib/Drupal/Core/StringTranslation/StringTranslationTrait.php +++ b/core/lib/Drupal/Core/StringTranslation/StringTranslationTrait.php @@ -67,7 +67,7 @@ * * @ingroup sanitization */ - protected function t($string, array $args = array(), array $options = array()) { + protected function t($string, array $args = [], array $options = []) { return new TranslatableMarkup($string, $args, $options, $this->getStringTranslation()); } @@ -76,7 +76,7 @@ protected function t($string, array $args = array(), array $options = array()) { * * @see \Drupal\Core\StringTranslation\TranslationInterface::formatPlural() */ - protected function formatPlural($count, $singular, $plural, array $args = array(), array $options = array()) { + protected function formatPlural($count, $singular, $plural, array $args = [], array $options = []) { return new PluralTranslatableMarkup($count, $singular, $plural, $args, $options, $this->getStringTranslation()); } diff --git a/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php b/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php index 8e3c13c..8016212 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php @@ -134,7 +134,7 @@ class TranslatableMarkup extends FormattableMarkup { * * @ingroup sanitization */ - public function __construct($string, array $arguments = array(), array $options = array(), TranslationInterface $string_translation = NULL) { + public function __construct($string, array $arguments = [], array $options = [], TranslationInterface $string_translation = NULL) { if (!is_string($string)) { $message = $string instanceof TranslatableMarkup ? '$string ("' . $string->getUntranslatedString() . '") must be a string.' : '$string ("' . (string) $string . '") must be a string.'; throw new \InvalidArgumentException($message); @@ -210,7 +210,7 @@ public function render() { * Magic __sleep() method to avoid serializing the string translator. */ public function __sleep() { - return array('string', 'arguments', 'options'); + return ['string', 'arguments', 'options']; } /** diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php index 8244302..6a977b4 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php @@ -45,7 +45,7 @@ * * @ingroup sanitization */ - public function translate($string, array $args = array(), array $options = array()); + public function translate($string, array $args = [], array $options = []); /** * Translates a TranslatableMarkup object to a string. @@ -107,6 +107,6 @@ public function translateString(TranslatableMarkup $translated_string); * @see \Drupal\Component\Utility\SafeMarkup::format() * @see \Drupal\Core\StringTranslation\PluralTranslatableMarkup::createFromTranslatedString() */ - public function formatPlural($count, $singular, $plural, array $args = array(), array $options = array()); + public function formatPlural($count, $singular, $plural, array $args = [], array $options = []); } diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php index ce96120..40bf8f4 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslationManager.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslationManager.php @@ -21,7 +21,7 @@ class TranslationManager implements TranslationInterface, TranslatorInterface { * @see \Drupal\Core\StringTranslation\TranslationManager::addTranslator() * @see \Drupal\Core\StringTranslation\TranslationManager::sortTranslators() */ - protected $translators = array(); + protected $translators = []; /** * An array of translators, sorted by priority. @@ -77,7 +77,7 @@ public function addTranslator(TranslatorInterface $translator, $priority = 0) { * A sorted array of translator objects. */ protected function sortTranslators() { - $sorted = array(); + $sorted = []; krsort($this->translators); foreach ($this->translators as $translators) { @@ -106,7 +106,7 @@ public function getStringTranslation($langcode, $string, $context) { /** * {@inheritdoc} */ - public function translate($string, array $args = array(), array $options = array()) { + public function translate($string, array $args = [], array $options = []) { return new TranslatableMarkup($string, $args, $options, $this); } @@ -131,7 +131,7 @@ public function translateString(TranslatableMarkup $translated_string) { * @return string * The translated string. */ - protected function doTranslate($string, array $options = array()) { + protected function doTranslate($string, array $options = []) { // If a NULL langcode has been provided, unset it. if (!isset($options['langcode']) && array_key_exists('langcode', $options)) { unset($options['langcode']); @@ -149,7 +149,7 @@ protected function doTranslate($string, array $options = array()) { /** * {@inheritdoc} */ - public function formatPlural($count, $singular, $plural, array $args = array(), array $options = array()) { + public function formatPlural($count, $singular, $plural, array $args = [], array $options = []) { return new PluralTranslatableMarkup($count, $singular, $plural, $args, $options, $this); } diff --git a/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php b/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php index 9d9a3b3..d018f1f 100644 --- a/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php +++ b/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php @@ -34,7 +34,7 @@ public function __construct(Settings $settings) { * {@inheritdoc} */ protected function getLanguage($langcode) { - return $this->settings->get('locale_custom_strings_' . $langcode, array()); + return $this->settings->get('locale_custom_strings_' . $langcode, []); } } diff --git a/core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php b/core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php index abe5e9a..deee5f4 100644 --- a/core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php +++ b/core/lib/Drupal/Core/StringTranslation/Translator/FileTranslation.php @@ -47,7 +47,7 @@ protected function getLanguage($langcode) { return $this->filesToArray($langcode, $files); } else { - return array(); + return []; } } @@ -70,7 +70,7 @@ protected function getLanguage($langcode) { * @see file_scan_directory() */ public function findTranslationFiles($langcode = NULL) { - $files = file_scan_directory($this->directory, $this->getTranslationFilesPattern($langcode), array('recurse' => FALSE)); + $files = file_scan_directory($this->directory, $this->getTranslationFilesPattern($langcode), ['recurse' => FALSE]); return $files; } diff --git a/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php b/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php index 375130f..15ee5c5 100644 --- a/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php +++ b/core/lib/Drupal/Core/StringTranslation/Translator/StaticTranslation.php @@ -23,7 +23,7 @@ class StaticTranslation implements TranslatorInterface { * @param array $translations * Array of override strings indexed by language and context */ - public function __construct($translations = array()) { + public function __construct($translations = []) { $this->translations = $translations; } @@ -46,7 +46,7 @@ public function getStringTranslation($langcode, $string, $context) { * {@inheritdoc} */ public function reset() { - $this->translations = array(); + $this->translations = []; } /** @@ -66,7 +66,7 @@ protected function getLanguage($langcode) { // constructor. This can be useful while testing, but it does not support // loading specific languages. All available languages should be passed // in the constructor array. - return array(); + return []; } } diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index 945c5bc..5449cde 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -69,7 +69,7 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { * * @var \Drupal\Core\Template\AttributeValueBase[] */ - protected $storage = array(); + protected $storage = []; /** * Constructs a \Drupal\Core\Template\Attribute object. @@ -77,7 +77,7 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface { * @param array $attributes * An associative array of key-value pairs to be converted to attributes. */ - public function __construct($attributes = array()) { + public function __construct($attributes = []) { foreach ($attributes as $name => $value) { $this->offsetSet($name, $value); } @@ -170,7 +170,7 @@ public function offsetExists($name) { public function addClass() { $args = func_get_args(); if ($args) { - $classes = array(); + $classes = []; foreach ($args as $arg) { // Merge the values passed in from the classes array. // The argument is cast to an array to support comma separated single @@ -245,7 +245,7 @@ public function removeClass() { // With no class attribute, there is no need to remove. if (isset($this->storage['class']) && $this->storage['class'] instanceof AttributeArray) { $args = func_get_args(); - $classes = array(); + $classes = []; foreach ($args as $arg) { // Merge the values passed in from the classes array. // The argument is cast to an array to support comma separated single diff --git a/core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php b/core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php index abd4ef2..3f727cf 100644 --- a/core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php +++ b/core/lib/Drupal/Core/Template/Loader/FilesystemLoader.php @@ -24,11 +24,11 @@ class FilesystemLoader extends \Twig_Loader_Filesystem { * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler * The theme handler service. */ - public function __construct($paths = array(), ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) { + public function __construct($paths = [], ModuleHandlerInterface $module_handler, ThemeHandlerInterface $theme_handler) { parent::__construct($paths); // Add namespaced paths for modules and themes. - $namespaces = array(); + $namespaces = []; foreach ($module_handler->getModuleList() as $name => $extension) { $namespaces[$name] = $extension->getPath(); } @@ -51,7 +51,7 @@ public function __construct($paths = array(), ModuleHandlerInterface $module_han */ public function addPath($path, $namespace = self::MAIN_NAMESPACE) { // Invalidate the cache. - $this->cache = array(); + $this->cache = []; $this->paths[$namespace][] = rtrim($path, '/\\'); } diff --git a/core/lib/Drupal/Core/Template/TwigEnvironment.php b/core/lib/Drupal/Core/Template/TwigEnvironment.php index fe391d8..5b75091 100644 --- a/core/lib/Drupal/Core/Template/TwigEnvironment.php +++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php @@ -37,19 +37,19 @@ class TwigEnvironment extends \Twig_Environment { * @param array $options * The options for the Twig environment. */ - public function __construct($root, CacheBackendInterface $cache, $twig_extension_hash, \Twig_LoaderInterface $loader = NULL, $options = array()) { + public function __construct($root, CacheBackendInterface $cache, $twig_extension_hash, \Twig_LoaderInterface $loader = NULL, $options = []) { // Ensure that twig.engine is loaded, given that it is needed to render a // template because functions like TwigExtension::escapeFilter() are called. require_once $root . '/core/themes/engines/twig/twig.engine'; - $this->templateClasses = array(); + $this->templateClasses = []; - $options += array( + $options += [ // @todo Ensure garbage collection of expired files. 'cache' => TRUE, 'debug' => FALSE, 'auto_reload' => NULL, - ); + ]; // Ensure autoescaping is always on. $options['autoescape'] = 'html'; @@ -110,7 +110,7 @@ public function getTemplateClass($name, $index = NULL) { * * @see \Drupal\Core\Template\Loader\StringLoader::exists() */ - public function renderInline($template_string, array $context = array()) { + public function renderInline($template_string, array $context = []) { // Prefix all inline templates with a special comment. $template_string = '{# inline_template_start #}' . $template_string; return Markup::create($this->loadTemplate($template_string, NULL)->render($context)); diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 3ebe01b..a6a24f7 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -122,12 +122,12 @@ public function setDateFormatter(DateFormatterInterface $date_formatter) { public function getFunctions() { return [ // This function will receive a renderable array, if an array is detected. - new \Twig_SimpleFunction('render_var', array($this, 'renderVar')), + new \Twig_SimpleFunction('render_var', [$this, 'renderVar']), // The url and path function are defined in close parallel to those found // in \Symfony\Bridge\Twig\Extension\RoutingExtension - new \Twig_SimpleFunction('url', array($this, 'getUrl'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))), - new \Twig_SimpleFunction('path', array($this, 'getPath'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))), - new \Twig_SimpleFunction('link', array($this, 'getLink')), + new \Twig_SimpleFunction('url', [$this, 'getUrl'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]), + new \Twig_SimpleFunction('path', [$this, 'getPath'], ['is_safe_callback' => [$this, 'isUrlGenerationSafe']]), + new \Twig_SimpleFunction('link', [$this, 'getLink']), new \Twig_SimpleFunction('file_url', function ($uri) { return file_url_transform_relative(file_create_url($uri)); }), @@ -141,19 +141,19 @@ public function getFunctions() { * {@inheritdoc} */ public function getFilters() { - return array( + return [ // Translation filters. - new \Twig_SimpleFilter('t', 't', array('is_safe' => array('html'))), - new \Twig_SimpleFilter('trans', 't', array('is_safe' => array('html'))), + new \Twig_SimpleFilter('t', 't', ['is_safe' => ['html']]), + new \Twig_SimpleFilter('trans', 't', ['is_safe' => ['html']]), // The "raw" filter is not detectable when parsing "trans" tags. To detect // which prefix must be used for translation (@, !, %), we must clone the // "raw" filter and give it identifiable names. These filters should only // be used in "trans" tags. // @see TwigNodeTrans::compileString() - new \Twig_SimpleFilter('placeholder', [$this, 'escapePlaceholder'], array('is_safe' => array('html'), 'needs_environment' => TRUE)), + new \Twig_SimpleFilter('placeholder', [$this, 'escapePlaceholder'], ['is_safe' => ['html'], 'needs_environment' => TRUE]), // Replace twig's escape filter with our own. - new \Twig_SimpleFilter('drupal_escape', [$this, 'escapeFilter'], array('needs_environment' => TRUE, 'is_safe_callback' => 'twig_escape_filter_is_safe')), + new \Twig_SimpleFilter('drupal_escape', [$this, 'escapeFilter'], ['needs_environment' => TRUE, 'is_safe_callback' => 'twig_escape_filter_is_safe']), // Implements safe joining. // @todo Make that the default for |join? Upstream issue: @@ -167,9 +167,9 @@ public function getFilters() { new \Twig_SimpleFilter('clean_class', '\Drupal\Component\Utility\Html::getClass'), new \Twig_SimpleFilter('clean_id', '\Drupal\Component\Utility\Html::getId'), // This filter will render a renderable array to use the string results. - new \Twig_SimpleFilter('render', array($this, 'renderVar')), - new \Twig_SimpleFilter('format_date', array($this->dateFormatter, 'format')), - ); + new \Twig_SimpleFilter('render', [$this, 'renderVar']), + new \Twig_SimpleFilter('format_date', [$this->dateFormatter, 'format']), + ]; } /** @@ -178,18 +178,18 @@ public function getFilters() { public function getNodeVisitors() { // The node visitor is needed to wrap all variables with // render_var -> TwigExtension->renderVar() function. - return array( + return [ new TwigNodeVisitor(), - ); + ]; } /** * {@inheritdoc} */ public function getTokenParsers() { - return array( + return [ new TwigTransTokenParser(), - ); + ]; } /** @@ -215,7 +215,7 @@ public function getName() { * * @see \Drupal\Core\Routing\UrlGeneratorInterface::generateFromRoute() */ - public function getPath($name, $parameters = array(), $options = array()) { + public function getPath($name, $parameters = [], $options = []) { $options['absolute'] = FALSE; return $this->urlGenerator->generateFromRoute($name, $parameters, $options); } @@ -236,7 +236,7 @@ public function getPath($name, $parameters = array(), $options = array()) { * * @todo Add an option for scheme-relative URLs. */ - public function getUrl($name, $parameters = array(), $options = array()) { + public function getUrl($name, $parameters = [], $options = []) { // Generate URL. $options['absolute'] = TRUE; $generated_url = $this->urlGenerator->generateFromRoute($name, $parameters, $options, TRUE); @@ -334,10 +334,10 @@ public function isUrlGenerationSafe(\Twig_Node $args_node) { if (!isset($parameter_node) || $parameter_node instanceof \Twig_Node_Expression_Array && count($parameter_node) <= 2 && (!$parameter_node->hasNode(1) || $parameter_node->getNode(1) instanceof \Twig_Node_Expression_Constant)) { - return array('html'); + return ['html']; } - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Template/TwigNodeTrans.php b/core/lib/Drupal/Core/Template/TwigNodeTrans.php index 21006fd..264a511 100644 --- a/core/lib/Drupal/Core/Template/TwigNodeTrans.php +++ b/core/lib/Drupal/Core/Template/TwigNodeTrans.php @@ -18,12 +18,12 @@ class TwigNodeTrans extends \Twig_Node { * {@inheritdoc} */ public function __construct(\Twig_Node $body, \Twig_Node $plural = NULL, \Twig_Node_Expression $count = NULL, \Twig_Node_Expression $options = NULL, $lineno, $tag = NULL) { - parent::__construct(array( + parent::__construct([ 'count' => $count, 'body' => $body, 'plural' => $plural, 'options' => $options, - ), array(), $lineno, $tag); + ], [], $lineno, $tag); } /** @@ -95,10 +95,10 @@ public function compile(\Twig_Compiler $compiler) { */ protected function compileString(\Twig_Node $body) { if ($body instanceof \Twig_Node_Expression_Name || $body instanceof \Twig_Node_Expression_Constant || $body instanceof \Twig_Node_Expression_TempName) { - return array($body, array()); + return [$body, []]; } - $tokens = array(); + $tokens = []; if (count($body)) { $text = ''; @@ -135,7 +135,7 @@ protected function compileString(\Twig_Node $body) { $args = $args->getNode('node'); } if ($args instanceof \Twig_Node_Expression_GetAttr) { - $argName = array(); + $argName = []; // Reuse the incoming expression. $expr = $args; // Assemble a valid argument name by walking through the expression. @@ -176,7 +176,7 @@ protected function compileString(\Twig_Node $body) { $text = $body->getAttribute('data'); } - return array(new \Twig_Node(array(new \Twig_Node_Expression_Constant(trim($text), $body->getLine()))), $tokens); + return [new \Twig_Node([new \Twig_Node_Expression_Constant(trim($text), $body->getLine())]), $tokens]; } } diff --git a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php index 6222d69..1ebfa57 100644 --- a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php +++ b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php @@ -35,7 +35,7 @@ protected function doLeaveNode(\Twig_Node $node, \Twig_Environment $env) { $class = get_class($node); $line = $node->getLine(); return new $class( - new \Twig_Node_Expression_Function('render_var', new \Twig_Node(array($node->getNode('expr'))), $line), + new \Twig_Node_Expression_Function('render_var', new \Twig_Node([$node->getNode('expr')]), $line), $line ); } diff --git a/core/lib/Drupal/Core/Template/TwigTransTokenParser.php b/core/lib/Drupal/Core/Template/TwigTransTokenParser.php index fb16017..96f5560 100644 --- a/core/lib/Drupal/Core/Template/TwigTransTokenParser.php +++ b/core/lib/Drupal/Core/Template/TwigTransTokenParser.php @@ -35,11 +35,11 @@ public function parse(\Twig_Token $token) { } if (!$body) { $stream->expect(\Twig_Token::BLOCK_END_TYPE); - $body = $this->parser->subparse(array($this, 'decideForFork')); + $body = $this->parser->subparse([$this, 'decideForFork']); if ('plural' === $stream->next()->getValue()) { $count = $this->parser->getExpressionParser()->parseExpression(); $stream->expect(\Twig_Token::BLOCK_END_TYPE); - $plural = $this->parser->subparse(array($this, 'decideForEnd'), TRUE); + $plural = $this->parser->subparse([$this, 'decideForEnd'], TRUE); } } @@ -56,7 +56,7 @@ public function parse(\Twig_Token $token) { * Detect a 'plural' switch or the end of a 'trans' tag. */ public function decideForFork($token) { - return $token->test(array('plural', 'endtrans')); + return $token->test(['plural', 'endtrans']); } /** diff --git a/core/lib/Drupal/Core/Test/TestRunnerKernel.php b/core/lib/Drupal/Core/Test/TestRunnerKernel.php index 6ab52b4..5260fdb 100644 --- a/core/lib/Drupal/Core/Test/TestRunnerKernel.php +++ b/core/lib/Drupal/Core/Test/TestRunnerKernel.php @@ -33,14 +33,14 @@ public function __construct($environment, $class_loader, $allow_dumping = FALSE, // \Drupal\Core\Datetime\DateFormatter has a (needless) dependency on the // 'date_format' entity, so calls to format_date()/format_interval() cause // a plugin not found exception. - $this->moduleList = array( + $this->moduleList = [ 'system' => 0, 'simpletest' => 0, - ); - $this->moduleData = array( + ]; + $this->moduleData = [ 'system' => new Extension($this->root, 'module', 'core/modules/system/system.info.yml', 'system.module'), 'simpletest' => new Extension($this->root, 'module', 'core/modules/simpletest/simpletest.info.yml', 'simpletest.module'), - ); + ]; } /** @@ -49,13 +49,13 @@ public function __construct($environment, $class_loader, $allow_dumping = FALSE, public function boot() { // Ensure that required Settings exist. if (!Settings::getAll()) { - new Settings(array( + new Settings([ 'hash_salt' => 'run-tests', 'container_yamls' => [], // If there is no settings.php, then there is no parent site. In turn, // there is no public files directory; use a custom public files path. 'file_public_path' => 'sites/default/files', - )); + ]); } // Remove Drupal's error/exception handlers; they are designed for HTML diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index d3f0455..4b3bcbe 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -239,7 +239,7 @@ public function get() { public function getRuntime() { $this->init($this->themeName); if (!isset($this->runtimeRegistry[$this->theme->getName()])) { - $this->runtimeRegistry[$this->theme->getName()] = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->cache, $this->lock, array('theme_registry'), $this->moduleHandler->isLoaded()); + $this->runtimeRegistry[$this->theme->getName()] = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->cache, $this->lock, ['theme_registry'], $this->moduleHandler->isLoaded()); } return $this->runtimeRegistry[$this->theme->getName()]; } @@ -248,7 +248,7 @@ public function getRuntime() { * Persists the theme registry in the cache backend. */ protected function setCache() { - $this->cache->set('theme_registry:' . $this->theme->getName(), $this->registry[$this->theme->getName()], Cache::PERMANENT, array('theme_registry')); + $this->cache->set('theme_registry:' . $this->theme->getName(), $this->registry[$this->theme->getName()], Cache::PERMANENT, ['theme_registry']); } /** @@ -310,7 +310,7 @@ public function getBaseHook($hook) { * @see hook_theme_registry_alter() */ protected function build() { - $cache = array(); + $cache = []; // First, preprocess the theme hooks advertised by modules. This will // serve as the basic registry. Since the list of enabled modules is the // same regardless of the theme used, this is cached in its own entry to @@ -324,7 +324,7 @@ protected function build() { } // Only cache this registry if all modules are loaded. if ($this->moduleHandler->isLoaded()) { - $this->cache->set("theme_registry:build:modules", $cache, Cache::PERMANENT, array('theme_registry')); + $this->cache->set("theme_registry:build:modules", $cache, Cache::PERMANENT, ['theme_registry']); } } @@ -418,14 +418,14 @@ protected function build() { * @throws \BadFunctionCallException */ protected function processExtension(array &$cache, $name, $type, $theme, $path) { - $result = array(); + $result = []; - $hook_defaults = array( + $hook_defaults = [ 'variables' => TRUE, 'render element' => TRUE, 'pattern' => TRUE, 'base hook' => TRUE, - ); + ]; $module_list = array_keys($this->moduleHandler->getModuleList()); @@ -509,8 +509,8 @@ protected function processExtension(array &$cache, $name, $type, $theme, $path) // Preprocess variables for all theming hooks, whether the hook is // implemented as a template or as a function. Ensure they are arrays. if (!isset($info['preprocess functions']) || !is_array($info['preprocess functions'])) { - $info['preprocess functions'] = array(); - $prefixes = array(); + $info['preprocess functions'] = []; + $prefixes = []; if ($type == 'module') { // Default variable preprocessor prefix. $prefixes[] = 'template'; @@ -568,7 +568,7 @@ protected function processExtension(array &$cache, $name, $type, $theme, $path) // Check only if not registered by the theme or engine. if (empty($result[$hook])) { if (!isset($info['preprocess functions'])) { - $cache[$hook]['preprocess functions'] = array(); + $cache[$hook]['preprocess functions'] = []; } // Only use non-hook-specific variable preprocessors for theme hooks // implemented as templates. See the @defgroup themeable topic. @@ -595,7 +595,7 @@ protected function processExtension(array &$cache, $name, $type, $theme, $path) */ protected function completeSuggestion($hook, array &$cache) { $previous_hook = $hook; - $incomplete_previous_hook = array(); + $incomplete_previous_hook = []; while ((!isset($cache[$previous_hook]) || isset($cache[$previous_hook]['incomplete preprocess functions'])) && $pos = strrpos($previous_hook, '__')) { if (isset($cache[$previous_hook]) && !$incomplete_previous_hook && isset($cache[$previous_hook]['incomplete preprocess functions'])) { @@ -728,7 +728,7 @@ public function reset() { $this->runtimeRegistry = []; $this->registry = []; - Cache::invalidateTags(array('theme_registry')); + Cache::invalidateTags(['theme_registry']); return $this; } diff --git a/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/core/lib/Drupal/Core/Theme/ThemeInitialization.php index bf58584..95ce5f3 100644 --- a/core/lib/Drupal/Core/Theme/ThemeInitialization.php +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php @@ -100,7 +100,7 @@ public function getActiveThemeByName($theme_name) { } // Find all our ancestor themes and put them in an array. - $base_themes = array(); + $base_themes = []; $ancestor = $theme_name; while ($ancestor && isset($themes[$ancestor]->base_theme)) { $ancestor = $themes[$ancestor]->base_theme; @@ -220,7 +220,7 @@ public function getActiveTheme(Extension $theme, array $base_themes = []) { } // Do basically the same as the above for libraries - $values['libraries'] = array(); + $values['libraries'] = []; // Grab libraries from base theme foreach ($base_themes as $base) { @@ -242,7 +242,7 @@ public function getActiveTheme(Extension $theme, array $base_themes = []) { $values['owner'] = isset($theme->owner) ? $theme->owner : NULL; $values['extension'] = $theme; - $base_active_themes = array(); + $base_active_themes = []; foreach ($base_themes as $base_theme) { $base_active_themes[$base_theme->getName()] = $this->getActiveTheme($base_theme, array_slice($base_themes, 1)); } @@ -310,7 +310,7 @@ protected function prepareStylesheetsRemove(Extension $theme, $base_themes) { // Prepare stylesheets from this theme as well as all ancestor themes. // We work it this way so that we can have child themes remove CSS files // easily from parent. - $stylesheets_remove = array(); + $stylesheets_remove = []; // Grab stylesheets from base theme. foreach ($base_themes as $base) { if (!empty($base->info['stylesheets-remove'])) { diff --git a/core/lib/Drupal/Core/Theme/ThemeManager.php b/core/lib/Drupal/Core/Theme/ThemeManager.php index ed18039..c58d176 100644 --- a/core/lib/Drupal/Core/Theme/ThemeManager.php +++ b/core/lib/Drupal/Core/Theme/ThemeManager.php @@ -171,7 +171,7 @@ public function render($hook, array $variables) { // Only log a message when not trying theme suggestions ($hook being an // array). if (!isset($candidate)) { - \Drupal::logger('theme')->warning('Theme hook %hook not found.', array('%hook' => $hook)); + \Drupal::logger('theme')->warning('Theme hook %hook not found.', ['%hook' => $hook]); } // There is no theme implementation for the hook passed. Return FALSE so // the function calling @@ -188,7 +188,7 @@ public function render($hook, array $variables) { // the arguments expected by the theme function. if (isset($variables['#theme']) || isset($variables['#theme_wrappers'])) { $element = $variables; - $variables = array(); + $variables = []; if (isset($info['variables'])) { foreach (array_keys($info['variables']) as $name) { if (isset($element["#$name"]) || array_key_exists("#$name", $element)) { @@ -208,12 +208,12 @@ public function render($hook, array $variables) { $variables += $info['variables']; } elseif (!empty($info['render element'])) { - $variables += array($info['render element'] => array()); + $variables += [$info['render element'] => []]; } // Supply original caller info. - $variables += array( + $variables += [ 'theme_hook_original' => $original_hook, - ); + ]; // Set base hook for later use. For example if '#theme' => 'node__article' // is called, we run hook_theme_suggestions_node_alter() rather than @@ -227,7 +227,7 @@ public function render($hook, array $variables) { } // Invoke hook_theme_suggestions_HOOK(). - $suggestions = $this->moduleHandler->invokeAll('theme_suggestions_' . $base_theme_hook, array($variables)); + $suggestions = $this->moduleHandler->invokeAll('theme_suggestions_' . $base_theme_hook, [$variables]); // If the theme implementation was invoked with a direct theme suggestion // like '#theme' => 'node__article', add it to the suggestions array before // invoking suggestion alter hooks. @@ -237,10 +237,10 @@ public function render($hook, array $variables) { // Invoke hook_theme_suggestions_alter() and // hook_theme_suggestions_HOOK_alter(). - $hooks = array( + $hooks = [ 'theme_suggestions', 'theme_suggestions_' . $base_theme_hook, - ); + ]; $this->moduleHandler->alter($hooks, $suggestions, $variables, $base_theme_hook); $this->alter($hooks, $suggestions, $variables, $base_theme_hook); @@ -347,14 +347,14 @@ public function render($hook, array $variables) { // intuitive, is reasonably safe, and allows us to save on the overhead of // adding some new variable to track that. if (!isset($variables['directory'])) { - $default_template_variables = array(); + $default_template_variables = []; template_preprocess($default_template_variables, $hook, $info); $variables += $default_template_variables; } if (!isset($default_attributes)) { $default_attributes = new Attribute(); } - foreach (array('attributes', 'title_attributes', 'content_attributes') as $key) { + foreach (['attributes', 'title_attributes', 'content_attributes'] as $key) { if (isset($variables[$key]) && !($variables[$key] instanceof Attribute)) { if ($variables[$key]) { $variables[$key] = new Attribute($variables[$key]); @@ -427,13 +427,13 @@ public function alterForTheme(ActiveTheme $theme, $type, &$data, &$context1 = NU } } - $theme_keys = array(); + $theme_keys = []; foreach ($theme->getBaseThemes() as $base) { $theme_keys[] = $base->getName(); } $theme_keys[] = $theme->getName(); - $functions = array(); + $functions = []; foreach ($theme_keys as $theme_key) { $function = $theme_key . '_' . $type . '_alter'; if (function_exists($function)) { diff --git a/core/lib/Drupal/Core/Theme/ThemeNegotiator.php b/core/lib/Drupal/Core/Theme/ThemeNegotiator.php index 1d6b589..65b09e2 100644 --- a/core/lib/Drupal/Core/Theme/ThemeNegotiator.php +++ b/core/lib/Drupal/Core/Theme/ThemeNegotiator.php @@ -17,7 +17,7 @@ class ThemeNegotiator implements ThemeNegotiatorInterface { * * @var array */ - protected $negotiators = array(); + protected $negotiators = []; /** * Holds the array of theme negotiators sorted by priority. @@ -71,7 +71,7 @@ protected function getSortedNegotiators() { krsort($this->negotiators); // Merge nested negotiators from $this->negotiators into // $this->sortedNegotiators. - $this->sortedNegotiators = array(); + $this->sortedNegotiators = []; foreach ($this->negotiators as $builders) { $this->sortedNegotiators = array_merge($this->sortedNegotiators, $builders); } diff --git a/core/lib/Drupal/Core/TypedData/DataDefinition.php b/core/lib/Drupal/Core/TypedData/DataDefinition.php index d0878ed..7eec1a9 100644 --- a/core/lib/Drupal/Core/TypedData/DataDefinition.php +++ b/core/lib/Drupal/Core/TypedData/DataDefinition.php @@ -12,7 +12,7 @@ class DataDefinition implements DataDefinitionInterface, \ArrayAccess { * * @var array */ - protected $definition = array(); + protected $definition = []; /** * Creates a new data definition. @@ -41,7 +41,7 @@ public static function createFromDataType($type) { * @param array $values * (optional) If given, an array of initial values to set on the definition. */ - public function __construct(array $values = array()) { + public function __construct(array $values = []) { $this->definition = $values; } @@ -213,7 +213,7 @@ public function setClass($class) { * {@inheritdoc} */ public function getSettings() { - return isset($this->definition['settings']) ? $this->definition['settings'] : array(); + return isset($this->definition['settings']) ? $this->definition['settings'] : []; } /** @@ -257,7 +257,7 @@ public function setSetting($setting_name, $value) { * {@inheritdoc} */ public function getConstraints() { - $constraints = isset($this->definition['constraints']) ? $this->definition['constraints'] : array(); + $constraints = isset($this->definition['constraints']) ? $this->definition['constraints'] : []; $constraints += \Drupal::typedDataManager()->getDefaultConstraints($this); return $constraints; } diff --git a/core/lib/Drupal/Core/TypedData/ListDataDefinition.php b/core/lib/Drupal/Core/TypedData/ListDataDefinition.php index 302f501..3109cd2 100644 --- a/core/lib/Drupal/Core/TypedData/ListDataDefinition.php +++ b/core/lib/Drupal/Core/TypedData/ListDataDefinition.php @@ -41,13 +41,13 @@ public static function createFromDataType($type) { * {@inheritdoc} */ public static function createFromItemType($item_type) { - return new static(array(), \Drupal::typedDataManager()->createDataDefinition($item_type)); + return new static([], \Drupal::typedDataManager()->createDataDefinition($item_type)); } /** * {@inheritdoc} */ - public function __construct(array $values = array(), DataDefinitionInterface $item_definition = NULL) { + public function __construct(array $values = [], DataDefinitionInterface $item_definition = NULL) { $this->definition = $values; $this->itemDefinition = $item_definition; } diff --git a/core/lib/Drupal/Core/TypedData/MapDataDefinition.php b/core/lib/Drupal/Core/TypedData/MapDataDefinition.php index 067a0f4..203e4a3 100644 --- a/core/lib/Drupal/Core/TypedData/MapDataDefinition.php +++ b/core/lib/Drupal/Core/TypedData/MapDataDefinition.php @@ -39,7 +39,7 @@ public static function createFromDataType($data_type) { */ public function getPropertyDefinitions() { if (!isset($this->propertyDefinitions)) { - $this->propertyDefinitions = array(); + $this->propertyDefinitions = []; } return $this->propertyDefinitions; } diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php index 7733427..4f756da 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php @@ -30,13 +30,13 @@ class ItemList extends TypedData implements \IteratorAggregate, ListInterface { * * @var \Drupal\Core\TypedData\TypedDataInterface[] */ - protected $list = array(); + protected $list = []; /** * {@inheritdoc} */ public function getValue() { - $values = array(); + $values = []; foreach ($this->list as $delta => $item) { $values[$delta] = $item->getValue(); } @@ -50,8 +50,8 @@ public function getValue() { * An array of values of the field items, or NULL to unset the field. */ public function setValue($values, $notify = TRUE) { - if (!isset($values) || $values === array()) { - $this->list = array(); + if (!isset($values) || $values === []) { + $this->list = []; } else { // Only arrays with numeric keys are supported. @@ -82,7 +82,7 @@ public function setValue($values, $notify = TRUE) { * {@inheritdoc} */ public function getString() { - $strings = array(); + $strings = []; foreach ($this->list as $item) { $strings[] = $item->getString(); } diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php index 3af3a6b..a95c14b 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php @@ -38,14 +38,14 @@ class Map extends TypedData implements \IteratorAggregate, ComplexDataInterface * * @var array */ - protected $values = array(); + protected $values = []; /** * The array of properties. * * @var \Drupal\Core\TypedData\TypedDataInterface[] */ - protected $properties = array(); + protected $properties = []; /** * {@inheritdoc} @@ -95,7 +95,7 @@ public function setValue($values, $notify = TRUE) { * {@inheritdoc} */ public function getString() { - $strings = array(); + $strings = []; foreach ($this->getProperties() as $property) { $strings[] = $property->getString(); } @@ -154,7 +154,7 @@ protected function writePropertyValue($property_name, $value) { * {@inheritdoc} */ public function getProperties($include_computed = FALSE) { - $properties = array(); + $properties = []; foreach ($this->definition->getPropertyDefinitions() as $name => $definition) { if ($include_computed || !$definition->isComputed()) { $properties[$name] = $this->get($name); @@ -167,7 +167,7 @@ public function getProperties($include_computed = FALSE) { * {@inheritdoc} */ public function toArray() { - $values = array(); + $values = []; foreach ($this->getProperties() as $name => $property) { $values[$name] = $property->getValue(); } diff --git a/core/lib/Drupal/Core/TypedData/TranslatableInterface.php b/core/lib/Drupal/Core/TypedData/TranslatableInterface.php index 5100e6e..5b57a87 100644 --- a/core/lib/Drupal/Core/TypedData/TranslatableInterface.php +++ b/core/lib/Drupal/Core/TypedData/TranslatableInterface.php @@ -95,7 +95,7 @@ public function hasTranslation($langcode); * @throws \InvalidArgumentException * If an invalid or existing translation language is specified. */ - public function addTranslation($langcode, array $values = array()); + public function addTranslation($langcode, array $values = []); /** * Removes the translation identified by the given language code. diff --git a/core/lib/Drupal/Core/TypedData/TypedData.php b/core/lib/Drupal/Core/TypedData/TypedData.php index 809d0e6..243d48a 100644 --- a/core/lib/Drupal/Core/TypedData/TypedData.php +++ b/core/lib/Drupal/Core/TypedData/TypedData.php @@ -121,7 +121,7 @@ public function getString() { */ public function getConstraints() { $constraint_manager = $this->getTypedDataManager()->getValidationConstraintManager(); - $constraints = array(); + $constraints = []; foreach ($this->definition->getConstraints() as $name => $options) { $constraints[] = $constraint_manager->create($name, $options); } diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManager.php b/core/lib/Drupal/Core/TypedData/TypedDataManager.php index 4904150..b7ca1f0 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManager.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManager.php @@ -40,7 +40,7 @@ class TypedDataManager extends DefaultPluginManager implements TypedDataManagerI * * @var array */ - protected $prototypes = array(); + protected $prototypes = []; /** * The class resolver. @@ -73,7 +73,7 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac /** * {@inheritdoc} */ - public function createInstance($data_type, array $configuration = array()) { + public function createInstance($data_type, array $configuration = []) { $data_definition = $configuration['data_definition']; $type_definition = $this->getDefinition($data_type); @@ -97,11 +97,11 @@ public function createInstance($data_type, array $configuration = array()) { * {@inheritdoc} */ public function create(DataDefinitionInterface $definition, $value = NULL, $name = NULL, $parent = NULL) { - $typed_data = $this->createInstance($definition->getDataType(), array( + $typed_data = $this->createInstance($definition->getDataType(), [ 'data_definition' => $definition, 'name' => $name, 'parent' => $parent, - )); + ]); if (isset($value)) { $typed_data->setValue($value, FALSE); } @@ -239,12 +239,12 @@ public function getValidationConstraintManager() { * {@inheritdoc} */ public function getDefaultConstraints(DataDefinitionInterface $definition) { - $constraints = array(); + $constraints = []; $type_definition = $this->getDefinition($definition->getDataType()); // Auto-generate a constraint for data types implementing a primitive // interface. if (is_subclass_of($type_definition['class'], '\Drupal\Core\TypedData\PrimitiveInterface')) { - $constraints['PrimitiveType'] = array(); + $constraints['PrimitiveType'] = []; } // Add in constraints specified by the data type. if (isset($type_definition['constraints'])) { @@ -252,11 +252,11 @@ public function getDefaultConstraints(DataDefinitionInterface $definition) { } // Add the NotNull constraint for required data. if ($definition->isRequired()) { - $constraints['NotNull'] = array(); + $constraints['NotNull'] = []; } // Check if the class provides allowed values. if (is_subclass_of($definition->getClass(), 'Drupal\Core\TypedData\OptionsProviderInterface')) { - $constraints['AllowedValues'] = array(); + $constraints['AllowedValues'] = []; } return $constraints; } @@ -266,7 +266,7 @@ public function getDefaultConstraints(DataDefinitionInterface $definition) { */ public function clearCachedDefinitions() { parent::clearCachedDefinitions(); - $this->prototypes = array(); + $this->prototypes = []; } /** diff --git a/core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php b/core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php index 16a910c..89c40dc 100644 --- a/core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php +++ b/core/lib/Drupal/Core/TypedData/TypedDataManagerInterface.php @@ -34,7 +34,7 @@ * * @see \Drupal\Core\TypedData\TypedDataManager::create() */ - public function createInstance($data_type, array $configuration = array()); + public function createInstance($data_type, array $configuration = []); /** * Creates a new typed data object instance. diff --git a/core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php b/core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php index a20fa52..c72cd55 100644 --- a/core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php +++ b/core/lib/Drupal/Core/TypedData/Validation/ExecutionContext.php @@ -96,14 +96,14 @@ class ExecutionContext implements ExecutionContextInterface { * * @var array */ - protected $validatedObjects = array(); + protected $validatedObjects = []; /** * Stores which class constraint has been validated for which object. * * @var array */ - protected $validatedConstraints = array(); + protected $validatedConstraints = []; /** * Creates a new ExecutionContext. @@ -155,7 +155,7 @@ public function setConstraint(Constraint $constraint) { /** * {@inheritdoc} */ - public function addViolation($message, array $parameters = array(), $invalidValue = NULL, $plural = NULL, $code = NULL) { + public function addViolation($message, array $parameters = [], $invalidValue = NULL, $plural = NULL, $code = NULL) { // The parameters $invalidValue and following are ignored by the new // API, as they are not present in the new interface anymore. // You should use buildViolation() instead. @@ -169,7 +169,7 @@ public function addViolation($message, array $parameters = array(), $invalidValu /** * {@inheritdoc} */ - public function buildViolation($message, array $parameters = array()) { + public function buildViolation($message, array $parameters = []) { return new ConstraintViolationBuilder($this->violations, $this->constraint, $message, $parameters, $this->root, $this->propertyPath, $this->value, $this->translator, $this->translationDomain); } @@ -246,7 +246,7 @@ public function getPropertyPath($sub_path = '') { /** * {@inheritdoc} */ - public function addViolationAt($subPath, $message, array $parameters = array(), $invalidValue = NULL, $plural = NULL, $code = NULL) { + public function addViolationAt($subPath, $message, array $parameters = [], $invalidValue = NULL, $plural = NULL, $code = NULL) { throw new \LogicException('Legacy validator API is unsupported.'); } diff --git a/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php b/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php index b765b05..a5d453a 100644 --- a/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php +++ b/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php @@ -93,7 +93,7 @@ public function validate($data, $constraints = NULL, $groups = NULL, $is_root_ca // You can pass a single constraint or an array of constraints. // Make sure to deal with an array in the rest of the code. if (isset($constraints) && !is_array($constraints)) { - $constraints = array($constraints); + $constraints = [$constraints]; } $this->validateNode($data, $constraints, $is_root_call); diff --git a/core/lib/Drupal/Core/Update/UpdateRegistry.php b/core/lib/Drupal/Core/Update/UpdateRegistry.php index 4d4bbf5..bb0b91f 100644 --- a/core/lib/Drupal/Core/Update/UpdateRegistry.php +++ b/core/lib/Drupal/Core/Update/UpdateRegistry.php @@ -187,7 +187,7 @@ public function getPendingUpdateInformation() { list($module, $update) = explode("_{$this->updateType}_", $function); // The description for an update comes from its Doxygen. $func = new \ReflectionFunction($function); - $description = trim(str_replace(array("\n", '*', '/'), '', $func->getDocComment()), ' '); + $description = trim(str_replace(["\n", '*', '/'], '', $func->getDocComment()), ' '); $ret[$module]['pending'][$update] = $description; if (!isset($ret[$module]['start'])) { $ret[$module]['start'] = $update; diff --git a/core/lib/Drupal/Core/Updater/Module.php b/core/lib/Drupal/Core/Updater/Module.php index be0d34b..0a244b4 100644 --- a/core/lib/Drupal/Core/Updater/Module.php +++ b/core/lib/Drupal/Core/Updater/Module.php @@ -49,7 +49,7 @@ public static function getRootDirectoryRelativePath() { public function isInstalled() { // Check if the module exists in the file system, regardless of whether it // is enabled or not. - $modules = \Drupal::state()->get('system.module.files', array()); + $modules = \Drupal::state()->get('system.module.files', []); return isset($modules[$this->name]); } @@ -84,12 +84,12 @@ public function getSchemaUpdates() { require_once DRUPAL_ROOT . '/core/includes/update.inc'; if (!self::canUpdate($this->name)) { - return array(); + return []; } module_load_include('install', $this->name); if (!$updates = drupal_get_schema_versions($this->name)) { - return array(); + return []; } $modules_with_updates = update_get_update_list(); if ($updates = $modules_with_updates[$this->name]) { @@ -97,7 +97,7 @@ public function getSchemaUpdates() { return $updates['pending']; } } - return array(); + return []; } /** diff --git a/core/lib/Drupal/Core/Updater/Theme.php b/core/lib/Drupal/Core/Updater/Theme.php index 48f68c7..d16af57 100644 --- a/core/lib/Drupal/Core/Updater/Theme.php +++ b/core/lib/Drupal/Core/Updater/Theme.php @@ -49,7 +49,7 @@ public static function getRootDirectoryRelativePath() { public function isInstalled() { // Check if the theme exists in the file system, regardless of whether it // is enabled or not. - $themes = \Drupal::state()->get('system.theme.files', array()); + $themes = \Drupal::state()->get('system.theme.files', []); return isset($themes[$this->name]); } diff --git a/core/lib/Drupal/Core/Updater/Updater.php b/core/lib/Drupal/Core/Updater/Updater.php index 0381728..a1ba103 100644 --- a/core/lib/Drupal/Core/Updater/Updater.php +++ b/core/lib/Drupal/Core/Updater/Updater.php @@ -86,7 +86,7 @@ public static function getUpdaterFromDirectory($directory) { $updaters = drupal_get_updaters(); foreach ($updaters as $updater) { $class = $updater['class']; - if (call_user_func(array($class, 'canUpdateDirectory'), $directory)) { + if (call_user_func([$class, 'canUpdateDirectory'], $directory)) { return $class; } } @@ -174,7 +174,7 @@ public static function getProjectTitle($directory) { $info_file = self::findInfoFile($directory); $info = \Drupal::service('info_parser')->parse($info_file); if (empty($info)) { - throw new UpdaterException(t('Unable to parse info file: %info_file.', array('%info_file' => $info_file))); + throw new UpdaterException(t('Unable to parse info file: %info_file.', ['%info_file' => $info_file])); } return $info['name']; } @@ -188,12 +188,12 @@ public static function getProjectTitle($directory) { * @return array * An array of configuration parameters for an update or install operation. */ - protected function getInstallArgs($overrides = array()) { - $args = array( + protected function getInstallArgs($overrides = []) { + $args = [ 'make_backup' => FALSE, 'install_dir' => $this->getInstallDirectory(), 'backup_dir' => $this->getBackupDir(), - ); + ]; return array_merge($args, $overrides); } @@ -212,7 +212,7 @@ protected function getInstallArgs($overrides = array()) { * @throws \Drupal\Core\Updater\UpdaterException * @throws \Drupal\Core\Updater\UpdaterFileTransferException */ - public function update(&$filetransfer, $overrides = array()) { + public function update(&$filetransfer, $overrides = []) { try { // Establish arguments with possible overrides. $args = $this->getInstallArgs($overrides); @@ -249,7 +249,7 @@ public function update(&$filetransfer, $overrides = array()) { return $this->postUpdateTasks(); } catch (FileTransferException $e) { - throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', array('@reason' => strtr($e->getMessage(), $e->arguments)))); + throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', ['@reason' => strtr($e->getMessage(), $e->arguments)])); } } @@ -266,7 +266,7 @@ public function update(&$filetransfer, $overrides = array()) { * * @throws \Drupal\Core\Updater\UpdaterFileTransferException */ - public function install(&$filetransfer, $overrides = array()) { + public function install(&$filetransfer, $overrides = []) { try { // Establish arguments with possible overrides. $args = $this->getInstallArgs($overrides); @@ -287,7 +287,7 @@ public function install(&$filetransfer, $overrides = array()) { return $this->postInstallTasks(); } catch (FileTransferException $e) { - throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', array('@reason' => strtr($e->getMessage(), $e->arguments)))); + throw new UpdaterFileTransferException(t('File Transfer failed, reason: @reason', ['@reason' => strtr($e->getMessage(), $e->arguments)])); } } @@ -326,7 +326,7 @@ public function prepareInstallDirectory(&$filetransfer, $directory) { } catch (FileTransferException $e) { $message = t($e->getMessage(), $e->arguments); - $throw_message = t('Unable to create %directory due to the following: %reason', array('%directory' => $directory, '%reason' => $message)); + $throw_message = t('Unable to create %directory due to the following: %reason', ['%directory' => $directory, '%reason' => $message]); throw new UpdaterException($throw_message); } } @@ -395,7 +395,7 @@ public function postInstall() { * Links which provide actions to take after the install is finished. */ public function postInstallTasks() { - return array(); + return []; } /** @@ -405,7 +405,7 @@ public function postInstallTasks() { * Links which provide actions to take after the update is finished. */ public function postUpdateTasks() { - return array(); + return []; } } diff --git a/core/lib/Drupal/Core/Url.php b/core/lib/Drupal/Core/Url.php index 6a58319..e4f571c 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -50,7 +50,7 @@ class Url { * * @var array */ - protected $routeParameters = array(); + protected $routeParameters = []; /** * The URL options. @@ -59,7 +59,7 @@ class Url { * * @var array */ - protected $options = array(); + protected $options = []; /** * Indicates whether this object contains an external URL. @@ -111,7 +111,7 @@ class Url { * @todo Update this documentation for non-routed URIs in * https://www.drupal.org/node/2346787 */ - public function __construct($route_name, $route_parameters = array(), $options = array()) { + public function __construct($route_name, $route_parameters = [], $options = []) { $this->routeName = $route_name; $this->routeParameters = $route_parameters; $this->options = $options; @@ -137,7 +137,7 @@ public function __construct($route_name, $route_parameters = array(), $options = * @see \Drupal\Core\Url::fromUserInput() * @see \Drupal\Core\Url::fromUri() */ - public static function fromRoute($route_name, $route_parameters = array(), $options = array()) { + public static function fromRoute($route_name, $route_parameters = [], $options = []) { return new static($route_name, $route_parameters, $options); } @@ -309,7 +309,7 @@ public static function fromUri($uri, $options = []) { $url = static::fromRouteUri($uri_parts, $uri_options, $uri); } else { - $url = new static($uri, array(), $options); + $url = new static($uri, [], $options); if ($uri_parts['scheme'] !== 'base') { $url->external = TRUE; $url->setOption('external', TRUE); @@ -493,7 +493,7 @@ protected function setUnrouted() { $this->uri = $this->routeName; // Set empty route name and parameters. $this->routeName = NULL; - $this->routeParameters = array(); + $this->routeParameters = []; return $this; } diff --git a/core/lib/Drupal/Core/Utility/Error.php b/core/lib/Drupal/Core/Utility/Error.php index 6105a59..eb452c2 100644 --- a/core/lib/Drupal/Core/Utility/Error.php +++ b/core/lib/Drupal/Core/Utility/Error.php @@ -23,7 +23,7 @@ class Error { * * @var array */ - protected static $blacklistFunctions = array('debug', '_drupal_error_handler', '_drupal_exception_handler'); + protected static $blacklistFunctions = ['debug', '_drupal_error_handler', '_drupal_exception_handler']; /** * Decodes an exception and retrieves the correct caller. @@ -39,7 +39,7 @@ public static function decodeException($exception) { $backtrace = $exception->getTrace(); // Add the line throwing the exception to the backtrace. - array_unshift($backtrace, array('line' => $exception->getLine(), 'file' => $exception->getFile())); + array_unshift($backtrace, ['line' => $exception->getLine(), 'file' => $exception->getFile()]); // For PDOException errors, we try to return the initial caller, // skipping internal functions of the database layer. @@ -47,7 +47,7 @@ public static function decodeException($exception) { // The first element in the stack is the call, the second element gives us // the caller. We skip calls that occurred in one of the classes of the // database layer or in one of its global functions. - $db_functions = array('db_query', 'db_query_range'); + $db_functions = ['db_query', 'db_query_range']; while (!empty($backtrace[1]) && ($caller = $backtrace[1]) && ((isset($caller['class']) && (strpos($caller['class'], 'Query') !== FALSE || strpos($caller['class'], 'Database') !== FALSE || strpos($caller['class'], 'PDO') !== FALSE)) || in_array($caller['function'], $db_functions))) { @@ -61,7 +61,7 @@ public static function decodeException($exception) { $caller = static::getLastCaller($backtrace); - return array( + return [ '%type' => get_class($exception), // The standard PHP exception handler considers that the exception message // is plain-text. We mimic this behavior here. @@ -72,7 +72,7 @@ public static function decodeException($exception) { 'severity_level' => static::ERROR, 'backtrace' => $backtrace, '@backtrace_string' => $exception->getTraceAsString(), - ); + ]; } /** @@ -152,7 +152,7 @@ public static function formatBacktrace(array $backtrace) { $return = ''; foreach ($backtrace as $trace) { - $call = array('function' => '', 'args' => array()); + $call = ['function' => '', 'args' => []]; if (isset($trace['class'])) { $call['function'] = $trace['class'] . $trace['type'] . $trace['function']; diff --git a/core/lib/Drupal/Core/Utility/LinkGenerator.php b/core/lib/Drupal/Core/Utility/LinkGenerator.php index 0ec5280..375167c 100644 --- a/core/lib/Drupal/Core/Utility/LinkGenerator.php +++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php @@ -85,20 +85,20 @@ public function generate($text, Url $url) { } // Start building a structured representation of our link to be altered later. - $variables = array( + $variables = [ 'text' => $text, 'url' => $url, 'options' => $url->getOptions(), - ); + ]; // Merge in default options. - $variables['options'] += array( - 'attributes' => array(), - 'query' => array(), + $variables['options'] += [ + 'attributes' => [], + 'query' => [], 'language' => NULL, 'set_active_class' => FALSE, 'absolute' => FALSE, - ); + ]; // Add a hreflang attribute if we know the language of this link's url and // hreflang has not already been set. @@ -145,7 +145,7 @@ public function generate($text, Url $url) { // Move attributes out of options since generateFromRoute() doesn't need // them. Make sure the "href" comes first for testing purposes. - $attributes = array('href' => '') + $variables['options']['attributes']; + $attributes = ['href' => ''] + $variables['options']['attributes']; unset($variables['options']['attributes']); $url->setOptions($variables['options']); diff --git a/core/lib/Drupal/Core/Utility/ProjectInfo.php b/core/lib/Drupal/Core/Utility/ProjectInfo.php index 1eed1fe..51d240e 100644 --- a/core/lib/Drupal/Core/Utility/ProjectInfo.php +++ b/core/lib/Drupal/Core/Utility/ProjectInfo.php @@ -39,7 +39,7 @@ class ProjectInfo { * (optional) Array of additional elements to be collected from the .info.yml * file. Defaults to array(). */ - function processInfoList(array &$projects, array $list, $project_type, $status, array $additional_whitelist = array()) { + function processInfoList(array &$projects, array $list, $project_type, $status, array $additional_whitelist = []) { foreach ($list as $file) { // Just projects with a matching status should be listed. if ($file->status != $status) { @@ -107,16 +107,16 @@ function processInfoList(array &$projects, array $list, $project_type, $status, if (!isset($projects[$project_name])) { // Only process this if we haven't done this project, since a single // project can have multiple modules or themes. - $projects[$project_name] = array( + $projects[$project_name] = [ 'name' => $project_name, // Only save attributes from the .info.yml file we care about so we do // not bloat our RAM usage needlessly. 'info' => $this->filterProjectInfo($file->info, $additional_whitelist), 'datestamp' => $file->info['datestamp'], - 'includes' => array($file->getName() => $file->info['name']), + 'includes' => [$file->getName() => $file->info['name']], 'project_type' => $project_display_type, 'project_status' => $status, - ); + ]; } elseif ($projects[$project_name]['project_type'] == $project_display_type) { // Only add the file we're processing to the 'includes' array for this @@ -174,8 +174,8 @@ function getProjectName(Extension $file) { * * @see \Drupal\Core\Utility\ProjectInfo->processInfoList() */ - function filterProjectInfo($info, $additional_whitelist = array()) { - $whitelist = array( + function filterProjectInfo($info, $additional_whitelist = []) { + $whitelist = [ '_info_file_ctime', 'datestamp', 'major', @@ -184,7 +184,7 @@ function filterProjectInfo($info, $additional_whitelist = array()) { 'project', 'project status url', 'version', - ); + ]; $whitelist = array_merge($whitelist, $additional_whitelist); return array_intersect_key($info, array_combine($whitelist, $whitelist)); } diff --git a/core/lib/Drupal/Core/Utility/ThemeRegistry.php b/core/lib/Drupal/Core/Utility/ThemeRegistry.php index 919571c..ca88347 100644 --- a/core/lib/Drupal/Core/Utility/ThemeRegistry.php +++ b/core/lib/Drupal/Core/Utility/ThemeRegistry.php @@ -46,7 +46,7 @@ class ThemeRegistry extends CacheCollector implements DestructableInterface { * @param bool $modules_loaded * Whether all modules have already been loaded. */ - function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, $tags = array(), $modules_loaded = FALSE) { + function __construct($cid, CacheBackendInterface $cache, LockBackendInterface $lock, $tags = [], $modules_loaded = FALSE) { $this->cid = $cid; $this->cache = $cache; $this->lock = $lock; @@ -136,7 +136,7 @@ protected function updateCache($lock = TRUE) { return; } // @todo: Is the custom implementation necessary? - $data = array(); + $data = []; foreach ($this->keysToPersist as $offset => $persist) { if ($persist) { $data[$offset] = $this->storage[$offset]; diff --git a/core/lib/Drupal/Core/Utility/Token.php b/core/lib/Drupal/Core/Utility/Token.php index 53432e8..2a7fd4a 100644 --- a/core/lib/Drupal/Core/Utility/Token.php +++ b/core/lib/Drupal/Core/Utility/Token.php @@ -182,7 +182,7 @@ public function __construct(ModuleHandlerInterface $module_handler, CacheBackend * otherwise for example the result can be put into #markup, in which case * it would be sanitized by Xss::filterAdmin(). */ - public function replace($text, array $data = array(), array $options = array(), BubbleableMetadata $bubbleable_metadata = NULL) { + public function replace($text, array $data = [], array $options = [], BubbleableMetadata $bubbleable_metadata = NULL) { $text_tokens = $this->scan($text); if (empty($text_tokens)) { return $text; @@ -191,7 +191,7 @@ public function replace($text, array $data = array(), array $options = array(), $bubbleable_metadata_is_passed_in = (bool) $bubbleable_metadata; $bubbleable_metadata = $bubbleable_metadata ?: new BubbleableMetadata(); - $replacements = array(); + $replacements = []; foreach ($text_tokens as $type => $tokens) { $replacements += $this->generate($type, $tokens, $data, $options, $bubbleable_metadata); if (!empty($options['clear'])) { @@ -251,7 +251,7 @@ public function scan($text) { // Iterate through the matches, building an associative array containing // $tokens grouped by $types, pointing to the version of the token found in // the source text. For example, $results['node']['title'] = '[node:title]'; - $results = array(); + $results = []; for ($i = 0; $i < count($tokens); $i++) { $results[$types[$i]][$tokens[$i]] = $matches[0][$i]; } @@ -304,12 +304,12 @@ public function generate($type, array $tokens, array $data, array $options, Bubb $replacements = $this->moduleHandler->invokeAll('tokens', [$type, $tokens, $data, $options, $bubbleable_metadata]); // Allow other modules to alter the replacements. - $context = array( + $context = [ 'type' => $type, 'tokens' => $tokens, 'data' => $data, 'options' => $options, - ); + ]; $this->moduleHandler->alter('tokens', $replacements, $context, $bubbleable_metadata); return $replacements; @@ -343,7 +343,7 @@ public function generate($type, array $tokens, array $data, array $options, Bubb * stripped from the key. */ public function findWithPrefix(array $tokens, $prefix, $delimiter = ':') { - $results = array(); + $results = []; foreach ($tokens as $token => $raw) { $parts = explode($delimiter, $token, 2); if (count($parts) == 2 && $parts[0] == $prefix) { @@ -376,9 +376,9 @@ public function getInfo() { else { $this->tokenInfo = $this->moduleHandler->invokeAll('token_info'); $this->moduleHandler->alter('token_info', $this->tokenInfo); - $this->cache->set($cache_id, $this->tokenInfo, CacheBackendInterface::CACHE_PERMANENT, array( + $this->cache->set($cache_id, $this->tokenInfo, CacheBackendInterface::CACHE_PERMANENT, [ static::TOKEN_INFO_CACHE_TAG, - )); + ]); } } diff --git a/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php b/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php index e0c0794..4422055 100644 --- a/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php +++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssemblerInterface.php @@ -52,6 +52,6 @@ * @throws \InvalidArgumentException * Thrown when the passed in path has no scheme. */ - public function assemble($uri, array $options = array(), $collect_bubbleable_metadata = FALSE); + public function assemble($uri, array $options = [], $collect_bubbleable_metadata = FALSE); } diff --git a/core/lib/Drupal/Core/Utility/token.api.php b/core/lib/Drupal/Core/Utility/token.api.php index 56d8f3a..54a5226 100644 --- a/core/lib/Drupal/Core/Utility/token.api.php +++ b/core/lib/Drupal/Core/Utility/token.api.php @@ -74,7 +74,7 @@ function hook_tokens($type, $tokens, array $data, array $options, \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata) { $token_service = \Drupal::token(); - $url_options = array('absolute' => TRUE); + $url_options = ['absolute' => TRUE]; if (isset($options['langcode'])) { $url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']); $langcode = $options['langcode']; @@ -82,7 +82,7 @@ function hook_tokens($type, $tokens, array $data, array $options, \Drupal\Core\R else { $langcode = NULL; } - $replacements = array(); + $replacements = []; if ($type == 'node' && !empty($data['node'])) { /** @var \Drupal\node\NodeInterface $node */ @@ -117,11 +117,11 @@ function hook_tokens($type, $tokens, array $data, array $options, \Drupal\Core\R } if ($author_tokens = $token_service->findWithPrefix($tokens, 'author')) { - $replacements = $token_service->generate('user', $author_tokens, array('user' => $node->getOwner()), $options, $bubbleable_metadata); + $replacements = $token_service->generate('user', $author_tokens, ['user' => $node->getOwner()], $options, $bubbleable_metadata); } if ($created_tokens = $token_service->findWithPrefix($tokens, 'created')) { - $replacements = $token_service->generate('date', $created_tokens, array('date' => $node->getCreatedTime()), $options, $bubbleable_metadata); + $replacements = $token_service->generate('date', $created_tokens, ['date' => $node->getCreatedTime()], $options, $bubbleable_metadata); } } @@ -219,39 +219,39 @@ function hook_tokens_alter(array &$replacements, array $context, \Drupal\Core\Re * @see hook_tokens() */ function hook_token_info() { - $type = array( + $type = [ 'name' => t('Nodes'), 'description' => t('Tokens related to individual nodes.'), 'needs-data' => 'node', - ); + ]; // Core tokens for nodes. - $node['nid'] = array( + $node['nid'] = [ 'name' => t("Node ID"), 'description' => t("The unique ID of the node."), - ); - $node['title'] = array( + ]; + $node['title'] = [ 'name' => t("Title"), - ); - $node['edit-url'] = array( + ]; + $node['edit-url'] = [ 'name' => t("Edit URL"), 'description' => t("The URL of the node's edit page."), - ); + ]; // Chained tokens for nodes. - $node['created'] = array( + $node['created'] = [ 'name' => t("Date created"), 'type' => 'date', - ); - $node['author'] = array( + ]; + $node['author'] = [ 'name' => t("Author"), 'type' => 'user', - ); + ]; - return array( - 'types' => array('node' => $type), - 'tokens' => array('node' => $node), - ); + return [ + 'types' => ['node' => $type], + 'tokens' => ['node' => $node], + ]; } /** @@ -264,21 +264,21 @@ function hook_token_info() { */ function hook_token_info_alter(&$data) { // Modify description of node tokens for our site. - $data['tokens']['node']['nid'] = array( + $data['tokens']['node']['nid'] = [ 'name' => t("Node ID"), 'description' => t("The unique ID of the article."), - ); - $data['tokens']['node']['title'] = array( + ]; + $data['tokens']['node']['title'] = [ 'name' => t("Title"), 'description' => t("The title of the article."), - ); + ]; // Chained tokens for nodes. - $data['tokens']['node']['created'] = array( + $data['tokens']['node']['created'] = [ 'name' => t("Date created"), 'description' => t("The date the article was posted."), 'type' => 'date', - ); + ]; } /** diff --git a/core/lib/Drupal/Core/Validation/ConstraintManager.php b/core/lib/Drupal/Core/Validation/ConstraintManager.php index 23bd7eb..a2bd604 100644 --- a/core/lib/Drupal/Core/Validation/ConstraintManager.php +++ b/core/lib/Drupal/Core/Validation/ConstraintManager.php @@ -74,7 +74,7 @@ public function create($name, $options) { // Plugins need an array as configuration, so make sure we have one. // The constraint classes support passing the options as part of the // 'value' key also. - $options = isset($options) ? array('value' => $options) : array(); + $options = isset($options) ? ['value' => $options] : []; } return $this->createInstance($name, $options); } @@ -85,26 +85,26 @@ public function create($name, $options) { * @see ConstraintManager::__construct() */ public function registerDefinitions() { - $this->getDiscovery()->setDefinition('Callback', array( + $this->getDiscovery()->setDefinition('Callback', [ 'label' => new TranslatableMarkup('Callback'), 'class' => '\Symfony\Component\Validator\Constraints\Callback', 'type' => FALSE, - )); - $this->getDiscovery()->setDefinition('Blank', array( + ]); + $this->getDiscovery()->setDefinition('Blank', [ 'label' => new TranslatableMarkup('Blank'), 'class' => '\Symfony\Component\Validator\Constraints\Blank', 'type' => FALSE, - )); - $this->getDiscovery()->setDefinition('NotBlank', array( + ]); + $this->getDiscovery()->setDefinition('NotBlank', [ 'label' => new TranslatableMarkup('Not blank'), 'class' => '\Symfony\Component\Validator\Constraints\NotBlank', 'type' => FALSE, - )); - $this->getDiscovery()->setDefinition('Email', array( + ]); + $this->getDiscovery()->setDefinition('Email', [ 'label' => new TranslatableMarkup('Email'), 'class' => '\Drupal\Core\Validation\Plugin\Validation\Constraint\EmailConstraint', - 'type' => array('string'), - )); + 'type' => ['string'], + ]); } /** @@ -113,7 +113,7 @@ public function registerDefinitions() { public function processDefinition(&$definition, $plugin_id) { // Make sure 'type' is set and either an array or FALSE. if ($definition['type'] !== FALSE && !is_array($definition['type'])) { - $definition['type'] = array($definition['type']); + $definition['type'] = [$definition['type']]; } } @@ -128,7 +128,7 @@ public function processDefinition(&$definition, $plugin_id) { * keyed by constraint name (plugin ID). */ public function getDefinitionsByType($type) { - $definitions = array(); + $definitions = []; foreach ($this->getDefinitions() as $plugin_id => $definition) { if ($definition['type'] === FALSE || in_array($type, $definition['type'])) { $definitions[$plugin_id] = $definition; diff --git a/core/lib/Drupal/Core/Validation/DrupalTranslator.php b/core/lib/Drupal/Core/Validation/DrupalTranslator.php index f00df20..505deca 100644 --- a/core/lib/Drupal/Core/Validation/DrupalTranslator.php +++ b/core/lib/Drupal/Core/Validation/DrupalTranslator.php @@ -22,7 +22,7 @@ class DrupalTranslator implements TranslatorInterface { /** * {@inheritdoc} */ - public function trans($id, array $parameters = array(), $domain = NULL, $locale = NULL) { + public function trans($id, array $parameters = [], $domain = NULL, $locale = NULL) { // If a TranslatableMarkup object is passed in as $id, return it since the // message has already been translated. return $id instanceof TranslatableMarkup ? $id : t($id, $this->processParameters($parameters), $this->getOptions($domain, $locale)); @@ -31,7 +31,7 @@ public function trans($id, array $parameters = array(), $domain = NULL, $locale /** * {@inheritdoc} */ - public function transChoice($id, $number, array $parameters = array(), $domain = NULL, $locale = NULL) { + public function transChoice($id, $number, array $parameters = [], $domain = NULL, $locale = NULL) { // Violation messages can separated singular and plural versions by "|". $ids = explode('|', $id); @@ -70,7 +70,7 @@ public function getLocale() { * Processes the parameters array for use with t(). */ protected function processParameters(array $parameters) { - $return = array(); + $return = []; foreach ($parameters as $key => $value) { // We allow the values in the parameters to be safe string objects. This // can be useful when we want to use parameter values that are @@ -101,7 +101,7 @@ protected function getOptions($domain = NULL, $locale = NULL) { // We do not support domains, so we ignore this parameter. // If locale is left NULL, t() will default to the interface language. $locale = isset($locale) ? $locale : $this->locale; - return array('langcode' => $locale); + return ['langcode' => $locale]; } } diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php index 5e7d0c7..a020cdc 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php @@ -29,7 +29,7 @@ class ComplexDataConstraint extends Constraint { public function __construct($options = NULL) { // Allow skipping the 'properties' key in the options. if (is_array($options) && !array_key_exists('properties', $options)) { - $options = array('properties' => $options); + $options = ['properties' => $options]; } parent::__construct($options); $constraint_manager = \Drupal::service('validation.constraint'); @@ -55,7 +55,7 @@ public function getDefaultOption() { * {@inheritdoc} */ public function getRequiredOptions() { - return array('properties'); + return ['properties']; } } diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php index 5829e39..f71e2e1 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php @@ -72,9 +72,9 @@ public function validate($value, Constraint $constraint) { if (!$valid) { // @todo: Provide a good violation message for each problem. - $this->context->addViolation($constraint->message, array( + $this->context->addViolation($constraint->message, [ '%value' => is_object($value) ? get_class($value) : (is_array($value) ? 'Array' : (string) $value) - )); + ]); } } diff --git a/core/modules/action/action.module b/core/modules/action/action.module index 7461302..5004a84 100644 --- a/core/modules/action/action.module +++ b/core/modules/action/action.module @@ -15,13 +15,13 @@ function action_help($route_name, RouteMatchInterface $route_match) { case 'help.page.action': $output = ''; $output .= '

    ' . t('About') . '

    '; - $output .= '

    ' . t('The Actions module provides tasks that can be executed by the site such as unpublishing content, sending email messages, or blocking a user. Other modules can trigger these actions when specific system events happen; for example, when new content is posted or when a user logs in. Modules can also provide additional actions. For more information, see the online documentation for the Actions module.', array(':documentation' => 'https://www.drupal.org/documentation/modules/action')) . '

    '; + $output .= '

    ' . t('The Actions module provides tasks that can be executed by the site such as unpublishing content, sending email messages, or blocking a user. Other modules can trigger these actions when specific system events happen; for example, when new content is posted or when a user logs in. Modules can also provide additional actions. For more information, see the online documentation for the Actions module.', [':documentation' => 'https://www.drupal.org/documentation/modules/action']) . '

    '; $output .= '

    ' . t('Uses') . '

    '; $output .= '
    '; $output .= '
    ' . t('Using simple actions') . '
    '; - $output .= '
    ' . t('Simple actions do not require configuration and are listed automatically as available on the Actions page.', array(':actions' => \Drupal::url('entity.action.collection'))) . '
    '; + $output .= '
    ' . t('Simple actions do not require configuration and are listed automatically as available on the Actions page.', [':actions' => \Drupal::url('entity.action.collection')]) . '
    '; $output .= '
    ' . t('Creating and configuring advanced actions') . '
    '; - $output .= '
    ' . t('Advanced actions are user-created and have to be configured individually. Create an advanced action on the Actions page by selecting an action type from the drop-down list. Then configure your action, for example by specifying the recipient of an automated email message.', array(':actions' => \Drupal::url('entity.action.collection'))) . '
    '; + $output .= '
    ' . t('Advanced actions are user-created and have to be configured individually. Create an advanced action on the Actions page by selecting an action type from the drop-down list. Then configure your action, for example by specifying the recipient of an automated email message.', [':actions' => \Drupal::url('entity.action.collection')]) . '
    '; $output .= '
    '; return $output; diff --git a/core/modules/action/action.views_execution.inc b/core/modules/action/action.views_execution.inc index 5b4f71f..71b8eeb 100644 --- a/core/modules/action/action.views_execution.inc +++ b/core/modules/action/action.views_execution.inc @@ -9,12 +9,12 @@ * Implements hook_views_form_substitutions(). */ function action_views_form_substitutions() { - $select_all = array( + $select_all = [ '#type' => 'checkbox', '#default_value' => FALSE, - '#attributes' => array('class' => array('action-table-select-all')), - ); - return array( + '#attributes' => ['class' => ['action-table-select-all']], + ]; + return [ '' => drupal_render($select_all), - ); + ]; } diff --git a/core/modules/action/src/ActionFormBase.php b/core/modules/action/src/ActionFormBase.php index 7a5746a..3fafd03 100644 --- a/core/modules/action/src/ActionFormBase.php +++ b/core/modules/action/src/ActionFormBase.php @@ -58,32 +58,32 @@ public function buildForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function form(array $form, FormStateInterface $form_state) { - $form['label'] = array( + $form['label'] = [ '#type' => 'textfield', '#title' => $this->t('Label'), '#default_value' => $this->entity->label(), '#maxlength' => '255', '#description' => $this->t('A unique label for this advanced action. This label will be displayed in the interface of modules that integrate with actions.'), - ); + ]; - $form['id'] = array( + $form['id'] = [ '#type' => 'machine_name', '#default_value' => $this->entity->id(), '#disabled' => !$this->entity->isNew(), '#maxlength' => 64, '#description' => $this->t('A unique name for this action. It must only contain lowercase letters, numbers and underscores.'), - '#machine_name' => array( - 'exists' => array($this, 'exists'), - ), - ); - $form['plugin'] = array( + '#machine_name' => [ + 'exists' => [$this, 'exists'], + ], + ]; + $form['plugin'] = [ '#type' => 'value', '#value' => $this->entity->get('plugin'), - ); - $form['type'] = array( + ]; + $form['type'] = [ '#type' => 'value', '#value' => $this->entity->getType(), - ); + ]; if ($this->plugin instanceof PluginFormInterface) { $form += $this->plugin->buildConfigurationForm($form, $form_state); diff --git a/core/modules/action/src/ActionListBuilder.php b/core/modules/action/src/ActionListBuilder.php index 0902403..2ae78d2 100644 --- a/core/modules/action/src/ActionListBuilder.php +++ b/core/modules/action/src/ActionListBuilder.php @@ -86,10 +86,10 @@ public function buildRow(EntityInterface $entity) { * {@inheritdoc} */ public function buildHeader() { - $header = array( + $header = [ 'type' => t('Action type'), 'label' => t('Label'), - ) + parent::buildHeader(); + ] + parent::buildHeader(); return $header; } @@ -97,7 +97,7 @@ public function buildHeader() { * {@inheritdoc} */ public function getDefaultOperations(EntityInterface $entity) { - $operations = $entity->isConfigurable() ? parent::getDefaultOperations($entity) : array(); + $operations = $entity->isConfigurable() ? parent::getDefaultOperations($entity) : []; if (isset($operations['edit'])) { $operations['edit']['title'] = t('Configure'); } diff --git a/core/modules/action/src/Form/ActionAdminManageForm.php b/core/modules/action/src/Form/ActionAdminManageForm.php index de48755..478e919 100644 --- a/core/modules/action/src/Form/ActionAdminManageForm.php +++ b/core/modules/action/src/Form/ActionAdminManageForm.php @@ -50,33 +50,33 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $actions = array(); + $actions = []; foreach ($this->manager->getDefinitions() as $id => $definition) { if (is_subclass_of($definition['class'], '\Drupal\Core\Plugin\PluginFormInterface')) { $key = Crypt::hashBase64($id); $actions[$key] = $definition['label'] . '...'; } } - $form['parent'] = array( + $form['parent'] = [ '#type' => 'details', '#title' => $this->t('Create an advanced action'), - '#attributes' => array('class' => array('container-inline')), + '#attributes' => ['class' => ['container-inline']], '#open' => TRUE, - ); - $form['parent']['action'] = array( + ]; + $form['parent']['action'] = [ '#type' => 'select', '#title' => $this->t('Action'), '#title_display' => 'invisible', '#options' => $actions, '#empty_option' => $this->t('Choose an advanced action'), - ); - $form['parent']['actions'] = array( + ]; + $form['parent']['actions'] = [ '#type' => 'actions' - ); - $form['parent']['actions']['submit'] = array( + ]; + $form['parent']['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Create'), - ); + ]; return $form; } @@ -87,7 +87,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state->getValue('action')) { $form_state->setRedirect( 'action.admin_add', - array('action_id' => $form_state->getValue('action')) + ['action_id' => $form_state->getValue('action')] ); } } diff --git a/core/modules/action/src/Plugin/Action/EmailAction.php b/core/modules/action/src/Plugin/Action/EmailAction.php index 1ee6184..e3845a6 100644 --- a/core/modules/action/src/Plugin/Action/EmailAction.php +++ b/core/modules/action/src/Plugin/Action/EmailAction.php @@ -129,7 +129,7 @@ public function execute($entity = NULL) { // If the recipient is a registered user with a language preference, use // the recipient's preferred language. Otherwise, use the system default // language. - $recipient_accounts = $this->storage->loadByProperties(array('mail' => $recipient)); + $recipient_accounts = $this->storage->loadByProperties(['mail' => $recipient]); $recipient_account = reset($recipient_accounts); if ($recipient_account) { $langcode = $recipient_account->getPreferredLangcode(); @@ -137,13 +137,13 @@ public function execute($entity = NULL) { else { $langcode = $this->languageManager->getDefaultLanguage()->getId(); } - $params = array('context' => $this->configuration); + $params = ['context' => $this->configuration]; if ($this->mailManager->mail('system', 'action_send_email', $recipient, $langcode, $params)) { - $this->logger->notice('Sent email to %recipient', array('%recipient' => $recipient)); + $this->logger->notice('Sent email to %recipient', ['%recipient' => $recipient]); } else { - $this->logger->error('Unable to send email to %recipient', array('%recipient' => $recipient)); + $this->logger->error('Unable to send email to %recipient', ['%recipient' => $recipient]); } } @@ -151,39 +151,39 @@ public function execute($entity = NULL) { * {@inheritdoc} */ public function defaultConfiguration() { - return array( + return [ 'recipient' => '', 'subject' => '', 'message' => '', - ); + ]; } /** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form['recipient'] = array( + $form['recipient'] = [ '#type' => 'textfield', '#title' => t('Recipient'), '#default_value' => $this->configuration['recipient'], '#maxlength' => '254', '#description' => t('The email address to which the message should be sent OR enter [node:author:mail], [comment:author:mail], etc. if you would like to send an email to the author of the original post.'), - ); - $form['subject'] = array( + ]; + $form['subject'] = [ '#type' => 'textfield', '#title' => t('Subject'), '#default_value' => $this->configuration['subject'], '#maxlength' => '254', '#description' => t('The subject of the message.'), - ); - $form['message'] = array( + ]; + $form['message'] = [ '#type' => 'textarea', '#title' => t('Message'), '#default_value' => $this->configuration['message'], '#cols' => '80', '#rows' => '20', '#description' => t('The message that should be sent. You may include placeholders like [node:title], [user:account-name], [user:display-name] and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'), - ); + ]; return $form; } @@ -193,7 +193,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { if (!$this->emailValidator->isValid($form_state->getValue('recipient')) && strpos($form_state->getValue('recipient'), ':mail') === FALSE) { // We want the literal %author placeholder to be emphasized in the error message. - $form_state->setErrorByName('recipient', t('Enter a valid email address or use a token email address such as %author.', array('%author' => '[node:author:mail]'))); + $form_state->setErrorByName('recipient', t('Enter a valid email address or use a token email address such as %author.', ['%author' => '[node:author:mail]'])); } } diff --git a/core/modules/action/src/Plugin/Action/GotoAction.php b/core/modules/action/src/Plugin/Action/GotoAction.php index 5c1b552..44e871b 100644 --- a/core/modules/action/src/Plugin/Action/GotoAction.php +++ b/core/modules/action/src/Plugin/Action/GotoAction.php @@ -103,22 +103,22 @@ public function execute($object = NULL) { * {@inheritdoc} */ public function defaultConfiguration() { - return array( + return [ 'url' => '', - ); + ]; } /** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form['url'] = array( + $form['url'] = [ '#type' => 'textfield', '#title' => t('URL'), - '#description' => t('The URL to which the user should be redirected. This can be an internal URL like /node/1234 or an external URL like @url.', array('@url' => 'http://example.com')), + '#description' => t('The URL to which the user should be redirected. This can be an internal URL like /node/1234 or an external URL like @url.', ['@url' => 'http://example.com']), '#default_value' => $this->configuration['url'], '#required' => TRUE, - ); + ]; return $form; } diff --git a/core/modules/action/src/Plugin/Action/MessageAction.php b/core/modules/action/src/Plugin/Action/MessageAction.php index ab32b4c..c85d249 100644 --- a/core/modules/action/src/Plugin/Action/MessageAction.php +++ b/core/modules/action/src/Plugin/Action/MessageAction.php @@ -84,23 +84,23 @@ public function execute($entity = NULL) { * {@inheritdoc} */ public function defaultConfiguration() { - return array( + return [ 'message' => '', - ); + ]; } /** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form['message'] = array( + $form['message'] = [ '#type' => 'textarea', '#title' => t('Message'), '#default_value' => $this->configuration['message'], '#required' => TRUE, '#rows' => '8', '#description' => t('The message to be displayed to the current user. You may include placeholders like [node:title], [user:account-name], [user:display-name] and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'), - ); + ]; return $form; } diff --git a/core/modules/action/src/Plugin/migrate/source/Action.php b/core/modules/action/src/Plugin/migrate/source/Action.php index e983b00..ac14a44 100644 --- a/core/modules/action/src/Plugin/migrate/source/Action.php +++ b/core/modules/action/src/Plugin/migrate/source/Action.php @@ -27,12 +27,12 @@ public function query() { * {@inheritdoc} */ public function fields() { - $fields = array( + $fields = [ 'aid' => $this->t('Action ID'), 'type' => $this->t('Module'), 'callback' => $this->t('Callback function'), 'parameters' => $this->t('Action configuration'), - ); + ]; if ($this->getModuleSchemaVersion('system') >= 7000) { $fields['label'] = $this->t('Label of the action'); } diff --git a/core/modules/action/tests/src/Functional/ActionUninstallTest.php b/core/modules/action/tests/src/Functional/ActionUninstallTest.php index 93e0bc0..6b52643 100644 --- a/core/modules/action/tests/src/Functional/ActionUninstallTest.php +++ b/core/modules/action/tests/src/Functional/ActionUninstallTest.php @@ -17,19 +17,19 @@ class ActionUninstallTest extends BrowserTestBase { * * @var array */ - public static $modules = array('views', 'action'); + public static $modules = ['views', 'action']; /** * Tests Action uninstall. */ public function testActionUninstall() { - \Drupal::service('module_installer')->uninstall(array('action')); + \Drupal::service('module_installer')->uninstall(['action']); $storage = $this->container->get('entity_type.manager')->getStorage('action'); $storage->resetCache(['user_block_user_action']); $this->assertTrue($storage->load('user_block_user_action'), 'Configuration entity \'user_block_user_action\' still exists after uninstalling action module.' ); - $admin_user = $this->drupalCreateUser(array('administer users')); + $admin_user = $this->drupalCreateUser(['administer users']); $this->drupalLogin($admin_user); $this->drupalGet('admin/people'); diff --git a/core/modules/action/tests/src/Functional/BulkFormTest.php b/core/modules/action/tests/src/Functional/BulkFormTest.php index 7d32b94..439ffe4 100644 --- a/core/modules/action/tests/src/Functional/BulkFormTest.php +++ b/core/modules/action/tests/src/Functional/BulkFormTest.php @@ -18,7 +18,7 @@ class BulkFormTest extends BrowserTestBase { * * @var array */ - public static $modules = array('node', 'action_bulk_test'); + public static $modules = ['node', 'action_bulk_test']; /** * Tests the bulk form. @@ -31,30 +31,30 @@ public function testBulkForm() { $this->drupalGet('test_bulk_form_empty'); $this->assertText(t('This view is empty.'), 'Empty text found on empty bulk form.'); - $nodes = array(); + $nodes = []; for ($i = 0; $i < 10; $i++) { // Ensure nodes are sorted in the same order they are inserted in the // array. $timestamp = REQUEST_TIME - $i; - $nodes[] = $this->drupalCreateNode(array( + $nodes[] = $this->drupalCreateNode([ 'sticky' => FALSE, 'created' => $timestamp, 'changed' => $timestamp, - )); + ]); } $this->drupalGet('test_bulk_form'); // Test that the views edit header appears first. - $first_form_element = $this->xpath('//form/div[1][@id = :id]', array(':id' => 'edit-header')); + $first_form_element = $this->xpath('//form/div[1][@id = :id]', [':id' => 'edit-header']); $this->assertTrue($first_form_element, 'The views form edit header appears first.'); $this->assertFieldById('edit-action', NULL, 'The action select field appears.'); // Make sure a checkbox appears on all rows. - $edit = array(); + $edit = []; for ($i = 0; $i < 10; $i++) { - $this->assertFieldById('edit-node-bulk-form-' . $i, NULL, format_string('The checkbox on row @row appears.', array('@row' => $i))); + $this->assertFieldById('edit-node-bulk-form-' . $i, NULL, format_string('The checkbox on row @row appears.', ['@row' => $i])); $edit["node_bulk_form[$i]"] = TRUE; } @@ -67,12 +67,12 @@ public function testBulkForm() { $this->drupalGet('test_bulk_form'); // Set all nodes to sticky and check that. - $edit += array('action' => 'node_make_sticky_action'); + $edit += ['action' => 'node_make_sticky_action']; $this->drupalPostForm(NULL, $edit, t('Apply to selected items')); foreach ($nodes as $node) { $changed_node = $node_storage->load($node->id()); - $this->assertTrue($changed_node->isSticky(), format_string('Node @nid got marked as sticky.', array('@nid' => $node->id()))); + $this->assertTrue($changed_node->isSticky(), format_string('Node @nid got marked as sticky.', ['@nid' => $node->id()])); } $this->assertText('Make content sticky was applied to 10 items.'); @@ -81,18 +81,18 @@ public function testBulkForm() { $node = $node_storage->load($nodes[0]->id()); $this->assertTrue($node->isPublished(), 'The node is published.'); - $edit = array('node_bulk_form[0]' => TRUE, 'action' => 'node_unpublish_action'); + $edit = ['node_bulk_form[0]' => TRUE, 'action' => 'node_unpublish_action']; $this->drupalPostForm(NULL, $edit, t('Apply to selected items')); $this->assertText('Unpublish content was applied to 1 item.'); // Load the node again. - $node_storage->resetCache(array($node->id())); + $node_storage->resetCache([$node->id()]); $node = $node_storage->load($node->id()); $this->assertFalse($node->isPublished(), 'A single node has been unpublished.'); // The second node should still be published. - $node_storage->resetCache(array($nodes[1]->id())); + $node_storage->resetCache([$nodes[1]->id()]); $node = $node_storage->load($nodes[1]->id()); $this->assertTrue($node->isPublished(), 'An unchecked node is still published.'); @@ -105,7 +105,7 @@ public function testBulkForm() { $view->save(); $this->drupalGet('test_bulk_form'); - $options = $this->xpath('//select[@id=:id]/option', array(':id' => 'edit-action')); + $options = $this->xpath('//select[@id=:id]/option', [':id' => 'edit-action']); $this->assertEqual(count($options), 2); $this->assertOption('edit-action', 'node_make_sticky_action'); $this->assertOption('edit-action', 'node_make_unsticky_action'); @@ -137,17 +137,17 @@ public function testBulkForm() { $this->drupalGet('test_bulk_form'); // Call the node delete action. - $edit = array(); + $edit = []; for ($i = 0; $i < 5; $i++) { $edit["node_bulk_form[$i]"] = TRUE; } - $edit += array('action' => 'node_delete_action'); + $edit += ['action' => 'node_delete_action']; $this->drupalPostForm(NULL, $edit, t('Apply to selected items')); // Make sure we don't show an action message while we are still on the // confirmation page. $errors = $this->xpath('//div[contains(@class, "messages--status")]'); $this->assertFalse($errors, 'No action message shown.'); - $this->drupalPostForm(NULL, array(), t('Delete')); + $this->drupalPostForm(NULL, [], t('Delete')); $this->assertText(t('Deleted 5 posts.')); // Check if we got redirected to the original page. $this->assertUrl('test_bulk_form'); diff --git a/core/modules/action/tests/src/Functional/ConfigurationTest.php b/core/modules/action/tests/src/Functional/ConfigurationTest.php index 23d0a38..063e4a8 100644 --- a/core/modules/action/tests/src/Functional/ConfigurationTest.php +++ b/core/modules/action/tests/src/Functional/ConfigurationTest.php @@ -19,24 +19,24 @@ class ConfigurationTest extends BrowserTestBase { * * @var array */ - public static $modules = array('action'); + public static $modules = ['action']; /** * Tests configuration of advanced actions through administration interface. */ function testActionConfiguration() { // Create a user with permission to view the actions administration pages. - $user = $this->drupalCreateUser(array('administer actions')); + $user = $this->drupalCreateUser(['administer actions']); $this->drupalLogin($user); // Make a POST request to admin/config/system/actions. - $edit = array(); + $edit = []; $edit['action'] = Crypt::hashBase64('action_goto_action'); $this->drupalPostForm('admin/config/system/actions', $edit, t('Create')); $this->assertResponse(200); // Make a POST request to the individual action configuration page. - $edit = array(); + $edit = []; $action_label = $this->randomMachineName(); $edit['label'] = $action_label; $edit['id'] = strtolower($action_label); @@ -52,7 +52,7 @@ function testActionConfiguration() { $this->clickLink(t('Configure')); preg_match('|admin/config/system/actions/configure/(.+)|', $this->getUrl(), $matches); $aid = $matches[1]; - $edit = array(); + $edit = []; $new_action_label = $this->randomMachineName(); $edit['label'] = $new_action_label; $edit['url'] = 'admin'; @@ -72,12 +72,12 @@ function testActionConfiguration() { $this->drupalGet('admin/config/system/actions'); $this->clickLink(t('Delete')); $this->assertResponse(200); - $edit = array(); + $edit = []; $this->drupalPostForm("admin/config/system/actions/configure/$aid/delete", $edit, t('Delete')); $this->assertResponse(200); // Make sure that the action was actually deleted. - $this->assertRaw(t('The action %action has been deleted.', array('%action' => $new_action_label)), 'Make sure that we get a delete confirmation message.'); + $this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'Make sure that we get a delete confirmation message.'); $this->drupalGet('admin/config/system/actions'); $this->assertResponse(200); $this->assertNoText($new_action_label, "Make sure the action label does not appear on the overview page after we've deleted the action."); diff --git a/core/modules/action/tests/src/Unit/Menu/ActionLocalTasksTest.php b/core/modules/action/tests/src/Unit/Menu/ActionLocalTasksTest.php index 34d24b1..1959f65 100644 --- a/core/modules/action/tests/src/Unit/Menu/ActionLocalTasksTest.php +++ b/core/modules/action/tests/src/Unit/Menu/ActionLocalTasksTest.php @@ -12,7 +12,7 @@ class ActionLocalTasksTest extends LocalTaskIntegrationTestBase { protected function setUp() { - $this->directoryList = array('action' => 'core/modules/action'); + $this->directoryList = ['action' => 'core/modules/action']; parent::setUp(); } @@ -20,7 +20,7 @@ protected function setUp() { * Tests local task existence. */ public function testActionLocalTasks() { - $this->assertLocalTasks('entity.action.collection', array(array('action.admin'))); + $this->assertLocalTasks('entity.action.collection', [['action.admin']]); } } diff --git a/core/modules/action/tests/src/Unit/Plugin/migrate/source/ActionTest.php b/core/modules/action/tests/src/Unit/Plugin/migrate/source/ActionTest.php index 3ef553e..da45fb1 100644 --- a/core/modules/action/tests/src/Unit/Plugin/migrate/source/ActionTest.php +++ b/core/modules/action/tests/src/Unit/Plugin/migrate/source/ActionTest.php @@ -16,46 +16,46 @@ class ActionTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = 'Drupal\action\Plugin\migrate\source\Action'; // The fake Migration configuration entity. - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ // The ID of the entity, can be any string. 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'action', - ), - ); + ], + ]; // We need to set up the database contents; it's easier to do that below. - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'aid' => 'Redirect to node list page', 'type' => 'system', 'callback' => 'system_goto_action', 'parameters' => 'a:1:{s:3:"url";s:4:"node";}', 'description' => 'Redirect to node list page', - ), - array( + ], + [ 'aid' => 'Test notice email', 'type' => 'system', 'callback' => 'system_send_email_action', 'parameters' => 'a:3:{s:9:"recipient";s:7:"%author";s:7:"subject";s:4:"Test";s:7:"message";s:4:"Test', 'description' => 'Test notice email', - ), - array( + ], + [ 'aid' => 'comment_publish_action', 'type' => 'comment', 'callback' => 'comment_publish_action', 'parameters' => NULL, 'description' => NULL, - ), - array( + ], + [ 'aid' => 'node_publish_action', 'type' => 'comment', 'callback' => 'node_publish_action', 'parameters' => NULL, 'description' => NULL, - ), - ); + ], + ]; /** * {@inheritdoc} diff --git a/core/modules/aggregator/aggregator.install b/core/modules/aggregator/aggregator.install index e236628..3c1bf52 100644 --- a/core/modules/aggregator/aggregator.install +++ b/core/modules/aggregator/aggregator.install @@ -10,11 +10,11 @@ */ function aggregator_requirements($phase) { $has_curl = function_exists('curl_init'); - $requirements = array(); - $requirements['curl'] = array( + $requirements = []; + $requirements['curl'] = [ 'title' => t('cURL'), 'value' => $has_curl ? t('Enabled') : t('Not found'), - ); + ]; if (!$has_curl) { $requirements['curl']['severity'] = REQUIREMENT_ERROR; $requirements['curl']['description'] = t('The Aggregator module could not be installed because the PHP cURL library is not available.'); diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index 7405699..b4c0c4b 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -22,35 +22,35 @@ function aggregator_help($route_name, RouteMatchInterface $route_match) { $path_validator = \Drupal::pathValidator(); $output = ''; $output .= '

    ' . t('About') . '

    '; - $output .= '

    ' . t('The Aggregator module is an on-site syndicator and news reader that gathers and displays fresh content from RSS-, RDF-, and Atom-based feeds made available across the web. Thousands of sites (particularly news sites and blogs) publish their latest headlines in feeds, using a number of standardized XML-based formats. For more information, see the online documentation for the Aggregator module.', array(':aggregator-module' => 'https://www.drupal.org/documentation/modules/aggregator')) . '

    '; + $output .= '

    ' . t('The Aggregator module is an on-site syndicator and news reader that gathers and displays fresh content from RSS-, RDF-, and Atom-based feeds made available across the web. Thousands of sites (particularly news sites and blogs) publish their latest headlines in feeds, using a number of standardized XML-based formats. For more information, see the online documentation for the Aggregator module.', [':aggregator-module' => 'https://www.drupal.org/documentation/modules/aggregator']) . '

    '; $output .= '

    ' . t('Uses') . '

    '; $output .= '
    '; // Check if the aggregator sources View is enabled. if ($url = $path_validator->getUrlIfValid('aggregator/sources')) { $output .= '
    ' . t('Viewing feeds') . '
    '; - $output .= '
    ' . t('Users view feed content in the main aggregator display, or by their source (usually via an RSS feed reader). The most recent content in a feed can be displayed as a block through the Blocks administration page.', array(':aggregator' => \Drupal::url('aggregator.page_last'), ':aggregator-sources' => $url->toString(), ':admin-block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '
    '; + $output .= '
    ' . t('Users view feed content in the main aggregator display, or by their source (usually via an RSS feed reader). The most recent content in a feed can be displayed as a block through the Blocks administration page.', [':aggregator' => \Drupal::url('aggregator.page_last'), ':aggregator-sources' => $url->toString(), ':admin-block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '
    '; } $output .= '
    ' . t('Adding, editing, and deleting feeds') . '
    '; - $output .= '
    ' . t('Administrators can add, edit, and delete feeds, and choose how often to check each feed for newly updated items on the Feed aggregator page.', array(':feededit' => \Drupal::url('aggregator.admin_overview'))) . '
    '; + $output .= '
    ' . t('Administrators can add, edit, and delete feeds, and choose how often to check each feed for newly updated items on the Feed aggregator page.', [':feededit' => \Drupal::url('aggregator.admin_overview')]) . '
    '; $output .= '
    ' . t('Configuring the display of feed items') . '
    '; - $output .= '
    ' . t('Administrators can choose how many items are displayed in the listing pages, which HTML tags are allowed in the content of feed items, and whether they should be trimmed to a maximum number of characters on the Feed aggregator settings page.', array(':settings' => \Drupal::url('aggregator.admin_settings'))) . '
    '; + $output .= '
    ' . t('Administrators can choose how many items are displayed in the listing pages, which HTML tags are allowed in the content of feed items, and whether they should be trimmed to a maximum number of characters on the Feed aggregator settings page.', [':settings' => \Drupal::url('aggregator.admin_settings')]) . '
    '; $output .= '
    ' . t('Discarding old feed items') . '
    '; - $output .= '
    ' . t('Administrators can choose whether to discard feed items that are older than a specified period of time on the Feed aggregator settings page. This requires a correctly configured cron maintenance task (see below).', array(':settings' => \Drupal::url('aggregator.admin_settings'))) . '
    '; + $output .= '
    ' . t('Administrators can choose whether to discard feed items that are older than a specified period of time on the Feed aggregator settings page. This requires a correctly configured cron maintenance task (see below).', [':settings' => \Drupal::url('aggregator.admin_settings')]) . '
    '; $output .= '
    ' . t('OPML integration') . '
    '; // Check if the aggregator opml View is enabled. if ($url = $path_validator->getUrlIfValid('aggregator/opml')) { - $output .= '
    ' . t('A machine-readable OPML file of all feeds is available. OPML is an XML-based file format used to share outline-structured information such as a list of RSS feeds. Feeds can also be imported via an OPML file.', array(':aggregator-opml' => $url->toString(), ':import-opml' => \Drupal::url('aggregator.opml_add'))) . '
    '; + $output .= '
    ' . t('A machine-readable OPML file of all feeds is available. OPML is an XML-based file format used to share outline-structured information such as a list of RSS feeds. Feeds can also be imported via an OPML file.', [':aggregator-opml' => $url->toString(), ':import-opml' => \Drupal::url('aggregator.opml_add')]) . '
    '; } $output .= '
    ' . t('Configuring cron') . '
    '; - $output .= '
    ' . t('A working cron maintenance task is required to update feeds automatically.', array(':cron' => \Drupal::url('system.cron_settings'))) . '
    '; + $output .= '
    ' . t('A working cron maintenance task is required to update feeds automatically.', [':cron' => \Drupal::url('system.cron_settings')]) . '
    '; $output .= '
    '; return $output; case 'aggregator.admin_overview': // Don't use placeholders for possibility to change URLs for translators. $output = '

    ' . t('Many sites publish their headlines and posts in feeds, using a number of standardized XML-based formats. The aggregator supports RSS, RDF, and Atom.') . '

    '; - $output .= '

    ' . t('Current feeds are listed below, and new feeds may be added. For each feed, the latest items block may be enabled at the blocks administration page.', array(':addfeed' => \Drupal::url('aggregator.feed_add'), ':block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '

    '; + $output .= '

    ' . t('Current feeds are listed below, and new feeds may be added. For each feed, the latest items block may be enabled at the blocks administration page.', [':addfeed' => \Drupal::url('aggregator.feed_add'), ':block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '

    '; return $output; case 'aggregator.feed_add': @@ -65,66 +65,66 @@ function aggregator_help($route_name, RouteMatchInterface $route_match) { * Implements hook_theme(). */ function aggregator_theme() { - return array( - 'aggregator_feed' => array( + return [ + 'aggregator_feed' => [ 'render element' => 'elements', 'file' => 'aggregator.theme.inc', - ), - 'aggregator_item' => array( + ], + 'aggregator_item' => [ 'render element' => 'elements', 'file' => 'aggregator.theme.inc', - ), - ); + ], + ]; } /** * Implements hook_entity_extra_field_info(). */ function aggregator_entity_extra_field_info() { - $extra = array(); + $extra = []; - $extra['aggregator_feed']['aggregator_feed'] = array( - 'display' => array( - 'items' => array( + $extra['aggregator_feed']['aggregator_feed'] = [ + 'display' => [ + 'items' => [ 'label' => t('Items'), 'description' => t('Items associated with this feed'), 'weight' => 0, - ), + ], // @todo Move to a formatter at https://www.drupal.org/node/2339917. - 'image' => array( + 'image' => [ 'label' => t('Image'), 'description' => t('The feed image'), 'weight' => 2, - ), + ], // @todo Move to a formatter at https://www.drupal.org/node/2149845. - 'description' => array( + 'description' => [ 'label' => t('Description'), 'description' => t('The description of this feed'), 'weight' => 3, - ), - 'more_link' => array( + ], + 'more_link' => [ 'label' => t('More link'), 'description' => t('A more link to the feed detail page'), 'weight' => 5, - ), - 'feed_icon' => array( + ], + 'feed_icon' => [ 'label' => t('Feed icon'), 'description' => t('An icon that links to the feed URL'), 'weight' => 6, - ), - ), - ); + ], + ], + ]; - $extra['aggregator_item']['aggregator_item'] = array( - 'display' => array( + $extra['aggregator_item']['aggregator_item'] = [ + 'display' => [ // @todo Move to a formatter at https://www.drupal.org/node/2149845. - 'description' => array( + 'description' => [ 'label' => t('Description'), 'description' => t('The description of this feed item'), 'weight' => 2, - ), - ), - ); + ], + ], + ]; return $extra; } diff --git a/core/modules/aggregator/src/AggregatorFeedViewsData.php b/core/modules/aggregator/src/AggregatorFeedViewsData.php index 2eb0d34..b47f837 100644 --- a/core/modules/aggregator/src/AggregatorFeedViewsData.php +++ b/core/modules/aggregator/src/AggregatorFeedViewsData.php @@ -15,12 +15,12 @@ class AggregatorFeedViewsData extends EntityViewsData { public function getViewsData() { $data = parent::getViewsData(); - $data['aggregator_feed']['table']['join'] = array( - 'aggregator_item' => array( + $data['aggregator_feed']['table']['join'] = [ + 'aggregator_item' => [ 'left_field' => 'fid', 'field' => 'fid', - ), - ); + ], + ]; $data['aggregator_feed']['fid']['help'] = $this->t('The unique ID of the aggregator feed.'); $data['aggregator_feed']['fid']['argument']['id'] = 'aggregator_fid'; diff --git a/core/modules/aggregator/src/Controller/AggregatorController.php b/core/modules/aggregator/src/Controller/AggregatorController.php index c84fb18..021e4d1 100644 --- a/core/modules/aggregator/src/Controller/AggregatorController.php +++ b/core/modules/aggregator/src/Controller/AggregatorController.php @@ -48,9 +48,9 @@ public static function create(ContainerInterface $container) { */ public function feedAdd() { $feed = $this->entityManager()->getStorage('aggregator_feed') - ->create(array( + ->create([ 'refresh' => 3600, - )); + ]); return $this->entityFormBuilder()->getForm($feed); } @@ -67,15 +67,15 @@ public function feedAdd() { */ protected function buildPageList(array $items, $feed_source = '') { // Assemble output. - $build = array( + $build = [ '#type' => 'container', - '#attributes' => array('class' => array('aggregator-wrapper')), - ); - $build['feed_source'] = is_array($feed_source) ? $feed_source : array('#markup' => $feed_source); + '#attributes' => ['class' => ['aggregator-wrapper']], + ]; + $build['feed_source'] = is_array($feed_source) ? $feed_source : ['#markup' => $feed_source]; if ($items) { $build['items'] = $this->entityManager()->getViewBuilder('aggregator_item') ->viewMultiple($items, 'default'); - $build['pager'] = array('#type' => 'pager'); + $build['pager'] = ['#type' => 'pager']; } return $build; } @@ -94,8 +94,8 @@ protected function buildPageList(array $items, $feed_source = '') { */ public function feedRefresh(FeedInterface $aggregator_feed) { $message = $aggregator_feed->refreshItems() - ? $this->t('There is new syndicated content from %site.', array('%site' => $aggregator_feed->label())) - : $this->t('There is no new syndicated content from %site.', array('%site' => $aggregator_feed->label())); + ? $this->t('There is new syndicated content from %site.', ['%site' => $aggregator_feed->label()]) + : $this->t('There is no new syndicated content from %site.', ['%site' => $aggregator_feed->label()]); drupal_set_message($message); return $this->redirect('aggregator.admin_overview'); } @@ -111,22 +111,22 @@ public function adminOverview() { $feeds = $entity_manager->getStorage('aggregator_feed') ->loadMultiple(); - $header = array($this->t('Title'), $this->t('Items'), $this->t('Last update'), $this->t('Next update'), $this->t('Operations')); - $rows = array(); + $header = [$this->t('Title'), $this->t('Items'), $this->t('Last update'), $this->t('Next update'), $this->t('Operations')]; + $rows = []; /** @var \Drupal\aggregator\FeedInterface[] $feeds */ foreach ($feeds as $feed) { - $row = array(); + $row = []; $row[] = $feed->link(); $row[] = $this->formatPlural($entity_manager->getStorage('aggregator_item')->getItemCount($feed), '1 item', '@count items'); $last_checked = $feed->getLastCheckedTime(); $refresh_rate = $feed->getRefreshRate(); - $row[] = ($last_checked ? $this->t('@time ago', array('@time' => $this->dateFormatter->formatInterval(REQUEST_TIME - $last_checked))) : $this->t('never')); + $row[] = ($last_checked ? $this->t('@time ago', ['@time' => $this->dateFormatter->formatInterval(REQUEST_TIME - $last_checked)]) : $this->t('never')); if (!$last_checked && $refresh_rate) { $next_update = $this->t('imminently'); } elseif ($last_checked && $refresh_rate) { - $next_update = $next = $this->t('%time left', array('%time' => $this->dateFormatter->formatInterval($last_checked + $refresh_rate - REQUEST_TIME))); + $next_update = $next = $this->t('%time left', ['%time' => $this->dateFormatter->formatInterval($last_checked + $refresh_rate - REQUEST_TIME)]); } else { $next_update = $this->t('never'); @@ -136,33 +136,33 @@ public function adminOverview() { 'title' => $this->t('Edit'), 'url' => Url::fromRoute('entity.aggregator_feed.edit_form', ['aggregator_feed' => $feed->id()]), ]; - $links['delete'] = array( + $links['delete'] = [ 'title' => $this->t('Delete'), 'url' => Url::fromRoute('entity.aggregator_feed.delete_form', ['aggregator_feed' => $feed->id()]), - ); - $links['delete_items'] = array( + ]; + $links['delete_items'] = [ 'title' => $this->t('Delete items'), 'url' => Url::fromRoute('aggregator.feed_items_delete', ['aggregator_feed' => $feed->id()]), - ); - $links['update'] = array( + ]; + $links['update'] = [ 'title' => $this->t('Update items'), 'url' => Url::fromRoute('aggregator.feed_refresh', ['aggregator_feed' => $feed->id()]), - ); - $row[] = array( - 'data' => array( + ]; + $row[] = [ + 'data' => [ '#type' => 'operations', '#links' => $links, - ), - ); + ], + ]; $rows[] = $row; } - $build['feeds'] = array( + $build['feeds'] = [ '#prefix' => '

    ' . $this->t('Feed overview') . '

    ', '#type' => 'table', '#header' => $header, '#rows' => $rows, - '#empty' => $this->t('No feeds available. Add feed.', array(':link' => $this->url('aggregator.feed_add'))), - ); + '#empty' => $this->t('No feeds available. Add feed.', [':link' => $this->url('aggregator.feed_add')]), + ]; return $build; } @@ -176,7 +176,7 @@ public function adminOverview() { public function pageLast() { $items = $this->entityManager()->getStorage('aggregator_item')->loadAll(20); $build = $this->buildPageList($items); - $build['#attached']['feed'][] = array('aggregator/rss', $this->config('system.site')->get('name') . ' ' . $this->t('aggregator')); + $build['#attached']['feed'][] = ['aggregator/rss', $this->config('system.site')->get('name') . ' ' . $this->t('aggregator')]; return $build; } diff --git a/core/modules/aggregator/src/Entity/Feed.php b/core/modules/aggregator/src/Entity/Feed.php index 834a55e..3b14e8c 100644 --- a/core/modules/aggregator/src/Entity/Feed.php +++ b/core/modules/aggregator/src/Entity/Feed.php @@ -88,11 +88,11 @@ public function refreshItems() { * {@inheritdoc} */ public static function preCreate(EntityStorageInterface $storage, array &$values) { - $values += array( + $values += [ 'link' => '', 'description' => '', 'image' => '', - ); + ]; } /** @@ -143,10 +143,10 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDescription(t('The name of the feed (or the name of the website providing the feed).')) ->setRequired(TRUE) ->setSetting('max_length', 255) - ->setDisplayOptions('form', array( + ->setDisplayOptions('form', [ 'type' => 'string_textfield', 'weight' => -5, - )) + ]) ->setDisplayConfigurable('form', TRUE) ->addConstraint('FeedTitle'); @@ -154,15 +154,15 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('URL')) ->setDescription(t('The fully-qualified URL of the feed.')) ->setRequired(TRUE) - ->setDisplayOptions('form', array( + ->setDisplayOptions('form', [ 'type' => 'uri', 'weight' => -3, - )) + ]) ->setDisplayConfigurable('form', TRUE) ->addConstraint('FeedUrl'); - $intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200); - $period = array_map(array(\Drupal::service('date.formatter'), 'formatInterval'), array_combine($intervals, $intervals)); + $intervals = [900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200]; + $period = array_map([\Drupal::service('date.formatter'), 'formatInterval'], array_combine($intervals, $intervals)); $period[AGGREGATOR_CLEAR_NEVER] = t('Never'); $fields['refresh'] = BaseFieldDefinition::create('list_integer') @@ -171,21 +171,21 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setSetting('unsigned', TRUE) ->setRequired(TRUE) ->setSetting('allowed_values', $period) - ->setDisplayOptions('form', array( + ->setDisplayOptions('form', [ 'type' => 'options_select', 'weight' => -2, - )) + ]) ->setDisplayConfigurable('form', TRUE); $fields['checked'] = BaseFieldDefinition::create('timestamp') ->setLabel(t('Checked')) ->setDescription(t('Last time feed was checked for new items, as Unix timestamp.')) ->setDefaultValue(0) - ->setDisplayOptions('view', array( + ->setDisplayOptions('view', [ 'label' => 'inline', 'type' => 'timestamp_ago', 'weight' => 1, - )) + ]) ->setDisplayConfigurable('view', TRUE); $fields['queued'] = BaseFieldDefinition::create('timestamp') @@ -196,15 +196,15 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['link'] = BaseFieldDefinition::create('uri') ->setLabel(t('URL')) ->setDescription(t('The link of the feed.')) - ->setDisplayOptions('view', array( + ->setDisplayOptions('view', [ 'label' => 'inline', 'weight' => 4, - )) + ]) ->setDisplayConfigurable('view', TRUE); $fields['description'] = BaseFieldDefinition::create('string_long') ->setLabel(t('Description')) - ->setDescription(t("The parent website's description that comes from the @description element in the feed.", array('@description' => ''))); + ->setDescription(t("The parent website's description that comes from the @description element in the feed.", ['@description' => ''])); $fields['image'] = BaseFieldDefinition::create('uri') ->setLabel(t('Image')) diff --git a/core/modules/aggregator/src/Entity/Item.php b/core/modules/aggregator/src/Entity/Item.php index 330aacb..7232c8e 100644 --- a/core/modules/aggregator/src/Entity/Item.php +++ b/core/modules/aggregator/src/Entity/Item.php @@ -61,11 +61,11 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setRequired(TRUE) ->setDescription(t('The aggregator feed entity associated with this item.')) ->setSetting('target_type', 'aggregator_feed') - ->setDisplayOptions('view', array( + ->setDisplayOptions('view', [ 'label' => 'hidden', 'type' => 'entity_reference_label', 'weight' => 0, - )) + ]) ->setDisplayConfigurable('form', TRUE); $fields['title'] = BaseFieldDefinition::create('string') @@ -75,18 +75,18 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['link'] = BaseFieldDefinition::create('uri') ->setLabel(t('Link')) ->setDescription(t('The link of the feed item.')) - ->setDisplayOptions('view', array( + ->setDisplayOptions('view', [ 'type' => 'hidden', - )) + ]) ->setDisplayConfigurable('view', TRUE); $fields['author'] = BaseFieldDefinition::create('string') ->setLabel(t('Author')) ->setDescription(t('The author of the feed item.')) - ->setDisplayOptions('view', array( + ->setDisplayOptions('view', [ 'label' => 'hidden', 'weight' => 3, - )) + ]) ->setDisplayConfigurable('view', TRUE); $fields['description'] = BaseFieldDefinition::create('string_long') @@ -96,11 +96,11 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { $fields['timestamp'] = BaseFieldDefinition::create('created') ->setLabel(t('Posted on')) ->setDescription(t('Posted date of the feed item, as a Unix timestamp.')) - ->setDisplayOptions('view', array( + ->setDisplayOptions('view', [ 'label' => 'hidden', 'type' => 'timestamp_ago', 'weight' => 1, - )) + ]) ->setDisplayConfigurable('view', TRUE); // @todo Convert to a real UUID field in diff --git a/core/modules/aggregator/src/FeedForm.php b/core/modules/aggregator/src/FeedForm.php index 3447cc8..1580a30 100644 --- a/core/modules/aggregator/src/FeedForm.php +++ b/core/modules/aggregator/src/FeedForm.php @@ -20,12 +20,12 @@ public function save(array $form, FormStateInterface $form_state) { $label = $feed->label(); $view_link = $feed->link($label, 'canonical'); if ($status == SAVED_UPDATED) { - drupal_set_message($this->t('The feed %feed has been updated.', array('%feed' => $view_link))); + drupal_set_message($this->t('The feed %feed has been updated.', ['%feed' => $view_link])); $form_state->setRedirectUrl($feed->urlInfo('canonical')); } else { - $this->logger('aggregator')->notice('Feed %feed added.', array('%feed' => $feed->label(), 'link' => $this->l($this->t('View'), new Url('aggregator.admin_overview')))); - drupal_set_message($this->t('The feed %feed has been added.', array('%feed' => $view_link))); + $this->logger('aggregator')->notice('Feed %feed added.', ['%feed' => $feed->label(), 'link' => $this->l($this->t('View'), new Url('aggregator.admin_overview'))]); + drupal_set_message($this->t('The feed %feed has been added.', ['%feed' => $view_link])); } } diff --git a/core/modules/aggregator/src/FeedStorage.php b/core/modules/aggregator/src/FeedStorage.php index 5085e6d..ded3531 100644 --- a/core/modules/aggregator/src/FeedStorage.php +++ b/core/modules/aggregator/src/FeedStorage.php @@ -16,10 +16,10 @@ class FeedStorage extends SqlContentEntityStorage implements FeedStorageInterfac * {@inheritdoc} */ public function getFeedIdsToRefresh() { - return $this->database->query('SELECT fid FROM {aggregator_feed} WHERE queued = 0 AND checked + refresh < :time AND refresh <> :never', array( + return $this->database->query('SELECT fid FROM {aggregator_feed} WHERE queued = 0 AND checked + refresh < :time AND refresh <> :never', [ ':time' => REQUEST_TIME, ':never' => AGGREGATOR_CLEAR_NEVER, - ))->fetchCol(); + ])->fetchCol(); } } diff --git a/core/modules/aggregator/src/FeedViewBuilder.php b/core/modules/aggregator/src/FeedViewBuilder.php index 5ce69ff..1efaa30 100644 --- a/core/modules/aggregator/src/FeedViewBuilder.php +++ b/core/modules/aggregator/src/FeedViewBuilder.php @@ -68,65 +68,65 @@ public function buildComponents(array &$build, array $entities, array $displays, if ($view_mode == 'full') { // Also add the pager. - $build[$id]['pager'] = array('#type' => 'pager'); + $build[$id]['pager'] = ['#type' => 'pager']; } } if ($display->getComponent('description')) { - $build[$id]['description'] = array( + $build[$id]['description'] = [ '#markup' => $entity->getDescription(), '#allowed_tags' => _aggregator_allowed_tags(), '#prefix' => '
    ', '#suffix' => '
    ', - ); + ]; } if ($display->getComponent('image')) { - $image_link = array(); + $image_link = []; // Render the image as link if it is available. $image = $entity->getImage(); $label = $entity->label(); $link_href = $entity->getWebsiteUrl(); if ($image && $label && $link_href) { - $link_title = array( + $link_title = [ '#theme' => 'image', '#uri' => $image, '#alt' => $label, - ); - $image_link = array( + ]; + $image_link = [ '#type' => 'link', '#title' => $link_title, '#url' => Url::fromUri($link_href), - '#options' => array( - 'attributes' => array('class' => array('feed-image')), - ), - ); + '#options' => [ + 'attributes' => ['class' => ['feed-image']], + ], + ]; } $build[$id]['image'] = $image_link; } if ($display->getComponent('feed_icon')) { - $build[$id]['feed_icon'] = array( + $build[$id]['feed_icon'] = [ '#theme' => 'feed_icon', '#url' => $entity->getUrl(), - '#title' => t('@title feed', array('@title' => $entity->label())), - ); + '#title' => t('@title feed', ['@title' => $entity->label()]), + ]; } if ($display->getComponent('more_link')) { $title_stripped = strip_tags($entity->label()); - $build[$id]['more_link'] = array( + $build[$id]['more_link'] = [ '#type' => 'link', - '#title' => t('More posts about @title', array( + '#title' => t('More posts about @title', [ '@title' => $title_stripped, - )), + ]), '#url' => Url::fromRoute('entity.aggregator_feed.canonical', ['aggregator_feed' => $entity->id()]), - '#options' => array( - 'attributes' => array( + '#options' => [ + 'attributes' => [ 'title' => $title_stripped, - ), - ), - ); + ], + ], + ]; } } diff --git a/core/modules/aggregator/src/Form/FeedDeleteForm.php b/core/modules/aggregator/src/Form/FeedDeleteForm.php index bcf1a32..17a1798 100644 --- a/core/modules/aggregator/src/Form/FeedDeleteForm.php +++ b/core/modules/aggregator/src/Form/FeedDeleteForm.php @@ -28,9 +28,9 @@ protected function getRedirectUrl() { * {@inheritdoc} */ protected function getDeletionMessage() { - return $this->t('The feed %label has been deleted.', array( + return $this->t('The feed %label has been deleted.', [ '%label' => $this->entity->label(), - )); + ]); } } diff --git a/core/modules/aggregator/src/Form/FeedItemsDeleteForm.php b/core/modules/aggregator/src/Form/FeedItemsDeleteForm.php index 1117359..48c83dc 100644 --- a/core/modules/aggregator/src/Form/FeedItemsDeleteForm.php +++ b/core/modules/aggregator/src/Form/FeedItemsDeleteForm.php @@ -15,7 +15,7 @@ class FeedItemsDeleteForm extends ContentEntityConfirmFormBase { * {@inheritdoc} */ public function getQuestion() { - return $this->t('Are you sure you want to delete all items from the feed %feed?', array('%feed' => $this->entity->label())); + return $this->t('Are you sure you want to delete all items from the feed %feed?', ['%feed' => $this->entity->label()]); } /** diff --git a/core/modules/aggregator/src/Form/OpmlFeedAdd.php b/core/modules/aggregator/src/Form/OpmlFeedAdd.php index 0ba285a..29a4611 100644 --- a/core/modules/aggregator/src/Form/OpmlFeedAdd.php +++ b/core/modules/aggregator/src/Form/OpmlFeedAdd.php @@ -63,33 +63,33 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200); - $period = array_map(array(\Drupal::service('date.formatter'), 'formatInterval'), array_combine($intervals, $intervals)); + $intervals = [900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200]; + $period = array_map([\Drupal::service('date.formatter'), 'formatInterval'], array_combine($intervals, $intervals)); - $form['upload'] = array( + $form['upload'] = [ '#type' => 'file', '#title' => $this->t('OPML File'), '#description' => $this->t('Upload an OPML file containing a list of feeds to be imported.'), - ); - $form['remote'] = array( + ]; + $form['remote'] = [ '#type' => 'url', '#title' => $this->t('OPML Remote URL'), '#maxlength' => 1024, '#description' => $this->t('Enter the URL of an OPML file. This file will be downloaded and processed only once on submission of the form.'), - ); - $form['refresh'] = array( + ]; + $form['refresh'] = [ '#type' => 'select', '#title' => $this->t('Update interval'), '#default_value' => 3600, '#options' => $period, - '#description' => $this->t('The length of time between feed updates. Requires a correctly configured cron maintenance task.', array(':cron' => $this->url('system.status'))), - ); + '#description' => $this->t('The length of time between feed updates. Requires a correctly configured cron maintenance task.', [':cron' => $this->url('system.status')]), + ]; - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Import'), - ); + ]; return $form; } @@ -109,7 +109,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - $validators = array('file_validate_extensions' => array('opml xml')); + $validators = ['file_validate_extensions' => ['opml xml']]; if ($file = file_save_upload('upload', $validators, FALSE, 0)) { $data = file_get_contents($file->getFileUri()); } @@ -120,8 +120,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $data = (string) $response->getBody(); } catch (RequestException $e) { - $this->logger('aggregator')->warning('Failed to download OPML file due to "%error".', array('%error' => $e->getMessage())); - drupal_set_message($this->t('Failed to download OPML file due to "%error".', array('%error' => $e->getMessage()))); + $this->logger('aggregator')->warning('Failed to download OPML file due to "%error".', ['%error' => $e->getMessage()]); + drupal_set_message($this->t('Failed to download OPML file due to "%error".', ['%error' => $e->getMessage()])); return; } } @@ -136,7 +136,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { foreach ($feeds as $feed) { // Ensure URL is valid. if (!UrlHelper::isValid($feed['url'], TRUE)) { - drupal_set_message($this->t('The URL %url is invalid.', array('%url' => $feed['url'])), 'warning'); + drupal_set_message($this->t('The URL %url is invalid.', ['%url' => $feed['url']]), 'warning'); continue; } @@ -151,20 +151,20 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $result = $this->feedStorage->loadMultiple($ids); foreach ($result as $old) { if (strcasecmp($old->label(), $feed['title']) == 0) { - drupal_set_message($this->t('A feed named %title already exists.', array('%title' => $old->label())), 'warning'); + drupal_set_message($this->t('A feed named %title already exists.', ['%title' => $old->label()]), 'warning'); continue 2; } if (strcasecmp($old->getUrl(), $feed['url']) == 0) { - drupal_set_message($this->t('A feed with the URL %url already exists.', array('%url' => $old->getUrl())), 'warning'); + drupal_set_message($this->t('A feed with the URL %url already exists.', ['%url' => $old->getUrl()]), 'warning'); continue 2; } } - $new_feed = $this->feedStorage->create(array( + $new_feed = $this->feedStorage->create([ 'title' => $feed['title'], 'url' => $feed['url'], 'refresh' => $form_state->getValue('refresh'), - )); + ]); $new_feed->save(); } @@ -189,14 +189,14 @@ public function submitForm(array &$form, FormStateInterface $form_state) { * @todo Move this to a parser in https://www.drupal.org/node/1963540. */ protected function parseOpml($opml) { - $feeds = array(); + $feeds = []; $xml_parser = drupal_xml_parser_create($opml); if (xml_parse_into_struct($xml_parser, $opml, $values)) { foreach ($values as $entry) { if ($entry['tag'] == 'OUTLINE' && isset($entry['attributes'])) { $item = $entry['attributes']; if (!empty($item['XMLURL']) && !empty($item['TEXT'])) { - $feeds[] = array('title' => $item['TEXT'], 'url' => $item['XMLURL']); + $feeds[] = ['title' => $item['TEXT'], 'url' => $item['XMLURL']]; } } } diff --git a/core/modules/aggregator/src/Form/SettingsForm.php b/core/modules/aggregator/src/Form/SettingsForm.php index edd5741..48b2dfe 100644 --- a/core/modules/aggregator/src/Form/SettingsForm.php +++ b/core/modules/aggregator/src/Form/SettingsForm.php @@ -21,25 +21,25 @@ class SettingsForm extends ConfigFormBase { * * @var \Drupal\aggregator\Plugin\AggregatorPluginManager[] */ - protected $managers = array(); + protected $managers = []; /** * The instantiated plugin instances that have configuration forms. * * @var \Drupal\Core\Plugin\PluginFormInterface[] */ - protected $configurableInstances = array(); + protected $configurableInstances = []; /** * The aggregator plugin definitions. * * @var array */ - protected $definitions = array( - 'fetcher' => array(), - 'parser' => array(), - 'processor' => array(), - ); + protected $definitions = [ + 'fetcher' => [], + 'parser' => [], + 'processor' => [], + ]; /** * Constructs a \Drupal\aggregator\SettingsForm object. @@ -58,15 +58,15 @@ class SettingsForm extends ConfigFormBase { public function __construct(ConfigFactoryInterface $config_factory, AggregatorPluginManager $fetcher_manager, AggregatorPluginManager $parser_manager, AggregatorPluginManager $processor_manager, TranslationInterface $string_translation) { parent::__construct($config_factory); $this->stringTranslation = $string_translation; - $this->managers = array( + $this->managers = [ 'fetcher' => $fetcher_manager, 'parser' => $parser_manager, 'processor' => $processor_manager, - ); + ]; // Get all available fetcher, parser and processor definitions. - foreach (array('fetcher', 'parser', 'processor') as $type) { + foreach (['fetcher', 'parser', 'processor'] as $type) { foreach ($this->managers[$type]->getDefinitions() as $id => $definition) { - $this->definitions[$type][$id] = SafeMarkup::format('@title @description', array('@title' => $definition['title'], '@description' => $definition['description'])); + $this->definitions[$type][$id] = SafeMarkup::format('@title @description', ['@title' => $definition['title'], '@description' => $definition['description']]); } } } @@ -105,56 +105,56 @@ public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('aggregator.settings'); // Global aggregator settings. - $form['aggregator_allowed_html_tags'] = array( + $form['aggregator_allowed_html_tags'] = [ '#type' => 'textfield', '#title' => $this->t('Allowed HTML tags'), '#size' => 80, '#maxlength' => 255, '#default_value' => $config->get('items.allowed_html'), '#description' => $this->t('A space-separated list of HTML tags allowed in the content of feed items. Disallowed tags are stripped from the content.'), - ); + ]; // Only show basic configuration if there are actually options. - $basic_conf = array(); + $basic_conf = []; if (count($this->definitions['fetcher']) > 1) { - $basic_conf['aggregator_fetcher'] = array( + $basic_conf['aggregator_fetcher'] = [ '#type' => 'radios', '#title' => $this->t('Fetcher'), '#description' => $this->t('Fetchers download data from an external source. Choose a fetcher suitable for the external source you would like to download from.'), '#options' => $this->definitions['fetcher'], '#default_value' => $config->get('fetcher'), - ); + ]; } if (count($this->definitions['parser']) > 1) { - $basic_conf['aggregator_parser'] = array( + $basic_conf['aggregator_parser'] = [ '#type' => 'radios', '#title' => $this->t('Parser'), '#description' => $this->t('Parsers transform downloaded data into standard structures. Choose a parser suitable for the type of feeds you would like to aggregate.'), '#options' => $this->definitions['parser'], '#default_value' => $config->get('parser'), - ); + ]; } if (count($this->definitions['processor']) > 1) { - $basic_conf['aggregator_processors'] = array( + $basic_conf['aggregator_processors'] = [ '#type' => 'checkboxes', '#title' => $this->t('Processors'), '#description' => $this->t('Processors act on parsed feed data, for example they store feed items. Choose the processors suitable for your task.'), '#options' => $this->definitions['processor'], '#default_value' => $config->get('processors'), - ); + ]; } if (count($basic_conf)) { - $form['basic_conf'] = array( + $form['basic_conf'] = [ '#type' => 'details', '#title' => $this->t('Basic configuration'), '#description' => $this->t('For most aggregation tasks, the default settings are fine.'), '#open' => TRUE, - ); + ]; $form['basic_conf'] += $basic_conf; } // Call buildConfigurationForm() on the active fetcher and parser. - foreach (array('fetcher', 'parser') as $type) { + foreach (['fetcher', 'parser'] as $type) { $active = $config->get($type); if (array_key_exists($active, $this->definitions[$type])) { $instance = $this->managers[$type]->createInstance($active); @@ -169,7 +169,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { } // Implementing processor plugins will expect an array at $form['processors']. - $form['processors'] = array(); + $form['processors'] = []; // Call buildConfigurationForm() for each active processor. foreach ($this->definitions['processor'] as $id => $definition) { if (in_array($id, $config->get('processors'))) { diff --git a/core/modules/aggregator/src/ItemViewBuilder.php b/core/modules/aggregator/src/ItemViewBuilder.php index feb0ffa..feb35b5 100644 --- a/core/modules/aggregator/src/ItemViewBuilder.php +++ b/core/modules/aggregator/src/ItemViewBuilder.php @@ -20,12 +20,12 @@ public function buildComponents(array &$build, array $entities, array $displays, $display = $displays[$bundle]; if ($display->getComponent('description')) { - $build[$id]['description'] = array( + $build[$id]['description'] = [ '#markup' => $entity->getDescription(), '#allowed_tags' => _aggregator_allowed_tags(), '#prefix' => '
    ', '#suffix' => '
    ', - ); + ]; } } } diff --git a/core/modules/aggregator/src/ItemsImporter.php b/core/modules/aggregator/src/ItemsImporter.php index df02564..aa18d65 100644 --- a/core/modules/aggregator/src/ItemsImporter.php +++ b/core/modules/aggregator/src/ItemsImporter.php @@ -95,7 +95,7 @@ public function refresh(FeedInterface $feed) { } // Store instances in an array so we dont have to instantiate new objects. - $processor_instances = array(); + $processor_instances = []; foreach ($this->config->get('processors') as $processor) { try { $processor_instances[$processor] = $this->processorManager->createInstance($processor); @@ -124,10 +124,10 @@ public function refresh(FeedInterface $feed) { // Log if feed URL has changed. if ($feed->getUrl() != $feed_url) { - $this->logger->notice('Updated URL for feed %title to %url.', array('%title' => $feed->label(), '%url' => $feed->getUrl())); + $this->logger->notice('Updated URL for feed %title to %url.', ['%title' => $feed->label(), '%url' => $feed->getUrl()]); } - $this->logger->notice('There is new syndicated content from %site.', array('%site' => $feed->label())); + $this->logger->notice('There is new syndicated content from %site.', ['%site' => $feed->label()]); // If there are items on the feed, let enabled processors process them. if (!empty($feed->items)) { diff --git a/core/modules/aggregator/src/Plugin/AggregatorPluginManager.php b/core/modules/aggregator/src/Plugin/AggregatorPluginManager.php index cd8a6e3..7310987 100644 --- a/core/modules/aggregator/src/Plugin/AggregatorPluginManager.php +++ b/core/modules/aggregator/src/Plugin/AggregatorPluginManager.php @@ -34,16 +34,16 @@ class AggregatorPluginManager extends DefaultPluginManager { * The module handler. */ public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) { - $type_annotations = array( + $type_annotations = [ 'fetcher' => 'Drupal\aggregator\Annotation\AggregatorFetcher', 'parser' => 'Drupal\aggregator\Annotation\AggregatorParser', 'processor' => 'Drupal\aggregator\Annotation\AggregatorProcessor', - ); - $plugin_interfaces = array( + ]; + $plugin_interfaces = [ 'fetcher' => 'Drupal\aggregator\Plugin\FetcherInterface', 'parser' => 'Drupal\aggregator\Plugin\ParserInterface', 'processor' => 'Drupal\aggregator\Plugin\ProcessorInterface', - ); + ]; parent::__construct("Plugin/aggregator/$type", $namespaces, $module_handler, $plugin_interfaces[$type], $type_annotations[$type]); $this->setCacheBackend($cache_backend, 'aggregator_' . $type . '_plugins'); diff --git a/core/modules/aggregator/src/Plugin/AggregatorPluginSettingsBase.php b/core/modules/aggregator/src/Plugin/AggregatorPluginSettingsBase.php index bc59ec5..403e6a3 100644 --- a/core/modules/aggregator/src/Plugin/AggregatorPluginSettingsBase.php +++ b/core/modules/aggregator/src/Plugin/AggregatorPluginSettingsBase.php @@ -25,7 +25,7 @@ * {@inheritdoc} */ public function defaultConfiguration() { - return array(); + return []; } /** @@ -38,7 +38,7 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form * {@inheritdoc} */ public function calculateDependencies() { - return array(); + return []; } } diff --git a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php index 7380e1d..f25a8e6 100644 --- a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php +++ b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php @@ -89,10 +89,10 @@ public static function create(ContainerInterface $container, array $configuratio */ public function defaultConfiguration() { // By default, the block will contain 10 feed items. - return array( + return [ 'block_count' => 10, 'feed' => NULL, - ); + ]; } /** @@ -108,23 +108,23 @@ protected function blockAccess(AccountInterface $account) { */ public function blockForm($form, FormStateInterface $form_state) { $feeds = $this->feedStorage->loadMultiple(); - $options = array(); + $options = []; foreach ($feeds as $feed) { $options[$feed->id()] = $feed->label(); } - $form['feed'] = array( + $form['feed'] = [ '#type' => 'select', '#title' => $this->t('Select the feed that should be displayed'), '#default_value' => $this->configuration['feed'], '#options' => $options, - ); + ]; $range = range(2, 20); - $form['block_count'] = array( + $form['block_count'] = [ '#type' => 'select', '#title' => $this->t('Number of news items in block'), '#default_value' => $this->configuration['block_count'], '#options' => array_combine($range, $range), - ); + ]; return $form; } diff --git a/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php b/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php index 99ec48d..91c7ac3 100644 --- a/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php +++ b/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php @@ -112,8 +112,8 @@ public function fetch(FeedInterface $feed) { return TRUE; } catch (RequestException $e) { - $this->logger->warning('The feed from %site seems to be broken because of error "%error".', array('%site' => $feed->label(), '%error' => $e->getMessage())); - drupal_set_message(t('The feed from %site seems to be broken because of error "%error".', array('%site' => $feed->label(), '%error' => $e->getMessage())), 'warning'); + $this->logger->warning('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]); + drupal_set_message(t('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]), 'warning'); return FALSE; } } diff --git a/core/modules/aggregator/src/Plugin/aggregator/parser/DefaultParser.php b/core/modules/aggregator/src/Plugin/aggregator/parser/DefaultParser.php index 2fb3682..03fa55f 100644 --- a/core/modules/aggregator/src/Plugin/aggregator/parser/DefaultParser.php +++ b/core/modules/aggregator/src/Plugin/aggregator/parser/DefaultParser.php @@ -31,7 +31,7 @@ public function parse(FeedInterface $feed) { } catch (ExceptionInterface $e) { watchdog_exception('aggregator', $e); - drupal_set_message(t('The feed from %site seems to be broken because of error "%error".', array('%site' => $feed->label(), '%error' => $e->getMessage())), 'error'); + drupal_set_message(t('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]), 'error'); return FALSE; } @@ -42,10 +42,10 @@ public function parse(FeedInterface $feed) { $feed->setImage($image['uri']); } // Initialize items array. - $feed->items = array(); + $feed->items = []; foreach ($channel as $item) { // Reset the parsed item. - $parsed_item = array(); + $parsed_item = []; // Move the values to an array as expected by processors. $parsed_item['title'] = $item->getTitle(); $parsed_item['guid'] = $item->getId(); diff --git a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php index 7f6754d..ed2bcfe 100644 --- a/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php +++ b/core/modules/aggregator/src/Plugin/aggregator/processor/DefaultProcessor.php @@ -117,53 +117,53 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $config = $this->config('aggregator.settings'); $processors = $config->get('processors'); $info = $this->getPluginDefinition(); - $counts = array(3, 5, 10, 15, 20, 25); + $counts = [3, 5, 10, 15, 20, 25]; $items = array_map(function ($count) { return $this->formatPlural($count, '1 item', '@count items'); }, array_combine($counts, $counts)); - $intervals = array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800); - $period = array_map(array($this->dateFormatter, 'formatInterval'), array_combine($intervals, $intervals)); + $intervals = [3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800]; + $period = array_map([$this->dateFormatter, 'formatInterval'], array_combine($intervals, $intervals)); $period[AGGREGATOR_CLEAR_NEVER] = t('Never'); - $form['processors'][$info['id']] = array(); + $form['processors'][$info['id']] = []; // Only wrap into details if there is a basic configuration. if (isset($form['basic_conf'])) { - $form['processors'][$info['id']] = array( + $form['processors'][$info['id']] = [ '#type' => 'details', '#title' => t('Default processor settings'), '#description' => $info['description'], '#open' => in_array($info['id'], $processors), - ); + ]; } - $form['processors'][$info['id']]['aggregator_summary_items'] = array( + $form['processors'][$info['id']]['aggregator_summary_items'] = [ '#type' => 'select', '#title' => t('Number of items shown in listing pages'), '#default_value' => $config->get('source.list_max'), '#empty_value' => 0, '#options' => $items, - ); + ]; - $form['processors'][$info['id']]['aggregator_clear'] = array( + $form['processors'][$info['id']]['aggregator_clear'] = [ '#type' => 'select', '#title' => t('Discard items older than'), '#default_value' => $config->get('items.expire'), '#options' => $period, - '#description' => t('Requires a correctly configured cron maintenance task.', array(':cron' => $this->url('system.status'))), - ); + '#description' => t('Requires a correctly configured cron maintenance task.', [':cron' => $this->url('system.status')]), + ]; - $lengths = array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000); + $lengths = [0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000]; $options = array_map(function($length) { return ($length == 0) ? t('Unlimited') : $this->formatPlural($length, '1 character', '@count characters'); }, array_combine($lengths, $lengths)); - $form['processors'][$info['id']]['aggregator_teaser_length'] = array( + $form['processors'][$info['id']]['aggregator_teaser_length'] = [ '#type' => 'select', '#title' => t('Length of trimmed description'), '#default_value' => $config->get('items.teaser_length'), '#options' => $options, '#description' => t('The maximum number of characters used in the trimmed version of content.'), - ); + ]; return $form; } @@ -197,13 +197,13 @@ public function process(FeedInterface $feed) { // we find a duplicate entry, we resolve it and pass along its ID is such // that we can update it if needed. if (!empty($item['guid'])) { - $values = array('fid' => $feed->id(), 'guid' => $item['guid']); + $values = ['fid' => $feed->id(), 'guid' => $item['guid']]; } elseif ($item['link'] && $item['link'] != $feed->link && $item['link'] != $feed->url) { - $values = array('fid' => $feed->id(), 'link' => $item['link']); + $values = ['fid' => $feed->id(), 'link' => $item['link']]; } else { - $values = array('fid' => $feed->id(), 'title' => $item['title']); + $values = ['fid' => $feed->id(), 'title' => $item['title']]; } // Try to load an existing entry. @@ -211,7 +211,7 @@ public function process(FeedInterface $feed) { $entry = reset($entry); } else { - $entry = Item::create(array('langcode' => $feed->language()->getId())); + $entry = Item::create(['langcode' => $feed->language()->getId()]); } if ($item['timestamp']) { $entry->setPostedTime($item['timestamp']); @@ -243,7 +243,7 @@ public function delete(FeedInterface $feed) { $this->itemStorage->delete($items); } // @todo This should be moved out to caller with a different message maybe. - drupal_set_message(t('The news items from %site have been deleted.', array('%site' => $feed->label()))); + drupal_set_message(t('The news items from %site have been deleted.', ['%site' => $feed->label()])); } /** diff --git a/core/modules/aggregator/src/Plugin/migrate/source/AggregatorFeed.php b/core/modules/aggregator/src/Plugin/migrate/source/AggregatorFeed.php index e623e5f..59244d4 100644 --- a/core/modules/aggregator/src/Plugin/migrate/source/AggregatorFeed.php +++ b/core/modules/aggregator/src/Plugin/migrate/source/AggregatorFeed.php @@ -26,7 +26,7 @@ public function query() { * {@inheritdoc} */ public function fields() { - $fields = array( + $fields = [ 'fid' => $this->t('The feed ID.'), 'title' => $this->t('Title of the feed.'), 'url' => $this->t('URL to the feed.'), @@ -38,7 +38,7 @@ public function fields() { 'etag' => $this->t('Entity tag HTTP response header.'), 'modified' => $this->t('When the feed was last modified.'), 'block' => $this->t("Number of items to display in the feed's block."), - ); + ]; if ($this->getModuleSchemaVersion('system') >= 7000) { $fields['queued'] = $this->t('Time when this feed was queued for refresh, 0 if not queued.'); } diff --git a/core/modules/aggregator/src/Plugin/migrate/source/AggregatorItem.php b/core/modules/aggregator/src/Plugin/migrate/source/AggregatorItem.php index fc1c5c6..428c558 100644 --- a/core/modules/aggregator/src/Plugin/migrate/source/AggregatorItem.php +++ b/core/modules/aggregator/src/Plugin/migrate/source/AggregatorItem.php @@ -27,7 +27,7 @@ public function query() { * {@inheritdoc} */ public function fields() { - return array( + return [ 'iid' => $this->t('Primary Key: Unique ID for feed item.'), 'fid' => $this->t('The {aggregator_feed}.fid to which this item belongs.'), 'title' => $this->t('Title of the feed item.'), @@ -36,7 +36,7 @@ public function fields() { 'description' => $this->t('Body of the feed item.'), 'timestamp' => $this->t('Post date of feed item, as a Unix timestamp.'), 'guid' => $this->t('Unique identifier for the feed item.'), - ); + ]; } /** diff --git a/core/modules/aggregator/src/Plugin/views/argument/Fid.php b/core/modules/aggregator/src/Plugin/views/argument/Fid.php index bb912e1..90564d5 100644 --- a/core/modules/aggregator/src/Plugin/views/argument/Fid.php +++ b/core/modules/aggregator/src/Plugin/views/argument/Fid.php @@ -50,7 +50,7 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function titleQuery() { - $titles = array(); + $titles = []; $feeds = $this->entityManager->getStorage('aggregator_feed')->loadMultiple($this->value); foreach ($feeds as $feed) { diff --git a/core/modules/aggregator/src/Plugin/views/argument/Iid.php b/core/modules/aggregator/src/Plugin/views/argument/Iid.php index 9468c98..44b4569 100644 --- a/core/modules/aggregator/src/Plugin/views/argument/Iid.php +++ b/core/modules/aggregator/src/Plugin/views/argument/Iid.php @@ -50,7 +50,7 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function titleQuery() { - $titles = array(); + $titles = []; $items = $this->entityManager->getStorage('aggregator_item')->loadMultiple($this->value); foreach ($items as $feed) { diff --git a/core/modules/aggregator/src/Plugin/views/row/Rss.php b/core/modules/aggregator/src/Plugin/views/row/Rss.php index ef46466..464a285 100644 --- a/core/modules/aggregator/src/Plugin/views/row/Rss.php +++ b/core/modules/aggregator/src/Plugin/views/row/Rss.php @@ -48,31 +48,31 @@ public function render($row) { $item->{$name} = $field->value; } - $item->elements = array( - array( + $item->elements = [ + [ 'key' => 'pubDate', // views_view_row_rss takes care about the escaping. 'value' => gmdate('r', $entity->timestamp->value), - ), - array( + ], + [ 'key' => 'dc:creator', // views_view_row_rss takes care about the escaping. 'value' => $entity->author->value, - ), - array( + ], + [ 'key' => 'guid', // views_view_row_rss takes care about the escaping. 'value' => $entity->guid->value, - 'attributes' => array('isPermaLink' => 'false'), - ), - ); + 'attributes' => ['isPermaLink' => 'false'], + ], + ]; - $build = array( + $build = [ '#theme' => $this->themeFunctions(), '#view' => $this->view, '#options' => $this->options, '#row' => $item, - ); + ]; return $build; } diff --git a/core/modules/aggregator/src/Tests/AddFeedTest.php b/core/modules/aggregator/src/Tests/AddFeedTest.php index b7ffe5f..4dfeb95 100644 --- a/core/modules/aggregator/src/Tests/AddFeedTest.php +++ b/core/modules/aggregator/src/Tests/AddFeedTest.php @@ -39,8 +39,8 @@ public function testAddFeed() { 'refresh' => '900', ]; $this->drupalPostForm('aggregator/sources/add', $edit, t('Save')); - $this->assertRaw(t('A feed named %feed already exists. Enter a unique title.', array('%feed' => $feed->label()))); - $this->assertRaw(t('A feed with this URL %url already exists. Enter a unique URL.', array('%url' => $feed->getUrl()))); + $this->assertRaw(t('A feed named %feed already exists. Enter a unique title.', ['%feed' => $feed->label()])); + $this->assertRaw(t('A feed with this URL %url already exists. Enter a unique URL.', ['%url' => $feed->getUrl()])); // Delete feed. $this->deleteFeed($feed); diff --git a/core/modules/aggregator/src/Tests/AggregatorAdminTest.php b/core/modules/aggregator/src/Tests/AggregatorAdminTest.php index 249817f..e3174c1 100644 --- a/core/modules/aggregator/src/Tests/AggregatorAdminTest.php +++ b/core/modules/aggregator/src/Tests/AggregatorAdminTest.php @@ -22,7 +22,7 @@ public function testSettingsPage() { $this->assertText('Test processor'); // Set new values and enable test plugins. - $edit = array( + $edit = [ 'aggregator_allowed_html_tags' => '', 'aggregator_summary_items' => 10, 'aggregator_clear' => 3600, @@ -30,27 +30,27 @@ public function testSettingsPage() { 'aggregator_fetcher' => 'aggregator_test_fetcher', 'aggregator_parser' => 'aggregator_test_parser', 'aggregator_processors[aggregator_test_processor]' => 'aggregator_test_processor', - ); + ]; $this->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.')); foreach ($edit as $name => $value) { - $this->assertFieldByName($name, $value, format_string('"@name" has correct default value.', array('@name' => $name))); + $this->assertFieldByName($name, $value, format_string('"@name" has correct default value.', ['@name' => $name])); } // Check for our test processor settings form. $this->assertText(t('Dummy length setting')); // Change its value to ensure that settingsSubmit is called. - $edit = array( + $edit = [ 'dummy_length' => 100, - ); + ]; $this->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.')); $this->assertFieldByName('dummy_length', 100, '"dummy_length" has correct default value.'); // Make sure settings form is still accessible even after uninstalling a module // that provides the selected plugins. - $this->container->get('module_installer')->uninstall(array('aggregator_test')); + $this->container->get('module_installer')->uninstall(['aggregator_test']); $this->resetAll(); $this->drupalGet('admin/config/services/aggregator/settings'); $this->assertResponse(200); diff --git a/core/modules/aggregator/src/Tests/AggregatorCronTest.php b/core/modules/aggregator/src/Tests/AggregatorCronTest.php index 34a4cb9..9ebb2d2 100644 --- a/core/modules/aggregator/src/Tests/AggregatorCronTest.php +++ b/core/modules/aggregator/src/Tests/AggregatorCronTest.php @@ -16,30 +16,30 @@ public function testCron() { $this->createSampleNodes(); $feed = $this->createFeed(); $this->cronRun(); - $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField()); + $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField()); $this->deleteFeedItems($feed); - $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField()); + $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField()); $this->cronRun(); - $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField()); + $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField()); // Test feed locking when queued for update. $this->deleteFeedItems($feed); db_update('aggregator_feed') ->condition('fid', $feed->id()) - ->fields(array( + ->fields([ 'queued' => REQUEST_TIME, - )) + ]) ->execute(); $this->cronRun(); - $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField()); + $this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField()); db_update('aggregator_feed') ->condition('fid', $feed->id()) - ->fields(array( + ->fields([ 'queued' => 0, - )) + ]) ->execute(); $this->cronRun(); - $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField()); + $this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField()); } } diff --git a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php index 888f1da..de7e401 100644 --- a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php +++ b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php @@ -17,7 +17,7 @@ class AggregatorRenderingTest extends AggregatorTestBase { * * @var array */ - public static $modules = array('block', 'test_page_test'); + public static $modules = ['block', 'test_page_test']; protected function setUp() { parent::setUp(); @@ -35,15 +35,15 @@ public function testBlockLinks() { $this->updateFeedItems($feed, $this->getDefaultFeedItemCount()); // Need admin user to be able to access block admin. - $admin_user = $this->drupalCreateUser(array( + $admin_user = $this->drupalCreateUser([ 'administer blocks', 'access administration pages', 'administer news feeds', 'access news feeds', - )); + ]); $this->drupalLogin($admin_user); - $block = $this->drupalPlaceBlock("aggregator_feed_block", array('label' => 'feed-' . $feed->label())); + $block = $this->drupalPlaceBlock("aggregator_feed_block", ['label' => 'feed-' . $feed->label()]); // Configure the feed that should be displayed. $block->getPlugin()->setConfigurationValue('feed', $feed->id()); @@ -56,20 +56,20 @@ public function testBlockLinks() { // Confirm items appear as links. $items = $this->container->get('entity.manager')->getStorage('aggregator_item')->loadByFeed($feed->id(), 1); - $links = $this->xpath('//a[@href = :href]', array(':href' => reset($items)->getLink())); + $links = $this->xpath('//a[@href = :href]', [':href' => reset($items)->getLink()]); $this->assert(isset($links[0]), 'Item link found.'); // Find the expected read_more link. $href = $feed->url(); - $links = $this->xpath('//a[@href = :href]', array(':href' => $href)); - $this->assert(isset($links[0]), format_string('Link to href %href found.', array('%href' => $href))); + $links = $this->xpath('//a[@href = :href]', [':href' => $href]); + $this->assert(isset($links[0]), format_string('Link to href %href found.', ['%href' => $href])); $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags'); $cache_tags = explode(' ', $cache_tags_header); $this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags)); // Visit that page. $this->drupalGet($feed->urlInfo()->getInternalPath()); - $correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', array(':title' => $feed->label())); + $correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', [':title' => $feed->label()]); $this->assertFalse(empty($correct_titles), 'Aggregator feed page is available and has the correct title.'); $cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags')); $this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags)); @@ -103,18 +103,18 @@ public function testFeedPage() { // Check for presence of an aggregator pager. $this->drupalGet('aggregator'); - $elements = $this->xpath("//ul[contains(@class, :class)]", array(':class' => 'pager__items')); + $elements = $this->xpath("//ul[contains(@class, :class)]", [':class' => 'pager__items']); $this->assertTrue(!empty($elements), 'Individual source page contains a pager.'); // Check for sources page title. $this->drupalGet('aggregator/sources'); - $titles = $this->xpath('//h1[normalize-space(text())=:title]', array(':title' => 'Sources')); + $titles = $this->xpath('//h1[normalize-space(text())=:title]', [':title' => 'Sources']); $this->assertTrue(!empty($titles), 'Source page contains correct title.'); // Find the expected read_more link on the sources page. $href = $feed->url(); - $links = $this->xpath('//a[@href = :href]', array(':href' => $href)); - $this->assertTrue(isset($links[0]), SafeMarkup::format('Link to href %href found.', array('%href' => $href))); + $links = $this->xpath('//a[@href = :href]', [':href' => $href]); + $this->assertTrue(isset($links[0]), SafeMarkup::format('Link to href %href found.', ['%href' => $href])); $cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags'); $cache_tags = explode(' ', $cache_tags_header); $this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags)); @@ -139,7 +139,7 @@ public function testFeedPage() { // Check for the presence of a pager. $this->drupalGet('aggregator/sources/' . $feed->id()); - $elements = $this->xpath("//ul[contains(@class, :class)]", array(':class' => 'pager__items')); + $elements = $this->xpath("//ul[contains(@class, :class)]", [':class' => 'pager__items']); $this->assertTrue(!empty($elements), 'Individual source page contains a pager.'); $cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags')); $this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags)); diff --git a/core/modules/aggregator/src/Tests/AggregatorTestBase.php b/core/modules/aggregator/src/Tests/AggregatorTestBase.php index 15be144..374eb97 100644 --- a/core/modules/aggregator/src/Tests/AggregatorTestBase.php +++ b/core/modules/aggregator/src/Tests/AggregatorTestBase.php @@ -34,10 +34,10 @@ protected function setUp() { // Create an Article node type. if ($this->profile != 'standard') { - $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); + $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); } - $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'administer news feeds', 'access news feeds', 'create article content')); + $this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer news feeds', 'access news feeds', 'create article content']); $this->drupalLogin($this->adminUser); $this->drupalPlaceBlock('local_tasks_block'); } @@ -58,16 +58,16 @@ protected function setUp() { * * @see getFeedEditArray() */ - public function createFeed($feed_url = NULL, array $edit = array()) { + public function createFeed($feed_url = NULL, array $edit = []) { $edit = $this->getFeedEditArray($feed_url, $edit); $this->drupalPostForm('aggregator/sources/add', $edit, t('Save')); - $this->assertText(t('The feed @name has been added.', array('@name' => $edit['title[0][value]'])), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]']))); + $this->assertText(t('The feed @name has been added.', ['@name' => $edit['title[0][value]']]), format_string('The feed @name has been added.', ['@name' => $edit['title[0][value]']])); // Verify that the creation message contains a link to a feed. - $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'aggregator/sources/')); + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'aggregator/sources/']); $this->assert(isset($view_link), 'The message area contains a link to a feed'); - $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']))->fetchField(); + $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", [':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']])->fetchField(); $this->assertTrue(!empty($fid), 'The feed found in database.'); return Feed::load($fid); } @@ -79,8 +79,8 @@ public function createFeed($feed_url = NULL, array $edit = array()) { * Feed object representing the feed. */ public function deleteFeed(FeedInterface $feed) { - $this->drupalPostForm('aggregator/sources/' . $feed->id() . '/delete', array(), t('Delete')); - $this->assertRaw(t('The feed %title has been deleted.', array('%title' => $feed->label())), 'Feed deleted successfully.'); + $this->drupalPostForm('aggregator/sources/' . $feed->id() . '/delete', [], t('Delete')); + $this->assertRaw(t('The feed %title has been deleted.', ['%title' => $feed->label()]), 'Feed deleted successfully.'); } /** @@ -95,19 +95,19 @@ public function deleteFeed(FeedInterface $feed) { * @return array * A feed array. */ - public function getFeedEditArray($feed_url = NULL, array $edit = array()) { + public function getFeedEditArray($feed_url = NULL, array $edit = []) { $feed_name = $this->randomMachineName(10); if (!$feed_url) { - $feed_url = \Drupal::url('view.frontpage.feed_1', array(), array( - 'query' => array('feed' => $feed_name), + $feed_url = \Drupal::url('view.frontpage.feed_1', [], [ + 'query' => ['feed' => $feed_name], 'absolute' => TRUE, - )); + ]); } - $edit += array( + $edit += [ 'title[0][value]' => $feed_name, 'url[0][value]' => $feed_url, 'refresh' => '900', - ); + ]; return $edit; } @@ -123,19 +123,19 @@ public function getFeedEditArray($feed_url = NULL, array $edit = array()) { * @return \Drupal\aggregator\FeedInterface * A feed object. */ - public function getFeedEditObject($feed_url = NULL, array $values = array()) { + public function getFeedEditObject($feed_url = NULL, array $values = []) { $feed_name = $this->randomMachineName(10); if (!$feed_url) { - $feed_url = \Drupal::url('view.frontpage.feed_1', array( - 'query' => array('feed' => $feed_name), + $feed_url = \Drupal::url('view.frontpage.feed_1', [ + 'query' => ['feed' => $feed_name], 'absolute' => TRUE, - )); + ]); } - $values += array( + $values += [ 'title' => $feed_name, 'url' => $feed_url, 'refresh' => '900', - ); + ]; return Feed::create($values); } @@ -165,7 +165,7 @@ public function getDefaultFeedItemCount() { public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) { // First, let's ensure we can get to the rss xml. $this->drupalGet($feed->getUrl()); - $this->assertResponse(200, format_string(':url is reachable.', array(':url' => $feed->getUrl()))); + $this->assertResponse(200, format_string(':url is reachable.', [':url' => $feed->getUrl()])); // Attempt to access the update link directly without an access token. $this->drupalGet('admin/config/services/aggregator/update/' . $feed->id()); @@ -176,15 +176,15 @@ public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) { $this->clickLink('Update items'); // Ensure we have the right number of items. - $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id())); - $feed->items = array(); + $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()]); + $feed->items = []; foreach ($result as $item) { $feed->items[] = $item->iid; } if ($expected_count !== NULL) { $feed->item_count = count($feed->items); - $this->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (@val1 != @val2)', array('@val1' => $expected_count, '@val2' => $feed->item_count))); + $this->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (@val1 != @val2)', ['@val1' => $expected_count, '@val2' => $feed->item_count])); } } @@ -195,8 +195,8 @@ public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) { * Feed object representing the feed. */ public function deleteFeedItems(FeedInterface $feed) { - $this->drupalPostForm('admin/config/services/aggregator/delete/' . $feed->id(), array(), t('Delete items')); - $this->assertRaw(t('The news items from %title have been deleted.', array('%title' => $feed->label())), 'Feed items deleted.'); + $this->drupalPostForm('admin/config/services/aggregator/delete/' . $feed->id(), [], t('Delete items')); + $this->assertRaw(t('The news items from %title have been deleted.', ['%title' => $feed->label()]), 'Feed items deleted.'); } /** @@ -209,10 +209,10 @@ public function deleteFeedItems(FeedInterface $feed) { */ public function updateAndDelete(FeedInterface $feed, $expected_count) { $this->updateFeedItems($feed, $expected_count); - $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField(); + $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField(); $this->assertTrue($count); $this->deleteFeedItems($feed); - $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField(); + $count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField(); $this->assertTrue($count == 0); } @@ -228,7 +228,7 @@ public function updateAndDelete(FeedInterface $feed, $expected_count) { * TRUE if feed is unique. */ public function uniqueFeed($feed_name, $feed_url) { - $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $feed_name, ':url' => $feed_url))->fetchField(); + $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", [':title' => $feed_name, ':url' => $feed_url])->fetchField(); return (1 == $result); } @@ -354,7 +354,7 @@ public function getHtmlEntitiesSample() { public function createSampleNodes($count = 5) { // Post $count article nodes. for ($i = 0; $i < $count; $i++) { - $edit = array(); + $edit = []; $edit['title[0][value]'] = $this->randomMachineName(); $edit['body[0][value]'] = $this->randomMachineName(); $this->drupalPostForm('node/add/article', $edit, t('Save')); @@ -368,10 +368,10 @@ public function enableTestPlugins() { $this->config('aggregator.settings') ->set('fetcher', 'aggregator_test_fetcher') ->set('parser', 'aggregator_test_parser') - ->set('processors', array( + ->set('processors', [ 'aggregator_test_processor' => 'aggregator_test_processor', 'aggregator' => 'aggregator', - )) + ]) ->save(); } diff --git a/core/modules/aggregator/src/Tests/DeleteFeedItemTest.php b/core/modules/aggregator/src/Tests/DeleteFeedItemTest.php index 0261ed5..69d0cf2 100644 --- a/core/modules/aggregator/src/Tests/DeleteFeedItemTest.php +++ b/core/modules/aggregator/src/Tests/DeleteFeedItemTest.php @@ -13,15 +13,15 @@ class DeleteFeedItemTest extends AggregatorTestBase { */ public function testDeleteFeedItem() { // Create a bunch of test feeds. - $feed_urls = array(); + $feed_urls = []; // No last-modified, no etag. - $feed_urls[] = \Drupal::url('aggregator_test.feed', array(), array('absolute' => TRUE)); + $feed_urls[] = \Drupal::url('aggregator_test.feed', [], ['absolute' => TRUE]); // Last-modified, but no etag. - $feed_urls[] = \Drupal::url('aggregator_test.feed', array('use_last_modified' => 1), array('absolute' => TRUE)); + $feed_urls[] = \Drupal::url('aggregator_test.feed', ['use_last_modified' => 1], ['absolute' => TRUE]); // No Last-modified, but etag. - $feed_urls[] = \Drupal::url('aggregator_test.feed', array('use_last_modified' => 0, 'use_etag' => 1), array('absolute' => TRUE)); + $feed_urls[] = \Drupal::url('aggregator_test.feed', ['use_last_modified' => 0, 'use_etag' => 1], ['absolute' => TRUE]); // Last-modified and etag. - $feed_urls[] = \Drupal::url('aggregator_test.feed', array('use_last_modified' => 1, 'use_etag' => 1), array('absolute' => TRUE)); + $feed_urls[] = \Drupal::url('aggregator_test.feed', ['use_last_modified' => 1, 'use_etag' => 1], ['absolute' => TRUE]); foreach ($feed_urls as $feed_url) { $feed = $this->createFeed($feed_url); diff --git a/core/modules/aggregator/src/Tests/DeleteFeedTest.php b/core/modules/aggregator/src/Tests/DeleteFeedTest.php index 4cde81a..537e813 100644 --- a/core/modules/aggregator/src/Tests/DeleteFeedTest.php +++ b/core/modules/aggregator/src/Tests/DeleteFeedTest.php @@ -14,7 +14,7 @@ class DeleteFeedTest extends AggregatorTestBase { * * @var array */ - public static $modules = array('block'); + public static $modules = ['block']; /** * Deletes a feed and ensures that all of its services are deleted. @@ -43,7 +43,7 @@ public function testDeleteFeed() { $this->assertResponse(404, 'Deleted feed source does not exists.'); // Check database for feed. - $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $feed1->label(), ':url' => $feed1->getUrl()))->fetchField(); + $result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", [':title' => $feed1->label(), ':url' => $feed1->getUrl()])->fetchField(); $this->assertFalse($result, 'Feed not found in database'); } diff --git a/core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php b/core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php index b6e36e9..7e93279 100644 --- a/core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php +++ b/core/modules/aggregator/src/Tests/FeedAdminDisplayTest.php @@ -14,7 +14,7 @@ class FeedAdminDisplayTest extends AggregatorTestBase { */ public function testFeedUpdateFields() { // Create scheduled feed. - $scheduled_feed = $this->createFeed(NULL, array('refresh' => '900')); + $scheduled_feed = $this->createFeed(NULL, ['refresh' => '900']); $this->drupalGet('admin/config/services/aggregator'); $this->assertResponse(200, 'Aggregator feed overview page exists.'); @@ -40,7 +40,7 @@ public function testFeedUpdateFields() { $this->deleteFeed($scheduled_feed); // Create non-scheduled feed. - $non_scheduled_feed = $this->createFeed(NULL, array('refresh' => '0')); + $non_scheduled_feed = $this->createFeed(NULL, ['refresh' => '0']); $this->drupalGet('admin/config/services/aggregator'); // The non scheduled feed shows that it has not been updated yet. diff --git a/core/modules/aggregator/src/Tests/FeedCacheTagsTest.php b/core/modules/aggregator/src/Tests/FeedCacheTagsTest.php index 2b85c19..e5b82c3 100644 --- a/core/modules/aggregator/src/Tests/FeedCacheTagsTest.php +++ b/core/modules/aggregator/src/Tests/FeedCacheTagsTest.php @@ -17,7 +17,7 @@ class FeedCacheTagsTest extends EntityWithUriCacheTagsTestBase { /** * {@inheritdoc} */ - public static $modules = array('aggregator'); + public static $modules = ['aggregator']; /** * {@inheritdoc} @@ -37,13 +37,13 @@ protected function setUp() { */ protected function createEntity() { // Create a "Llama" feed. - $feed = Feed::create(array( + $feed = Feed::create([ 'title' => 'Llama', 'url' => 'https://www.drupal.org/', 'refresh' => 900, 'checked' => 1389919932, 'description' => 'Drupal.org', - )); + ]); $feed->save(); return $feed; diff --git a/core/modules/aggregator/src/Tests/FeedLanguageTest.php b/core/modules/aggregator/src/Tests/FeedLanguageTest.php index af8335e..98d04fa 100644 --- a/core/modules/aggregator/src/Tests/FeedLanguageTest.php +++ b/core/modules/aggregator/src/Tests/FeedLanguageTest.php @@ -16,14 +16,14 @@ class FeedLanguageTest extends AggregatorTestBase { * * @var array */ - public static $modules = array('language'); + public static $modules = ['language']; /** * List of langcodes. * * @var string[] */ - protected $langcodes = array(); + protected $langcodes = []; /** * {@inheritdoc} @@ -32,12 +32,12 @@ protected function setUp() { parent::setUp(); // Create test languages. - $this->langcodes = array(ConfigurableLanguage::load('en')); + $this->langcodes = [ConfigurableLanguage::load('en')]; for ($i = 1; $i < 3; ++$i) { - $language = ConfigurableLanguage::create(array( + $language = ConfigurableLanguage::create([ 'id' => 'l' . $i, 'label' => $this->randomString(), - )); + ]); $language->save(); $this->langcodes[$i] = $language->id(); } @@ -57,10 +57,10 @@ public function testFeedLanguage() { $this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration')); /** @var \Drupal\aggregator\FeedInterface[] $feeds */ - $feeds = array(); + $feeds = []; // Create feeds. - $feeds[1] = $this->createFeed(NULL, array('langcode[0][value]' => $this->langcodes[1])); - $feeds[2] = $this->createFeed(NULL, array('langcode[0][value]' => $this->langcodes[2])); + $feeds[1] = $this->createFeed(NULL, ['langcode[0][value]' => $this->langcodes[1]]); + $feeds[2] = $this->createFeed(NULL, ['langcode[0][value]' => $this->langcodes[2]]); // Make sure that the language has been assigned. $this->assertEqual($feeds[1]->language()->getId(), $this->langcodes[1]); @@ -74,7 +74,7 @@ public function testFeedLanguage() { // the one from the feed. foreach ($feeds as $feed) { /** @var \Drupal\aggregator\ItemInterface[] $items */ - $items = entity_load_multiple_by_properties('aggregator_item', array('fid' => $feed->id())); + $items = entity_load_multiple_by_properties('aggregator_item', ['fid' => $feed->id()]); $this->assertTrue(count($items) > 0, 'Feed items were created.'); foreach ($items as $item) { $this->assertEqual($item->language()->getId(), $feed->language()->getId()); diff --git a/core/modules/aggregator/src/Tests/FeedParserTest.php b/core/modules/aggregator/src/Tests/FeedParserTest.php index 6c4a04d..97a5a37 100644 --- a/core/modules/aggregator/src/Tests/FeedParserTest.php +++ b/core/modules/aggregator/src/Tests/FeedParserTest.php @@ -30,7 +30,7 @@ public function testRSS091Sample() { $feed = $this->createFeed($this->getRSS091Sample()); $feed->refreshItems(); $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->label()))); + $this->assertResponse(200, format_string('Feed %name exists.', ['%name' => $feed->label()])); $this->assertText('First example feed item title'); $this->assertLinkByHref('http://example.com/example-turns-one'); $this->assertText('First example feed item description.'); @@ -53,19 +53,19 @@ public function testAtomSample() { $feed = $this->createFeed($this->getAtomSample()); $feed->refreshItems(); $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->label()))); + $this->assertResponse(200, format_string('Feed %name exists.', ['%name' => $feed->label()])); $this->assertText('Atom-Powered Robots Run Amok'); $this->assertLinkByHref('http://example.org/2003/12/13/atom03'); $this->assertText('Some text.'); - $this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', db_query('SELECT guid FROM {aggregator_item} WHERE link = :link', array(':link' => 'http://example.org/2003/12/13/atom03'))->fetchField(), 'Atom entry id element is parsed correctly.'); + $this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', db_query('SELECT guid FROM {aggregator_item} WHERE link = :link', [':link' => 'http://example.org/2003/12/13/atom03'])->fetchField(), 'Atom entry id element is parsed correctly.'); // Check for second feed entry. $this->assertText('We tried to stop them, but we failed.'); $this->assertLinkByHref('http://example.org/2003/12/14/atom03'); $this->assertText('Some other text.'); - $db_guid = db_query('SELECT guid FROM {aggregator_item} WHERE link = :link', array( + $db_guid = db_query('SELECT guid FROM {aggregator_item} WHERE link = :link', [ ':link' => 'http://example.org/2003/12/14/atom03', - ))->fetchField(); + ])->fetchField(); $this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-bbbb-80da344efa6a', $db_guid, 'Atom entry id element is parsed correctly.'); } @@ -76,7 +76,7 @@ public function testHtmlEntitiesSample() { $feed = $this->createFeed($this->getHtmlEntitiesSample()); $feed->refreshItems(); $this->drupalGet('aggregator/sources/' . $feed->id()); - $this->assertResponse(200, format_string('Feed %name exists.', array('%name' => $feed->label()))); + $this->assertResponse(200, format_string('Feed %name exists.', ['%name' => $feed->label()])); $this->assertRaw("Quote" Amp&"); } @@ -85,12 +85,12 @@ public function testHtmlEntitiesSample() { */ public function testRedirectFeed() { $redirect_url = Url::fromRoute('aggregator_test.redirect')->setAbsolute()->toString(); - $feed = Feed::create(array('url' => $redirect_url, 'title' => $this->randomMachineName())); + $feed = Feed::create(['url' => $redirect_url, 'title' => $this->randomMachineName()]); $feed->save(); $feed->refreshItems(); // Make sure that the feed URL was updated correctly. - $this->assertEqual($feed->getUrl(), \Drupal::url('aggregator_test.feed', array(), array('absolute' => TRUE))); + $this->assertEqual($feed->getUrl(), \Drupal::url('aggregator_test.feed', [], ['absolute' => TRUE])); } /** @@ -99,13 +99,13 @@ public function testRedirectFeed() { public function testInvalidFeed() { // Simulate a typo in the URL to force a curl exception. $invalid_url = 'http:/www.drupal.org'; - $feed = Feed::create(array('url' => $invalid_url, 'title' => $this->randomMachineName())); + $feed = Feed::create(['url' => $invalid_url, 'title' => $this->randomMachineName()]); $feed->save(); // Update the feed. Use the UI to be able to check the message easily. $this->drupalGet('admin/config/services/aggregator'); $this->clickLink(t('Update items')); - $this->assertRaw(t('The feed from %title seems to be broken because of error', array('%title' => $feed->label()))); + $this->assertRaw(t('The feed from %title seems to be broken because of error', ['%title' => $feed->label()])); } } diff --git a/core/modules/aggregator/src/Tests/FeedProcessorPluginTest.php b/core/modules/aggregator/src/Tests/FeedProcessorPluginTest.php index 8a7ade0..7680886 100644 --- a/core/modules/aggregator/src/Tests/FeedProcessorPluginTest.php +++ b/core/modules/aggregator/src/Tests/FeedProcessorPluginTest.php @@ -45,7 +45,7 @@ public function testDelete() { $description = $feed->description->value ?: ''; $this->updateAndDelete($feed, NULL); // Make sure the feed title is changed. - $entities = entity_load_multiple_by_properties('aggregator_feed', array('description' => $description)); + $entities = entity_load_multiple_by_properties('aggregator_feed', ['description' => $description]); $this->assertTrue(empty($entities)); } @@ -53,11 +53,11 @@ public function testDelete() { * Test post-processing functionality. */ public function testPostProcess() { - $feed = $this->createFeed(NULL, array('refresh' => 1800)); + $feed = $this->createFeed(NULL, ['refresh' => 1800]); $this->updateFeedItems($feed); $feed_id = $feed->id(); // Reset entity cache manually. - \Drupal::entityManager()->getStorage('aggregator_feed')->resetCache(array($feed_id)); + \Drupal::entityManager()->getStorage('aggregator_feed')->resetCache([$feed_id]); // Reload the feed to get new values. $feed = Feed::load($feed_id); // Make sure its refresh rate doubled. diff --git a/core/modules/aggregator/src/Tests/ImportOpmlTest.php b/core/modules/aggregator/src/Tests/ImportOpmlTest.php index 1f1e90d..8cb58d0 100644 --- a/core/modules/aggregator/src/Tests/ImportOpmlTest.php +++ b/core/modules/aggregator/src/Tests/ImportOpmlTest.php @@ -14,7 +14,7 @@ class ImportOpmlTest extends AggregatorTestBase { * * @var array */ - public static $modules = array('block', 'help'); + public static $modules = ['block', 'help']; /** * {@inheritdoc} @@ -22,7 +22,7 @@ class ImportOpmlTest extends AggregatorTestBase { protected function setUp() { parent::setUp(); - $admin_user = $this->drupalCreateUser(array('administer news feeds', 'access news feeds', 'create article content', 'administer blocks')); + $admin_user = $this->drupalCreateUser(['administer news feeds', 'access news feeds', 'create article content', 'administer blocks']); $this->drupalLogin($admin_user); } @@ -31,7 +31,7 @@ protected function setUp() { */ public function openImportForm() { // Enable the help block. - $this->drupalPlaceBlock('help_block', array('region' => 'help')); + $this->drupalPlaceBlock('help_block', ['region' => 'help']); $this->drupalGet('admin/config/services/aggregator/add/opml'); $this->assertText('A single OPML document may contain many feeds.', 'Found OPML help text.'); @@ -46,19 +46,19 @@ public function openImportForm() { public function validateImportFormFields() { $before = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField(); - $edit = array(); + $edit = []; $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import')); $this->assertRaw(t('Either upload a file or enter a URL.'), 'Error if no fields are filled.'); $path = $this->getEmptyOpml(); - $edit = array( + $edit = [ 'files[upload]' => $path, 'remote' => file_create_url($path), - ); + ]; $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import')); $this->assertRaw(t('Either upload a file or enter a URL.'), 'Error if both fields are filled.'); - $edit = array('remote' => 'invalidUrl://empty'); + $edit = ['remote' => 'invalidUrl://empty']; $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import')); $this->assertText(t('The URL invalidUrl://empty is not valid.'), 'Error if the URL is invalid.'); @@ -76,7 +76,7 @@ protected function submitImportForm() { $this->drupalPostForm('admin/config/services/aggregator/add/opml', $form, t('Import')); $this->assertText(t('No new feed has been added.'), 'Attempting to upload invalid XML.'); - $edit = array('remote' => file_create_url($this->getEmptyOpml())); + $edit = ['remote' => file_create_url($this->getEmptyOpml())]; $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import')); $this->assertText(t('No new feed has been added.'), 'Attempting to load empty OPML from remote URL.'); @@ -88,13 +88,13 @@ protected function submitImportForm() { $feeds[0] = $this->getFeedEditArray(); $feeds[1] = $this->getFeedEditArray(); $feeds[2] = $this->getFeedEditArray(); - $edit = array( + $edit = [ 'files[upload]' => $this->getValidOpml($feeds), 'refresh' => '900', - ); + ]; $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import')); - $this->assertRaw(t('A feed with the URL %url already exists.', array('%url' => $feeds[0]['url[0][value]'])), 'Verifying that a duplicate URL was identified'); - $this->assertRaw(t('A feed named %title already exists.', array('%title' => $feeds[1]['title[0][value]'])), 'Verifying that a duplicate title was identified'); + $this->assertRaw(t('A feed with the URL %url already exists.', ['%url' => $feeds[0]['url[0][value]']]), 'Verifying that a duplicate URL was identified'); + $this->assertRaw(t('A feed named %title already exists.', ['%title' => $feeds[1]['title[0][value]']]), 'Verifying that a duplicate title was identified'); $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField(); $this->assertEqual($after, 2, 'Verifying that two distinct feeds were added.'); diff --git a/core/modules/aggregator/src/Tests/ItemCacheTagsTest.php b/core/modules/aggregator/src/Tests/ItemCacheTagsTest.php index 1986cea..aac4517 100644 --- a/core/modules/aggregator/src/Tests/ItemCacheTagsTest.php +++ b/core/modules/aggregator/src/Tests/ItemCacheTagsTest.php @@ -19,7 +19,7 @@ class ItemCacheTagsTest extends EntityCacheTagsTestBase { /** * {@inheritdoc} */ - public static $modules = array('aggregator'); + public static $modules = ['aggregator']; /** * {@inheritdoc} @@ -39,21 +39,21 @@ protected function setUp() { */ protected function createEntity() { // Create a "Camelids" feed. - $feed = Feed::create(array( + $feed = Feed::create([ 'title' => 'Camelids', 'url' => 'https://groups.drupal.org/not_used/167169', 'refresh' => 900, 'checked' => 1389919932, 'description' => 'Drupal Core Group feed', - )); + ]); $feed->save(); // Create a "Llama" aggregator feed item. - $item = Item::create(array( + $item = Item::create([ 'fid' => $feed->id(), 'title' => t('Llama'), 'path' => 'https://www.drupal.org/', - )); + ]); $item->save(); return $item; @@ -67,14 +67,14 @@ public function testEntityCreation() { \Drupal::cache('render')->set('foo', 'bar', CacheBackendInterface::CACHE_PERMANENT, $this->entity->getCacheTags()); // Verify a cache hit. - $this->verifyRenderCache('foo', array('aggregator_feed:1')); + $this->verifyRenderCache('foo', ['aggregator_feed:1']); // Now create a feed item in that feed. - Item::create(array( + Item::create([ 'fid' => $this->entity->getFeedId(), 'title' => t('Llama 2'), 'path' => 'https://groups.drupal.org/', - ))->save(); + ])->save(); // Verify a cache miss. $this->assertFalse(\Drupal::cache('render')->get('foo'), 'Creating a new feed item invalidates the cache tag of the feed.'); diff --git a/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php b/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php index ae78205..67e96f1 100644 --- a/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php +++ b/core/modules/aggregator/src/Tests/UpdateFeedItemTest.php @@ -26,47 +26,47 @@ public function testUpdateFeedItem() { $this->deleteFeed($feed); // Test updating feed items without valid timestamp information. - $edit = array( + $edit = [ 'title[0][value]' => "Feed without publish timestamp", 'url[0][value]' => $this->getRSS091Sample(), - ); + ]; $this->drupalGet($edit['url[0][value]']); $this->assertResponse(200); $this->drupalPostForm('aggregator/sources/add', $edit, t('Save')); - $this->assertText(t('The feed @name has been added.', array('@name' => $edit['title[0][value]'])), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]']))); + $this->assertText(t('The feed @name has been added.', ['@name' => $edit['title[0][value]']]), format_string('The feed @name has been added.', ['@name' => $edit['title[0][value]']])); // Verify that the creation message contains a link to a feed. - $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'aggregator/sources/')); + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'aggregator/sources/']); $this->assert(isset($view_link), 'The message area contains a link to a feed'); - $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE url = :url", array(':url' => $edit['url[0][value]']))->fetchField(); + $fid = db_query("SELECT fid FROM {aggregator_feed} WHERE url = :url", [':url' => $edit['url[0][value]']])->fetchField(); $feed = Feed::load($fid); $feed->refreshItems(); - $before = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField(); + $before = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField(); // Sleep for 3 second. sleep(3); db_update('aggregator_feed') ->condition('fid', $feed->id()) - ->fields(array( + ->fields([ 'checked' => 0, 'hash' => '', 'etag' => '', 'modified' => 0, - )) + ]) ->execute(); $feed->refreshItems(); - $after = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField(); - $this->assertTrue($before === $after, format_string('Publish timestamp of feed item was not updated (@before === @after)', array('@before' => $before, '@after' => $after))); + $after = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField(); + $this->assertTrue($before === $after, format_string('Publish timestamp of feed item was not updated (@before === @after)', ['@before' => $before, '@after' => $after])); // Make sure updating items works even after uninstalling a module // that provides the selected plugins. $this->enableTestPlugins(); - $this->container->get('module_installer')->uninstall(array('aggregator_test')); + $this->container->get('module_installer')->uninstall(['aggregator_test']); $this->updateFeedItems($feed); $this->assertResponse(200); } diff --git a/core/modules/aggregator/src/Tests/UpdateFeedTest.php b/core/modules/aggregator/src/Tests/UpdateFeedTest.php index 8c797a5..d230874 100644 --- a/core/modules/aggregator/src/Tests/UpdateFeedTest.php +++ b/core/modules/aggregator/src/Tests/UpdateFeedTest.php @@ -12,7 +12,7 @@ class UpdateFeedTest extends AggregatorTestBase { * Creates a feed and attempts to update it. */ public function testUpdateFeed() { - $remaining_fields = array('title[0][value]', 'url[0][value]', ''); + $remaining_fields = ['title[0][value]', 'url[0][value]', '']; foreach ($remaining_fields as $same_field) { $feed = $this->createFeed(); @@ -24,10 +24,10 @@ public function testUpdateFeed() { $edit[$same_field] = $feed->{$same_field}->value; } $this->drupalPostForm('aggregator/sources/' . $feed->id() . '/configure', $edit, t('Save')); - $this->assertText(t('The feed @name has been updated.', array('@name' => $edit['title[0][value]'])), format_string('The feed %name has been updated.', array('%name' => $edit['title[0][value]']))); + $this->assertText(t('The feed @name has been updated.', ['@name' => $edit['title[0][value]']]), format_string('The feed %name has been updated.', ['%name' => $edit['title[0][value]']])); // Verify that the creation message contains a link to a feed. - $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'aggregator/sources/')); + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'aggregator/sources/']); $this->assert(isset($view_link), 'The message area contains a link to a feed'); // Check feed data. diff --git a/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php b/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php index 2f73c5f..294697a 100644 --- a/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php +++ b/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/processor/TestProcessor.php @@ -75,20 +75,20 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $processors = $this->config('aggregator.settings')->get('processors'); $info = $this->getPluginDefinition(); - $form['processors'][$info['id']] = array( + $form['processors'][$info['id']] = [ '#type' => 'details', '#title' => t('Test processor settings'), '#description' => $info['description'], '#open' => in_array($info['id'], $processors), - ); + ]; // Add some dummy settings to verify settingsForm is called. - $form['processors'][$info['id']]['dummy_length'] = array( + $form['processors'][$info['id']]['dummy_length'] = [ '#title' => t('Dummy length setting'), '#type' => 'number', '#min' => 1, '#max' => 1000, '#default_value' => $this->configuration['items']['dummy_length'], - ); + ]; return $form; } diff --git a/core/modules/aggregator/tests/src/Kernel/FeedValidationTest.php b/core/modules/aggregator/tests/src/Kernel/FeedValidationTest.php index 81a501e..d8804dd9 100644 --- a/core/modules/aggregator/tests/src/Kernel/FeedValidationTest.php +++ b/core/modules/aggregator/tests/src/Kernel/FeedValidationTest.php @@ -17,7 +17,7 @@ class FeedValidationTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('aggregator', 'options'); + public static $modules = ['aggregator', 'options']; /** * {@inheritdoc} diff --git a/core/modules/aggregator/tests/src/Kernel/Migrate/d6/MigrateAggregatorConfigsTest.php b/core/modules/aggregator/tests/src/Kernel/Migrate/d6/MigrateAggregatorConfigsTest.php index de6c87e..cda6d4e 100644 --- a/core/modules/aggregator/tests/src/Kernel/Migrate/d6/MigrateAggregatorConfigsTest.php +++ b/core/modules/aggregator/tests/src/Kernel/Migrate/d6/MigrateAggregatorConfigsTest.php @@ -34,7 +34,7 @@ public function testAggregatorSettings() { $config = $this->config('aggregator.settings'); $this->assertIdentical('aggregator', $config->get('fetcher')); $this->assertIdentical('aggregator', $config->get('parser')); - $this->assertIdentical(array('aggregator'), $config->get('processors')); + $this->assertIdentical(['aggregator'], $config->get('processors')); $this->assertIdentical(600, $config->get('items.teaser_length')); $this->assertIdentical('
      • ', $config->get('items.allowed_html')); $this->assertIdentical(9676800, $config->get('items.expire')); diff --git a/core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php b/core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php index a72da23..39f57b2 100644 --- a/core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php +++ b/core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php @@ -21,14 +21,14 @@ class IntegrationTest extends ViewsKernelTestBase { * * @var array */ - public static $modules = array('aggregator', 'aggregator_test_views', 'system', 'field', 'options', 'user'); + public static $modules = ['aggregator', 'aggregator_test_views', 'system', 'field', 'options', 'user']; /** * Views used by this test. * * @var array */ - public static $testViews = array('test_aggregator_items'); + public static $testViews = ['test_aggregator_items']; /** * The entity storage for aggregator items. @@ -53,7 +53,7 @@ protected function setUp($import_test_views = TRUE) { $this->installEntitySchema('aggregator_item'); $this->installEntitySchema('aggregator_feed'); - ViewTestData::createTestViews(get_class($this), array('aggregator_test_views')); + ViewTestData::createTestViews(get_class($this), ['aggregator_test_views']); $this->itemStorage = $this->container->get('entity.manager')->getStorage('aggregator_item'); $this->feedStorage = $this->container->get('entity.manager')->getStorage('aggregator_feed'); @@ -66,19 +66,19 @@ public function testAggregatorItemView() { /** @var \Drupal\Core\Render\RendererInterface $renderer */ $renderer = \Drupal::service('renderer'); - $feed = $this->feedStorage->create(array( + $feed = $this->feedStorage->create([ 'title' => $this->randomMachineName(), 'url' => 'https://www.drupal.org/', 'refresh' => 900, 'checked' => 123543535, 'description' => $this->randomMachineName(), - )); + ]); $feed->save(); - $items = array(); - $expected = array(); + $items = []; + $expected = []; for ($i = 0; $i < 10; $i++) { - $values = array(); + $values = []; $values['fid'] = $feed->id(); $values['timestamp'] = mt_rand(REQUEST_TIME - 10, REQUEST_TIME + 10); $values['title'] = $this->randomMachineName(); @@ -99,13 +99,13 @@ public function testAggregatorItemView() { $view = Views::getView('test_aggregator_items'); $this->executeView($view); - $column_map = array( + $column_map = [ 'iid' => 'iid', 'title' => 'title', 'aggregator_item_timestamp' => 'timestamp', 'description' => 'description', 'aggregator_item_author' => 'author', - ); + ]; $this->assertIdenticalResultset($view, $expected, $column_map); // Ensure that the rendering of the linked title works as expected. diff --git a/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php b/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php index c9f6906..7a78ad9 100644 --- a/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php +++ b/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php @@ -15,7 +15,7 @@ class AggregatorLocalTasksTest extends LocalTaskIntegrationTestBase { * {@inheritdoc} */ protected function setUp() { - $this->directoryList = array('aggregator' => 'core/modules/aggregator'); + $this->directoryList = ['aggregator' => 'core/modules/aggregator']; parent::setUp(); } @@ -25,19 +25,19 @@ protected function setUp() { * @dataProvider getAggregatorAdminRoutes */ public function testAggregatorAdminLocalTasks($route) { - $this->assertLocalTasks($route, array( - 0 => array('aggregator.admin_overview', 'aggregator.admin_settings'), - )); + $this->assertLocalTasks($route, [ + 0 => ['aggregator.admin_overview', 'aggregator.admin_settings'], + ]); } /** * Provides a list of routes to test. */ public function getAggregatorAdminRoutes() { - return array( - array('aggregator.admin_overview'), - array('aggregator.admin_settings'), - ); + return [ + ['aggregator.admin_overview'], + ['aggregator.admin_settings'], + ]; } /** @@ -46,9 +46,9 @@ public function getAggregatorAdminRoutes() { * @dataProvider getAggregatorSourceRoutes */ public function testAggregatorSourceLocalTasks($route) { - $this->assertLocalTasks($route, array( - 0 => array('entity.aggregator_feed.canonical', 'entity.aggregator_feed.edit_form', 'entity.aggregator_feed.delete_form'), - )); + $this->assertLocalTasks($route, [ + 0 => ['entity.aggregator_feed.canonical', 'entity.aggregator_feed.edit_form', 'entity.aggregator_feed.delete_form'], + ]); ; } @@ -56,10 +56,10 @@ public function testAggregatorSourceLocalTasks($route) { * Provides a list of source routes to test. */ public function getAggregatorSourceRoutes() { - return array( - array('entity.aggregator_feed.canonical'), - array('entity.aggregator_feed.edit_form'), - ); + return [ + ['entity.aggregator_feed.canonical'], + ['entity.aggregator_feed.edit_form'], + ]; } } diff --git a/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php b/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php index 022b793..6db2057 100644 --- a/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php +++ b/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php @@ -39,20 +39,20 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase { */ protected function setUp() { $this->configFactory = $this->getConfigFactoryStub( - array( - 'aggregator.settings' => array( - 'processors' => array('aggregator_test'), - ), - 'aggregator_test.settings' => array(), - ) + [ + 'aggregator.settings' => [ + 'processors' => ['aggregator_test'], + ], + 'aggregator_test.settings' => [], + ] ); - foreach (array('fetcher', 'parser', 'processor') as $type) { + foreach (['fetcher', 'parser', 'processor'] as $type) { $this->managers[$type] = $this->getMockBuilder('Drupal\aggregator\Plugin\AggregatorPluginManager') ->disableOriginalConstructor() ->getMock(); $this->managers[$type]->expects($this->once()) ->method('getDefinitions') - ->will($this->returnValue(array('aggregator_test' => array('title' => '', 'description' => '')))); + ->will($this->returnValue(['aggregator_test' => ['title' => '', 'description' => '']])); } $this->settingsForm = new SettingsForm( @@ -79,8 +79,8 @@ public function testSettingsForm() { $test_processor = $this->getMock( 'Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor', - array('buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'), - array(array(), 'aggregator_test', array('description' => ''), $this->configFactory) + ['buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'], + [[], 'aggregator_test', ['description' => ''], $this->configFactory] ); $test_processor->expects($this->at(0)) ->method('buildConfigurationForm') @@ -98,7 +98,7 @@ public function testSettingsForm() { ->with($this->equalTo('aggregator_test')) ->will($this->returnValue($test_processor)); - $form = $this->settingsForm->buildForm(array(), $form_state); + $form = $this->settingsForm->buildForm([], $form_state); $this->settingsForm->validateForm($form, $form_state); $this->settingsForm->submitForm($form, $form_state); } diff --git a/core/modules/aggregator/tests/src/Unit/Plugin/migrate/source/AggregatorItemTest.php b/core/modules/aggregator/tests/src/Unit/Plugin/migrate/source/AggregatorItemTest.php index edae6d6..0a91253 100644 --- a/core/modules/aggregator/tests/src/Unit/Plugin/migrate/source/AggregatorItemTest.php +++ b/core/modules/aggregator/tests/src/Unit/Plugin/migrate/source/AggregatorItemTest.php @@ -13,15 +13,15 @@ class AggregatorItemTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = 'Drupal\aggregator\Plugin\migrate\source\AggregatorItem'; - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'aggregator_item', - ), - ); + ], + ]; - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'iid' => 1, 'fid' => 1, 'title' => 'This (three) weeks in Drupal Core - January 10th 2014', @@ -30,8 +30,8 @@ class AggregatorItemTest extends MigrateSqlSourceTestCase { 'description' => "

        What's new with Drupal 8?

        ", 'timestamp' => 1389297196, 'guid' => '395218 at https://groups.drupal.org', - ), - ); + ], + ]; /** * {@inheritdoc} diff --git a/core/modules/aggregator/tests/src/Unit/Plugin/migrate/source/d6/AggregatorFeedTest.php b/core/modules/aggregator/tests/src/Unit/Plugin/migrate/source/d6/AggregatorFeedTest.php index 85eaf8e..45807a6 100644 --- a/core/modules/aggregator/tests/src/Unit/Plugin/migrate/source/d6/AggregatorFeedTest.php +++ b/core/modules/aggregator/tests/src/Unit/Plugin/migrate/source/d6/AggregatorFeedTest.php @@ -13,15 +13,15 @@ class AggregatorFeedTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = 'Drupal\aggregator\Plugin\migrate\source\AggregatorFeed'; - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'd6_aggregator_feed', - ), - ); + ], + ]; - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'fid' => 1, 'title' => 'feed title 1', 'url' => 'http://example.com/feed.rss', @@ -33,8 +33,8 @@ class AggregatorFeedTest extends MigrateSqlSourceTestCase { 'etag' => '', 'modified' => 0, 'block' => 5, - ), - array( + ], + [ 'fid' => 2, 'title' => 'feed title 2', 'url' => 'http://example.net/news.rss', @@ -46,8 +46,8 @@ class AggregatorFeedTest extends MigrateSqlSourceTestCase { 'etag' => '', 'modified' => 0, 'block' => 5, - ), - ); + ], + ]; /** * {@inheritdoc} diff --git a/core/modules/aggregator/tests/src/Unit/Plugin/migrate/source/d7/AggregatorFeedTest.php b/core/modules/aggregator/tests/src/Unit/Plugin/migrate/source/d7/AggregatorFeedTest.php index e80b461..5c8c54a 100644 --- a/core/modules/aggregator/tests/src/Unit/Plugin/migrate/source/d7/AggregatorFeedTest.php +++ b/core/modules/aggregator/tests/src/Unit/Plugin/migrate/source/d7/AggregatorFeedTest.php @@ -13,15 +13,15 @@ class AggregatorFeedTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = 'Drupal\aggregator\Plugin\migrate\source\AggregatorFeed'; - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'd7_aggregator_feed', - ), - ); + ], + ]; - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'fid' => 1, 'title' => 'feed title 1', 'url' => 'http://example.com/feed.rss', @@ -34,8 +34,8 @@ class AggregatorFeedTest extends MigrateSqlSourceTestCase { 'etag' => '', 'modified' => 0, 'block' => 5, - ), - array( + ], + [ 'fid' => 2, 'title' => 'feed title 2', 'url' => 'http://example.net/news.rss', @@ -48,8 +48,8 @@ class AggregatorFeedTest extends MigrateSqlSourceTestCase { 'etag' => '', 'modified' => 0, 'block' => 5, - ), - ); + ], + ]; /** * {@inheritdoc} diff --git a/core/modules/ban/ban.install b/core/modules/ban/ban.install index b2ea1fe..f3c003a 100644 --- a/core/modules/ban/ban.install +++ b/core/modules/ban/ban.install @@ -9,27 +9,27 @@ * Implements hook_schema(). */ function ban_schema() { - $schema['ban_ip'] = array( + $schema['ban_ip'] = [ 'description' => 'Stores banned IP addresses.', - 'fields' => array( - 'iid' => array( + 'fields' => [ + 'iid' => [ 'description' => 'Primary Key: unique ID for IP addresses.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, - ), - 'ip' => array( + ], + 'ip' => [ 'description' => 'IP address', 'type' => 'varchar_ascii', 'length' => 40, 'not null' => TRUE, 'default' => '', - ), - ), - 'indexes' => array( - 'ip' => array('ip'), - ), - 'primary key' => array('iid'), - ); + ], + ], + 'indexes' => [ + 'ip' => ['ip'], + ], + 'primary key' => ['iid'], + ]; return $schema; } diff --git a/core/modules/ban/ban.module b/core/modules/ban/ban.module index a1ee238..b8b72c5 100644 --- a/core/modules/ban/ban.module +++ b/core/modules/ban/ban.module @@ -15,11 +15,11 @@ function ban_help($route_name, RouteMatchInterface $route_match) { case 'help.page.ban': $output = ''; $output .= '

        ' . t('About') . '

        '; - $output .= '

        ' . t('The Ban module allows administrators to ban visits to their site from individual IP addresses. For more information, see the online documentation for the Ban module.', array(':url' => 'https://www.drupal.org/documentation/modules/ban')) . '

        '; + $output .= '

        ' . t('The Ban module allows administrators to ban visits to their site from individual IP addresses. For more information, see the online documentation for the Ban module.', [':url' => 'https://www.drupal.org/documentation/modules/ban']) . '

        '; $output .= '

        ' . t('Uses') . '

        '; $output .= '
        '; $output .= '
        ' . t('Banning IP addresses') . '
        '; - $output .= '
        ' . t('Administrators can enter IP addresses to ban on the IP address bans page.', array(':bans' => \Drupal::url('ban.admin_page'))) . '
        '; + $output .= '
        ' . t('Administrators can enter IP addresses to ban on the IP address bans page.', [':bans' => \Drupal::url('ban.admin_page')]) . '
        '; $output .= '
        '; return $output; diff --git a/core/modules/ban/src/BanIpManager.php b/core/modules/ban/src/BanIpManager.php index a92731c..d354f7a 100644 --- a/core/modules/ban/src/BanIpManager.php +++ b/core/modules/ban/src/BanIpManager.php @@ -30,7 +30,7 @@ public function __construct(Connection $connection) { * {@inheritdoc} */ public function isBanned($ip) { - return (bool) $this->connection->query("SELECT * FROM {ban_ip} WHERE ip = :ip", array(':ip' => $ip))->fetchField(); + return (bool) $this->connection->query("SELECT * FROM {ban_ip} WHERE ip = :ip", [':ip' => $ip])->fetchField(); } /** @@ -45,8 +45,8 @@ public function findAll() { */ public function banIp($ip) { $this->connection->merge('ban_ip') - ->key(array('ip' => $ip)) - ->fields(array('ip' => $ip)) + ->key(['ip' => $ip]) + ->fields(['ip' => $ip]) ->execute(); } @@ -63,7 +63,7 @@ public function unbanIp($id) { * {@inheritdoc} */ public function findById($ban_id) { - return $this->connection->query("SELECT ip FROM {ban_ip} WHERE iid = :iid", array(':iid' => $ban_id))->fetchField(); + return $this->connection->query("SELECT ip FROM {ban_ip} WHERE iid = :iid", [':iid' => $ban_id])->fetchField(); } } diff --git a/core/modules/ban/src/Form/BanAdmin.php b/core/modules/ban/src/Form/BanAdmin.php index a0c769f..731d065 100644 --- a/core/modules/ban/src/Form/BanAdmin.php +++ b/core/modules/ban/src/Form/BanAdmin.php @@ -52,47 +52,47 @@ public function getFormId() { * address form field. */ public function buildForm(array $form, FormStateInterface $form_state, $default_ip = '') { - $rows = array(); - $header = array($this->t('banned IP addresses'), $this->t('Operations')); + $rows = []; + $header = [$this->t('banned IP addresses'), $this->t('Operations')]; $result = $this->ipManager->findAll(); foreach ($result as $ip) { - $row = array(); + $row = []; $row[] = $ip->ip; - $links = array(); - $links['delete'] = array( + $links = []; + $links['delete'] = [ 'title' => $this->t('Delete'), 'url' => Url::fromRoute('ban.delete', ['ban_id' => $ip->iid]), - ); - $row[] = array( - 'data' => array( + ]; + $row[] = [ + 'data' => [ '#type' => 'operations', '#links' => $links, - ), - ); + ], + ]; $rows[] = $row; } - $form['ip'] = array( + $form['ip'] = [ '#title' => $this->t('IP address'), '#type' => 'textfield', '#size' => 48, '#maxlength' => 40, '#default_value' => $default_ip, '#description' => $this->t('Enter a valid IP address.'), - ); - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( + ]; + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Add'), - ); + ]; - $form['ban_ip_banning_table'] = array( + $form['ban_ip_banning_table'] = [ '#type' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => $this->t('No blocked IP addresses available.'), '#weight' => 120, - ); + ]; return $form; } @@ -118,7 +118,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) { $ip = trim($form_state->getValue('ip')); $this->ipManager->banIp($ip); - drupal_set_message($this->t('The IP address %ip has been banned.', array('%ip' => $ip))); + drupal_set_message($this->t('The IP address %ip has been banned.', ['%ip' => $ip])); $form_state->setRedirect('ban.admin_page'); } diff --git a/core/modules/ban/src/Form/BanDelete.php b/core/modules/ban/src/Form/BanDelete.php index a8a4962..3d14ca3 100644 --- a/core/modules/ban/src/Form/BanDelete.php +++ b/core/modules/ban/src/Form/BanDelete.php @@ -58,7 +58,7 @@ public function getFormId() { * {@inheritdoc} */ public function getQuestion() { - return $this->t('Are you sure you want to unblock %ip?', array('%ip' => $this->banIp)); + return $this->t('Are you sure you want to unblock %ip?', ['%ip' => $this->banIp]); } /** @@ -93,8 +93,8 @@ public function buildForm(array $form, FormStateInterface $form_state, $ban_id = */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->ipManager->unbanIp($this->banIp); - $this->logger('user')->notice('Deleted %ip', array('%ip' => $this->banIp)); - drupal_set_message($this->t('The IP address %ip was deleted.', array('%ip' => $this->banIp))); + $this->logger('user')->notice('Deleted %ip', ['%ip' => $this->banIp]); + drupal_set_message($this->t('The IP address %ip was deleted.', ['%ip' => $this->banIp])); $form_state->setRedirectUrl($this->getCancelUrl()); } diff --git a/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php b/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php index 94135fd..7c570bb 100644 --- a/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php +++ b/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php @@ -76,7 +76,7 @@ public function fields(MigrationInterface $migration = NULL) { /** * {@inheritdoc} */ - public function import(Row $row, array $old_destination_id_values = array()) { + public function import(Row $row, array $old_destination_id_values = []) { $this->banManager->banIp($row->getDestinationProperty('ip')); } diff --git a/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php b/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php index 9738915..0a155fb 100644 --- a/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php +++ b/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php @@ -18,55 +18,55 @@ class IpAddressBlockingTest extends BrowserTestBase { * * @var array */ - public static $modules = array('ban'); + public static $modules = ['ban']; /** * Tests various user input to confirm correct validation and saving of data. */ function testIPAddressValidation() { // Create user. - $admin_user = $this->drupalCreateUser(array('ban IP addresses')); + $admin_user = $this->drupalCreateUser(['ban IP addresses']); $this->drupalLogin($admin_user); $this->drupalGet('admin/config/people/ban'); // Ban a valid IP address. - $edit = array(); + $edit = []; $edit['ip'] = '1.2.3.3'; $this->drupalPostForm('admin/config/people/ban', $edit, t('Add')); - $ip = db_query("SELECT iid from {ban_ip} WHERE ip = :ip", array(':ip' => $edit['ip']))->fetchField(); + $ip = db_query("SELECT iid from {ban_ip} WHERE ip = :ip", [':ip' => $edit['ip']])->fetchField(); $this->assertTrue($ip, 'IP address found in database.'); - $this->assertRaw(t('The IP address %ip has been banned.', array('%ip' => $edit['ip'])), 'IP address was banned.'); + $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $edit['ip']]), 'IP address was banned.'); // Try to block an IP address that's already blocked. - $edit = array(); + $edit = []; $edit['ip'] = '1.2.3.3'; $this->drupalPostForm('admin/config/people/ban', $edit, t('Add')); $this->assertText(t('This IP address is already banned.')); // Try to block a reserved IP address. - $edit = array(); + $edit = []; $edit['ip'] = '255.255.255.255'; $this->drupalPostForm('admin/config/people/ban', $edit, t('Add')); $this->assertText(t('Enter a valid IP address.')); // Try to block a reserved IP address. - $edit = array(); + $edit = []; $edit['ip'] = 'test.example.com'; $this->drupalPostForm('admin/config/people/ban', $edit, t('Add')); $this->assertText(t('Enter a valid IP address.')); // Submit an empty form. - $edit = array(); + $edit = []; $edit['ip'] = ''; $this->drupalPostForm('admin/config/people/ban', $edit, t('Add')); $this->assertText(t('Enter a valid IP address.')); // Pass an IP address as a URL parameter and submit it. $submit_ip = '1.2.3.4'; - $this->drupalPostForm('admin/config/people/ban/' . $submit_ip, array(), t('Add')); - $ip = db_query("SELECT iid from {ban_ip} WHERE ip = :ip", array(':ip' => $submit_ip))->fetchField(); + $this->drupalPostForm('admin/config/people/ban/' . $submit_ip, [], t('Add')); + $ip = db_query("SELECT iid from {ban_ip} WHERE ip = :ip", [':ip' => $submit_ip])->fetchField(); $this->assertTrue($ip, 'IP address found in database'); - $this->assertRaw(t('The IP address %ip has been banned.', array('%ip' => $submit_ip)), 'IP address was banned.'); + $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $submit_ip]), 'IP address was banned.'); // Submit your own IP address. This fails, although it works when testing // manually. @@ -85,7 +85,7 @@ function testIPAddressValidation() { $banIp->banIp($ip); $banIp->banIp($ip); $query = db_select('ban_ip', 'bip'); - $query->fields('bip', array('iid')); + $query->fields('bip', ['iid']); $query->condition('bip.ip', $ip); $ip_count = $query->execute()->fetchAll(); $this->assertEqual(1, count($ip_count)); @@ -93,7 +93,7 @@ function testIPAddressValidation() { $banIp->banIp($ip); $banIp->banIp($ip); $query = db_select('ban_ip', 'bip'); - $query->fields('bip', array('iid')); + $query->fields('bip', ['iid']); $query->condition('bip.ip', $ip); $ip_count = $query->execute()->fetchAll(); $this->assertEqual(1, count($ip_count)); diff --git a/core/modules/basic_auth/basic_auth.module b/core/modules/basic_auth/basic_auth.module index ea64c5b..7d1d01f 100644 --- a/core/modules/basic_auth/basic_auth.module +++ b/core/modules/basic_auth/basic_auth.module @@ -15,7 +15,7 @@ function basic_auth_help($route_name, RouteMatchInterface $route_match) { case 'help.page.basic_auth': $output = ''; $output .= '

        ' . t('About') . '

        '; - $output .= '

        ' . t('The HTTP Basic Authentication module supplies an HTTP Basic authentication provider for web service requests. This authentication provider authenticates requests using the HTTP Basic Authentication username and password, as an alternative to using Drupal\'s standard cookie-based authentication system. It is only useful if your site provides web services configured to use this type of authentication (for instance, the RESTful Web Services module). For more information, see the online documentation for the HTTP Basic Authentication module.', array(':hba_do' => 'https://www.drupal.org/documentation/modules/basic_auth', ':rest_help' => (\Drupal::moduleHandler()->moduleExists('rest')) ? \Drupal::url('help.page', array('name' => 'rest')) : '#')) . '

        '; + $output .= '

        ' . t('The HTTP Basic Authentication module supplies an HTTP Basic authentication provider for web service requests. This authentication provider authenticates requests using the HTTP Basic Authentication username and password, as an alternative to using Drupal\'s standard cookie-based authentication system. It is only useful if your site provides web services configured to use this type of authentication (for instance, the RESTful Web Services module). For more information, see the online documentation for the HTTP Basic Authentication module.', [':hba_do' => 'https://www.drupal.org/documentation/modules/basic_auth', ':rest_help' => (\Drupal::moduleHandler()->moduleExists('rest')) ? \Drupal::url('help.page', ['name' => 'rest']) : '#']) . '

        '; return $output; } } diff --git a/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php b/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php index eac482c..c72e3f0 100644 --- a/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php +++ b/core/modules/basic_auth/src/Authentication/Provider/BasicAuth.php @@ -88,7 +88,7 @@ public function authenticate(Request $request) { // in to many different user accounts. We have a reasonably high limit // since there may be only one apparent IP for all users at an institution. if ($this->flood->isAllowed('basic_auth.failed_login_ip', $flood_config->get('ip_limit'), $flood_config->get('ip_window'))) { - $accounts = $this->entityManager->getStorage('user')->loadByProperties(array('name' => $username, 'status' => 1)); + $accounts = $this->entityManager->getStorage('user')->loadByProperties(['name' => $username, 'status' => 1]); $account = reset($accounts); if ($account) { if ($flood_config->get('uid_only')) { @@ -127,9 +127,9 @@ public function authenticate(Request $request) { */ public function challengeException(Request $request, \Exception $previous) { $site_name = $this->configFactory->get('system.site')->get('name'); - $challenge = SafeMarkup::format('Basic realm="@realm"', array( + $challenge = SafeMarkup::format('Basic realm="@realm"', [ '@realm' => !empty($site_name) ? $site_name : 'Access restricted', - )); + ]); return new UnauthorizedHttpException((string) $challenge, 'No authentication credentials provided.', $previous); } diff --git a/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php b/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php index 22bb9ca..d8bda2b 100644 --- a/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php +++ b/core/modules/basic_auth/src/Tests/Authentication/BasicAuthTest.php @@ -22,7 +22,7 @@ class BasicAuthTest extends WebTestBase { * * @var array */ - public static $modules = array('basic_auth', 'router_test', 'locale'); + public static $modules = ['basic_auth', 'router_test', 'locale']; /** * Test http basic authentication. @@ -55,7 +55,7 @@ public function testBasicAuth() { $this->drupalGet('admin'); $this->assertResponse('403', 'No authentication prompt for routes not explicitly defining authentication providers.'); - $account = $this->drupalCreateUser(array('access administration pages')); + $account = $this->drupalCreateUser(['access administration pages']); $this->basicAuthGet(Url::fromRoute('system.admin'), $account->getUsername(), $account->pass_raw); $this->assertNoLink('Log out', 'User is not logged in'); @@ -82,7 +82,7 @@ function testGlobalLoginFloodControl() { ->set('user_limit', 4000) ->save(); - $user = $this->drupalCreateUser(array()); + $user = $this->drupalCreateUser([]); $incorrect_user = clone $user; $incorrect_user->pass_raw .= 'incorrect'; $url = Url::fromRoute('router_test.11'); @@ -107,10 +107,10 @@ function testPerUserLoginFloodControl() { ->set('user_limit', 2) ->save(); - $user = $this->drupalCreateUser(array()); + $user = $this->drupalCreateUser([]); $incorrect_user = clone $user; $incorrect_user->pass_raw .= 'incorrect'; - $user2 = $this->drupalCreateUser(array()); + $user2 = $this->drupalCreateUser([]); $url = Url::fromRoute('router_test.11'); // Try a failed login. diff --git a/core/modules/basic_auth/src/Tests/BasicAuthTestTrait.php b/core/modules/basic_auth/src/Tests/BasicAuthTestTrait.php index b5766fb..8a289b0 100644 --- a/core/modules/basic_auth/src/Tests/BasicAuthTestTrait.php +++ b/core/modules/basic_auth/src/Tests/BasicAuthTestTrait.php @@ -51,7 +51,7 @@ protected function basicAuthGet($path, $username, $password, array $options = [] * * @see \Drupal\simpletest\WebTestBase::drupalPostForm() */ - protected function basicAuthPostForm($path, $edit, $submit, $username, $password, array $options = array(), $form_html_id = NULL, $extra_post = NULL) { + protected function basicAuthPostForm($path, $edit, $submit, $username, $password, array $options = [], $form_html_id = NULL, $extra_post = NULL) { return $this->drupalPostForm($path, $edit, $submit, $options, $this->getBasicAuthHeaders($username, $password), $form_html_id, $extra_post); } diff --git a/core/modules/big_pipe/tests/modules/big_pipe_test/src/Form/BigPipeTestForm.php b/core/modules/big_pipe/tests/modules/big_pipe_test/src/Form/BigPipeTestForm.php index ccb15b7..c56ee32 100644 --- a/core/modules/big_pipe/tests/modules/big_pipe_test/src/Form/BigPipeTestForm.php +++ b/core/modules/big_pipe/tests/modules/big_pipe_test/src/Form/BigPipeTestForm.php @@ -20,14 +20,14 @@ public function getFormId() { public function buildForm(array $form, FormStateInterface $form_state) { $form['#token'] = FALSE; - $form['big_pipe'] = array( + $form['big_pipe'] = [ '#type' => 'checkboxes', '#title' => $this->t('BigPipe works…'), '#options' => [ 'js' => $this->t('… with JavaScript'), 'nojs' => $this->t('… without JavaScript'), ], - ); + ]; return $form; } diff --git a/core/modules/block/block.module b/core/modules/block/block.module index 7e39da4..ee6a4a1 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -18,24 +18,24 @@ function block_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { case 'help.page.block': - $block_content = \Drupal::moduleHandler()->moduleExists('block_content') ? \Drupal::url('help.page', array('name' => 'block_content')) : '#'; + $block_content = \Drupal::moduleHandler()->moduleExists('block_content') ? \Drupal::url('help.page', ['name' => 'block_content']) : '#'; $output = ''; $output .= '

        ' . t('About') . '

        '; - $output .= '

        ' . t('The Block module allows you to place blocks in regions of your installed themes, and configure block settings. For more information, see the online documentation for the Block module.', array(':blocks-documentation' => 'https://www.drupal.org/documentation/modules/block/')) . '

        '; + $output .= '

        ' . t('The Block module allows you to place blocks in regions of your installed themes, and configure block settings. For more information, see the online documentation for the Block module.', [':blocks-documentation' => 'https://www.drupal.org/documentation/modules/block/']) . '

        '; $output .= '

        ' . t('Uses') . '

        '; $output .= '
        '; $output .= '
        ' . t('Placing and moving blocks') . '
        '; - $output .= '
        ' . t('You can place a new block in a region by selecting Place block on the Block layout page. Once a block is placed, it can be moved to a different region by drag-and-drop or by using the Region drop-down list, and then clicking Save blocks.', array(':blocks' => \Drupal::url('block.admin_display'))) . '
        '; + $output .= '
        ' . t('You can place a new block in a region by selecting Place block on the Block layout page. Once a block is placed, it can be moved to a different region by drag-and-drop or by using the Region drop-down list, and then clicking Save blocks.', [':blocks' => \Drupal::url('block.admin_display')]) . '
        '; $output .= '
        ' . t('Toggling between different themes') . '
        '; $output .= '
        ' . t('Blocks are placed and configured specifically for each theme. The Block layout page opens with the default theme, but you can toggle to other installed themes.') . '
        '; $output .= '
        ' . t('Demonstrating block regions for a theme') . '
        '; - $output .= '
        ' . t('You can see where the regions are for the current theme by clicking the Demonstrate block regions link on the Block layout page. Regions are specific to each theme.', array(':blocks' => \Drupal::url('block.admin_display'))) . '
        '; + $output .= '
        ' . t('You can see where the regions are for the current theme by clicking the Demonstrate block regions link on the Block layout page. Regions are specific to each theme.', [':blocks' => \Drupal::url('block.admin_display')]) . '
        '; $output .= '
        ' . t('Configuring block settings') . '
        '; - $output .= '
        ' . t('To change the settings of an individual block click on the Configure link on the Block layout page. The available options vary depending on the module that provides the block. For all blocks you can change the block title and toggle whether to display it.', array(':blocks' => Drupal::url('block.admin_display'))) . '
        '; + $output .= '
        ' . t('To change the settings of an individual block click on the Configure link on the Block layout page. The available options vary depending on the module that provides the block. For all blocks you can change the block title and toggle whether to display it.', [':blocks' => Drupal::url('block.admin_display')]) . '
        '; $output .= '
        ' . t('Controlling visibility') . '
        '; $output .= '
        ' . t('You can control the visibility of a block by restricting it to specific pages, content types, and/or roles by setting the appropriate options under Visibility settings of the block configuration.') . '
        '; $output .= '
        ' . t('Adding custom blocks') . '
        '; - $output .= '
        ' . t('You can add custom blocks, if the Custom Block module is installed. For more information, see the Custom Block help page.', array(':blockcontent-help' => $block_content)) . '
        '; + $output .= '
        ' . t('You can add custom blocks, if the Custom Block module is installed. For more information, see the Custom Block help page.', [':blockcontent-help' => $block_content]) . '
        '; $output .= '
        '; return $output; } @@ -43,7 +43,7 @@ function block_help($route_name, RouteMatchInterface $route_match) { $demo_theme = $route_match->getParameter('theme') ?: \Drupal::config('system.theme')->get('default'); $themes = \Drupal::service('theme_handler')->listInfo(); $output = '

        ' . t('Block placement is specific to each theme on your site. Changes will not be saved until you click Save blocks at the bottom of the page.') . '

        '; - $output .= '

        ' . \Drupal::l(t('Demonstrate block regions (@theme)', array('@theme' => $themes[$demo_theme]->info['name'])), new Url('block.admin_demo', array('theme' => $demo_theme))) . '

        '; + $output .= '

        ' . \Drupal::l(t('Demonstrate block regions (@theme)', ['@theme' => $themes[$demo_theme]->info['name']]), new Url('block.admin_demo', ['theme' => $demo_theme])) . '

        '; return $output; } } @@ -52,11 +52,11 @@ function block_help($route_name, RouteMatchInterface $route_match) { * Implements hook_theme(). */ function block_theme() { - return array( - 'block' => array( + return [ + 'block' => [ 'render element' => 'elements', - ), - ); + ], + ]; } /** @@ -65,12 +65,12 @@ function block_theme() { function block_page_top(array &$page_top) { if (\Drupal::routeMatch()->getRouteName() === 'block.admin_demo') { $theme = \Drupal::theme()->getActiveTheme()->getName(); - $page_top['backlink'] = array( + $page_top['backlink'] = [ '#type' => 'link', '#title' => t('Exit block region demonstration'), - '#options' => array('attributes' => array('class' => array('block-demo-backlink'))), + '#options' => ['attributes' => ['class' => ['block-demo-backlink']]], '#weight' => -10, - ); + ]; if (\Drupal::config('system.theme')->get('default') == $theme) { $page_top['backlink']['#url'] = Url::fromRoute('block.admin_display'); } @@ -108,12 +108,12 @@ function block_themes_installed($theme_list) { */ function block_theme_initialize($theme) { // Initialize theme's blocks if none already registered. - $has_blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(array('theme' => $theme)); + $has_blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(['theme' => $theme]); if (!$has_blocks) { $default_theme = \Drupal::config('system.theme')->get('default'); // Apply only to new theme's visible regions. $regions = system_region_list($theme, REGIONS_VISIBLE); - $default_theme_blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(array('theme' => $default_theme)); + $default_theme_blocks = \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(['theme' => $default_theme]); foreach ($default_theme_blocks as $default_theme_block_id => $default_theme_block) { if (strpos($default_theme_block_id, $default_theme . '_') === 0) { $id = str_replace($default_theme, $theme, $default_theme_block_id); @@ -161,7 +161,7 @@ function block_rebuild() { * Implements hook_theme_suggestions_HOOK(). */ function block_theme_suggestions_block(array $variables) { - $suggestions = array(); + $suggestions = []; $suggestions[] = 'block__' . $variables['elements']['#configuration']['provider']; // Hyphens (-) and underscores (_) play a special role in theme suggestions. diff --git a/core/modules/block/block.post_update.php b/core/modules/block/block.post_update.php index 7bab413..792d199 100644 --- a/core/modules/block/block.post_update.php +++ b/core/modules/block/block.post_update.php @@ -63,10 +63,10 @@ function block_post_update_disable_blocks_with_missing_contexts() { $message = t('Encountered an unknown context mapping key coming probably from a contributed or custom module: One or more mappings could not be updated. Please manually review your visibility settings for the following blocks, which are disabled now:'); $message .= '
          '; foreach ($blocks as $disabled_block_id => $disabled_block) { - $message .= '
        • ' . t('@label (Visibility: @plugin_ids)', array( + $message .= '
        • ' . t('@label (Visibility: @plugin_ids)', [ '@label' => $disabled_block->get('settings')['label'], '@plugin_ids' => implode(', ', array_intersect_key($condition_plugin_id_label_map, array_flip(array_keys($block_update_8001[$disabled_block_id]['missing_context_ids'])))) - )) . '
        • '; + ]) . ''; } $message .= '
        '; diff --git a/core/modules/block/src/BlockForm.php b/core/modules/block/src/BlockForm.php index 9b1b027..bc78df2 100644 --- a/core/modules/block/src/BlockForm.php +++ b/core/modules/block/src/BlockForm.php @@ -140,50 +140,50 @@ public function form(array $form, FormStateInterface $form_state) { $form['visibility'] = $this->buildVisibilityInterface([], $form_state); // If creating a new block, calculate a safe default machine name. - $form['id'] = array( + $form['id'] = [ '#type' => 'machine_name', '#maxlength' => 64, '#description' => $this->t('A unique name for this block instance. Must be alpha-numeric and underscore separated.'), '#default_value' => !$entity->isNew() ? $entity->id() : $this->getUniqueMachineName($entity), - '#machine_name' => array( + '#machine_name' => [ 'exists' => '\Drupal\block\Entity\Block::load', 'replace_pattern' => '[^a-z0-9_.]+', - 'source' => array('settings', 'label'), - ), + 'source' => ['settings', 'label'], + ], '#required' => TRUE, '#disabled' => !$entity->isNew(), - ); + ]; // Theme settings. if ($entity->getTheme()) { - $form['theme'] = array( + $form['theme'] = [ '#type' => 'value', '#value' => $theme, - ); + ]; } else { - $theme_options = array(); + $theme_options = []; foreach ($this->themeHandler->listInfo() as $theme_name => $theme_info) { if (!empty($theme_info->status)) { $theme_options[$theme_name] = $theme_info->info['name']; } } - $form['theme'] = array( + $form['theme'] = [ '#type' => 'select', '#options' => $theme_options, '#title' => t('Theme'), '#default_value' => $theme, - '#ajax' => array( + '#ajax' => [ 'callback' => '::themeSwitch', 'wrapper' => 'edit-block-region-wrapper', - ), - ); + ], + ]; } // Region settings. $entity_region = $entity->getRegion(); $region = $entity->isNew() ? $this->getRequest()->query->get('region', $entity_region) : $entity_region; - $form['region'] = array( + $form['region'] = [ '#type' => 'select', '#title' => $this->t('Region'), '#description' => $this->t('Select the region where this block should be displayed.'), @@ -192,7 +192,7 @@ public function form(array $form, FormStateInterface $form_state) { '#options' => system_region_list($theme, REGIONS_VISIBLE), '#prefix' => '
        ', '#suffix' => '
        ', - ); + ]; $form['#attached']['library'][] = 'block/drupal.block.admin'; return $form; } @@ -351,10 +351,10 @@ public function submitForm(array &$form, FormStateInterface $form_state) { drupal_set_message($this->t('The block configuration has been saved.')); $form_state->setRedirect( 'block.admin_display_theme', - array( + [ 'theme' => $form_state->getValue('theme'), - ), - array('query' => array('block-placement' => Html::getClass($this->entity->id()))) + ], + ['query' => ['block-placement' => Html::getClass($this->entity->id())]] ); } diff --git a/core/modules/block/src/BlockListBuilder.php b/core/modules/block/src/BlockListBuilder.php index 7858d6b..0b5439c 100644 --- a/core/modules/block/src/BlockListBuilder.php +++ b/core/modules/block/src/BlockListBuilder.php @@ -125,15 +125,15 @@ public function buildForm(array $form, FormStateInterface $form_state) { // Build the form tree. $form['blocks'] = $this->buildBlocksForm(); - $form['actions'] = array( + $form['actions'] = [ '#tree' => FALSE, '#type' => 'actions', - ); - $form['actions']['submit'] = array( + ]; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Save blocks'), '#button_type' => 'primary', - ); + ]; return $form; } @@ -150,29 +150,29 @@ protected function buildBlocksForm() { /** @var \Drupal\block\BlockInterface[] $entities */ foreach ($entities as $entity_id => $entity) { $definition = $entity->getPlugin()->getPluginDefinition(); - $blocks[$entity->getRegion()][$entity_id] = array( + $blocks[$entity->getRegion()][$entity_id] = [ 'label' => $entity->label(), 'entity_id' => $entity_id, 'weight' => $entity->getWeight(), 'entity' => $entity, 'category' => $definition['category'], 'status' => $entity->status(), - ); + ]; } - $form = array( + $form = [ '#type' => 'table', - '#header' => array( + '#header' => [ $this->t('Block'), $this->t('Category'), $this->t('Region'), $this->t('Weight'), $this->t('Operations'), - ), - '#attributes' => array( + ], + '#attributes' => [ 'id' => 'blocks', - ), - ); + ], + ]; // Weights range from -delta to +delta, so delta should be at least half // of the amount of blocks present. This makes sure all blocks in the same @@ -188,39 +188,39 @@ protected function buildBlocksForm() { // Loop over each region and build blocks. $regions = $this->systemRegionList($this->getThemeName(), REGIONS_VISIBLE); foreach ($regions as $region => $title) { - $form['#tabledrag'][] = array( + $form['#tabledrag'][] = [ 'action' => 'match', 'relationship' => 'sibling', 'group' => 'block-region-select', 'subgroup' => 'block-region-' . $region, 'hidden' => FALSE, - ); - $form['#tabledrag'][] = array( + ]; + $form['#tabledrag'][] = [ 'action' => 'order', 'relationship' => 'sibling', 'group' => 'block-weight', 'subgroup' => 'block-weight-' . $region, - ); + ]; - $form['region-' . $region] = array( - '#attributes' => array( - 'class' => array('region-title', 'region-title-' . $region), + $form['region-' . $region] = [ + '#attributes' => [ + 'class' => ['region-title', 'region-title-' . $region], 'no_striping' => TRUE, - ), - ); - $form['region-' . $region]['title'] = array( - '#theme_wrappers' => array( - 'container' => array( - '#attributes' => array('class' => 'region-title__action'), - ) - ), + ], + ]; + $form['region-' . $region]['title'] = [ + '#theme_wrappers' => [ + 'container' => [ + '#attributes' => ['class' => 'region-title__action'], + ] + ], '#prefix' => $title, '#type' => 'link', '#title' => $this->t('Place block in the %region region', ['%region' => $title]), '#url' => Url::fromRoute('block.admin_library', ['theme' => $this->getThemeName()], ['query' => ['region' => $region]]), - '#wrapper_attributes' => array( + '#wrapper_attributes' => [ 'colspan' => 5, - ), + ], '#attributes' => [ 'class' => ['use-ajax', 'button', 'button--small'], 'data-dialog-type' => 'modal', @@ -228,74 +228,74 @@ protected function buildBlocksForm() { 'width' => 700, ]), ], - ); + ]; - $form['region-' . $region . '-message'] = array( - '#attributes' => array( - 'class' => array( + $form['region-' . $region . '-message'] = [ + '#attributes' => [ + 'class' => [ 'region-message', 'region-' . $region . '-message', empty($blocks[$region]) ? 'region-empty' : 'region-populated', - ), - ), - ); - $form['region-' . $region . '-message']['message'] = array( + ], + ], + ]; + $form['region-' . $region . '-message']['message'] = [ '#markup' => '' . $this->t('No blocks in this region') . '', - '#wrapper_attributes' => array( + '#wrapper_attributes' => [ 'colspan' => 5, - ), - ); + ], + ]; if (isset($blocks[$region])) { foreach ($blocks[$region] as $info) { $entity_id = $info['entity_id']; - $form[$entity_id] = array( - '#attributes' => array( - 'class' => array('draggable'), - ), - ); + $form[$entity_id] = [ + '#attributes' => [ + 'class' => ['draggable'], + ], + ]; $form[$entity_id]['#attributes']['class'][] = $info['status'] ? 'block-enabled' : 'block-disabled'; if ($placement && $placement == Html::getClass($entity_id)) { $form[$entity_id]['#attributes']['class'][] = 'color-success'; $form[$entity_id]['#attributes']['class'][] = 'js-block-placed'; } - $form[$entity_id]['info'] = array( + $form[$entity_id]['info'] = [ '#plain_text' => $info['status'] ? $info['label'] : $this->t('@label (disabled)', ['@label' => $info['label']]), - '#wrapper_attributes' => array( - 'class' => array('block'), - ), - ); - $form[$entity_id]['type'] = array( + '#wrapper_attributes' => [ + 'class' => ['block'], + ], + ]; + $form[$entity_id]['type'] = [ '#markup' => $info['category'], - ); - $form[$entity_id]['region-theme']['region'] = array( + ]; + $form[$entity_id]['region-theme']['region'] = [ '#type' => 'select', '#default_value' => $region, '#required' => TRUE, - '#title' => $this->t('Region for @block block', array('@block' => $info['label'])), + '#title' => $this->t('Region for @block block', ['@block' => $info['label']]), '#title_display' => 'invisible', '#options' => $regions, - '#attributes' => array( - 'class' => array('block-region-select', 'block-region-' . $region), - ), - '#parents' => array('blocks', $entity_id, 'region'), - ); - $form[$entity_id]['region-theme']['theme'] = array( + '#attributes' => [ + 'class' => ['block-region-select', 'block-region-' . $region], + ], + '#parents' => ['blocks', $entity_id, 'region'], + ]; + $form[$entity_id]['region-theme']['theme'] = [ '#type' => 'hidden', '#value' => $this->getThemeName(), - '#parents' => array('blocks', $entity_id, 'theme'), - ); - $form[$entity_id]['weight'] = array( + '#parents' => ['blocks', $entity_id, 'theme'], + ]; + $form[$entity_id]['weight'] = [ '#type' => 'weight', '#default_value' => $info['weight'], '#delta' => $weight_delta, - '#title' => $this->t('Weight for @block block', array('@block' => $info['label'])), + '#title' => $this->t('Weight for @block block', ['@block' => $info['label']]), '#title_display' => 'invisible', - '#attributes' => array( - 'class' => array('block-weight', 'block-weight-' . $region), - ), - ); + '#attributes' => [ + 'class' => ['block-weight', 'block-weight-' . $region], + ], + ]; $form[$entity_id]['operations'] = $this->buildOperations($info['entity']); } } @@ -359,7 +359,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $entities = $this->storage->loadMultiple(array_keys($form_state->getValue('blocks'))); /** @var \Drupal\block\BlockInterface[] $entities */ foreach ($entities as $entity_id => $entity) { - $entity_values = $form_state->getValue(array('blocks', $entity_id)); + $entity_values = $form_state->getValue(['blocks', $entity_id]); $entity->setWeight($entity_values['weight']); $entity->setRegion($entity_values['region']); $entity->save(); diff --git a/core/modules/block/src/BlockRepository.php b/core/modules/block/src/BlockRepository.php index 53620a0..4cdd710 100644 --- a/core/modules/block/src/BlockRepository.php +++ b/core/modules/block/src/BlockRepository.php @@ -48,10 +48,10 @@ public function __construct(EntityManagerInterface $entity_manager, ThemeManager public function getVisibleBlocksPerRegion(array &$cacheable_metadata = []) { $active_theme = $this->themeManager->getActiveTheme(); // Build an array of the region names in the right order. - $empty = array_fill_keys($active_theme->getRegions(), array()); + $empty = array_fill_keys($active_theme->getRegions(), []); - $full = array(); - foreach ($this->blockStorage->loadByProperties(array('theme' => $active_theme->getName())) as $block_id => $block) { + $full = []; + foreach ($this->blockStorage->loadByProperties(['theme' => $active_theme->getName()]) as $block_id => $block) { /** @var \Drupal\block\BlockInterface $block */ $access = $block->access('view', NULL, TRUE); $region = $block->getRegion(); diff --git a/core/modules/block/src/BlockViewBuilder.php b/core/modules/block/src/BlockViewBuilder.php index d3f501b..3b20d7b 100644 --- a/core/modules/block/src/BlockViewBuilder.php +++ b/core/modules/block/src/BlockViewBuilder.php @@ -68,16 +68,16 @@ public function buildComponents(array &$build, array $entities, array $displays, * {@inheritdoc} */ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { - $build = $this->viewMultiple(array($entity), $view_mode, $langcode); + $build = $this->viewMultiple([$entity], $view_mode, $langcode); return reset($build); } /** * {@inheritdoc} */ - public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) { + public function viewMultiple(array $entities = [], $view_mode = 'full', $langcode = NULL) { /** @var \Drupal\block\BlockInterface[] $entities */ - $build = array(); + $build = []; foreach ($entities as $entity) { $entity_id = $entity->id(); $plugin = $entity->getPlugin(); @@ -87,7 +87,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la // Create the render array for the block as a whole. // @see template_preprocess_block(). - $build[$entity_id] = array( + $build[$entity_id] = [ '#cache' => [ 'keys' => ['entity_view', 'block', $entity->id()], 'contexts' => Cache::mergeContexts( @@ -98,7 +98,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la 'max-age' => $plugin->getCacheMaxAge(), ], '#weight' => $entity->getWeight(), - ); + ]; // Allow altering of cacheability metadata or setting #create_placeholder. $this->moduleHandler->alter(['block_build', "block_build_" . $plugin->getBaseId()], $build[$entity_id], $plugin); @@ -216,7 +216,7 @@ public static function preRender($build) { // #contextual_links is information about the *entire* block. Therefore, // we must move these properties from $content and merge them into the // top-level element. - foreach (array('#attributes', '#contextual_links') as $property) { + foreach (['#attributes', '#contextual_links'] as $property) { if (isset($content[$property])) { $build[$property] += $content[$property]; unset($content[$property]); @@ -231,10 +231,10 @@ public static function preRender($build) { // render cached, so we can avoid the work of having to repeatedly // determine whether the block is empty. For instance, modifying or adding // entities could cause the block to no longer be empty. - $build = array( + $build = [ '#markup' => '', '#cache' => $build['#cache'], - ); + ]; // If $content is not empty, then it contains cacheability metadata, and // we must merge it with the existing cacheability metadata. This allows // blocks to be empty, yet still bubble cacheability metadata, to indicate diff --git a/core/modules/block/src/Controller/BlockAddController.php b/core/modules/block/src/Controller/BlockAddController.php index f983763..973a859 100644 --- a/core/modules/block/src/Controller/BlockAddController.php +++ b/core/modules/block/src/Controller/BlockAddController.php @@ -22,7 +22,7 @@ class BlockAddController extends ControllerBase { */ public function blockAddConfigureForm($plugin_id, $theme) { // Create a block entity. - $entity = $this->entityManager()->getStorage('block')->create(array('plugin' => $plugin_id, 'theme' => $theme)); + $entity = $this->entityManager()->getStorage('block')->create(['plugin' => $plugin_id, 'theme' => $theme]); return $this->entityFormBuilder()->getForm($entity); } diff --git a/core/modules/block/src/Controller/BlockController.php b/core/modules/block/src/Controller/BlockController.php index 58417d5..7398ff9 100644 --- a/core/modules/block/src/Controller/BlockController.php +++ b/core/modules/block/src/Controller/BlockController.php @@ -74,7 +74,7 @@ public function demo($theme) { $page = [ '#title' => Html::escape($this->themeHandler->getName($theme)), '#type' => 'page', - '#attached' => array( + '#attached' => [ 'drupalSettings' => [ // The block demonstration page is not marked as an administrative // page by \Drupal::service('router.admin_context')->isAdminRoute() @@ -83,20 +83,20 @@ public function demo($theme) { // is an actual administrative page. 'path' => ['currentPathIsAdmin' => TRUE], ], - 'library' => array( + 'library' => [ 'block/drupal.block.admin', - ), - ), + ], + ], ]; // Show descriptions in each visible page region, nothing else. $visible_regions = $this->getVisibleRegionNames($theme); foreach (array_keys($visible_regions) as $region) { - $page[$region]['block_description'] = array( + $page[$region]['block_description'] = [ '#type' => 'inline_template', '#template' => '
        {{ region_name }}
        ', - '#context' => array('region_name' => $visible_regions[$region]), - ); + '#context' => ['region_name' => $visible_regions[$region]], + ]; } return $page; diff --git a/core/modules/block/src/Controller/CategoryAutocompleteController.php b/core/modules/block/src/Controller/CategoryAutocompleteController.php index a856670..c95fd47 100644 --- a/core/modules/block/src/Controller/CategoryAutocompleteController.php +++ b/core/modules/block/src/Controller/CategoryAutocompleteController.php @@ -51,10 +51,10 @@ public static function create(ContainerInterface $container) { */ public function autocomplete(Request $request) { $typed_category = $request->query->get('q'); - $matches = array(); + $matches = []; foreach ($this->blockManager->getCategories() as $category) { if (stripos($category, $typed_category) === 0) { - $matches[] = array('value' => $category, 'label' => Html::escape($category)); + $matches[] = ['value' => $category, 'label' => Html::escape($category)]; } } return new JsonResponse($matches); diff --git a/core/modules/block/src/Entity/Block.php b/core/modules/block/src/Entity/Block.php index 63b5205..a0bbd25 100644 --- a/core/modules/block/src/Entity/Block.php +++ b/core/modules/block/src/Entity/Block.php @@ -66,7 +66,7 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin * * @var array */ - protected $settings = array(); + protected $settings = []; /** * The region this block is placed in. diff --git a/core/modules/block/src/EventSubscriber/BlockPageDisplayVariantSubscriber.php b/core/modules/block/src/EventSubscriber/BlockPageDisplayVariantSubscriber.php index 2c85587..5faf8b8 100644 --- a/core/modules/block/src/EventSubscriber/BlockPageDisplayVariantSubscriber.php +++ b/core/modules/block/src/EventSubscriber/BlockPageDisplayVariantSubscriber.php @@ -27,7 +27,7 @@ public function onSelectPageDisplayVariant(PageDisplayVariantSelectionEvent $eve * {@inheritdoc} */ static function getSubscribedEvents() { - $events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = array('onSelectPageDisplayVariant'); + $events[RenderEvents::SELECT_PAGE_DISPLAY_VARIANT][] = ['onSelectPageDisplayVariant']; return $events; } diff --git a/core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php b/core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php index 74da932..927cb61 100644 --- a/core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php +++ b/core/modules/block/src/Plugin/Derivative/ThemeLocalTask.php @@ -48,7 +48,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { if ($this->themeHandler->hasUi($theme_name)) { $this->derivatives[$theme_name] = $base_plugin_definition; $this->derivatives[$theme_name]['title'] = $theme->info['name']; - $this->derivatives[$theme_name]['route_parameters'] = array('theme' => $theme_name); + $this->derivatives[$theme_name]['route_parameters'] = ['theme' => $theme_name]; } // Default task! if ($default_theme == $theme_name) { diff --git a/core/modules/block/src/Plugin/migrate/destination/EntityBlock.php b/core/modules/block/src/Plugin/migrate/destination/EntityBlock.php index c904a37..537b160 100644 --- a/core/modules/block/src/Plugin/migrate/destination/EntityBlock.php +++ b/core/modules/block/src/Plugin/migrate/destination/EntityBlock.php @@ -17,10 +17,10 @@ class EntityBlock extends EntityConfigBase { */ protected function getEntityId(Row $row) { // Try to find the block by its plugin ID and theme. - $properties = array( + $properties = [ 'plugin' => $row->getDestinationProperty('plugin'), 'theme' => $row->getDestinationProperty('theme'), - ); + ]; $blocks = array_keys($this->storage->loadByProperties($properties)); return reset($blocks); } diff --git a/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php b/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php index cd4bce5..0852567 100644 --- a/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php +++ b/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php @@ -47,12 +47,12 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { $entity_manager = $container->get('entity.manager'); - $migration_configuration = array( - 'migration' => array( + $migration_configuration = [ + 'migration' => [ 'd6_custom_block', 'd7_custom_block', - ), - ); + ], + ]; return new static( $configuration, $plugin_id, diff --git a/core/modules/block/src/Plugin/migrate/process/BlockRegion.php b/core/modules/block/src/Plugin/migrate/process/BlockRegion.php index d05743e..50c245b 100644 --- a/core/modules/block/src/Plugin/migrate/process/BlockRegion.php +++ b/core/modules/block/src/Plugin/migrate/process/BlockRegion.php @@ -43,7 +43,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - $regions = array(); + $regions = []; foreach ($container->get('theme_handler')->listInfo() as $key => $theme) { $regions[$key] = $theme->info['regions']; } diff --git a/core/modules/block/src/Plugin/migrate/process/BlockSettings.php b/core/modules/block/src/Plugin/migrate/process/BlockSettings.php index 134bf28..a199830 100644 --- a/core/modules/block/src/Plugin/migrate/process/BlockSettings.php +++ b/core/modules/block/src/Plugin/migrate/process/BlockSettings.php @@ -21,7 +21,7 @@ class BlockSettings extends ProcessPluginBase { */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { list($plugin, $delta, $old_settings, $title) = $value; - $settings = array(); + $settings = []; $settings['label'] = $title; if ($title) { $settings['label_display'] = BlockInterface::BLOCK_LABEL_VISIBLE; diff --git a/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php b/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php index e38d60b..8860791 100644 --- a/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php +++ b/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php @@ -59,12 +59,12 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { - $migration_configuration = array( - 'migration' => array( + $migration_configuration = [ + 'migration' => [ 'd6_user_role', 'd7_user_role', - ), - ); + ], + ]; return new static( $configuration, $plugin_id, @@ -80,18 +80,18 @@ public static function create(ContainerInterface $container, array $configuratio public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { list($old_visibility, $pages, $roles) = $value; - $visibility = array(); + $visibility = []; // If the block is assigned to specific roles, add the user_role condition. if ($roles) { - $visibility['user_role'] = array( + $visibility['user_role'] = [ 'id' => 'user_role', - 'roles' => array(), - 'context_mapping' => array( + 'roles' => [], + 'context_mapping' => [ 'user' => '@user.current_user_context:current_user', - ), + ], 'negate' => FALSE, - ); + ]; foreach ($roles as $key => $role_id) { $roles[$key] = $this->migrationPlugin->transform($role_id, $migrate_executable, $row, $destination_property); @@ -104,12 +104,12 @@ public function transform($value, MigrateExecutableInterface $migrate_executable if ($old_visibility == 2) { // If the PHP module is present, migrate the visibility code unaltered. if ($this->moduleHandler->moduleExists('php')) { - $visibility['php'] = array( + $visibility['php'] = [ 'id' => 'php', // PHP code visibility could not be negated in Drupal 6 or 7. 'negate' => FALSE, 'php' => $pages, - ); + ]; } // Skip the row if we're configured to. If not, we don't need to do // anything else -- the block will simply have no PHP or request_path @@ -123,11 +123,11 @@ public function transform($value, MigrateExecutableInterface $migrate_executable foreach ($paths as $key => $path) { $paths[$key] = $path === '' ? $path : '/' . ltrim($path, '/'); } - $visibility['request_path'] = array( + $visibility['request_path'] = [ 'id' => 'request_path', 'negate' => !$old_visibility, 'pages' => implode("\n", $paths), - ); + ]; } } diff --git a/core/modules/block/src/Plugin/migrate/source/Block.php b/core/modules/block/src/Plugin/migrate/source/Block.php index b691283..df4c0e9 100644 --- a/core/modules/block/src/Plugin/migrate/source/Block.php +++ b/core/modules/block/src/Plugin/migrate/source/Block.php @@ -81,7 +81,7 @@ protected function initializeIterator() { * {@inheritdoc} */ public function fields() { - return array( + return [ 'bid' => $this->t('The block numeric identifier.'), 'module' => $this->t('The module providing the block.'), 'delta' => $this->t('The block\'s delta.'), @@ -93,7 +93,7 @@ public function fields() { 'pages' => $this->t('Pages list.'), 'title' => $this->t('Block title.'), 'cache' => $this->t('Cache rule.'), - ); + ]; } /** @@ -117,7 +117,7 @@ public function prepareRow(Row $row) { $delta = $row->getSourceProperty('delta'); $query = $this->select($this->blockRoleTable, 'br') - ->fields('br', array('rid')) + ->fields('br', ['rid']) ->condition('module', $module) ->condition('delta', $delta); $query->join($this->userRoleTable, 'ur', 'br.rid = ur.rid'); @@ -125,7 +125,7 @@ public function prepareRow(Row $row) { ->fetchCol(); $row->setSourceProperty('roles', $roles); - $settings = array(); + $settings = []; switch ($module) { case 'aggregator': list($type, $id) = explode('-', $delta); @@ -152,7 +152,7 @@ public function prepareRow(Row $row) { $settings['forum']['block_num'] = $this->variableGet('forum_block_num_' . $delta, 5); break; case 'statistics': - foreach (array('statistics_block_top_day_num', 'statistics_block_top_all_num', 'statistics_block_top_last_num') as $name) { + foreach (['statistics_block_top_day_num', 'statistics_block_top_all_num', 'statistics_block_top_last_num'] as $name) { $settings['statistics'][$name] = $this->variableGet($name, 0); } break; diff --git a/core/modules/block/src/Tests/BlockAdminThemeTest.php b/core/modules/block/src/Tests/BlockAdminThemeTest.php index ab444d5..7736e05 100644 --- a/core/modules/block/src/Tests/BlockAdminThemeTest.php +++ b/core/modules/block/src/Tests/BlockAdminThemeTest.php @@ -16,14 +16,14 @@ class BlockAdminThemeTest extends WebTestBase { * * @var array */ - public static $modules = array('block', 'contextual'); + public static $modules = ['block', 'contextual']; /** * Check for the accessibility of the admin theme on the block admin page. */ function testAdminTheme() { // Create administrative user. - $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes')); + $admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']); $this->drupalLogin($admin_user); // Ensure that access to block admin page is denied when theme is not @@ -32,7 +32,7 @@ function testAdminTheme() { $this->assertResponse(403); // Install admin theme and confirm that tab is accessible. - \Drupal::service('theme_handler')->install(array('bartik')); + \Drupal::service('theme_handler')->install(['bartik']); $edit['admin_theme'] = 'bartik'; $this->drupalPostForm('admin/appearance', $edit, t('Save configuration')); $this->drupalGet('admin/structure/block/list/bartik'); diff --git a/core/modules/block/src/Tests/BlockCacheTest.php b/core/modules/block/src/Tests/BlockCacheTest.php index f774539..4bde7a9 100644 --- a/core/modules/block/src/Tests/BlockCacheTest.php +++ b/core/modules/block/src/Tests/BlockCacheTest.php @@ -17,7 +17,7 @@ class BlockCacheTest extends WebTestBase { * * @var array */ - public static $modules = array('block', 'block_test', 'test_page_test'); + public static $modules = ['block', 'block_test', 'test_page_test']; /** * A user with permission to create and edit books and to administer blocks. @@ -51,7 +51,7 @@ protected function setUp() { parent::setUp(); // Create an admin user, log in and enable test blocks. - $this->adminUser = $this->drupalCreateUser(array('administer blocks', 'access administration pages')); + $this->adminUser = $this->drupalCreateUser(['administer blocks', 'access administration pages']); $this->drupalLogin($this->adminUser); // Create additional users to test caching modes. @@ -87,7 +87,7 @@ function testCachePerRole() { $this->assertText($old_content, 'Block is served from the cache.'); // Clear the cache and verify that the stale data is no longer there. - Cache::invalidateTags(array('block_view')); + Cache::invalidateTags(['block_view']); $this->drupalGet(''); $this->assertNoText($old_content, 'Block cache clear removes stale cache data.'); $this->assertText($current_content, 'Fresh block content is displayed after clearing the cache.'); diff --git a/core/modules/block/src/Tests/BlockHiddenRegionTest.php b/core/modules/block/src/Tests/BlockHiddenRegionTest.php index b7d44ad..fd88cf4 100644 --- a/core/modules/block/src/Tests/BlockHiddenRegionTest.php +++ b/core/modules/block/src/Tests/BlockHiddenRegionTest.php @@ -22,17 +22,17 @@ class BlockHiddenRegionTest extends WebTestBase { * * @var array */ - public static $modules = array('block', 'block_test', 'search'); + public static $modules = ['block', 'block_test', 'search']; protected function setUp() { parent::setUp(); // Create administrative user. - $this->adminUser = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser([ 'administer blocks', 'administer themes', 'search content', - ) + ] ); $this->drupalLogin($this->adminUser); @@ -53,7 +53,7 @@ public function testBlockNotInHiddenRegion() { $theme = 'block_test_theme'; // We need to install a non-hidden theme so that there is more than one // local task. - \Drupal::service('theme_handler')->install(array($theme, 'stark')); + \Drupal::service('theme_handler')->install([$theme, 'stark']); $this->config('system.theme') ->set('default', $theme) ->save(); diff --git a/core/modules/block/src/Tests/BlockHookOperationTest.php b/core/modules/block/src/Tests/BlockHookOperationTest.php index 91ea843..f4f506b 100644 --- a/core/modules/block/src/Tests/BlockHookOperationTest.php +++ b/core/modules/block/src/Tests/BlockHookOperationTest.php @@ -17,14 +17,14 @@ class BlockHookOperationTest extends WebTestBase { * * @var array */ - public static $modules = array('block', 'entity_test'); + public static $modules = ['block', 'entity_test']; protected function setUp() { parent::setUp(); - $permissions = array( + $permissions = [ 'administer blocks', - ); + ]; // Create and log in user. $admin_user = $this->drupalCreateUser($permissions); @@ -38,7 +38,7 @@ public function testBlockOperationAlter() { // Add a test block, any block will do. // Set the machine name so the test_operation link can be built later. $block_id = Unicode::strtolower($this->randomMachineName(16)); - $this->drupalPlaceBlock('system_powered_by_block', array('id' => $block_id)); + $this->drupalPlaceBlock('system_powered_by_block', ['id' => $block_id]); // Get the Block listing. $this->drupalGet('admin/structure/block'); diff --git a/core/modules/block/src/Tests/BlockHtmlTest.php b/core/modules/block/src/Tests/BlockHtmlTest.php index baf5d4b..d0bc81d 100644 --- a/core/modules/block/src/Tests/BlockHtmlTest.php +++ b/core/modules/block/src/Tests/BlockHtmlTest.php @@ -16,7 +16,7 @@ class BlockHtmlTest extends WebTestBase { * * @var array */ - public static $modules = array('block', 'block_test'); + public static $modules = ['block', 'block_test']; protected function setUp() { parent::setUp(); @@ -24,9 +24,9 @@ protected function setUp() { $this->drupalLogin($this->rootUser); // Enable the test_html block, to test HTML ID and attributes. - \Drupal::state()->set('block_test.attributes', array('data-custom-attribute' => 'foo')); + \Drupal::state()->set('block_test.attributes', ['data-custom-attribute' => 'foo']); \Drupal::state()->set('block_test.content', $this->randomMachineName()); - $this->drupalPlaceBlock('test_html', array('id' => 'test_html_block')); + $this->drupalPlaceBlock('test_html', ['id' => 'test_html_block']); // Enable a menu block, to test more complicated HTML. $this->drupalPlaceBlock('system_menu_block:admin'); @@ -43,7 +43,7 @@ function testHtml() { $this->assertFieldByXPath('//div[@id="block-test-html-block" and @data-custom-attribute="foo"]', NULL, 'HTML ID and attributes for test block are valid and on the same DOM element.'); // Ensure expected markup for a menu block. - $elements = $this->xpath('//nav[contains(@class, :nav-class)]/ul[contains(@class, :ul-class)]/li', array(':nav-class' => 'block-menu', ':ul-class' => 'menu')); + $elements = $this->xpath('//nav[contains(@class, :nav-class)]/ul[contains(@class, :ul-class)]/li', [':nav-class' => 'block-menu', ':ul-class' => 'menu']); $this->assertTrue(!empty($elements), 'The proper block markup was found.'); } diff --git a/core/modules/block/src/Tests/BlockInvalidRegionTest.php b/core/modules/block/src/Tests/BlockInvalidRegionTest.php index 99ef06d..abb05c3 100644 --- a/core/modules/block/src/Tests/BlockInvalidRegionTest.php +++ b/core/modules/block/src/Tests/BlockInvalidRegionTest.php @@ -18,16 +18,16 @@ class BlockInvalidRegionTest extends WebTestBase { * * @var array */ - public static $modules = array('block', 'block_test'); + public static $modules = ['block', 'block_test']; protected function setUp() { parent::setUp(); // Create an admin user. - $admin_user = $this->drupalCreateUser(array( + $admin_user = $this->drupalCreateUser([ 'administer site configuration', 'access administration pages', 'administer blocks', - )); + ]); $this->drupalLogin($admin_user); } @@ -40,14 +40,14 @@ function testBlockInInvalidRegion() { \Drupal::configFactory()->getEditable('block.block.' . $block->id())->set('region', 'invalid_region')->save(); $block = Block::load($block->id()); - $warning_message = t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $block->id(), '%region' => 'invalid_region')); + $warning_message = t('The block %info was assigned to the invalid region %region and has been disabled.', ['%info' => $block->id(), '%region' => 'invalid_region']); // Clearing the cache should disable the test block placed in the invalid region. - $this->drupalPostForm('admin/config/development/performance', array(), 'Clear all caches'); + $this->drupalPostForm('admin/config/development/performance', [], 'Clear all caches'); $this->assertRaw($warning_message, 'Enabled block was in the invalid region and has been disabled.'); // Clear the cache to check if the warning message is not triggered. - $this->drupalPostForm('admin/config/development/performance', array(), 'Clear all caches'); + $this->drupalPostForm('admin/config/development/performance', [], 'Clear all caches'); $this->assertNoRaw($warning_message, 'Disabled block in the invalid region will not trigger the warning.'); // Place disabled test block in the invalid region of the default theme. @@ -55,7 +55,7 @@ function testBlockInInvalidRegion() { $block = Block::load($block->id()); // Clear the cache to check if the warning message is not triggered. - $this->drupalPostForm('admin/config/development/performance', array(), 'Clear all caches'); + $this->drupalPostForm('admin/config/development/performance', [], 'Clear all caches'); $this->assertNoRaw($warning_message, 'Disabled block in the invalid region will not trigger the warning.'); } diff --git a/core/modules/block/src/Tests/BlockLanguageCacheTest.php b/core/modules/block/src/Tests/BlockLanguageCacheTest.php index fd5871e..269536d 100644 --- a/core/modules/block/src/Tests/BlockLanguageCacheTest.php +++ b/core/modules/block/src/Tests/BlockLanguageCacheTest.php @@ -18,25 +18,25 @@ class BlockLanguageCacheTest extends WebTestBase { * * @var array */ - public static $modules = array('block', 'language', 'menu_ui'); + public static $modules = ['block', 'language', 'menu_ui']; /** * List of langcodes. * * @var array */ - protected $langcodes = array(); + protected $langcodes = []; protected function setUp() { parent::setUp(); // Create test languages. - $this->langcodes = array(ConfigurableLanguage::load('en')); + $this->langcodes = [ConfigurableLanguage::load('en')]; for ($i = 1; $i < 3; ++$i) { - $language = ConfigurableLanguage::create(array( + $language = ConfigurableLanguage::create([ 'id' => 'l' . $i, 'label' => $this->randomString(), - )); + ]); $language->save(); $this->langcodes[$i] = $language; } @@ -47,16 +47,16 @@ protected function setUp() { */ public function testBlockLinks() { // Create admin user to be able to access block admin. - $admin_user = $this->drupalCreateUser(array( + $admin_user = $this->drupalCreateUser([ 'administer blocks', 'access administration pages', 'administer menu', - )); + ]); $this->drupalLogin($admin_user); // Create the block cache for all languages. foreach ($this->langcodes as $langcode) { - $this->drupalGet('admin/structure/block', array('language' => $langcode)); + $this->drupalGet('admin/structure/block', ['language' => $langcode]); $this->clickLinkPartialName('Place block'); } @@ -64,11 +64,11 @@ public function testBlockLinks() { $edit['label'] = $this->randomMachineName(); $edit['id'] = Unicode::strtolower($edit['label']); $this->drupalPostForm('admin/structure/menu/add', $edit, t('Save')); - $this->assertText(t('Menu @label has been added.', array('@label' => $edit['label']))); + $this->assertText(t('Menu @label has been added.', ['@label' => $edit['label']])); // Check that the block is listed for all languages. foreach ($this->langcodes as $langcode) { - $this->drupalGet('admin/structure/block', array('language' => $langcode)); + $this->drupalGet('admin/structure/block', ['language' => $langcode]); $this->clickLinkPartialName('Place block'); $this->assertText($edit['label']); } diff --git a/core/modules/block/src/Tests/BlockLanguageTest.php b/core/modules/block/src/Tests/BlockLanguageTest.php index a2bf249..cd9e584 100644 --- a/core/modules/block/src/Tests/BlockLanguageTest.php +++ b/core/modules/block/src/Tests/BlockLanguageTest.php @@ -23,19 +23,19 @@ class BlockLanguageTest extends WebTestBase { * * @var array */ - public static $modules = array('language', 'block', 'content_translation'); + public static $modules = ['language', 'block', 'content_translation']; protected function setUp() { parent::setUp(); // Create a new user, allow him to manage the blocks and the languages. - $this->adminUser = $this->drupalCreateUser(array('administer blocks', 'administer languages')); + $this->adminUser = $this->drupalCreateUser(['administer blocks', 'administer languages']); $this->drupalLogin($this->adminUser); // Add predefined language. - $edit = array( + $edit = [ 'predefined_langcode' => 'fr', - ); + ]; $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); $this->assertText('French', 'Language added successfully.'); } @@ -52,17 +52,17 @@ public function testLanguageBlockVisibility() { $this->assertNoField('visibility[language][context_mapping][language]', 'Language type field is not visible.'); // Enable a standard block and set the visibility setting for one language. - $edit = array( + $edit = [ 'visibility[language][langcodes][en]' => TRUE, 'id' => strtolower($this->randomMachineName(8)), 'region' => 'sidebar_first', - ); + ]; $this->drupalPostForm('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme, $edit, t('Save block')); // Change the default language. - $edit = array( + $edit = [ 'site_default_language' => 'fr', - ); + ]; $this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration')); // Check that a page has a block. @@ -79,16 +79,16 @@ public function testLanguageBlockVisibility() { */ public function testLanguageBlockVisibilityLanguageDelete() { // Enable a standard block and set the visibility setting for one language. - $edit = array( - 'visibility' => array( - 'language' => array( - 'langcodes' => array( + $edit = [ + 'visibility' => [ + 'language' => [ + 'langcodes' => [ 'fr' => 'fr', - ), + ], 'context_mapping' => ['language' => '@language.current_language_context:language_interface'], - ), - ), - ); + ], + ], + ]; $block = $this->drupalPlaceBlock('system_powered_by_block', $edit); // Check that we have the language in config after saving the setting. @@ -96,7 +96,7 @@ public function testLanguageBlockVisibilityLanguageDelete() { $this->assertEqual('fr', $visibility['language']['langcodes']['fr'], 'Language is set in the block configuration.'); // Delete the language. - $this->drupalPostForm('admin/config/regional/language/delete/fr', array(), t('Delete')); + $this->drupalPostForm('admin/config/regional/language/delete/fr', [], t('Delete')); // Check that the language is no longer stored in the configuration after // it is deleted. diff --git a/core/modules/block/src/Tests/BlockRenderOrderTest.php b/core/modules/block/src/Tests/BlockRenderOrderTest.php index faf667e..d74a90a 100644 --- a/core/modules/block/src/Tests/BlockRenderOrderTest.php +++ b/core/modules/block/src/Tests/BlockRenderOrderTest.php @@ -17,14 +17,14 @@ class BlockRenderOrderTest extends WebTestBase { * * @var array */ - public static $modules = array('node', 'block'); + public static $modules = ['node', 'block']; protected function setUp() { parent::setUp(); // Create a test user. - $end_user = $this->drupalCreateUser(array( + $end_user = $this->drupalCreateUser([ 'access content', - )); + ]); $this->drupalLogin($end_user); } @@ -34,32 +34,32 @@ protected function setUp() { function testBlockRenderOrder() { // Enable test blocks and place them in the same region. $region = 'header'; - $test_blocks = array( - 'stark_powered' => array( + $test_blocks = [ + 'stark_powered' => [ 'weight' => '-3', 'id' => 'stark_powered', 'label' => 'Test block A', - ), - 'stark_by' => array( + ], + 'stark_by' => [ 'weight' => '3', 'id' => 'stark_by', 'label' => 'Test block C', - ), - 'stark_drupal' => array( + ], + 'stark_drupal' => [ 'weight' => '3', 'id' => 'stark_drupal', 'label' => 'Test block B', - ), - ); + ], + ]; // Place the test blocks. foreach ($test_blocks as $test_block) { - $this->drupalPlaceBlock('system_powered_by_block', array( + $this->drupalPlaceBlock('system_powered_by_block', [ 'label' => $test_block['label'], 'region' => $region, 'weight' => $test_block['weight'], 'id' => $test_block['id'], - )); + ]); } $this->drupalGet(''); diff --git a/core/modules/block/src/Tests/BlockSystemBrandingTest.php b/core/modules/block/src/Tests/BlockSystemBrandingTest.php index f3dfa3c..b5025e8 100644 --- a/core/modules/block/src/Tests/BlockSystemBrandingTest.php +++ b/core/modules/block/src/Tests/BlockSystemBrandingTest.php @@ -14,7 +14,7 @@ class BlockSystemBrandingTest extends BlockTestBase { * * @var array */ - public static $modules = array('block', 'system'); + public static $modules = ['block', 'system']; /** * {@inheritdoc} @@ -26,7 +26,7 @@ protected function setUp() { ->set('slogan', 'Community plumbing') ->save(); // Add the system branding block to the page. - $this->drupalPlaceBlock('system_branding_block', array('region' => 'header', 'id' => 'site-branding')); + $this->drupalPlaceBlock('system_branding_block', ['region' => 'header', 'id' => 'site-branding']); } /** diff --git a/core/modules/block/src/Tests/BlockTemplateSuggestionsTest.php b/core/modules/block/src/Tests/BlockTemplateSuggestionsTest.php index d5ce8e6..42e88ee 100644 --- a/core/modules/block/src/Tests/BlockTemplateSuggestionsTest.php +++ b/core/modules/block/src/Tests/BlockTemplateSuggestionsTest.php @@ -17,7 +17,7 @@ class BlockTemplateSuggestionsTest extends WebTestBase { * * @var array */ - public static $modules = array('block'); + public static $modules = ['block']; /** * Tests template suggestions from block_theme_suggestions_block(). @@ -27,22 +27,22 @@ function testBlockThemeHookSuggestions() { // an underscore (not transformed) and a hyphen (transformed to underscore), // and generates possibilities for each level of derivative. // @todo Clarify this comment. - $block = Block::create(array( + $block = Block::create([ 'plugin' => 'system_menu_block:admin', 'region' => 'footer', 'id' => 'machinename', - )); + ]); - $variables = array(); + $variables = []; $plugin = $block->getPlugin(); $variables['elements']['#configuration'] = $plugin->getConfiguration(); $variables['elements']['#plugin_id'] = $plugin->getPluginId(); $variables['elements']['#id'] = $block->id(); $variables['elements']['#base_plugin_id'] = $plugin->getBaseId(); $variables['elements']['#derivative_plugin_id'] = $plugin->getDerivativeId(); - $variables['elements']['content'] = array(); + $variables['elements']['content'] = []; $suggestions = block_theme_suggestions_block($variables); - $this->assertEqual($suggestions, array('block__system', 'block__system_menu_block', 'block__system_menu_block__admin', 'block__machinename')); + $this->assertEqual($suggestions, ['block__system', 'block__system_menu_block', 'block__system_menu_block__admin', 'block__machinename']); } } diff --git a/core/modules/block/src/Tests/BlockTest.php b/core/modules/block/src/Tests/BlockTest.php index 032b87a..25f08e7 100644 --- a/core/modules/block/src/Tests/BlockTest.php +++ b/core/modules/block/src/Tests/BlockTest.php @@ -24,12 +24,12 @@ function testBlockVisibility() { $title = $this->randomMachineName(8); // Enable a standard block. $default_theme = $this->config('system.theme')->get('default'); - $edit = array( + $edit = [ 'id' => strtolower($this->randomMachineName(8)), 'region' => 'sidebar_first', 'settings[label]' => $title, 'settings[label_display]' => TRUE, - ); + ]; // Set the block to be hidden on any user path, and to be shown only to // authenticated users. $edit['visibility[request_path][pages]'] = '/user*'; @@ -69,11 +69,11 @@ public function testBlockToggleVisibility() { $title = $this->randomMachineName(8); // Enable a standard block. $default_theme = $this->config('system.theme')->get('default'); - $edit = array( + $edit = [ 'id' => strtolower($this->randomMachineName(8)), 'region' => 'sidebar_first', 'settings[label]' => $title, - ); + ]; $block_id = $edit['id']; // Set the block to be shown only to authenticated users. $edit['visibility[user_role][roles][' . RoleInterface::AUTHENTICATED_ID . ']'] = TRUE; @@ -105,12 +105,12 @@ function testBlockVisibilityListedEmpty() { $title = $this->randomMachineName(8); // Enable a standard block. $default_theme = $this->config('system.theme')->get('default'); - $edit = array( + $edit = [ 'id' => strtolower($this->randomMachineName(8)), 'region' => 'sidebar_first', 'settings[label]' => $title, 'visibility[request_path][negate]' => TRUE, - ); + ]; // Set the block to be hidden on any user path, and to be shown only to // authenticated users. $this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, t('Save block')); @@ -183,7 +183,7 @@ function testBlock() { $this->clickLink('Disable'); // Select the 'Powered by Drupal' block to be configured and moved. - $block = array(); + $block = []; $block['id'] = 'system_powered_by_block'; $block['settings[label]'] = $this->randomMachineName(8); $block['settings[label_display]'] = TRUE; @@ -191,7 +191,7 @@ function testBlock() { $block['region'] = 'header'; // Set block title to confirm that interface works and override any custom titles. - $this->drupalPostForm('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], array('settings[label]' => $block['settings[label]'], 'settings[label_display]' => $block['settings[label_display]'], 'id' => $block['id'], 'region' => $block['region']), t('Save block')); + $this->drupalPostForm('admin/structure/block/add/' . $block['id'] . '/' . $block['theme'], ['settings[label]' => $block['settings[label]'], 'settings[label_display]' => $block['settings[label_display]'], 'id' => $block['id'], 'region' => $block['region']], t('Save block')); $this->assertText(t('The block configuration has been saved.'), 'Block title set.'); // Check to see if the block was created by checking its configuration. $instance = Block::load($block['id']); @@ -215,23 +215,23 @@ function testBlock() { $this->assertNoText(t($block['settings[label]'])); // Check for
        if the machine name // is my_block_instance_name. - $xpath = $this->buildXPathQuery('//div[@id=:id]/*', array(':id' => 'block-' . str_replace('_', '-', strtolower($block['id'])))); + $xpath = $this->buildXPathQuery('//div[@id=:id]/*', [':id' => 'block-' . str_replace('_', '-', strtolower($block['id']))]); $this->assertNoFieldByXPath($xpath, FALSE, 'Block found in no regions.'); // Test deleting the block from the edit form. $this->drupalGet('admin/structure/block/manage/' . $block['id']); $this->clickLink(t('Delete')); - $this->assertRaw(t('Are you sure you want to delete the block @name?', array('@name' => $block['settings[label]']))); - $this->drupalPostForm(NULL, array(), t('Delete')); - $this->assertRaw(t('The block %name has been deleted.', array('%name' => $block['settings[label]']))); + $this->assertRaw(t('Are you sure you want to delete the block @name?', ['@name' => $block['settings[label]']])); + $this->drupalPostForm(NULL, [], t('Delete')); + $this->assertRaw(t('The block %name has been deleted.', ['%name' => $block['settings[label]']])); // Test deleting a block via "Configure block" link. $block = $this->drupalPlaceBlock('system_powered_by_block'); - $this->drupalGet('admin/structure/block/manage/' . $block->id(), array('query' => array('destination' => 'admin'))); + $this->drupalGet('admin/structure/block/manage/' . $block->id(), ['query' => ['destination' => 'admin']]); $this->clickLink(t('Delete')); - $this->assertRaw(t('Are you sure you want to delete the block @name?', array('@name' => $block->label()))); - $this->drupalPostForm(NULL, array(), t('Delete')); - $this->assertRaw(t('The block %name has been deleted.', array('%name' => $block->label()))); + $this->assertRaw(t('Are you sure you want to delete the block @name?', ['@name' => $block->label()])); + $this->drupalPostForm(NULL, [], t('Delete')); + $this->assertRaw(t('The block %name has been deleted.', ['%name' => $block->label()])); $this->assertUrl('admin'); $this->assertNoRaw($block->id()); } @@ -247,7 +247,7 @@ public function testBlockThemeSelector() { $this->drupalGet('admin/structure/block/list/' . $theme); $this->assertTitle(t('Block layout') . ' | Drupal'); // Select the 'Powered by Drupal' block to be placed. - $block = array(); + $block = []; $block['id'] = strtolower($this->randomMachineName()); $block['theme'] = $theme; $block['region'] = 'content'; @@ -258,7 +258,7 @@ public function testBlockThemeSelector() { // Set the default theme and ensure the block is placed. $theme_settings->set('default', $theme)->save(); $this->drupalGet(''); - $elements = $this->xpath('//div[@id = :id]', array(':id' => Html::getUniqueId('block-' . $block['id']))); + $elements = $this->xpath('//div[@id = :id]', [':id' => Html::getUniqueId('block-' . $block['id'])]); $this->assertTrue(!empty($elements), 'The block was found.'); } } @@ -268,11 +268,11 @@ public function testBlockThemeSelector() { */ function testThemeName() { // Enable the help block. - $this->drupalPlaceBlock('help_block', array('region' => 'help')); + $this->drupalPlaceBlock('help_block', ['region' => 'help']); $this->drupalPlaceBlock('local_tasks_block'); // Explicitly set the default and admin themes. $theme = 'block_test_specialchars_theme'; - \Drupal::service('theme_handler')->install(array($theme)); + \Drupal::service('theme_handler')->install([$theme]); \Drupal::service('router.builder')->rebuild(); $this->drupalGet('admin/structure/block'); $this->assertEscaped('<"Cat" & \'Mouse\'>'); @@ -290,20 +290,20 @@ function testHideBlockTitle() { $id = strtolower($this->randomMachineName(8)); // Enable a standard block. $default_theme = $this->config('system.theme')->get('default'); - $edit = array( + $edit = [ 'id' => $id, 'region' => 'sidebar_first', 'settings[label]' => $title, - ); + ]; $this->drupalPostForm('admin/structure/block/add/' . $block_name . '/' . $default_theme, $edit, t('Save block')); $this->assertText('The block configuration has been saved.', 'Block was saved'); $this->drupalGet('user'); $this->assertNoText($title, 'Block title was not displayed by default.'); - $edit = array( + $edit = [ 'settings[label_display]' => TRUE, - ); + ]; $this->drupalPostForm('admin/structure/block/manage/' . $id, $edit, t('Save block')); $this->assertText('The block configuration has been saved.', 'Block was saved'); @@ -328,24 +328,24 @@ function testHideBlockTitle() { */ function moveBlockToRegion(array $block, $region) { // Set the created block to a specific region. - $block += array('theme' => $this->config('system.theme')->get('default')); - $edit = array(); + $block += ['theme' => $this->config('system.theme')->get('default')]; + $edit = []; $edit['blocks[' . $block['id'] . '][region]'] = $region; $this->drupalPostForm('admin/structure/block', $edit, t('Save blocks')); // Confirm that the block was moved to the proper region. - $this->assertText(t('The block settings have been updated.'), format_string('Block successfully moved to %region_name region.', array( '%region_name' => $region))); + $this->assertText(t('The block settings have been updated.'), format_string('Block successfully moved to %region_name region.', [ '%region_name' => $region])); // Confirm that the block is being displayed. $this->drupalGet(''); $this->assertText(t($block['settings[label]']), 'Block successfully being displayed on the page.'); // Confirm that the custom block was found at the proper region. - $xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', array( + $xpath = $this->buildXPathQuery('//div[@class=:region-class]//div[@id=:block-id]/*', [ ':region-class' => 'region region-' . Html::getClass($region), ':block-id' => 'block-' . str_replace('_', '-', strtolower($block['id'])), - )); - $this->assertFieldByXPath($xpath, NULL, t('Block found in %region_name region.', array('%region_name' => Html::getClass($region)))); + ]); + $this->assertFieldByXPath($xpath, NULL, t('Block found in %region_name region.', ['%region_name' => Html::getClass($region)])); } /** @@ -365,7 +365,7 @@ public function testBlockCacheTags() { $config->save(); // Place the "Powered by Drupal" block. - $block = $this->drupalPlaceBlock('system_powered_by_block', array('id' => 'powered')); + $block = $this->drupalPlaceBlock('system_powered_by_block', ['id' => 'powered']); // Prime the page cache. $this->drupalGet(''); @@ -375,25 +375,25 @@ public function testBlockCacheTags() { // both the page and block caches. $this->drupalGet(''); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT'); - $cid_parts = array(\Drupal::url('', array(), array('absolute' => TRUE)), 'html'); + $cid_parts = [\Drupal::url('', [], ['absolute' => TRUE]), 'html']; $cid = implode(':', $cid_parts); $cache_entry = \Drupal::cache('render')->get($cid); - $expected_cache_tags = array( + $expected_cache_tags = [ 'config:block_list', 'block_view', 'config:block.block.powered', 'config:user.role.anonymous', 'rendered', - ); + ]; sort($expected_cache_tags); $keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys(); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered:' . implode(':', $keys)); - $expected_cache_tags = array( + $expected_cache_tags = [ 'block_view', 'config:block.block.powered', 'rendered', - ); + ]; sort($expected_cache_tags); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); @@ -408,40 +408,40 @@ public function testBlockCacheTags() { $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT'); // Place the "Powered by Drupal" block another time; verify a cache miss. - $block_2 = $this->drupalPlaceBlock('system_powered_by_block', array('id' => 'powered-2')); + $block_2 = $this->drupalPlaceBlock('system_powered_by_block', ['id' => 'powered-2']); $this->drupalGet(''); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS'); // Verify a cache hit, but also the presence of the correct cache tags. $this->drupalGet(''); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT'); - $cid_parts = array(\Drupal::url('', array(), array('absolute' => TRUE)), 'html'); + $cid_parts = [\Drupal::url('', [], ['absolute' => TRUE]), 'html']; $cid = implode(':', $cid_parts); $cache_entry = \Drupal::cache('render')->get($cid); - $expected_cache_tags = array( + $expected_cache_tags = [ 'config:block_list', 'block_view', 'config:block.block.powered', 'config:block.block.powered-2', 'config:user.role.anonymous', 'rendered', - ); + ]; sort($expected_cache_tags); $this->assertEqual($cache_entry->tags, $expected_cache_tags); - $expected_cache_tags = array( + $expected_cache_tags = [ 'block_view', 'config:block.block.powered', 'rendered', - ); + ]; sort($expected_cache_tags); $keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys(); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered:' . implode(':', $keys)); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); - $expected_cache_tags = array( + $expected_cache_tags = [ 'block_view', 'config:block.block.powered-2', 'rendered', - ); + ]; sort($expected_cache_tags); $keys = \Drupal::service('cache_contexts_manager')->convertTokensToKeys(['languages:language_interface', 'theme', 'user.permissions'])->getKeys(); $cache_entry = \Drupal::cache('render')->get('entity_view:block:powered-2:' . implode(':', $keys)); @@ -452,7 +452,7 @@ public function testBlockCacheTags() { $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT'); // Delete the "Powered by Drupal" blocks; verify a cache miss. - entity_delete_multiple('block', array('powered', 'powered-2')); + entity_delete_multiple('block', ['powered', 'powered-2']); $this->drupalGet(''); $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS'); } diff --git a/core/modules/block/src/Tests/BlockTestBase.php b/core/modules/block/src/Tests/BlockTestBase.php index 970de52..71f0ae6 100644 --- a/core/modules/block/src/Tests/BlockTestBase.php +++ b/core/modules/block/src/Tests/BlockTestBase.php @@ -15,7 +15,7 @@ * * @var array */ - public static $modules = array('block', 'filter', 'test_page_test', 'help', 'block_test'); + public static $modules = ['block', 'filter', 'test_page_test', 'help', 'block_test']; /** * A list of theme regions to test. @@ -38,31 +38,31 @@ protected function setUp() { $this->config('system.site')->set('page.front', '/test-page')->save(); // Create Full HTML text format. - $full_html_format = FilterFormat::create(array( + $full_html_format = FilterFormat::create([ 'format' => 'full_html', 'name' => 'Full HTML', - )); + ]); $full_html_format->save(); // Create and log in an administrative user having access to the Full HTML // text format. - $this->adminUser = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser([ 'administer blocks', $full_html_format->getPermissionName(), 'access administration pages', - )); + ]); $this->drupalLogin($this->adminUser); // Define the existing regions. - $this->regions = array( + $this->regions = [ 'header', 'sidebar_first', 'content', 'sidebar_second', 'footer', - ); + ]; $block_storage = $this->container->get('entity_type.manager')->getStorage('block'); - $blocks = $block_storage->loadByProperties(array('theme' => $this->config('system.theme')->get('default'))); + $blocks = $block_storage->loadByProperties(['theme' => $this->config('system.theme')->get('default')]); foreach ($blocks as $block) { $block->delete(); } diff --git a/core/modules/block/src/Tests/BlockUiTest.php b/core/modules/block/src/Tests/BlockUiTest.php index f2bcaae..c197d23 100644 --- a/core/modules/block/src/Tests/BlockUiTest.php +++ b/core/modules/block/src/Tests/BlockUiTest.php @@ -17,7 +17,7 @@ class BlockUiTest extends WebTestBase { * * @var array */ - public static $modules = array('block', 'block_test', 'help'); + public static $modules = ['block', 'block_test', 'help']; protected $regions; @@ -43,30 +43,30 @@ class BlockUiTest extends WebTestBase { protected function setUp() { parent::setUp(); // Create and log in an administrative user. - $this->adminUser = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser([ 'administer blocks', 'access administration pages', - )); + ]); $this->drupalLogin($this->adminUser); // Enable some test blocks. - $this->blockValues = array( - array( + $this->blockValues = [ + [ 'label' => 'Tools', 'tr' => '5', 'plugin_id' => 'system_menu_block:tools', - 'settings' => array('region' => 'sidebar_second', 'id' => 'tools'), + 'settings' => ['region' => 'sidebar_second', 'id' => 'tools'], 'test_weight' => '-1', - ), - array( + ], + [ 'label' => 'Powered by Drupal', 'tr' => '16', 'plugin_id' => 'system_powered_by_block', - 'settings' => array('region' => 'footer', 'id' => 'powered'), + 'settings' => ['region' => 'footer', 'id' => 'powered'], 'test_weight' => '0', - ), - ); - $this->blocks = array(); + ], + ]; + $this->blocks = []; foreach ($this->blockValues as $values) { $this->blocks[] = $this->drupalPlaceBlock($values['plugin_id'], $values['settings']); } @@ -76,13 +76,13 @@ protected function setUp() { * Test block demo page exists and functions correctly. */ public function testBlockDemoUiPage() { - $this->drupalPlaceBlock('help_block', array('region' => 'help')); + $this->drupalPlaceBlock('help_block', ['region' => 'help']); $this->drupalGet('admin/structure/block'); - $this->clickLink(t('Demonstrate block regions (@theme)', array('@theme' => 'Classy'))); - $elements = $this->xpath('//div[contains(@class, "region-highlighted")]/div[contains(@class, "block-region") and contains(text(), :title)]', array(':title' => 'Highlighted')); + $this->clickLink(t('Demonstrate block regions (@theme)', ['@theme' => 'Classy'])); + $elements = $this->xpath('//div[contains(@class, "region-highlighted")]/div[contains(@class, "block-region") and contains(text(), :title)]', [':title' => 'Highlighted']); $this->assertTrue(!empty($elements), 'Block demo regions are shown.'); - \Drupal::service('theme_handler')->install(array('test_theme')); + \Drupal::service('theme_handler')->install(['test_theme']); $this->drupalGet('admin/structure/block/demo/test_theme'); $this->assertEscaped('Test theme'); @@ -163,11 +163,11 @@ function testBlockAdminUiPage() { * Tests the block categories on the listing page. */ public function testCandidateBlockList() { - $arguments = array( + $arguments = [ ':title' => 'Display message', ':category' => 'Block test', ':href' => 'admin/structure/block/add/test_block_instantiation/classy', - ); + ]; $pattern = '//tr[.//td/div[text()=:title] and .//td[text()=:category] and .//td//a[contains(@href, :href)]]'; $this->drupalGet('admin/structure/block'); @@ -190,11 +190,11 @@ public function testCandidateBlockList() { * Tests the behavior of unsatisfied context-aware blocks. */ public function testContextAwareUnsatisfiedBlocks() { - $arguments = array( + $arguments = [ ':category' => 'Block test', ':href' => 'admin/structure/block/add/test_context_aware_unsatisfied/classy', ':text' => 'Test context-aware unsatisfied block', - ); + ]; $this->drupalGet('admin/structure/block'); $this->clickLinkPartialName('Place block'); @@ -215,11 +215,11 @@ public function testContextAwareBlocks() { $this->assertNoRaw($expected_text); $block_url = 'admin/structure/block/add/test_context_aware/classy'; - $arguments = array( + $arguments = [ ':title' => 'Test context-aware block', ':category' => 'Block test', ':href' => $block_url, - ); + ]; $pattern = '//tr[.//td/div[text()=:title] and .//td[text()=:category] and .//td//a[contains(@href, :href)]]'; $this->drupalGet('admin/structure/block'); @@ -277,7 +277,7 @@ public function testMachineNameSuggestion() { */ public function testBlockPlacementIndicator() { // Select the 'Powered by Drupal' block to be placed. - $block = array(); + $block = []; $block['id'] = strtolower($this->randomMachineName()); $block['theme'] = 'classy'; $block['region'] = 'content'; @@ -287,7 +287,7 @@ public function testBlockPlacementIndicator() { $this->assertUrl('admin/structure/block/list/classy?block-placement=' . Html::getClass($block['id'])); // Resaving the block page will remove the block indicator. - $this->drupalPostForm(NULL, array(), t('Save blocks')); + $this->drupalPostForm(NULL, [], t('Save blocks')); $this->assertUrl('admin/structure/block/list/classy'); } diff --git a/core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php b/core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php index 9442df5..30b8cab 100644 --- a/core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php +++ b/core/modules/block/src/Tests/NewDefaultThemeBlocksTest.php @@ -16,7 +16,7 @@ class NewDefaultThemeBlocksTest extends WebTestBase { * * @var array */ - public static $modules = array('block'); + public static $modules = ['block']; /** * Check the enabled Bartik blocks are correctly copied over. @@ -25,22 +25,22 @@ function testNewDefaultThemeBlocks() { $default_theme = $this->config('system.theme')->get('default'); // Add two instances of the user login block. - $this->drupalPlaceBlock('user_login_block', array( + $this->drupalPlaceBlock('user_login_block', [ 'id' => $default_theme . '_' . strtolower($this->randomMachineName(8)), - )); - $this->drupalPlaceBlock('user_login_block', array( + ]); + $this->drupalPlaceBlock('user_login_block', [ 'id' => $default_theme . '_' . strtolower($this->randomMachineName(8)), - )); + ]); // Add an instance of a different block. - $this->drupalPlaceBlock('system_powered_by_block', array( + $this->drupalPlaceBlock('system_powered_by_block', [ 'id' => $default_theme . '_' . strtolower($this->randomMachineName(8)), - )); + ]); // Install a different theme. $new_theme = 'bartik'; $this->assertFalse($new_theme == $default_theme, 'The new theme is different from the previous default theme.'); - \Drupal::service('theme_handler')->install(array($new_theme)); + \Drupal::service('theme_handler')->install([$new_theme]); $this->config('system.theme') ->set('default', $new_theme) ->save(); diff --git a/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php b/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php index 218832d..9f3590c 100644 --- a/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php +++ b/core/modules/block/src/Tests/NonDefaultBlockAdminTest.php @@ -16,7 +16,7 @@ class NonDefaultBlockAdminTest extends WebTestBase { * * @var array */ - public static $modules = array('block'); + public static $modules = ['block']; /** * {@inheritdoc} @@ -31,10 +31,10 @@ protected function setUp() { * Test non-default theme admin. */ function testNonDefaultBlockAdmin() { - $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer themes')); + $admin_user = $this->drupalCreateUser(['administer blocks', 'administer themes']); $this->drupalLogin($admin_user); $new_theme = 'bartik'; - \Drupal::service('theme_handler')->install(array($new_theme)); + \Drupal::service('theme_handler')->install([$new_theme]); $this->drupalGet('admin/structure/block/list/' . $new_theme); $this->assertText('Bartik(' . t('active tab') . ')', 'Tab for non-default theme found.'); } diff --git a/core/modules/block/src/Tests/Views/DisplayBlockTest.php b/core/modules/block/src/Tests/Views/DisplayBlockTest.php index 368af68..eab63d2 100644 --- a/core/modules/block/src/Tests/Views/DisplayBlockTest.php +++ b/core/modules/block/src/Tests/Views/DisplayBlockTest.php @@ -26,19 +26,19 @@ class DisplayBlockTest extends ViewTestBase { * * @var array */ - public static $modules = array('node', 'block_test_views', 'test_page_test', 'contextual', 'views_ui'); + public static $modules = ['node', 'block_test_views', 'test_page_test', 'contextual', 'views_ui']; /** * Views used by this test. * * @var array */ - public static $testViews = array('test_view_block', 'test_view_block2'); + public static $testViews = ['test_view_block', 'test_view_block2']; protected function setUp() { parent::setUp(); - ViewTestData::createTestViews(get_class($this), array('block_test_views')); + ViewTestData::createTestViews(get_class($this), ['block_test_views']); $this->enableViewsTestModule(); } @@ -46,10 +46,10 @@ protected function setUp() { * Tests default and custom block categories. */ public function testBlockCategory() { - $this->drupalLogin($this->drupalCreateUser(array('administer views', 'administer blocks'))); + $this->drupalLogin($this->drupalCreateUser(['administer views', 'administer blocks'])); // Create a new view in the UI. - $edit = array(); + $edit = []; $edit['label'] = $this->randomString(); $edit['id'] = strtolower($this->randomMachineName()); $edit['show[wizard_key]'] = 'standard:views_test_data'; @@ -62,20 +62,20 @@ public function testBlockCategory() { // Test that the block was given a default category corresponding to its // base table. - $arguments = array( - ':href' => \Drupal::Url('block.admin_add', array( + $arguments = [ + ':href' => \Drupal::Url('block.admin_add', [ 'plugin_id' => 'views_block:' . $edit['id'] . '-block_1', 'theme' => 'classy', - )), + ]), ':category' => t('Lists (Views)'), - ); + ]; $this->drupalGet('admin/structure/block'); $this->clickLinkPartialName('Place block'); $elements = $this->xpath($pattern, $arguments); $this->assertTrue(!empty($elements), 'The test block appears in the category for its base table.'); // Duplicate the block before changing the category. - $this->drupalPostForm('admin/structure/views/view/' . $edit['id'] . '/edit/block_1', array(), t('Duplicate @display_title', array('@display_title' => 'Block'))); + $this->drupalPostForm('admin/structure/views/view/' . $edit['id'] . '/edit/block_1', [], t('Duplicate @display_title', ['@display_title' => 'Block'])); $this->assertUrl('admin/structure/views/view/' . $edit['id'] . '/edit/block_2'); // Change the block category to a random string. @@ -84,13 +84,13 @@ public function testBlockCategory() { $this->assertTrue(!empty($link)); $this->clickLink(t('Lists (Views)')); $category = $this->randomString(); - $this->drupalPostForm(NULL, array('block_category' => $category), t('Apply')); + $this->drupalPostForm(NULL, ['block_category' => $category], t('Apply')); // Duplicate the block after changing the category. - $this->drupalPostForm(NULL, array(), t('Duplicate @display_title', array('@display_title' => 'Block'))); + $this->drupalPostForm(NULL, [], t('Duplicate @display_title', ['@display_title' => 'Block'])); $this->assertUrl('admin/structure/views/view/' . $edit['id'] . '/edit/block_3'); - $this->drupalPostForm(NULL, array(), t('Save')); + $this->drupalPostForm(NULL, [], t('Save')); // Test that the blocks are listed under the correct categories. $arguments[':category'] = $category; @@ -99,23 +99,23 @@ public function testBlockCategory() { $elements = $this->xpath($pattern, $arguments); $this->assertTrue(!empty($elements), 'The test block appears in the custom category.'); - $arguments = array( - ':href' => \Drupal::Url('block.admin_add', array( + $arguments = [ + ':href' => \Drupal::Url('block.admin_add', [ 'plugin_id' => 'views_block:' . $edit['id'] . '-block_2', 'theme' => 'classy', - )), + ]), ':category' => t('Lists (Views)'), - ); + ]; $elements = $this->xpath($pattern, $arguments); $this->assertTrue(!empty($elements), 'The first duplicated test block remains in the original category.'); - $arguments = array( - ':href' => \Drupal::Url('block.admin_add', array( + $arguments = [ + ':href' => \Drupal::Url('block.admin_add', [ 'plugin_id' => 'views_block:' . $edit['id'] . '-block_3', 'theme' => 'classy', - )), + ]), ':category' => $category, - ); + ]; $elements = $this->xpath($pattern, $arguments); $this->assertTrue(!empty($elements), 'The second duplicated test block appears in the custom category.'); } @@ -126,13 +126,13 @@ public function testBlockCategory() { public function testDeleteBlockDisplay() { // To test all combinations possible we first place create two instances // of the block display of the first view. - $block_1 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('label' => 'test_view_block-block_1:1')); - $block_2 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('label' => 'test_view_block-block_1:2')); + $block_1 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', ['label' => 'test_view_block-block_1:1']); + $block_2 = $this->drupalPlaceBlock('views_block:test_view_block-block_1', ['label' => 'test_view_block-block_1:2']); // Then we add one instance of blocks for each of the two displays of the // second view. - $block_3 = $this->drupalPlaceBlock('views_block:test_view_block2-block_1', array('label' => 'test_view_block2-block_1')); - $block_4 = $this->drupalPlaceBlock('views_block:test_view_block2-block_2', array('label' => 'test_view_block2-block_2')); + $block_3 = $this->drupalPlaceBlock('views_block:test_view_block2-block_1', ['label' => 'test_view_block2-block_1']); + $block_4 = $this->drupalPlaceBlock('views_block:test_view_block2-block_2', ['label' => 'test_view_block2-block_2']); $this->drupalGet('test-page'); $this->assertBlockAppears($block_1); @@ -177,7 +177,7 @@ public function testDeleteBlockDisplay() { * Test the block form for a Views block. */ public function testViewsBlockForm() { - $this->drupalLogin($this->drupalCreateUser(array('administer blocks'))); + $this->drupalLogin($this->drupalCreateUser(['administer blocks'])); $default_theme = $this->config('system.theme')->get('default'); $this->drupalGet('admin/structure/block/add/views_block:test_view_block-block_1/' . $default_theme); $elements = $this->xpath('//input[@name="label"]'); @@ -239,7 +239,7 @@ public function testViewsBlockForm() { */ public function testBlockRendering() { // Create a block and set a custom title. - $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('label' => 'test_view_block-block_1:1', 'views_label' => 'Custom title')); + $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', ['label' => 'test_view_block-block_1:1', 'views_label' => 'Custom title']); $this->drupalGet(''); $result = $this->xpath('//div[contains(@class, "region-sidebar-first")]/div[contains(@class, "block-views")]/h2'); @@ -276,7 +276,7 @@ public function testBlockEmptyRendering() { $view = View::load('test_view_block'); $view->invalidateCaches(); - $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('label' => 'test_view_block-block_1:1', 'views_label' => 'Custom title')); + $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', ['label' => 'test_view_block-block_1:1', 'views_label' => 'Custom title']); $this->drupalGet(''); $this->assertEqual(1, count($this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]'))); @@ -349,7 +349,7 @@ public function testBlockEmptyRendering() { * Tests the contextual links on a Views block. */ public function testBlockContextualLinks() { - $this->drupalLogin($this->drupalCreateUser(array('administer views', 'access contextual links', 'administer blocks'))); + $this->drupalLogin($this->drupalCreateUser(['administer views', 'access contextual links', 'administer blocks'])); $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1'); $cached_block = $this->drupalPlaceBlock('views_block:test_view_block-block_1'); $this->drupalGet('test-page'); @@ -357,13 +357,13 @@ public function testBlockContextualLinks() { $id = 'block:block=' . $block->id() . ':langcode=en|entity.view.edit_form:view=test_view_block:location=block&name=test_view_block&display_id=block_1&langcode=en'; $cached_id = 'block:block=' . $cached_block->id() . ':langcode=en|entity.view.edit_form:view=test_view_block:location=block&name=test_view_block&display_id=block_1&langcode=en'; // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder() - $this->assertRaw(' $id)) . '>
        ', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id))); - $this->assertRaw(' $cached_id)) . '>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $cached_id))); + $this->assertRaw(' $id]) . '>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id])); + $this->assertRaw(' $cached_id]) . '>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $cached_id])); // Get server-rendered contextual links. // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks() - $post = array('ids[0]' => $id, 'ids[1]' => $cached_id); - $response = $this->drupalPostWithFormat('contextual/render', 'json', $post, array('query' => array('destination' => 'test-page'))); + $post = ['ids[0]' => $id, 'ids[1]' => $cached_id]; + $response = $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => 'test-page']]); $this->assertResponse(200); $json = Json::decode($response); $this->assertIdentical($json[$id], ''); diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php index e5ad8da..0d14639 100644 --- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php +++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php @@ -21,9 +21,9 @@ class TestBlockInstantiation extends BlockBase { * {@inheritdoc} */ public function defaultConfiguration() { - return array( + return [ 'display_message' => 'no message set', - ); + ]; } /** @@ -37,11 +37,11 @@ protected function blockAccess(AccountInterface $account) { * {@inheritdoc} */ public function blockForm($form, FormStateInterface $form_state) { - $form['display_message'] = array( + $form['display_message'] = [ '#type' => 'textfield', '#title' => $this->t('Display message'), '#default_value' => $this->configuration['display_message'], - ); + ]; return $form; } @@ -56,9 +56,9 @@ public function blockSubmit($form, FormStateInterface $form_state) { * {@inheritdoc} */ public function build() { - return array( + return [ '#children' => $this->configuration['display_message'], - ); + ]; } } diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php index b395b92..5fec14c 100644 --- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php +++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestCacheBlock.php @@ -20,7 +20,7 @@ class TestCacheBlock extends BlockBase { public function build() { $content = \Drupal::state()->get('block_test.content'); - $build = array(); + $build = []; if (!empty($content)) { $build['#markup'] = $content; } diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php index bc7f20b..7db350d 100644 --- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php +++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php @@ -25,11 +25,11 @@ class TestContextAwareBlock extends BlockBase { public function build() { /** @var $user \Drupal\user\UserInterface */ $user = $this->getContextValue('user'); - return array( + return [ '#prefix' => '
        ', '#suffix' => '
        ', '#markup' => $user ? $user->getUsername() : 'No context mapping selected.' , - ); + ]; } /** diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestHtmlBlock.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestHtmlBlock.php index de90af4..35f08c4 100644 --- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestHtmlBlock.php +++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestHtmlBlock.php @@ -18,10 +18,10 @@ class TestHtmlBlock extends BlockBase { * {@inheritdoc} */ public function build() { - return array( + return [ '#attributes' => \Drupal::state()->get('block_test.attributes'), '#children' => \Drupal::state()->get('block_test.content'), - ); + ]; } } diff --git a/core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php b/core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php index 3f7d778..5f2f83f 100644 --- a/core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php +++ b/core/modules/block/tests/src/Kernel/BlockConfigSchemaTest.php @@ -18,7 +18,7 @@ class BlockConfigSchemaTest extends KernelTestBase { /** * {@inheritdoc} */ - public static $modules = array( + public static $modules = [ 'block', 'aggregator', 'book', @@ -32,7 +32,7 @@ class BlockConfigSchemaTest extends KernelTestBase { 'taxonomy', 'user', 'text', - ); + ]; /** * The typed config manager. @@ -59,7 +59,7 @@ protected function setUp() { $this->installEntitySchema('block_content'); $this->installEntitySchema('taxonomy_term'); $this->installEntitySchema('node'); - $this->installSchema('book', array('book')); + $this->installSchema('book', ['book']); } /** @@ -68,20 +68,20 @@ protected function setUp() { public function testBlockConfigSchema() { foreach ($this->blockManager->getDefinitions() as $block_id => $definition) { $id = strtolower($this->randomMachineName()); - $block = Block::create(array( + $block = Block::create([ 'id' => $id, 'theme' => 'classy', 'weight' => 00, 'status' => TRUE, 'region' => 'content', 'plugin' => $block_id, - 'settings' => array( + 'settings' => [ 'label' => $this->randomMachineName(), 'provider' => 'system', 'label_display' => FALSE, - ), - 'visibility' => array(), - )); + ], + 'visibility' => [], + ]); $block->save(); $config = $this->config("block.block.$id"); diff --git a/core/modules/block/tests/src/Kernel/BlockInterfaceTest.php b/core/modules/block/tests/src/Kernel/BlockInterfaceTest.php index 9216d49..e017a71 100644 --- a/core/modules/block/tests/src/Kernel/BlockInterfaceTest.php +++ b/core/modules/block/tests/src/Kernel/BlockInterfaceTest.php @@ -13,7 +13,7 @@ */ class BlockInterfaceTest extends KernelTestBase { - public static $modules = array('system', 'block', 'block_test', 'user'); + public static $modules = ['system', 'block', 'block_test', 'user']; /** * Test configuration and subsequent form() and build() method calls. @@ -31,16 +31,16 @@ class BlockInterfaceTest extends KernelTestBase { */ public function testBlockInterface() { $manager = $this->container->get('plugin.manager.block'); - $configuration = array( + $configuration = [ 'label' => 'Custom Display Message', - ); - $expected_configuration = array( + ]; + $expected_configuration = [ 'id' => 'test_block_instantiation', 'label' => 'Custom Display Message', 'provider' => 'block_test', 'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE, 'display_message' => 'no message set', - ); + ]; // Initial configuration of the block at construction time. /** @var $display_block \Drupal\Core\Block\BlockPluginInterface */ $display_block = $manager->createInstance('test_block_instantiation', $configuration); @@ -52,46 +52,46 @@ public function testBlockInterface() { $this->assertIdentical($display_block->getConfiguration(), $expected_configuration, 'The block configuration was updated correctly.'); $definition = $display_block->getPluginDefinition(); - $expected_form = array( - 'provider' => array( + $expected_form = [ + 'provider' => [ '#type' => 'value', '#value' => 'block_test', - ), - 'admin_label' => array( + ], + 'admin_label' => [ '#type' => 'item', '#title' => t('Block description'), '#plain_text' => $definition['admin_label'], - ), - 'label' => array( + ], + 'label' => [ '#type' => 'textfield', '#title' => 'Title', '#maxlength' => 255, '#default_value' => 'Custom Display Message', '#required' => TRUE, - ), - 'label_display' => array( + ], + 'label_display' => [ '#type' => 'checkbox', '#title' => 'Display title', '#default_value' => TRUE, '#return_value' => 'visible', - ), - 'context_mapping' => array(), - 'display_message' => array( + ], + 'context_mapping' => [], + 'display_message' => [ '#type' => 'textfield', '#title' => t('Display message'), '#default_value' => 'My custom display message.', - ), - ); + ], + ]; $form_state = new FormState(); // Ensure there are no form elements that do not belong to the plugin. - $actual_form = $display_block->buildConfigurationForm(array(), $form_state); + $actual_form = $display_block->buildConfigurationForm([], $form_state); // Remove the visibility sections, as that just tests condition plugins. unset($actual_form['visibility'], $actual_form['visibility_tabs']); $this->assertIdentical($this->castSafeStrings($actual_form), $this->castSafeStrings($expected_form), 'Only the expected form elements were present.'); - $expected_build = array( + $expected_build = [ '#children' => 'My custom display message.', - ); + ]; // Ensure the build array is proper. $this->assertIdentical($display_block->build(), $expected_build, 'The plugin returned the appropriate build array.'); diff --git a/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php b/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php index 5704476..ae3489b 100644 --- a/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php +++ b/core/modules/block/tests/src/Kernel/BlockStorageUnitTest.php @@ -21,7 +21,7 @@ class BlockStorageUnitTest extends KernelTestBase { * * @var array */ - public static $modules = array('block', 'block_test', 'system'); + public static $modules = ['block', 'block_test', 'system']; /** * The block storage. @@ -56,7 +56,7 @@ public function testBlockCRUD() { protected function createTests() { // Attempt to create a block without a plugin. try { - $entity = $this->controller->create(array()); + $entity = $this->controller->create([]); $entity->getPlugin(); $this->fail('A block without a plugin was created with no exception thrown.'); } @@ -65,12 +65,12 @@ protected function createTests() { } // Create a block with only required values. - $entity = $this->controller->create(array( + $entity = $this->controller->create([ 'id' => 'test_block', 'theme' => 'stark', 'region' => 'content', 'plugin' => 'test_html', - )); + ]); $entity->save(); $this->assertTrue($entity instanceof Block, 'The newly created entity is a Block.'); @@ -81,24 +81,24 @@ protected function createTests() { unset($actual_properties['uuid']); // Ensure that default values are filled in. - $expected_properties = array( + $expected_properties = [ 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), 'status' => TRUE, - 'dependencies' => array('module' => array('block_test'), 'theme' => array('stark')), + 'dependencies' => ['module' => ['block_test'], 'theme' => ['stark']], 'id' => 'test_block', 'theme' => 'stark', 'region' => 'content', 'weight' => NULL, 'provider' => NULL, 'plugin' => 'test_html', - 'settings' => array( + 'settings' => [ 'id' => 'test_html', 'label' => '', 'provider' => 'block_test', 'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE, - ), - 'visibility' => array(), - ); + ], + 'visibility' => [], + ]; $this->assertIdentical($actual_properties, $expected_properties); @@ -148,7 +148,7 @@ public function testDefaultBlocks() { $this->assertTrue(empty($entities), 'There are no blocks initially.'); // Install the block_test.module, so that its default config is installed. - $this->installConfig(array('block_test')); + $this->installConfig(['block_test']); $entities = $this->controller->loadMultiple(); $entity = reset($entities); diff --git a/core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php b/core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php index 64b2109..71c4f55 100644 --- a/core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php +++ b/core/modules/block/tests/src/Kernel/BlockViewBuilderTest.php @@ -20,7 +20,7 @@ class BlockViewBuilderTest extends KernelTestBase { * * @var array */ - public static $modules = array('block', 'block_test', 'system', 'user'); + public static $modules = ['block', 'block_test', 'system', 'user']; /** * The block being tested. @@ -56,11 +56,11 @@ protected function setUp() { \Drupal::state()->set('block_test.content', 'Llamas > unicorns!'); // Create a block with only required values. - $this->block = $this->controller->create(array( + $this->block = $this->controller->create([ 'id' => 'test_block', 'theme' => 'stark', 'plugin' => 'test_cache', - )); + ]); $this->block->save(); $this->container->get('cache.render')->deleteAll(); @@ -74,17 +74,17 @@ protected function setUp() { public function testBasicRendering() { \Drupal::state()->set('block_test.content', ''); - $entity = $this->controller->create(array( + $entity = $this->controller->create([ 'id' => 'test_block1', 'theme' => 'stark', 'plugin' => 'test_html', - )); + ]); $entity->save(); // Test the rendering of a block. $entity = Block::load('test_block1'); $output = entity_view($entity, 'block'); - $expected = array(); + $expected = []; $expected[] = '
        '; $expected[] = ' '; $expected[] = ' '; @@ -98,17 +98,17 @@ public function testBasicRendering() { Html::resetSeenIds(); // Test the rendering of a block with a given title. - $entity = $this->controller->create(array( + $entity = $this->controller->create([ 'id' => 'test_block2', 'theme' => 'stark', 'plugin' => 'test_html', - 'settings' => array( + 'settings' => [ 'label' => 'Powered by Bananas', - ), - )); + ], + ]); $entity->save(); $output = entity_view($entity, 'block'); - $expected = array(); + $expected = []; $expected[] = '
        '; $expected[] = ' '; $expected[] = '

        Powered by Bananas

        '; @@ -128,11 +128,11 @@ public function testBlockViewBuilderCache() { $this->verifyRenderCacheHandling(); // Create an empty block. - $this->block = $this->controller->create(array( + $this->block = $this->controller->create([ 'id' => 'test_block', 'theme' => 'stark', 'plugin' => 'test_cache', - )); + ]); $this->block->save(); \Drupal::state()->set('block_test.content', NULL); diff --git a/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php b/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php index 453cdcc..8df0e93 100644 --- a/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php +++ b/core/modules/block/tests/src/Unit/BlockConfigEntityUnitTest.php @@ -69,20 +69,20 @@ protected function setUp() { * @covers ::calculateDependencies */ public function testCalculateDependencies() { - $values = array('theme' => 'stark'); + $values = ['theme' => 'stark']; // Mock the entity under test so that we can mock getPluginCollections(). $entity = $this->getMockBuilder('\Drupal\block\Entity\Block') - ->setConstructorArgs(array($values, $this->entityTypeId)) - ->setMethods(array('getPluginCollections')) + ->setConstructorArgs([$values, $this->entityTypeId]) + ->setMethods(['getPluginCollections']) ->getMock(); // Create a configurable plugin that would add a dependency. $instance_id = $this->randomMachineName(); - $instance = new TestConfigurablePlugin(array(), $instance_id, array('provider' => 'test')); + $instance = new TestConfigurablePlugin([], $instance_id, ['provider' => 'test']); // Create a plugin collection to contain the instance. $plugin_collection = $this->getMockBuilder('\Drupal\Core\Plugin\DefaultLazyPluginCollection') ->disableOriginalConstructor() - ->setMethods(array('get')) + ->setMethods(['get']) ->getMock(); $plugin_collection->expects($this->atLeastOnce()) ->method('get') @@ -93,7 +93,7 @@ public function testCalculateDependencies() { // Return the mocked plugin collection. $entity->expects($this->once()) ->method('getPluginCollections') - ->will($this->returnValue(array($plugin_collection))); + ->will($this->returnValue([$plugin_collection])); $dependencies = $entity->calculateDependencies()->getDependencies(); $this->assertContains('test', $dependencies['module']); diff --git a/core/modules/block/tests/src/Unit/BlockFormTest.php b/core/modules/block/tests/src/Unit/BlockFormTest.php index d8efe2b..b846349 100644 --- a/core/modules/block/tests/src/Unit/BlockFormTest.php +++ b/core/modules/block/tests/src/Unit/BlockFormTest.php @@ -88,7 +88,7 @@ protected function setUp() { * @see \Drupal\block\BlockForm::getUniqueMachineName() */ public function testGetUniqueMachineName() { - $blocks = array(); + $blocks = []; $blocks['test'] = $this->getBlockMockWithMachineName('test'); $blocks['other_test'] = $this->getBlockMockWithMachineName('other_test'); @@ -102,7 +102,7 @@ public function testGetUniqueMachineName() { $query->expects($this->exactly(5)) ->method('execute') - ->will($this->returnValue(array('test', 'other_test', 'other_test_1', 'other_test_2'))); + ->will($this->returnValue(['test', 'other_test', 'other_test_1', 'other_test_2'])); $this->storage->expects($this->exactly(5)) ->method('getQuery') diff --git a/core/modules/block/tests/src/Unit/BlockRepositoryTest.php b/core/modules/block/tests/src/Unit/BlockRepositoryTest.php index aab11fe..5584b0b 100644 --- a/core/modules/block/tests/src/Unit/BlockRepositoryTest.php +++ b/core/modules/block/tests/src/Unit/BlockRepositoryTest.php @@ -116,25 +116,25 @@ public function testGetVisibleBlocksPerRegion(array $blocks_config, array $expec } public function providerBlocksConfig() { - $blocks_config = array( - 'block1' => array( + $blocks_config = [ + 'block1' => [ AccessResult::allowed(), 'top', 0 - ), + ], // Test a block without access. - 'block2' => array( + 'block2' => [ AccessResult::forbidden(), 'bottom', 0 - ), + ], // Test some blocks in the same region with specific weight. - 'block4' => array( + 'block4' => [ AccessResult::allowed(), 'bottom', 5 - ), - 'block3' => array( + ], + 'block3' => [ AccessResult::allowed(), 'bottom', 5 - ), - 'block5' => array( + ], + 'block5' => [ AccessResult::allowed(), 'bottom', -5 - ), - ); + ], + ]; $test_cases = []; $test_cases[] = [$blocks_config, diff --git a/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php b/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php index c47d65a..d91ebbc 100644 --- a/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php +++ b/core/modules/block/tests/src/Unit/CategoryAutocompleteTest.php @@ -24,7 +24,7 @@ protected function setUp() { $block_manager = $this->getMock('Drupal\Core\Block\BlockManagerInterface'); $block_manager->expects($this->any()) ->method('getCategories') - ->will($this->returnValue(array('Comment', 'Node', 'None & Such', 'User'))); + ->will($this->returnValue(['Comment', 'Node', 'None & Such', 'User'])); $this->autocompleteController = new CategoryAutocompleteController($block_manager); } @@ -43,9 +43,9 @@ protected function setUp() { */ public function testAutocompleteSuggestions($string, $suggestions) { $suggestions = array_map(function ($suggestion) { - return array('value' => $suggestion, 'label' => Html::escape($suggestion)); + return ['value' => $suggestion, 'label' => Html::escape($suggestion)]; }, $suggestions); - $result = $this->autocompleteController->autocomplete(new Request(array('q' => $string))); + $result = $this->autocompleteController->autocomplete(new Request(['q' => $string])); $this->assertSame($suggestions, json_decode($result->getContent(), TRUE)); } @@ -55,30 +55,30 @@ public function testAutocompleteSuggestions($string, $suggestions) { * @return array */ public function providerTestAutocompleteSuggestions() { - $test_parameters = array(); - $test_parameters[] = array( + $test_parameters = []; + $test_parameters[] = [ 'string' => 'Com', - 'suggestions' => array( + 'suggestions' => [ 'Comment', - ), - ); - $test_parameters[] = array( + ], + ]; + $test_parameters[] = [ 'string' => 'No', - 'suggestions' => array( + 'suggestions' => [ 'Node', 'None & Such', - ), - ); - $test_parameters[] = array( + ], + ]; + $test_parameters[] = [ 'string' => 'us', - 'suggestions' => array( + 'suggestions' => [ 'User', - ), - ); - $test_parameters[] = array( + ], + ]; + $test_parameters[] = [ 'string' => 'Banana', - 'suggestions' => array(), - ); + 'suggestions' => [], + ]; return $test_parameters; } diff --git a/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php b/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php index a513c4e..6d7dbf2 100644 --- a/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php +++ b/core/modules/block/tests/src/Unit/Menu/BlockLocalTasksTest.php @@ -13,33 +13,33 @@ class BlockLocalTasksTest extends LocalTaskIntegrationTestBase { protected function setUp() { - $this->directoryList = array('block' => 'core/modules/block'); + $this->directoryList = ['block' => 'core/modules/block']; parent::setUp(); - $config_factory = $this->getConfigFactoryStub(array('system.theme' => array( + $config_factory = $this->getConfigFactoryStub(['system.theme' => [ 'default' => 'test_c', - ))); + ]]); - $themes = array(); - $themes['test_a'] = (object) array( + $themes = []; + $themes['test_a'] = (object) [ 'status' => 1, - 'info' => array( + 'info' => [ 'name' => 'test_a', 'hidden' => TRUE, - ), - ); - $themes['test_b'] = (object) array( + ], + ]; + $themes['test_b'] = (object) [ 'status' => 1, - 'info' => array( + 'info' => [ 'name' => 'test_b', - ), - ); - $themes['test_c'] = (object) array( + ], + ]; + $themes['test_c'] = (object) [ 'status' => 1, - 'info' => array( + 'info' => [ 'name' => 'test_c', - ), - ); + ], + ]; $theme_handler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface'); $theme_handler->expects($this->any()) ->method('listInfo') @@ -63,7 +63,7 @@ protected function setUp() { * Tests the admin edit local task. */ public function testBlockAdminLocalTasks() { - $this->assertLocalTasks('entity.block.edit_form', array(array('entity.block.edit_form'))); + $this->assertLocalTasks('entity.block.edit_form', [['entity.block.edit_form']]); } /** @@ -79,10 +79,10 @@ public function testBlockAdminDisplay($route, $expected) { * Provides a list of routes to test. */ public function providerTestBlockAdminDisplay() { - return array( - array('block.admin_display', array(array('block.admin_display'), array('block.admin_display_theme:test_b', 'block.admin_display_theme:test_c'))), - array('block.admin_display_theme', array(array('block.admin_display'), array('block.admin_display_theme:test_b', 'block.admin_display_theme:test_c'))), - ); + return [ + ['block.admin_display', [['block.admin_display'], ['block.admin_display_theme:test_b', 'block.admin_display_theme:test_c']]], + ['block.admin_display_theme', [['block.admin_display'], ['block.admin_display_theme:test_b', 'block.admin_display_theme:test_c']]], + ]; } } diff --git a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php index 7701eca..1569411 100644 --- a/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php +++ b/core/modules/block/tests/src/Unit/Plugin/DisplayVariant/BlockPageVariantTest.php @@ -44,7 +44,7 @@ class BlockPageVariantTest extends UnitTestCase { * @return \Drupal\block\Plugin\DisplayVariant\BlockPageVariant|\PHPUnit_Framework_MockObject_MockObject * A mocked display variant plugin. */ - public function setUpDisplayVariant($configuration = array(), $definition = array()) { + public function setUpDisplayVariant($configuration = [], $definition = []) { $container = new Container(); $cache_context_manager = $this->getMockBuilder('Drupal\Core\Cache\CacheContextsManager') @@ -60,37 +60,37 @@ public function setUpDisplayVariant($configuration = array(), $definition = arra $this->blockViewBuilder = $this->getMock('Drupal\Core\Entity\EntityViewBuilderInterface'); return $this->getMockBuilder('Drupal\block\Plugin\DisplayVariant\BlockPageVariant') - ->setConstructorArgs(array($configuration, 'test', $definition, $this->blockRepository, $this->blockViewBuilder, ['config:block_list'])) - ->setMethods(array('getRegionNames')) + ->setConstructorArgs([$configuration, 'test', $definition, $this->blockRepository, $this->blockViewBuilder, ['config:block_list']]) + ->setMethods(['getRegionNames']) ->getMock(); } public function providerBuild() { - $blocks_config = array( - 'block1' => array( + $blocks_config = [ + 'block1' => [ // region, is main content block, is messages block, is title block 'top', FALSE, FALSE, FALSE, - ), + ], // Test multiple blocks in the same region. - 'block2' => array( + 'block2' => [ 'bottom', FALSE, FALSE, FALSE, - ), - 'block3' => array( + ], + 'block3' => [ 'bottom', FALSE, FALSE, FALSE, - ), + ], // Test a block implementing MainContentBlockPluginInterface. - 'block4' => array( + 'block4' => [ 'center', TRUE, FALSE, FALSE, - ), + ], // Test a block implementing MessagesBlockPluginInterface. - 'block5' => array( + 'block5' => [ 'center', FALSE, TRUE, FALSE, - ), + ], // Test a block implementing TitleBlockPluginInterface. - 'block6' => array( + 'block6' => [ 'center', FALSE, FALSE, TRUE, - ), - ); + ], + ]; $test_cases = []; $test_cases[] = [$blocks_config, 6, @@ -219,7 +219,7 @@ public function testBuild(array $blocks_config, $visible_block_count, array $exp } $this->blockViewBuilder->expects($this->exactly($visible_block_count)) ->method('view') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $this->blockRepository->expects($this->once()) ->method('getVisibleBlocksPerRegion') ->willReturnCallback(function (&$cacheable_metadata) use ($blocks) { diff --git a/core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockRegionTest.php b/core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockRegionTest.php index 8194709..d6596b6 100644 --- a/core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockRegionTest.php +++ b/core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockRegionTest.php @@ -30,13 +30,13 @@ protected function transform(array $value, Row $row = NULL) { $row = $this->prophesize(Row::class)->reveal(); } - $regions = array( - 'bartik' => array( + $regions = [ + 'bartik' => [ 'triptych_first' => 'Triptych first', 'triptych_second' => 'Triptych second', 'triptych_third' => 'Triptych third', - ), - ); + ], + ]; $plugin = new BlockRegion(['region_map' => []], 'block_region', [], $regions); return $plugin->transform($value, $executable, $row, 'foo'); } diff --git a/core/modules/block/tests/src/Unit/Plugin/migrate/source/BlockTest.php b/core/modules/block/tests/src/Unit/Plugin/migrate/source/BlockTest.php index 4a60bd1..aabaed4 100644 --- a/core/modules/block/tests/src/Unit/Plugin/migrate/source/BlockTest.php +++ b/core/modules/block/tests/src/Unit/Plugin/migrate/source/BlockTest.php @@ -14,18 +14,18 @@ class BlockTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = 'Drupal\block\Plugin\migrate\source\Block'; - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'block', - ), - ); + ], + ]; /** * Sample block instance query results from the source. */ - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'bid' => 1, 'module' => 'block', 'delta' => '1', @@ -38,8 +38,8 @@ class BlockTest extends MigrateSqlSourceTestCase { 'title' => 'Test Title 01', 'cache' => -1, 'roles' => [2] - ), - array( + ], + [ 'bid' => 2, 'module' => 'block', 'delta' => '2', @@ -52,13 +52,13 @@ class BlockTest extends MigrateSqlSourceTestCase { 'title' => 'Test Title 02', 'cache' => -1, 'roles' => [2] - ), - ); + ], + ]; /** * Sample block table. */ - protected $expectedBlocks = array( - array( + protected $expectedBlocks = [ + [ 'bid' => 1, 'module' => 'block', 'delta' => '1', @@ -70,8 +70,8 @@ class BlockTest extends MigrateSqlSourceTestCase { 'pages' => '', 'title' => 'Test Title 01', 'cache' => -1, - ), - array( + ], + [ 'bid' => 2, 'module' => 'block', 'delta' => '2', @@ -83,39 +83,39 @@ class BlockTest extends MigrateSqlSourceTestCase { 'pages' => '', 'title' => 'Test Title 02', 'cache' => -1, - ), - ); + ], + ]; /** * Sample block roles table. */ - protected $expectedBlocksRoles = array( - array( + protected $expectedBlocksRoles = [ + [ 'module' => 'block', 'delta' => 1, 'rid' => 2, - ), - array( + ], + [ 'module' => 'block', 'delta' => 2, 'rid' => 2, - ), - array( + ], + [ 'module' => 'block', 'delta' => 2, 'rid' => 100, - ), - ); + ], + ]; /** * Sample role table. */ - protected $expectedRole = array( - array( + protected $expectedRole = [ + [ 'rid' => 2, 'name' => 'authenticated user', - ), - ); + ], + ]; /** * Prepopulate database contents. @@ -124,8 +124,8 @@ protected function setUp() { $this->databaseContents['blocks'] = $this->expectedBlocks; $this->databaseContents['blocks_roles'] = $this->expectedBlocksRoles; $this->databaseContents['role'] = $this->expectedRole; - $this->databaseContents['system'] = array( - array( + $this->databaseContents['system'] = [ + [ 'filename' => 'modules/system/system.module', 'name' => 'system', 'type' => 'module', @@ -136,8 +136,8 @@ protected function setUp() { 'schema_version' => '6055', 'weight' => '0', 'info' => 'a:0:{}', - ) - ); + ] + ]; parent::setUp(); } diff --git a/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module index e0b5729..1b32a52 100644 --- a/core/modules/block_content/block_content.module +++ b/core/modules/block_content/block_content.module @@ -15,25 +15,25 @@ function block_content_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { case 'help.page.block_content': - $field_ui = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#'; + $field_ui = \Drupal::moduleHandler()->moduleExists('field_ui') ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#'; $output = ''; $output .= '

        ' . t('About') . '

        '; - $output .= '

        ' . t('The Custom Block module allows you to create and manage custom block types and content-containing blocks from the Custom block library page. Custom block types have fields; see the Field module help for more information. Once created, custom blocks can be placed in regions just like blocks provided by other modules; see the Block module help page for details. For more information, see the online documentation for the Custom Block module.', array(':block-library' => \Drupal::url('entity.block_content.collection'), ':block-content' => \Drupal::url('entity.block_content.collection'), ':field-help' => \Drupal::url('help.page', array('name' => 'field')), ':blocks' => \Drupal::url('help.page', array('name' => 'block')), ':online-help' => 'https://www.drupal.org/documentation/modules/block_content')) . '

        '; + $output .= '

        ' . t('The Custom Block module allows you to create and manage custom block types and content-containing blocks from the Custom block library page. Custom block types have fields; see the Field module help for more information. Once created, custom blocks can be placed in regions just like blocks provided by other modules; see the Block module help page for details. For more information, see the online documentation for the Custom Block module.', [':block-library' => \Drupal::url('entity.block_content.collection'), ':block-content' => \Drupal::url('entity.block_content.collection'), ':field-help' => \Drupal::url('help.page', ['name' => 'field']), ':blocks' => \Drupal::url('help.page', ['name' => 'block']), ':online-help' => 'https://www.drupal.org/documentation/modules/block_content']) . '

        '; $output .= '

        ' . t('Uses') . '

        '; $output .= '
        '; $output .= '
        ' . t('Creating and managing custom block types') . '
        '; - $output .= '
        ' . t('Users with the Administer blocks permission can create and edit custom block types with fields and display settings, from the Block types page in the Custom block library. For more information about managing fields and display settings, see the Field UI module help.', array(':types' => \Drupal::url('entity.block_content_type.collection'), ':field-ui' => $field_ui)) . '
        '; + $output .= '
        ' . t('Users with the Administer blocks permission can create and edit custom block types with fields and display settings, from the Block types page in the Custom block library. For more information about managing fields and display settings, see the Field UI module help.', [':types' => \Drupal::url('entity.block_content_type.collection'), ':field-ui' => $field_ui]) . '
        '; $output .= '
        ' . t('Creating custom blocks') . '
        '; - $output .= '
        ' . t('Users with the Administer blocks permission can create, edit, and delete custom blocks of each defined custom block type, from the Blocks page in the Custom block library. After creating a block, place it in a region from the Block layout page; see the Block module help for more information about placing blocks.', array(':blocks' => \Drupal::url('block.admin_display'), ':block-library' => \Drupal::url('entity.block_content.collection'), ':block_help' => \Drupal::url('help.page', array('name' => 'block')))) . '
        '; + $output .= '
        ' . t('Users with the Administer blocks permission can create, edit, and delete custom blocks of each defined custom block type, from the Blocks page in the Custom block library. After creating a block, place it in a region from the Block layout page; see the Block module help for more information about placing blocks.', [':blocks' => \Drupal::url('block.admin_display'), ':block-library' => \Drupal::url('entity.block_content.collection'), ':block_help' => \Drupal::url('help.page', ['name' => 'block'])]) . '
        '; $output .= '
        '; return $output; case 'entity.block_content.collection': - $output = '

        ' . t('Blocks in the block library belong to Custom block types, each with its own fields and display settings. After creating a block, place it in a region from the Block layout page.', array(':types' => \Drupal::url('entity.block_content_type.collection'), ':blocks' => \Drupal::url('block.admin_display'))) . '

        '; + $output = '

        ' . t('Blocks in the block library belong to Custom block types, each with its own fields and display settings. After creating a block, place it in a region from the Block layout page.', [':types' => \Drupal::url('entity.block_content_type.collection'), ':blocks' => \Drupal::url('block.admin_display')]) . '

        '; return $output; case 'entity.block_content_type.collection': - $output = '

        ' . t('Each block type has its own fields and display settings. Create blocks of each type on the Blocks page in the custom block library.', array(':block-library' => \Drupal::url('entity.block_content.collection'))) . '

        '; + $output = '

        ' . t('Each block type has its own fields and display settings. Create blocks of each type on the Blocks page in the custom block library.', [':block-library' => \Drupal::url('entity.block_content.collection')]) . '

        '; return $output; } @@ -43,12 +43,12 @@ function block_content_help($route_name, RouteMatchInterface $route_match) { * Implements hook_theme(). */ function block_content_theme($existing, $type, $theme, $path) { - return array( - 'block_content_add_list' => array( - 'variables' => array('content' => NULL), + return [ + 'block_content_add_list' => [ + 'variables' => ['content' => NULL], 'file' => 'block_content.pages.inc', - ), - ); + ], + ]; } /** @@ -83,23 +83,23 @@ function block_content_add_body_field($block_type_id, $label = 'Body') { 'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'), 'bundle' => $block_type_id, 'label' => $label, - 'settings' => array('display_summary' => FALSE), + 'settings' => ['display_summary' => FALSE], ]); $field->save(); // Assign widget settings for the 'default' form mode. entity_get_form_display('block_content', $block_type_id, 'default') - ->setComponent('body', array( + ->setComponent('body', [ 'type' => 'text_textarea_with_summary', - )) + ]) ->save(); // Assign display settings for 'default' view mode. entity_get_display('block_content', $block_type_id, 'default') - ->setComponent('body', array( + ->setComponent('body', [ 'label' => 'hidden', 'type' => 'text_default', - )) + ]) ->save(); } diff --git a/core/modules/block_content/block_content.pages.inc b/core/modules/block_content/block_content.pages.inc index 8629690..e50e717 100644 --- a/core/modules/block_content/block_content.pages.inc +++ b/core/modules/block_content/block_content.pages.inc @@ -19,18 +19,18 @@ * @see block_content_add_page() */ function template_preprocess_block_content_add_list(&$variables) { - $variables['types'] = array(); + $variables['types'] = []; $query = \Drupal::request()->query->all(); foreach ($variables['content'] as $type) { - $variables['types'][$type->id()] = array( - 'link' => \Drupal::l($type->label(), new Url('block_content.add_form', array('block_content_type' => $type->id()), array('query' => $query))), - 'description' => array( + $variables['types'][$type->id()] = [ + 'link' => \Drupal::l($type->label(), new Url('block_content.add_form', ['block_content_type' => $type->id()], ['query' => $query])), + 'description' => [ '#markup' => $type->getDescription(), - ), + ], 'title' => $type->label(), - 'localized_options' => array( + 'localized_options' => [ 'query' => $query, - ), - ); + ], + ]; } } diff --git a/core/modules/block_content/src/BlockContentForm.php b/core/modules/block_content/src/BlockContentForm.php index 8815f56..892da8d 100644 --- a/core/modules/block_content/src/BlockContentForm.php +++ b/core/modules/block_content/src/BlockContentForm.php @@ -102,61 +102,61 @@ public function form(array $form, FormStateInterface $form_state) { $account = $this->currentUser(); if ($this->operation == 'edit') { - $form['#title'] = $this->t('Edit custom block %label', array('%label' => $block->label())); + $form['#title'] = $this->t('Edit custom block %label', ['%label' => $block->label()]); } // Override the default CSS class name, since the user-defined custom block // type name in 'TYPE-block-form' potentially clashes with third-party class // names. $form['#attributes']['class'][0] = 'block-' . Html::getClass($block->bundle()) . '-form'; - $form['advanced'] = array( + $form['advanced'] = [ '#type' => 'vertical_tabs', '#weight' => 99, - ); + ]; // Add a log field if the "Create new revision" option is checked, or if the // current user has the ability to check that option. - $form['revision_information'] = array( + $form['revision_information'] = [ '#type' => 'details', '#title' => $this->t('Revision information'), // Open by default when "Create new revision" is checked. '#open' => $block->isNewRevision(), '#group' => 'advanced', - '#attributes' => array( - 'class' => array('block-content-form-revision-information'), - ), - '#attached' => array( - 'library' => array('block_content/drupal.block_content'), - ), + '#attributes' => [ + 'class' => ['block-content-form-revision-information'], + ], + '#attached' => [ + 'library' => ['block_content/drupal.block_content'], + ], '#weight' => 20, '#access' => $block->isNewRevision() || $account->hasPermission('administer blocks'), - ); + ]; - $form['revision_information']['revision'] = array( + $form['revision_information']['revision'] = [ '#type' => 'checkbox', '#title' => $this->t('Create new revision'), '#default_value' => $block->isNewRevision(), '#access' => $account->hasPermission('administer blocks'), - ); + ]; // Check the revision log checkbox when the log textarea is filled in. // This must not happen if "Create new revision" is enabled by default, // since the state would auto-disable the checkbox otherwise. if (!$block->isNewRevision()) { - $form['revision_information']['revision']['#states'] = array( - 'checked' => array( - 'textarea[name="revision_log"]' => array('empty' => FALSE), - ), - ); + $form['revision_information']['revision']['#states'] = [ + 'checked' => [ + 'textarea[name="revision_log"]' => ['empty' => FALSE], + ], + ]; } - $form['revision_information']['revision_log'] = array( + $form['revision_information']['revision_log'] = [ '#type' => 'textarea', '#title' => $this->t('Revision log message'), '#rows' => 4, '#default_value' => $block->getRevisionLog(), '#description' => $this->t('Briefly describe the changes you have made.'), - ); + ]; return parent::form($form, $form_state, $block); } @@ -177,10 +177,10 @@ public function save(array $form, FormStateInterface $form_state) { $insert = $block->isNew(); $block->save(); - $context = array('@type' => $block->bundle(), '%info' => $block->label()); + $context = ['@type' => $block->bundle(), '%info' => $block->label()]; $logger = $this->logger('block_content'); $block_type = $this->blockContentTypeStorage->load($block->bundle()); - $t_args = array('@type' => $block_type->label(), '%info' => $block->label()); + $t_args = ['@type' => $block_type->label(), '%info' => $block->label()]; if ($insert) { $logger->notice('@type: added %info.', $context); @@ -200,10 +200,10 @@ public function save(array $form, FormStateInterface $form_state) { } $form_state->setRedirect( 'block.admin_add', - array( + [ 'plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme, - ) + ] ); } else { diff --git a/core/modules/block_content/src/BlockContentTranslationHandler.php b/core/modules/block_content/src/BlockContentTranslationHandler.php index 781ba1b..bd0c29c 100644 --- a/core/modules/block_content/src/BlockContentTranslationHandler.php +++ b/core/modules/block_content/src/BlockContentTranslationHandler.php @@ -19,13 +19,13 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En parent::entityFormAlter($form, $form_state, $entity); // Move the translation fieldset to a vertical tab. if (isset($form['translation'])) { - $form['translation'] += array( + $form['translation'] += [ '#group' => 'additional_settings', '#weight' => 100, - '#attributes' => array( - 'class' => array('block-content-translation-options'), - ), - ); + '#attributes' => [ + 'class' => ['block-content-translation-options'], + ], + ]; } } @@ -34,7 +34,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En */ protected function entityFormTitle(EntityInterface $entity) { $block_type = BlockContentType::load($entity->bundle()); - return t('Edit @type @title', array('@type' => $block_type->label(), '@title' => $entity->label())); + return t('Edit @type @title', ['@type' => $block_type->label(), '@title' => $entity->label()]); } } diff --git a/core/modules/block_content/src/BlockContentTypeForm.php b/core/modules/block_content/src/BlockContentTypeForm.php index d864e8d..4e140b1 100644 --- a/core/modules/block_content/src/BlockContentTypeForm.php +++ b/core/modules/block_content/src/BlockContentTypeForm.php @@ -25,65 +25,65 @@ public function form(array $form, FormStateInterface $form_state) { $form['#title'] = $this->t('Add custom block type'); } else { - $form['#title'] = $this->t('Edit %label custom block type', array('%label' => $block_type->label())); + $form['#title'] = $this->t('Edit %label custom block type', ['%label' => $block_type->label()]); } - $form['label'] = array( + $form['label'] = [ '#type' => 'textfield', '#title' => t('Label'), '#maxlength' => 255, '#default_value' => $block_type->label(), '#description' => t("Provide a label for this block type to help identify it in the administration pages."), '#required' => TRUE, - ); - $form['id'] = array( + ]; + $form['id'] = [ '#type' => 'machine_name', '#default_value' => $block_type->id(), - '#machine_name' => array( + '#machine_name' => [ 'exists' => '\Drupal\block_content\Entity\BlockContentType::load', - ), + ], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, - ); + ]; - $form['description'] = array( + $form['description'] = [ '#type' => 'textarea', '#default_value' => $block_type->getDescription(), '#description' => t('Enter a description for this block type.'), '#title' => t('Description'), - ); + ]; - $form['revision'] = array( + $form['revision'] = [ '#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $block_type->shouldCreateNewRevision(), '#description' => t('Create a new revision by default for this block type.'), - ); + ]; if ($this->moduleHandler->moduleExists('language')) { - $form['language'] = array( + $form['language'] = [ '#type' => 'details', '#title' => t('Language settings'), '#group' => 'additional_settings', - ); + ]; $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('block_content', $block_type->id()); - $form['language']['language_configuration'] = array( + $form['language']['language_configuration'] = [ '#type' => 'language_configuration', - '#entity_information' => array( + '#entity_information' => [ 'entity_type' => 'block_content', 'bundle' => $block_type->id(), - ), + ], '#default_value' => $language_configuration, - ); + ]; $form['#submit'][] = 'language_configuration_element_submit'; } - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => t('Save'), - ); + ]; return $this->protectBundleIdElement($form); } @@ -98,13 +98,13 @@ public function save(array $form, FormStateInterface $form_state) { $edit_link = $this->entity->link($this->t('Edit')); $logger = $this->logger('block_content'); if ($status == SAVED_UPDATED) { - drupal_set_message(t('Custom block type %label has been updated.', array('%label' => $block_type->label()))); - $logger->notice('Custom block type %label has been updated.', array('%label' => $block_type->label(), 'link' => $edit_link)); + drupal_set_message(t('Custom block type %label has been updated.', ['%label' => $block_type->label()])); + $logger->notice('Custom block type %label has been updated.', ['%label' => $block_type->label(), 'link' => $edit_link]); } else { block_content_add_body_field($block_type->id()); - drupal_set_message(t('Custom block type %label has been added.', array('%label' => $block_type->label()))); - $logger->notice('Custom block type %label has been added.', array('%label' => $block_type->label(), 'link' => $edit_link)); + drupal_set_message(t('Custom block type %label has been added.', ['%label' => $block_type->label()])); + $logger->notice('Custom block type %label has been added.', ['%label' => $block_type->label(), 'link' => $edit_link]); } $form_state->setRedirectUrl($this->entity->urlInfo('collection')); diff --git a/core/modules/block_content/src/BlockContentViewBuilder.php b/core/modules/block_content/src/BlockContentViewBuilder.php index 322a087..29c668c 100644 --- a/core/modules/block_content/src/BlockContentViewBuilder.php +++ b/core/modules/block_content/src/BlockContentViewBuilder.php @@ -15,13 +15,13 @@ class BlockContentViewBuilder extends EntityViewBuilder { * {@inheritdoc} */ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { - return $this->viewMultiple(array($entity), $view_mode, $langcode)[0]; + return $this->viewMultiple([$entity], $view_mode, $langcode)[0]; } /** * {@inheritdoc} */ - public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) { + public function viewMultiple(array $entities = [], $view_mode = 'full', $langcode = NULL) { $build_list = parent::viewMultiple($entities, $view_mode, $langcode); // Apply the buildMultiple() #pre_render callback immediately, to make // bubbling of attributes and contextual links to the actual block work. @@ -48,10 +48,10 @@ protected function alterBuild(array &$build, EntityInterface $entity, EntityView parent::alterBuild($build, $entity, $display, $view_mode); // Add contextual links for this custom block. if (!$entity->isNew()) { - $build['#contextual_links']['block_content'] = array( - 'route_parameters' => array('block_content' => $entity->id()), - 'metadata' => array('changed' => $entity->getChangedTime()), - ); + $build['#contextual_links']['block_content'] = [ + 'route_parameters' => ['block_content' => $entity->id()], + 'metadata' => ['changed' => $entity->getChangedTime()], + ]; } } diff --git a/core/modules/block_content/src/BlockContentViewsData.php b/core/modules/block_content/src/BlockContentViewsData.php index 1d5d46f..010ede0 100644 --- a/core/modules/block_content/src/BlockContentViewsData.php +++ b/core/modules/block_content/src/BlockContentViewsData.php @@ -23,13 +23,13 @@ public function getViewsData() { $data['block_content_field_data']['type']['field']['id'] = 'field'; - $data['block_content']['block_content_listing_empty'] = array( + $data['block_content']['block_content_listing_empty'] = [ 'title' => $this->t('Empty block library behavior'), 'help' => $this->t('Provides a link to add a new block.'), - 'area' => array( + 'area' => [ 'id' => 'block_content_listing_empty', - ), - ); + ], + ]; // Advertise this table as a possible base table. $data['block_content_field_revision']['table']['base']['help'] = $this->t('Block Content revision is a history of changes to block content.'); $data['block_content_field_revision']['table']['base']['defaults']['title'] = 'info'; diff --git a/core/modules/block_content/src/Controller/BlockContentController.php b/core/modules/block_content/src/Controller/BlockContentController.php index 1caad74..7c1f8aa 100644 --- a/core/modules/block_content/src/Controller/BlockContentController.php +++ b/core/modules/block_content/src/Controller/BlockContentController.php @@ -79,14 +79,14 @@ public function add(Request $request) { return $this->addForm($type, $request); } if (count($types) === 0) { - return array( + return [ '#markup' => $this->t('You have not created any block types yet. Go to the block type creation page to add a new block type.', [ ':url' => Url::fromRoute('block_content.type_add')->toString(), ]), - ); + ]; } - return array('#theme' => 'block_content_add_list', '#content' => $types); + return ['#theme' => 'block_content_add_list', '#content' => $types]; } /** @@ -101,9 +101,9 @@ public function add(Request $request) { * A form array as expected by drupal_render(). */ public function addForm(BlockContentTypeInterface $block_content_type, Request $request) { - $block = $this->blockContentStorage->create(array( + $block = $this->blockContentStorage->create([ 'type' => $block_content_type->id() - )); + ]); if (($theme = $request->query->get('theme')) && in_array($theme, array_keys($this->themeHandler->listInfo()))) { // We have navigated to this page from the block library and will keep track // of the theme for redirecting the user to the configuration page for the @@ -123,7 +123,7 @@ public function addForm(BlockContentTypeInterface $block_content_type, Request $ * The page title. */ public function getAddFormTitle(BlockContentTypeInterface $block_content_type) { - return $this->t('Add %type custom block', array('%type' => $block_content_type->label())); + return $this->t('Add %type custom block', ['%type' => $block_content_type->label()]); } } diff --git a/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php index 9e0531e..1fec0c8 100644 --- a/core/modules/block_content/src/Entity/BlockContent.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -114,7 +114,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { * {@inheritdoc} */ public function getInstances() { - return \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(array('plugin' => 'block_content:' . $this->uuid())); + return \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(['plugin' => 'block_content:' . $this->uuid()]); } /** @@ -166,10 +166,10 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setRevisionable(TRUE) ->setTranslatable(TRUE) ->setRequired(TRUE) - ->setDisplayOptions('form', array( + ->setDisplayOptions('form', [ 'type' => 'string_textfield', 'weight' => -5, - )) + ]) ->setDisplayConfigurable('form', TRUE) ->addConstraint('UniqueField', []); diff --git a/core/modules/block_content/src/Form/BlockContentDeleteForm.php b/core/modules/block_content/src/Form/BlockContentDeleteForm.php index 3fe725d..035ec4c 100644 --- a/core/modules/block_content/src/Form/BlockContentDeleteForm.php +++ b/core/modules/block_content/src/Form/BlockContentDeleteForm.php @@ -16,10 +16,10 @@ class BlockContentDeleteForm extends ContentEntityDeleteForm { public function buildForm(array $form, FormStateInterface $form_state) { $instances = $this->entity->getInstances(); - $form['message'] = array( + $form['message'] = [ '#markup' => $this->formatPlural(count($instances), 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instances.'), '#access' => !empty($instances), - ); + ]; return parent::buildForm($form, $form_state); } diff --git a/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php b/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php index 49ba038..2f8bd4d 100644 --- a/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php +++ b/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php @@ -44,8 +44,8 @@ public static function create(ContainerInterface $container) { public function buildForm(array $form, FormStateInterface $form_state) { $blocks = $this->queryFactory->get('block_content')->condition('type', $this->entity->id())->execute(); if (!empty($blocks)) { - $caption = '

        ' . $this->formatPlural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', array('%label' => $this->entity->label())) . '

        '; - $form['description'] = array('#markup' => $caption); + $caption = '

        ' . $this->formatPlural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', ['%label' => $this->entity->label()]) . '

        '; + $form['description'] = ['#markup' => $caption]; return $form; } else { diff --git a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php index 2afd040..e97e740 100644 --- a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php +++ b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php @@ -105,11 +105,11 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function defaultConfiguration() { - return array( + return [ 'status' => TRUE, 'info' => '', 'view_mode' => 'full', - ); + ]; } /** @@ -122,14 +122,14 @@ public function blockForm($form, FormStateInterface $form_state) { $block = $this->entityManager->loadEntityByUuid('block_content', $uuid); $options = $this->entityManager->getViewModeOptionsByBundle('block_content', $block->bundle()); - $form['view_mode'] = array( + $form['view_mode'] = [ '#type' => 'select', '#options' => $options, '#title' => $this->t('View mode'), '#description' => $this->t('Output the block in this view mode.'), '#default_value' => $this->configuration['view_mode'], '#access' => (count($options) > 1), - ); + ]; $form['title']['#description'] = $this->t('The title of the block as shown to the user.'); return $form; } @@ -161,13 +161,13 @@ public function build() { return $this->entityManager->getViewBuilder($block->getEntityTypeId())->view($block, $this->configuration['view_mode']); } else { - return array( - '#markup' => $this->t('Block with uuid %uuid does not exist. Add custom block.', array( + return [ + '#markup' => $this->t('Block with uuid %uuid does not exist. Add custom block.', [ '%uuid' => $this->getDerivativeId(), ':url' => $this->urlGenerator->generate('block_content.add_page') - )), + ]), '#access' => $this->account->hasPermission('administer blocks') - ); + ]; } } diff --git a/core/modules/block_content/src/Plugin/Derivative/BlockContent.php b/core/modules/block_content/src/Plugin/Derivative/BlockContent.php index 63b68c0..72b8773 100644 --- a/core/modules/block_content/src/Plugin/Derivative/BlockContent.php +++ b/core/modules/block_content/src/Plugin/Derivative/BlockContent.php @@ -48,9 +48,9 @@ public function getDerivativeDefinitions($base_plugin_definition) { foreach ($block_contents as $block_content) { $this->derivatives[$block_content->uuid()] = $base_plugin_definition; $this->derivatives[$block_content->uuid()]['admin_label'] = $block_content->label(); - $this->derivatives[$block_content->uuid()]['config_dependencies']['content'] = array( + $this->derivatives[$block_content->uuid()]['config_dependencies']['content'] = [ $block_content->getConfigDependencyName() - ); + ]; } return parent::getDerivativeDefinitions($base_plugin_definition); } diff --git a/core/modules/block_content/src/Plugin/migrate/source/d6/Box.php b/core/modules/block_content/src/Plugin/migrate/source/d6/Box.php index 4135233..a28927b 100644 --- a/core/modules/block_content/src/Plugin/migrate/source/d6/Box.php +++ b/core/modules/block_content/src/Plugin/migrate/source/d6/Box.php @@ -18,7 +18,7 @@ class Box extends DrupalSqlBase { */ public function query() { $query = $this->select('boxes', 'b') - ->fields('b', array('bid', 'body', 'info', 'format')); + ->fields('b', ['bid', 'body', 'info', 'format']); $query->orderBy('b.bid'); return $query; @@ -28,12 +28,12 @@ public function query() { * {@inheritdoc} */ public function fields() { - return array( + return [ 'bid' => $this->t('The numeric identifier of the block/box'), 'body' => $this->t('The block/box content'), 'info' => $this->t('Admin title of the block/box.'), 'format' => $this->t('Input format of the custom block/box content.'), - ); + ]; } /** diff --git a/core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustom.php b/core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustom.php index 4aee2a4..ea33682 100644 --- a/core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustom.php +++ b/core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustom.php @@ -24,12 +24,12 @@ public function query() { * {@inheritdoc} */ public function fields() { - return array( + return [ 'bid' => $this->t('The numeric identifier of the block/box'), 'body' => $this->t('The block/box content'), 'info' => $this->t('Admin title of the block/box.'), 'format' => $this->t('Input format of the custom block/box content.'), - ); + ]; } /** diff --git a/core/modules/block_content/src/Plugin/views/area/ListingEmpty.php b/core/modules/block_content/src/Plugin/views/area/ListingEmpty.php index d2bd026..e412f18 100644 --- a/core/modules/block_content/src/Plugin/views/area/ListingEmpty.php +++ b/core/modules/block_content/src/Plugin/views/area/ListingEmpty.php @@ -71,19 +71,19 @@ public static function create(ContainerInterface $container, array $configuratio public function render($empty = FALSE) { if (!$empty || !empty($this->options['empty'])) { /** @var \Drupal\Core\Access\AccessResultInterface|\Drupal\Core\Cache\CacheableDependencyInterface $access_result */ - $access_result = $this->accessManager->checkNamedRoute('block_content.add_page', array(), $this->currentUser, TRUE); - $element = array( - '#markup' => $this->t('Add a custom block.', array(':url' => Url::fromRoute('block_content.add_page')->toString())), + $access_result = $this->accessManager->checkNamedRoute('block_content.add_page', [], $this->currentUser, TRUE); + $element = [ + '#markup' => $this->t('Add a custom block.', [':url' => Url::fromRoute('block_content.add_page')->toString()]), '#access' => $access_result->isAllowed(), '#cache' => [ 'contexts' => $access_result->getCacheContexts(), 'tags' => $access_result->getCacheTags(), 'max-age' => $access_result->getCacheMaxAge(), ], - ); + ]; return $element; } - return array(); + return []; } } diff --git a/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php b/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php index 7eefdc7..0489def 100644 --- a/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php +++ b/core/modules/block_content/src/Tests/BlockContentCacheTagsTest.php @@ -20,29 +20,29 @@ class BlockContentCacheTagsTest extends EntityCacheTagsTestBase { /** * {@inheritdoc} */ - public static $modules = array('block_content'); + public static $modules = ['block_content']; /** * {@inheritdoc} */ protected function createEntity() { - $block_content_type = BlockContentType::create(array( + $block_content_type = BlockContentType::create([ 'id' => 'basic', 'label' => 'basic', 'revision' => FALSE - )); + ]); $block_content_type->save(); block_content_add_body_field($block_content_type->id()); // Create a "Llama" custom block. - $block_content = BlockContent::create(array( + $block_content = BlockContent::create([ 'info' => 'Llama', 'type' => 'basic', - 'body' => array( + 'body' => [ 'value' => 'The name "llama" was adopted by European settlers from native Peruvians.', 'format' => 'plain_text', - ), - )); + ], + ]); $block_content->save(); return $block_content; diff --git a/core/modules/block_content/src/Tests/BlockContentCreationTest.php b/core/modules/block_content/src/Tests/BlockContentCreationTest.php index e45892c..ac9e824 100644 --- a/core/modules/block_content/src/Tests/BlockContentCreationTest.php +++ b/core/modules/block_content/src/Tests/BlockContentCreationTest.php @@ -21,17 +21,17 @@ class BlockContentCreationTest extends BlockContentTestBase { * * @var array */ - public static $modules = array('block_content_test', 'dblog', 'field_ui'); + public static $modules = ['block_content_test', 'dblog', 'field_ui']; /** * Permissions to grant admin user. * * @var array */ - protected $permissions = array( + protected $permissions = [ 'administer blocks', 'administer block_content display' - ); + ]; /** * Sets the test up. @@ -48,22 +48,22 @@ public function testBlockContentCreation() { $this->drupalLogin($this->adminUser); // Create a block. - $edit = array(); + $edit = []; $edit['info[0][value]'] = 'Test Block'; $edit['body[0][value]'] = $this->randomMachineName(16); $this->drupalPostForm('block/add/basic', $edit, t('Save')); // Check that the Basic block has been created. - $this->assertRaw(format_string('@block %name has been created.', array( + $this->assertRaw(format_string('@block %name has been created.', [ '@block' => 'basic', '%name' => $edit['info[0][value]'] - )), 'Basic block created.'); + ]), 'Basic block created.'); // Check that the view mode setting is hidden because only one exists. $this->assertNoFieldByXPath('//select[@name="settings[view_mode]"]', NULL, 'View mode setting hidden because only one exists'); // Check that the block exists in the database. - $blocks = entity_load_multiple_by_properties('block_content', array('info' => $edit['info[0][value]'])); + $blocks = entity_load_multiple_by_properties('block_content', ['info' => $edit['info[0][value]']]); $block = reset($blocks); $this->assertTrue($block, 'Custom Block found in database.'); @@ -72,9 +72,9 @@ public function testBlockContentCreation() { $this->drupalPostForm('block/add/basic', $edit, t('Save')); // Check that the Basic block has been created. - $this->assertRaw(format_string('A custom block with block description %value already exists.', array( + $this->assertRaw(format_string('A custom block with block description %value already exists.', [ '%value' => $edit['info[0][value]'] - ))); + ])); $this->assertResponse(200); } @@ -83,28 +83,28 @@ public function testBlockContentCreation() { */ public function testBlockContentCreationMultipleViewModes() { // Add a new view mode and verify if it is selected as expected. - $this->drupalLogin($this->drupalCreateUser(array('administer display modes'))); + $this->drupalLogin($this->drupalCreateUser(['administer display modes'])); $this->drupalGet('admin/structure/display-modes/view/add/block_content'); - $edit = array( + $edit = [ 'id' => 'test_view_mode', 'label' => 'Test View Mode', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw(t('Saved the %label view mode.', array('%label' => $edit['label']))); + $this->assertRaw(t('Saved the %label view mode.', ['%label' => $edit['label']])); $this->drupalLogin($this->adminUser); // Create a block. - $edit = array(); + $edit = []; $edit['info[0][value]'] = 'Test Block'; $edit['body[0][value]'] = $this->randomMachineName(16); $this->drupalPostForm('block/add/basic', $edit, t('Save')); // Check that the Basic block has been created. - $this->assertRaw(format_string('@block %name has been created.', array( + $this->assertRaw(format_string('@block %name has been created.', [ '@block' => 'basic', '%name' => $edit['info[0][value]'] - )), 'Basic block created.'); + ]), 'Basic block created.'); // Save our block permanently $this->drupalPostForm(NULL, ['region' => 'content'], t('Save block')); @@ -114,9 +114,9 @@ public function testBlockContentCreationMultipleViewModes() { $this->drupalGet('admin/structure/block/block-content/types'); $this->clickLink(t('Manage display')); $this->drupalGet('admin/structure/block/block-content/manage/basic/display'); - $custom_view_mode = array( + $custom_view_mode = [ 'display_modes_custom[test_view_mode]' => 1, - ); + ]; $this->drupalPostForm(NULL, $custom_view_mode, t('Save')); // Go to the configure page and change the view mode. @@ -143,7 +143,7 @@ public function testBlockContentCreationMultipleViewModes() { $this->assertFieldByXPath('//select[@name="settings[view_mode]"]/option[@selected="selected"]/@value', 'test_view_mode', 'View mode changed to Test View Mode'); // Check that the block exists in the database. - $blocks = entity_load_multiple_by_properties('block_content', array('info' => $edit['info[0][value]'])); + $blocks = entity_load_multiple_by_properties('block_content', ['info' => $edit['info[0][value]']]); $block = reset($blocks); $this->assertTrue($block, 'Custom Block found in database.'); @@ -152,9 +152,9 @@ public function testBlockContentCreationMultipleViewModes() { $this->drupalPostForm('block/add/basic', $edit, t('Save')); // Check that the Basic block has been created. - $this->assertRaw(format_string('A custom block with block description %value already exists.', array( + $this->assertRaw(format_string('A custom block with block description %value already exists.', [ '%value' => $edit['info[0][value]'] - ))); + ])); $this->assertResponse(200); } @@ -165,20 +165,20 @@ public function testBlockContentCreationMultipleViewModes() { * type is being used. */ public function testDefaultBlockContentCreation() { - $edit = array(); + $edit = []; $edit['info[0][value]'] = $this->randomMachineName(8); $edit['body[0][value]'] = $this->randomMachineName(16); // Don't pass the custom block type in the url so the default is forced. $this->drupalPostForm('block/add', $edit, t('Save')); // Check that the block has been created and that it is a basic block. - $this->assertRaw(format_string('@block %name has been created.', array( + $this->assertRaw(format_string('@block %name has been created.', [ '@block' => 'basic', '%name' => $edit['info[0][value]'], - )), 'Basic block created.'); + ]), 'Basic block created.'); // Check that the block exists in the database. - $blocks = entity_load_multiple_by_properties('block_content', array('info' => $edit['info[0][value]'])); + $blocks = entity_load_multiple_by_properties('block_content', ['info' => $edit['info[0][value]']]); $block = reset($blocks); $this->assertTrue($block, 'Default Custom Block found in database.'); } @@ -199,7 +199,7 @@ public function testFailedBlockCreation() { if (Database::getConnection()->supportsTransactions()) { // Check that the block does not exist in the database. $id = db_select('block_content_field_data', 'b') - ->fields('b', array('id')) + ->fields('b', ['id']) ->condition('info', 'fail_creation') ->execute() ->fetchField(); @@ -208,7 +208,7 @@ public function testFailedBlockCreation() { else { // Check that the block exists in the database. $id = db_select('block_content_field_data', 'b') - ->fields('b', array('id')) + ->fields('b', ['id']) ->condition('info', 'fail_creation') ->execute() ->fetchField(); @@ -225,18 +225,18 @@ public function testFailedBlockCreation() { */ public function testBlockDelete() { // Create a block. - $edit = array(); + $edit = []; $edit['info[0][value]'] = $this->randomMachineName(8); $body = $this->randomMachineName(16); $edit['body[0][value]'] = $body; $this->drupalPostForm('block/add/basic', $edit, t('Save')); // Place the block. - $instance = array( + $instance = [ 'id' => Unicode::strtolower($edit['info[0][value]']), 'settings[label]' => $edit['info[0][value]'], 'region' => 'sidebar_first', - ); + ]; $block = BlockContent::load(1); $url = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . $this->config('system.theme')->get('default'); $this->drupalPostForm($url, $instance, t('Save block')); @@ -254,11 +254,11 @@ public function testBlockDelete() { $this->drupalGet('block/1/delete'); $this->assertText(\Drupal::translation()->formatPlural(1, 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instance.')); - $this->drupalPostForm(NULL, array(), 'Delete'); - $this->assertRaw(t('The custom block %name has been deleted.', array('%name' => $edit['info[0][value]']))); + $this->drupalPostForm(NULL, [], 'Delete'); + $this->assertRaw(t('The custom block %name has been deleted.', ['%name' => $edit['info[0][value]']])); // Create another block and force the plugin cache to flush. - $edit2 = array(); + $edit2 = []; $edit2['info[0][value]'] = $this->randomMachineName(8); $body2 = $this->randomMachineName(16); $edit2['body[0][value]'] = $body2; @@ -268,7 +268,7 @@ public function testBlockDelete() { // Create another block with no instances, and test we don't get a // confirmation message about deleting instances. - $edit3 = array(); + $edit3 = []; $edit3['info[0][value]'] = $this->randomMachineName(8); $body = $this->randomMachineName(16); $edit3['body[0][value]'] = $body; @@ -286,16 +286,16 @@ public function testConfigDependencies() { $block = $this->createBlockContent(); // Place the block. $block_placement_id = Unicode::strtolower($block->label()); - $instance = array( + $instance = [ 'id' => $block_placement_id, 'settings[label]' => $block->label(), 'region' => 'sidebar_first', - ); + ]; $block = BlockContent::load(1); $url = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . $this->config('system.theme')->get('default'); $this->drupalPostForm($url, $instance, t('Save block')); - $dependencies = \Drupal::service('config.manager')->findConfigEntityDependentsAsEntities('content', array($block->getConfigDependencyName())); + $dependencies = \Drupal::service('config.manager')->findConfigEntityDependentsAsEntities('content', [$block->getConfigDependencyName()]); $block_placement = reset($dependencies); $this->assertEqual($block_placement_id, $block_placement->id(), "The block placement config entity has a dependency on the block content entity."); } diff --git a/core/modules/block_content/src/Tests/BlockContentListTest.php b/core/modules/block_content/src/Tests/BlockContentListTest.php index be8ea5e..e00706e 100644 --- a/core/modules/block_content/src/Tests/BlockContentListTest.php +++ b/core/modules/block_content/src/Tests/BlockContentListTest.php @@ -18,13 +18,13 @@ class BlockContentListTest extends BlockContentTestBase { * * @var array */ - public static $modules = array('block', 'block_content', 'config_translation'); + public static $modules = ['block', 'block_content', 'config_translation']; /** * Tests the custom block listing page. */ public function testListing() { - $this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'translate configuration'))); + $this->drupalLogin($this->drupalCreateUser(['administer blocks', 'translate configuration'])); $this->drupalGet('admin/structure/block/block-content'); // Test for the page title. @@ -39,7 +39,7 @@ public function testListing() { $this->assertEqual(count($elements), 2, 'Correct number of table header cells found.'); // Test the contents of each th cell. - $expected_items = array(t('Block description'), t('Operations')); + $expected_items = [t('Block description'), t('Operations')]; foreach ($elements as $key => $element) { $this->assertEqual($element[0], $expected_items[$key]); } @@ -51,7 +51,7 @@ public function testListing() { $this->assertLink($link_text); $this->clickLink($link_text); $this->assertResponse(200); - $edit = array(); + $edit = []; $edit['info[0][value]'] = $label; $edit['body[0][value]'] = $this->randomMachineName(16); $this->drupalPostForm(NULL, $edit, t('Save')); @@ -72,14 +72,14 @@ public function testListing() { $blocks = $this->container ->get('entity.manager') ->getStorage('block_content') - ->loadByProperties(array('info' => $label)); + ->loadByProperties(['info' => $label]); $block = reset($blocks); if (!empty($block)) { $this->assertLinkByHref('block/' . $block->id()); $this->clickLink(t('Edit')); $this->assertResponse(200); - $this->assertTitle(strip_tags(t('Edit custom block %label', array('%label' => $label)) . ' | Drupal')); - $edit = array('info[0][value]' => $new_label); + $this->assertTitle(strip_tags(t('Edit custom block %label', ['%label' => $label]) . ' | Drupal')); + $edit = ['info[0][value]' => $new_label]; $this->drupalPostForm(NULL, $edit, t('Save')); } else { @@ -95,8 +95,8 @@ public function testListing() { $delete_text = t('Delete'); $this->clickLink($delete_text); $this->assertResponse(200); - $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', array('%label' => $new_label)) . ' | Drupal')); - $this->drupalPostForm(NULL, array(), $delete_text); + $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', ['%label' => $new_label]) . ' | Drupal')); + $this->drupalPostForm(NULL, [], $delete_text); // Verify that the text of the label and machine name does not appear in // the list (though it may appear elsewhere on the page). diff --git a/core/modules/block_content/src/Tests/BlockContentListViewsTest.php b/core/modules/block_content/src/Tests/BlockContentListViewsTest.php index de0ff3b..77117fb 100644 --- a/core/modules/block_content/src/Tests/BlockContentListViewsTest.php +++ b/core/modules/block_content/src/Tests/BlockContentListViewsTest.php @@ -22,7 +22,7 @@ class BlockContentListViewsTest extends BlockContentTestBase { * Tests the custom block listing page. */ public function testListing() { - $this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'translate configuration'))); + $this->drupalLogin($this->drupalCreateUser(['administer blocks', 'translate configuration'])); $this->drupalGet('admin/structure/block/block-content'); // Test for the page title. @@ -58,7 +58,7 @@ public function testListing() { $this->assertLink($link_text); $this->clickLink($link_text); $this->assertResponse(200); - $edit = array(); + $edit = []; $edit['info[0][value]'] = $label; $edit['body[0][value]'] = $this->randomMachineName(16); $this->drupalPostForm(NULL, $edit, t('Save')); @@ -79,14 +79,14 @@ public function testListing() { $blocks = $this->container ->get('entity.manager') ->getStorage('block_content') - ->loadByProperties(array('info' => $label)); + ->loadByProperties(['info' => $label]); $block = reset($blocks); if (!empty($block)) { $this->assertLinkByHref('block/' . $block->id()); $this->clickLink(t('Edit')); $this->assertResponse(200); - $this->assertTitle(strip_tags(t('Edit custom block %label', array('%label' => $label)) . ' | Drupal')); - $edit = array('info[0][value]' => $new_label); + $this->assertTitle(strip_tags(t('Edit custom block %label', ['%label' => $label]) . ' | Drupal')); + $edit = ['info[0][value]' => $new_label]; $this->drupalPostForm(NULL, $edit, t('Save')); } else { @@ -102,8 +102,8 @@ public function testListing() { $delete_text = t('Delete'); $this->clickLink($delete_text); $this->assertResponse(200); - $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', array('%label' => $new_label)) . ' | Drupal')); - $this->drupalPostForm(NULL, array(), $delete_text); + $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', ['%label' => $new_label]) . ' | Drupal')); + $this->drupalPostForm(NULL, [], $delete_text); // Verify that the text of the label and machine name does not appear in // the list (though it may appear elsewhere on the page). diff --git a/core/modules/block_content/src/Tests/BlockContentPageViewTest.php b/core/modules/block_content/src/Tests/BlockContentPageViewTest.php index 46c19cb..3c63eab 100644 --- a/core/modules/block_content/src/Tests/BlockContentPageViewTest.php +++ b/core/modules/block_content/src/Tests/BlockContentPageViewTest.php @@ -14,7 +14,7 @@ class BlockContentPageViewTest extends BlockContentTestBase { * * @var array */ - public static $modules = array('block_content_test'); + public static $modules = ['block_content_test']; /** * Checks block edit and fallback functionality. diff --git a/core/modules/block_content/src/Tests/BlockContentRevisionsTest.php b/core/modules/block_content/src/Tests/BlockContentRevisionsTest.php index 7c4a8f2..dff7248 100644 --- a/core/modules/block_content/src/Tests/BlockContentRevisionsTest.php +++ b/core/modules/block_content/src/Tests/BlockContentRevisionsTest.php @@ -37,8 +37,8 @@ protected function setUp() { // Create initial block. $block = $this->createBlockContent('initial'); - $blocks = array(); - $logs = array(); + $blocks = []; + $logs = []; // Get original block. $blocks[] = $block->getRevisionId(); @@ -74,9 +74,9 @@ public function testRevisions() { ->getStorage('block_content') ->loadRevision($revision_id); // Verify revision log is the same. - $this->assertEqual($loaded->getRevisionLogMessage(), $logs[$delta], format_string('Correct log message found for revision @revision', array( + $this->assertEqual($loaded->getRevisionLogMessage(), $logs[$delta], format_string('Correct log message found for revision @revision', [ '@revision' => $loaded->getRevisionId(), - ))); + ])); if ($delta > 0) { $this->assertTrue($loaded->getRevisionUser() instanceof UserInterface, 'Revision User found.'); $this->assertTrue(is_numeric($loaded->getRevisionUserId()), 'Revision User ID found.'); diff --git a/core/modules/block_content/src/Tests/BlockContentSaveTest.php b/core/modules/block_content/src/Tests/BlockContentSaveTest.php index aabf7b6..3cc2add 100644 --- a/core/modules/block_content/src/Tests/BlockContentSaveTest.php +++ b/core/modules/block_content/src/Tests/BlockContentSaveTest.php @@ -16,7 +16,7 @@ class BlockContentSaveTest extends BlockContentTestBase { * * @var array */ - public static $modules = array('block_content_test'); + public static $modules = ['block_content_test']; /** * Sets the test up. @@ -35,12 +35,12 @@ public function testImport() { $max_id = db_query('SELECT MAX(id) FROM {block_content}')->fetchField(); $test_id = $max_id + mt_rand(1000, 1000000); $info = $this->randomMachineName(8); - $block_array = array( + $block_array = [ 'info' => $info, - 'body' => array('value' => $this->randomMachineName(32)), + 'body' => ['value' => $this->randomMachineName(32)], 'type' => 'basic', 'id' => $test_id - ); + ]; $block = BlockContent::create($block_array); $block->enforceIsNew(TRUE); $block->save(); diff --git a/core/modules/block_content/src/Tests/BlockContentTestBase.php b/core/modules/block_content/src/Tests/BlockContentTestBase.php index 16df855..5f3b5ce 100644 --- a/core/modules/block_content/src/Tests/BlockContentTestBase.php +++ b/core/modules/block_content/src/Tests/BlockContentTestBase.php @@ -28,16 +28,16 @@ * * @var array */ - protected $permissions = array( + protected $permissions = [ 'administer blocks' - ); + ]; /** * Modules to enable. * * @var array */ - public static $modules = array('block', 'block_content'); + public static $modules = ['block', 'block_content']; /** * Whether or not to auto-create the basic block type during setup. @@ -75,11 +75,11 @@ protected function setUp() { */ protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = TRUE) { $title = $title ?: $this->randomMachineName(); - $block_content = BlockContent::create(array( + $block_content = BlockContent::create([ 'info' => $title, 'type' => $bundle, 'langcode' => 'en' - )); + ]); if ($block_content && $save === TRUE) { $block_content->save(); } @@ -98,11 +98,11 @@ protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = * Created custom block type. */ protected function createBlockContentType($label, $create_body = FALSE) { - $bundle = BlockContentType::create(array( + $bundle = BlockContentType::create([ 'id' => $label, 'label' => $label, 'revision' => FALSE, - )); + ]); $bundle->save(); if ($create_body) { block_content_add_body_field($bundle->id()); diff --git a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php index 332bf3d..198beee 100644 --- a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php +++ b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php @@ -19,13 +19,13 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase { * * @var array */ - public static $modules = array( + public static $modules = [ 'language', 'content_translation', 'block', 'field_ui', 'block_content' - ); + ]; /** * {@inheritdoc} @@ -57,11 +57,11 @@ protected function setUp() { */ protected function setupBundle() { // Create the basic bundle since it is provided by standard. - $bundle = BlockContentType::create(array( + $bundle = BlockContentType::create([ 'id' => $this->bundle, 'label' => $this->bundle, 'revision' => FALSE - )); + ]); $bundle->save(); } @@ -69,12 +69,12 @@ protected function setupBundle() { * {@inheritdoc} */ public function getTranslatorPermissions() { - return array_merge(parent::getTranslatorPermissions(), array( + return array_merge(parent::getTranslatorPermissions(), [ 'translate any entity', 'access administration pages', 'administer blocks', 'administer block_content fields' - )); + ]); } /** @@ -93,11 +93,11 @@ public function getTranslatorPermissions() { protected function createBlockContent($title = FALSE, $bundle = FALSE) { $title = $title ?: $this->randomMachineName(); $bundle = $bundle ?: $this->bundle; - $block_content = BlockContent::create(array( + $block_content = BlockContent::create([ 'info' => $title, 'type' => $bundle, 'langcode' => 'en' - )); + ]); $block_content->save(); return $block_content; } @@ -106,7 +106,7 @@ protected function createBlockContent($title = FALSE, $bundle = FALSE) { * {@inheritdoc} */ protected function getNewEntityValues($langcode) { - return array('info' => Unicode::strtolower($this->randomMachineName())) + parent::getNewEntityValues($langcode); + return ['info' => Unicode::strtolower($this->randomMachineName())] + parent::getNewEntityValues($langcode); } /** @@ -135,7 +135,7 @@ protected function doTestBasicTranslation() { $values = $this->getNewEntityValues($default_langcode); $storage = \Drupal::entityManager()->getStorage($this->entityTypeId); /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ - $entity = $storage->create(array('type' => 'basic') + $values); + $entity = $storage->create(['type' => 'basic'] + $values); $entity->save(); $entity->addTranslation('it', $values); @@ -159,11 +159,11 @@ protected function doTestBasicTranslation() { public function testDisabledBundle() { // Create a bundle that does not have translation enabled. $disabled_bundle = $this->randomMachineName(); - $bundle = BlockContentType::create(array( + $bundle = BlockContentType::create([ 'id' => $disabled_bundle, 'label' => $disabled_bundle, 'revision' => FALSE - )); + ]); $bundle->save(); // Create a block content for each bundle. @@ -171,7 +171,7 @@ public function testDisabledBundle() { $disabled_block_content = $this->createBlockContent(FALSE, $bundle->id()); // Make sure that only a single row was inserted into the block table. - $rows = db_query('SELECT * FROM {block_content_field_data} WHERE id = :id', array(':id' => $enabled_block_content->id()))->fetchAll(); + $rows = db_query('SELECT * FROM {block_content_field_data} WHERE id = :id', [':id' => $enabled_block_content->id()])->fetchAll(); $this->assertEqual(1, count($rows)); } @@ -188,15 +188,15 @@ protected function doTestTranslationEdit() { foreach ($this->langcodes as $langcode) { // We only want to test the title for non-english translations. if ($langcode != 'en') { - $options = array('language' => $languages[$langcode]); + $options = ['language' => $languages[$langcode]]; $url = $entity->urlInfo('edit-form', $options); $this->drupalGet($url); - $title = t('Edit @type @title [%language translation]', array( + $title = t('Edit @type @title [%language translation]', [ '@type' => $entity->bundle(), '@title' => $entity->getTranslation($langcode)->label(), '%language' => $languages[$langcode]->getName(), - )); + ]); $this->assertRaw($title); } } diff --git a/core/modules/block_content/src/Tests/BlockContentTypeTest.php b/core/modules/block_content/src/Tests/BlockContentTypeTest.php index 8f6ffe1..e69394b 100644 --- a/core/modules/block_content/src/Tests/BlockContentTypeTest.php +++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php @@ -17,17 +17,17 @@ class BlockContentTypeTest extends BlockContentTestBase { * * @var array */ - public static $modules = array('field_ui'); + public static $modules = ['field_ui']; /** * Permissions to grant admin user. * * @var array */ - protected $permissions = array( + protected $permissions = [ 'administer blocks', 'administer block_content fields' - ); + ]; /** * Whether or not to create an initial block type. @@ -56,10 +56,10 @@ public function testBlockContentTypeCreation() { $this->clickLink('block type creation page'); // Create a block type via the user interface. - $edit = array( + $edit = [ 'id' => 'foo', 'label' => 'title for foo', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); $block_type = BlockContentType::load('foo'); $this->assertTrue($block_type, 'The new block type has been created.'); @@ -107,9 +107,9 @@ public function testBlockContentTypeEditing() { $this->assertRaw('Body', 'Body field was found.'); // Change the block type name. - $edit = array( + $edit = [ 'label' => 'Bar', - ); + ]; $this->drupalGet('admin/structure/block/block-content/manage/basic'); $this->assertTitle(format_string('Edit @type custom block type | Drupal', ['@type' => 'basic'])); $this->drupalPostForm(NULL, $edit, t('Save')); @@ -121,9 +121,9 @@ public function testBlockContentTypeEditing() { $this->assertUrl(\Drupal::url('block_content.add_form', ['block_content_type' => 'basic'], ['absolute' => TRUE]), [], 'Original machine name was used in URL.'); // Remove the body field. - $this->drupalPostForm('admin/structure/block/block-content/manage/basic/fields/block_content.basic.body/delete', array(), t('Delete')); + $this->drupalPostForm('admin/structure/block/block-content/manage/basic/fields/block_content.basic.body/delete', [], t('Delete')); // Resave the settings for this type. - $this->drupalPostForm('admin/structure/block/block-content/manage/basic', array(), t('Save')); + $this->drupalPostForm('admin/structure/block/block-content/manage/basic', [], t('Save')); // Check that the body field doesn't exist. $this->drupalGet('block/add/basic'); $this->assertNoRaw('Body', 'Body field was not found.'); @@ -146,7 +146,7 @@ public function testBlockContentTypeDeletion() { // Attempt to delete the block type, which should not be allowed. $this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete'); $this->assertRaw( - t('%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', array('%label' => $type->label())), + t('%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', ['%label' => $type->label()]), 'The block type will not be deleted until all blocks of that type are removed.' ); $this->assertNoText(t('This action cannot be undone.'), 'The block type deletion confirmation form is not available.'); @@ -156,7 +156,7 @@ public function testBlockContentTypeDeletion() { // Attempt to delete the block type, which should now be allowed. $this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete'); $this->assertRaw( - t('Are you sure you want to delete the custom block type %type?', array('%type' => $type->id())), + t('Are you sure you want to delete the custom block type %type?', ['%type' => $type->id()]), 'The block type is available for deletion.' ); $this->assertText(t('This action cannot be undone.'), 'The custom block type deletion confirmation form is available.'); @@ -197,22 +197,22 @@ public function testsBlockContentAddTypes() { $this->clickLink(t('Add custom block')); // The seven theme has markup inside the link, we cannot use clickLink(). if ($default_theme == 'seven') { - $options = $theme != $default_theme ? array('query' => array('theme' => $theme)) : array(); - $this->assertLinkByHref(\Drupal::url('block_content.add_form', array('block_content_type' => 'foo'), $options)); + $options = $theme != $default_theme ? ['query' => ['theme' => $theme]] : []; + $this->assertLinkByHref(\Drupal::url('block_content.add_form', ['block_content_type' => 'foo'], $options)); $this->drupalGet('block/add/foo', $options); } else { $this->clickLink('foo'); } // Create a new block. - $edit = array('info[0][value]' => $this->randomMachineName(8)); + $edit = ['info[0][value]' => $this->randomMachineName(8)]; $this->drupalPostForm(NULL, $edit, t('Save')); - $blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]'])); + $blocks = $storage->loadByProperties(['info' => $edit['info[0][value]']]); if (!empty($blocks)) { $block = reset($blocks); - $this->assertUrl(\Drupal::url('block.admin_add', array('plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme), array('absolute' => TRUE))); + $this->assertUrl(\Drupal::url('block.admin_add', ['plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme], ['absolute' => TRUE])); $this->drupalPostForm(NULL, ['region' => 'content'], t('Save block')); - $this->assertUrl(\Drupal::url('block.admin_display_theme', array('theme' => $theme), array('absolute' => TRUE, 'query' => array('block-placement' => Html::getClass($edit['info[0][value]']))))); + $this->assertUrl(\Drupal::url('block.admin_display_theme', ['theme' => $theme], ['absolute' => TRUE, 'query' => ['block-placement' => Html::getClass($edit['info[0][value]'])]])); } else { $this->fail('Could not load created block.'); @@ -225,11 +225,11 @@ public function testsBlockContentAddTypes() { $this->drupalGet('admin/structure/block/block-content'); $this->clickLink(t('Add custom block')); $this->clickLink('foo'); - $edit = array('info[0][value]' => $this->randomMachineName(8)); + $edit = ['info[0][value]' => $this->randomMachineName(8)]; $this->drupalPostForm(NULL, $edit, t('Save')); - $blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]'])); + $blocks = $storage->loadByProperties(['info' => $edit['info[0][value]']]); if (!empty($blocks)) { - $this->assertUrl(\Drupal::url('entity.block_content.collection', array(), array('absolute' => TRUE))); + $this->assertUrl(\Drupal::url('entity.block_content.collection', [], ['absolute' => TRUE])); } else { $this->fail('Could not load created block.'); diff --git a/core/modules/block_content/src/Tests/PageEditTest.php b/core/modules/block_content/src/Tests/PageEditTest.php index 4a3fb90..8934859 100644 --- a/core/modules/block_content/src/Tests/PageEditTest.php +++ b/core/modules/block_content/src/Tests/PageEditTest.php @@ -27,7 +27,7 @@ public function testPageEdit() { $title_key = 'info[0][value]'; $body_key = 'body[0][value]'; // Create block to edit. - $edit = array(); + $edit = []; $edit['info[0][value]'] = Unicode::strtolower($this->randomMachineName(8)); $edit[$body_key] = $this->randomMachineName(16); $this->drupalPostForm('block/add/basic', $edit, t('Save')); @@ -43,7 +43,7 @@ public function testPageEdit() { $this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.'); // Edit the content of the block. - $edit = array(); + $edit = []; $edit[$title_key] = $this->randomMachineName(8); $edit[$body_key] = $this->randomMachineName(16); // Stay on the current page, without reloading. @@ -51,21 +51,21 @@ public function testPageEdit() { // Edit the same block, creating a new revision. $this->drupalGet("block/" . $block->id()); - $edit = array(); + $edit = []; $edit['info[0][value]'] = $this->randomMachineName(8); $edit[$body_key] = $this->randomMachineName(16); $edit['revision'] = TRUE; $this->drupalPostForm(NULL, $edit, t('Save')); // Ensure that the block revision has been created. - \Drupal::entityManager()->getStorage('block_content')->resetCache(array($block->id())); + \Drupal::entityManager()->getStorage('block_content')->resetCache([$block->id()]); $revised_block = BlockContent::load($block->id()); $this->assertNotIdentical($block->getRevisionId(), $revised_block->getRevisionId(), 'A new revision has been created.'); // Test deleting the block. $this->drupalGet("block/" . $revised_block->id()); $this->clickLink(t('Delete')); - $this->assertText(format_string('Are you sure you want to delete the custom block @label?', array('@label' => $revised_block->label()))); + $this->assertText(format_string('Are you sure you want to delete the custom block @label?', ['@label' => $revised_block->label()])); } } diff --git a/core/modules/block_content/src/Tests/Views/BlockContentFieldFilterTest.php b/core/modules/block_content/src/Tests/Views/BlockContentFieldFilterTest.php index 5a46ddd..905a7a0 100644 --- a/core/modules/block_content/src/Tests/Views/BlockContentFieldFilterTest.php +++ b/core/modules/block_content/src/Tests/Views/BlockContentFieldFilterTest.php @@ -15,14 +15,14 @@ class BlockContentFieldFilterTest extends BlockContentTestBase { /** * {@inheritdoc} */ - public static $modules = array('language'); + public static $modules = ['language']; /** * Views used by this test. * * @var array */ - public static $testViews = array('test_field_filters'); + public static $testViews = ['test_field_filters']; /** * List of block_content infos by language. @@ -49,15 +49,15 @@ function setUp() { $field_storage->save(); // Set up block_content infos. - $this->blockContentInfos = array( + $this->blockContentInfos = [ 'en' => 'Food in Paris', 'es' => 'Comida en Paris', 'fr' => 'Nouriture en Paris', - ); + ]; // Create block_content with translations. $block_content = $this->createBlockContent(['info' => $this->blockContentInfos['en'], 'langcode' => 'en', 'type' => 'basic', 'body' => [['value' => $this->blockContentInfos['en']]]]); - foreach (array('es', 'fr') as $langcode) { + foreach (['es', 'fr'] as $langcode) { $translation = $block_content->addTranslation($langcode, ['info' => $this->blockContentInfos[$langcode]]); $translation->body->value = $this->blockContentInfos[$langcode]; } @@ -70,19 +70,19 @@ function setUp() { public function testFilters() { // Test the info filter page, which filters for info contains 'Comida'. // Should show just the Spanish translation, once. - $this->assertPageCounts('test-info-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida info filter'); + $this->assertPageCounts('test-info-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida info filter'); // Test the body filter page, which filters for body contains 'Comida'. // Should show just the Spanish translation, once. - $this->assertPageCounts('test-body-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida body filter'); + $this->assertPageCounts('test-body-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida body filter'); // Test the info Paris filter page, which filters for info contains // 'Paris'. Should show each translation once. - $this->assertPageCounts('test-info-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris info filter'); + $this->assertPageCounts('test-info-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris info filter'); // Test the body Paris filter page, which filters for body contains // 'Paris'. Should show each translation once. - $this->assertPageCounts('test-body-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris body filter'); + $this->assertPageCounts('test-body-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris body filter'); } /** diff --git a/core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php b/core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php index d92c5be..8ec17e2 100644 --- a/core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php +++ b/core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php @@ -14,23 +14,23 @@ class BlockContentIntegrationTest extends BlockContentTestBase { * * @var array */ - public static $testViews = array('test_block_content_view'); + public static $testViews = ['test_block_content_view']; /** * Tests basic block_content view with a block_content_type argument. */ public function testBlockContentViewTypeArgument() { // Create two content types with three block_contents each. - $types = array(); - $all_ids = array(); - $block_contents = array(); + $types = []; + $all_ids = []; + $block_contents = []; for ($i = 0; $i < 2; $i++) { $type = $this->createBlockContentType(); $types[] = $type; for ($j = 0; $j < 5; $j++) { // Ensure the right order of the block_contents. - $block_content = $this->createBlockContent(array('type' => $type->id())); + $block_content = $this->createBlockContent(['type' => $type->id()]); $block_contents[$type->id()][$block_content->id()] = $block_content; $all_ids[] = $block_content->id(); } @@ -55,9 +55,9 @@ public function testBlockContentViewTypeArgument() { * @param array $expected_ids * An array of block_content IDs. */ - protected function assertIds(array $expected_ids = array()) { + protected function assertIds(array $expected_ids = []) { $result = $this->xpath('//span[@class="field-content"]'); - $ids = array(); + $ids = []; foreach ($result as $element) { $ids[] = (int) $element; } diff --git a/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php b/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php index 65d33c88..db665c9 100644 --- a/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php +++ b/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php @@ -25,26 +25,26 @@ * * @var array */ - protected $permissions = array( + protected $permissions = [ 'administer blocks', - ); + ]; /** * Modules to enable. * * @var array */ - public static $modules = array('block', 'block_content', 'block_content_test_views'); + public static $modules = ['block', 'block_content', 'block_content_test_views']; protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); // Ensure the basic bundle exists. This is provided by the standard profile. - $this->createBlockContentType(array('id' => 'basic')); + $this->createBlockContentType(['id' => 'basic']); $this->adminUser = $this->drupalCreateUser($this->permissions); if ($import_test_views) { - ViewTestData::createTestViews(get_class($this), array('block_content_test_views')); + ViewTestData::createTestViews(get_class($this), ['block_content_test_views']); } } @@ -58,17 +58,17 @@ protected function setUp($import_test_views = TRUE) { * @return \Drupal\block_content\Entity\BlockContent * Created custom block. */ - protected function createBlockContent(array $settings = array()) { + protected function createBlockContent(array $settings = []) { $status = 0; - $settings += array( + $settings += [ 'info' => $this->randomMachineName(), 'type' => 'basic', 'langcode' => 'en', - ); + ]; if ($block_content = BlockContent::create($settings)) { $status = $block_content->save(); } - $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content %info.', array('%info' => $block_content->label()))); + $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content %info.', ['%info' => $block_content->label()])); return $block_content; } @@ -81,7 +81,7 @@ protected function createBlockContent(array $settings = array()) { * @return \Drupal\block_content\Entity\BlockContentType * Created custom block type. */ - protected function createBlockContentType(array $values = array()) { + protected function createBlockContentType(array $values = []) { // Find a non-existent random type name. if (!isset($values['id'])) { do { @@ -91,16 +91,16 @@ protected function createBlockContentType(array $values = array()) { else { $id = $values['id']; } - $values += array( + $values += [ 'id' => $id, 'label' => $id, 'revision' => FALSE - ); + ]; $bundle = BlockContentType::create($values); $status = $bundle->save(); block_content_add_body_field($bundle->id()); - $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content type %bundle.', array('%bundle' => $bundle->id()))); + $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content type %bundle.', ['%bundle' => $bundle->id()])); return $bundle; } diff --git a/core/modules/block_content/src/Tests/Views/FieldTypeTest.php b/core/modules/block_content/src/Tests/Views/FieldTypeTest.php index f14653f..e9aa336 100644 --- a/core/modules/block_content/src/Tests/Views/FieldTypeTest.php +++ b/core/modules/block_content/src/Tests/Views/FieldTypeTest.php @@ -16,18 +16,18 @@ class FieldTypeTest extends BlockContentTestBase { * * @var array */ - public static $testViews = array('test_field_type'); + public static $testViews = ['test_field_type']; public function testFieldType() { $block_content = $this->createBlockContent(); - $expected_result[] = array( + $expected_result[] = [ 'id' => $block_content->id(), 'type' => $block_content->bundle(), - ); - $column_map = array( + ]; + $column_map = [ 'id' => 'id', 'type:target_id' => 'type', - ); + ]; $view = Views::getView('test_field_type'); $this->executeView($view); diff --git a/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php b/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php index 516705d..7bad093 100644 --- a/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php +++ b/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php @@ -20,72 +20,72 @@ class RevisionRelationshipsTest extends ViewTestBase { * * @var array */ - public static $modules = array('block_content' , 'block_content_test_views'); + public static $modules = ['block_content' , 'block_content_test_views']; /** * Views used by this test. * * @var array */ - public static $testViews = array('test_block_content_revision_id', 'test_block_content_revision_revision_id'); + public static $testViews = ['test_block_content_revision_id', 'test_block_content_revision_revision_id']; protected function setUp() { parent::setUp(); - BlockContentType::create(array( + BlockContentType::create([ 'id' => 'basic', 'label' => 'basic', 'revision' => TRUE, - )); - ViewTestData::createTestViews(get_class($this), array('block_content_test_views')); + ]); + ViewTestData::createTestViews(get_class($this), ['block_content_test_views']); } /** * Create a block_content with revision and rest result count for both views. */ public function testBlockContentRevisionRelationship() { - $block_content = BlockContent::create(array( + $block_content = BlockContent::create([ 'info' => $this->randomMachineName(), 'type' => 'basic', 'langcode' => 'en', - )); + ]); $block_content->save(); // Create revision of the block_content. $block_content_revision = clone $block_content; $block_content_revision->setNewRevision(); $block_content_revision->save(); - $column_map = array( + $column_map = [ 'revision_id' => 'revision_id', 'id_1' => 'id_1', 'block_content_field_data_block_content_field_revision_id' => 'block_content_field_data_block_content_field_revision_id', - ); + ]; // Here should be two rows. $view_id = Views::getView('test_block_content_revision_id'); - $this->executeView($view_id, array($block_content->id())); - $resultset_id = array( - array( + $this->executeView($view_id, [$block_content->id()]); + $resultset_id = [ + [ 'revision_id' => '1', 'id_1' => '1', 'block_content_field_data_block_content_field_revision_id' => '1', - ), - array( + ], + [ 'revision_id' => '2', 'id_1' => '1', 'block_content_field_data_block_content_field_revision_id' => '1', - ), - ); + ], + ]; $this->assertIdenticalResultset($view_id, $resultset_id, $column_map); // There should be only one row with active revision 2. $view_revision_id = Views::getView('test_block_content_revision_revision_id'); - $this->executeView($view_revision_id, array($block_content->id())); - $resultset_revision_id = array( - array( + $this->executeView($view_revision_id, [$block_content->id()]); + $resultset_revision_id = [ + [ 'revision_id' => '2', 'id_1' => '1', 'block_content_field_data_block_content_field_revision_id' => '1', - ), - ); + ], + ]; $this->assertIdenticalResultset($view_revision_id, $resultset_revision_id, $column_map); } diff --git a/core/modules/block_content/tests/modules/block_content_test/block_content_test.module b/core/modules/block_content/tests/modules/block_content_test/block_content_test.module index 57ea2a6..0489a61 100644 --- a/core/modules/block_content/tests/modules/block_content_test/block_content_test.module +++ b/core/modules/block_content/tests/modules/block_content_test/block_content_test.module @@ -15,9 +15,9 @@ */ function block_content_test_block_content_view(array &$build, BlockContent $block_content, $view_mode) { // Add extra content. - $build['extra_content'] = array( + $build['extra_content'] = [ '#markup' => 'Yowser', - ); + ]; } /** diff --git a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentBodyFieldTest.php b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentBodyFieldTest.php index 0bf29fd..7d34373 100644 --- a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentBodyFieldTest.php +++ b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentBodyFieldTest.php @@ -15,7 +15,7 @@ */ class MigrateBlockContentBodyFieldTest extends MigrateDrupal7TestBase { - public static $modules = array('block', 'block_content', 'filter', 'text'); + public static $modules = ['block', 'block_content', 'filter', 'text']; /** * {@inheritdoc} diff --git a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentTypeTest.php b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentTypeTest.php index 9a3cbf0..4accc20 100644 --- a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentTypeTest.php +++ b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentTypeTest.php @@ -13,7 +13,7 @@ */ class MigrateBlockContentTypeTest extends MigrateDrupal7TestBase { - public static $modules = array('block', 'block_content', 'filter', 'text'); + public static $modules = ['block', 'block_content', 'filter', 'text']; /** * {@inheritdoc} diff --git a/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php b/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php index 42990db..706a7cc 100644 --- a/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php +++ b/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php @@ -13,11 +13,11 @@ */ class MigrateCustomBlockTest extends MigrateDrupal7TestBase { - public static $modules = array( + public static $modules = [ 'block_content', 'filter', 'text', - ); + ]; /** * {@inheritdoc} diff --git a/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php b/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php index 3ab934c..ced7e84 100644 --- a/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php +++ b/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php @@ -13,32 +13,32 @@ class BlockContentLocalTasksTest extends LocalTaskIntegrationTestBase { protected function setUp() { - $this->directoryList = array( + $this->directoryList = [ 'block' => 'core/modules/block', 'block_content' => 'core/modules/block_content', - ); + ]; parent::setUp(); - $config_factory = $this->getConfigFactoryStub(array('system.theme' => array( + $config_factory = $this->getConfigFactoryStub(['system.theme' => [ 'default' => 'test_c', - ))); + ]]); - $themes = array(); - $themes['test_a'] = (object) array( + $themes = []; + $themes['test_a'] = (object) [ 'status' => 0, - ); - $themes['test_b'] = (object) array( + ]; + $themes['test_b'] = (object) [ 'status' => 1, - 'info' => array( + 'info' => [ 'name' => 'test_b', - ), - ); - $themes['test_c'] = (object) array( + ], + ]; + $themes['test_c'] = (object) [ 'status' => 1, - 'info' => array( + 'info' => [ 'name' => 'test_c', - ), - ); + ], + ]; $theme_handler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface'); $theme_handler->expects($this->any()) ->method('listInfo') @@ -56,25 +56,25 @@ protected function setUp() { * @dataProvider getBlockContentListingRoutes */ public function testBlockContentListLocalTasks($route) { - $this->assertLocalTasks($route, array( - 0 => array( + $this->assertLocalTasks($route, [ + 0 => [ 'block.admin_display', 'entity.block_content.collection', - ), - 1 => array( + ], + 1 => [ 'block_content.list_sub', 'entity.block_content_type.collection', - ), - )); + ], + ]); } /** * Provides a list of routes to test. */ public function getBlockContentListingRoutes() { - return array( - array('entity.block_content.collection', 'entity.block_content_type.collection'), - ); + return [ + ['entity.block_content.collection', 'entity.block_content_type.collection'], + ]; } } diff --git a/core/modules/block_content/tests/src/Unit/Plugin/migrate/source/d6/BoxTest.php b/core/modules/block_content/tests/src/Unit/Plugin/migrate/source/d6/BoxTest.php index bb4a1ac..f6f1167 100644 --- a/core/modules/block_content/tests/src/Unit/Plugin/migrate/source/d6/BoxTest.php +++ b/core/modules/block_content/tests/src/Unit/Plugin/migrate/source/d6/BoxTest.php @@ -13,27 +13,27 @@ class BoxTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = 'Drupal\block_content\Plugin\migrate\source\d6\Box'; - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'd6_boxes', - ), - ); + ], + ]; - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'bid' => 1, 'body' => '

        I made some custom content.

        ', 'info' => 'Static Block', 'format' => 1, - ), - array( + ], + [ 'bid' => 2, 'body' => '

        I made some more custom content.

        ', 'info' => 'Test Content', 'format' => 1, - ), - ); + ], + ]; /** * Prepopulate contents with results. diff --git a/core/modules/block_content/tests/src/Unit/Plugin/migrate/source/d7/BlockCustomTest.php b/core/modules/block_content/tests/src/Unit/Plugin/migrate/source/d7/BlockCustomTest.php index f213296..6c77803 100644 --- a/core/modules/block_content/tests/src/Unit/Plugin/migrate/source/d7/BlockCustomTest.php +++ b/core/modules/block_content/tests/src/Unit/Plugin/migrate/source/d7/BlockCustomTest.php @@ -13,21 +13,21 @@ class BlockCustomTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = BlockCustom::class; - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'd7_block_custom', - ), - ); + ], + ]; - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'bid' => '1', 'body' => "I don't feel creative enough to write anything clever here.", 'info' => 'Meh', 'format' => 'filtered_html', - ), - ); + ], + ]; /** * {@inheritdoc} diff --git a/core/modules/book/book.install b/core/modules/book/book.install index 76ddc81..7704483 100644 --- a/core/modules/book/book.install +++ b/core/modules/book/book.install @@ -17,119 +17,119 @@ function book_uninstall() { * Implements hook_schema(). */ function book_schema() { - $schema['book'] = array( + $schema['book'] = [ 'description' => 'Stores book outline information. Uniquely defines the location of each node in the book outline', - 'fields' => array( - 'nid' => array( + 'fields' => [ + 'nid' => [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => "The book page's {node}.nid.", - ), - 'bid' => array( + ], + 'bid' => [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => "The book ID is the {book}.nid of the top-level page.", - ), - 'pid' => array( + ], + 'pid' => [ 'description' => 'The parent ID (pid) is the id of the node above in the hierarchy, or zero if the node is at the top level in its outline.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'has_children' => array( + ], + 'has_children' => [ 'description' => 'Flag indicating whether any nodes have this node as a parent (1 = children exist, 0 = no children).', 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small', - ), - 'weight' => array( + ], + 'weight' => [ 'description' => 'Weight among book entries in the same book at the same depth.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, - ), - 'depth' => array( + ], + 'depth' => [ 'description' => 'The depth relative to the top level. A link with pid == 0 will have depth == 1.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small', - ), - 'p1' => array( + ], + 'p1' => [ 'description' => 'The first nid in the materialized path. If N = depth, then pN must equal the nid. If depth > 1 then p(N-1) must equal the pid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p2' => array( + ], + 'p2' => [ 'description' => 'The second nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p3' => array( + ], + 'p3' => [ 'description' => 'The third nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p4' => array( + ], + 'p4' => [ 'description' => 'The fourth nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p5' => array( + ], + 'p5' => [ 'description' => 'The fifth nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p6' => array( + ], + 'p6' => [ 'description' => 'The sixth nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p7' => array( + ], + 'p7' => [ 'description' => 'The seventh nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p8' => array( + ], + 'p8' => [ 'description' => 'The eighth nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p9' => array( + ], + 'p9' => [ 'description' => 'The ninth nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - ), - 'primary key' => array('nid'), - 'indexes' => array( - 'book_parents' => array('bid', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'), - ), - ); + ], + ], + 'primary key' => ['nid'], + 'indexes' => [ + 'book_parents' => ['bid', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'], + ], + ]; return $schema; } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index ecccb74..988201e 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -25,17 +25,17 @@ function book_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { case 'help.page.book': $output = '

        ' . t('About') . '

        '; - $output .= '

        ' . t('The Book module is used for creating structured, multi-page content, such as site resource guides, manuals, and wikis. It allows you to create content that has chapters, sections, subsections, or any similarly-tiered structure. Enabling the module creates a new content type Book page. For more information, see the online documentation for the Book module.', array(':book' => 'https://www.drupal.org/documentation/modules/book')) . '

        '; + $output .= '

        ' . t('The Book module is used for creating structured, multi-page content, such as site resource guides, manuals, and wikis. It allows you to create content that has chapters, sections, subsections, or any similarly-tiered structure. Enabling the module creates a new content type Book page. For more information, see the online documentation for the Book module.', [':book' => 'https://www.drupal.org/documentation/modules/book']) . '

        '; $output .= '

        ' . t('Uses') . '

        '; $output .= '
        '; $output .= '
        ' . t('Adding and managing book content') . '
        '; $output .= '
        ' . t('Books have a hierarchical structure, called a book outline. Each book outline can have nested pages up to nine levels deep. Multiple content types can be configured to behave as a book outline. From the content edit form, it is possible to add a page to a book outline or create a new book.') . '
        '; - $output .= '
        ' . t('You can assign separate permissions for creating new books as well as creating, editing and deleting book content. Users with the Administer book outlines permission can add any type of content to a book by selecting the appropriate book outline while editing the content. They can also view a list of all books, and edit and rearrange section titles on the Book list page.', array(':admin-book' => \Drupal::url('book.admin'))) . '
        '; + $output .= '
        ' . t('You can assign separate permissions for creating new books as well as creating, editing and deleting book content. Users with the Administer book outlines permission can add any type of content to a book by selecting the appropriate book outline while editing the content. They can also view a list of all books, and edit and rearrange section titles on the Book list page.', [':admin-book' => \Drupal::url('book.admin')]) . '
        '; $output .= '
        ' . t('Configuring content types for books') . '
        '; - $output .= '
        ' . t('The Book page content type is the initial content type enabled for book outlines. On the Book settings page you can configure content types that can used in book outlines.', array(':admin-settings' => \Drupal::url('book.settings'))) . '
        '; - $output .= '
        ' . t('Users with the Add content and child pages to books permission will see a link to Add child page when viewing a content item that is part of a book outline. This link will allow users to create a new content item of the content type you select on the Book settings page. By default this is the Book page content type.', array(':admin-settings' => \Drupal::url('book.settings'))) . '
        '; + $output .= '
        ' . t('The Book page content type is the initial content type enabled for book outlines. On the Book settings page you can configure content types that can used in book outlines.', [':admin-settings' => \Drupal::url('book.settings')]) . '
        '; + $output .= '
        ' . t('Users with the Add content and child pages to books permission will see a link to Add child page when viewing a content item that is part of a book outline. This link will allow users to create a new content item of the content type you select on the Book settings page. By default this is the Book page content type.', [':admin-settings' => \Drupal::url('book.settings')]) . '
        '; $output .= '
        ' . t('Book navigation') . '
        '; - $output .= '
        ' . t("Book pages have a default book-specific navigation block. This navigation block contains links that lead to the previous and next pages in the book, and to the level above the current page in the book's structure. This block can be enabled on the Blocks layout page. For book pages to show up in the book navigation, they must be added to a book outline.", array(':admin-block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '
        '; + $output .= '
        ' . t("Book pages have a default book-specific navigation block. This navigation block contains links that lead to the previous and next pages in the book, and to the level above the current page in the book's structure. This block can be enabled on the Blocks layout page. For book pages to show up in the book navigation, they must be added to a book outline.", [':admin-block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '
        '; $output .= '
        ' . t('Collaboration') . '
        '; $output .= '
        ' . t('Books can be created collaboratively, as they allow users with appropriate permissions to add pages into existing books, and add those pages to a custom table of contents.') . '
        '; $output .= '
        ' . t('Printing books') . '
        '; @@ -47,7 +47,7 @@ function book_help($route_name, RouteMatchInterface $route_match) { return '

        ' . t('The book module offers a means to organize a collection of related content pages, collectively known as a book. When viewed, this content automatically displays links to adjacent book pages, providing a simple navigation system for creating and reviewing structured content.') . '

        '; case 'entity.node.book_outline_form': - return '

        ' . t('The outline feature allows you to include pages in the Book hierarchy, as well as move them within the hierarchy or to reorder an entire book.', array(':book' => \Drupal::url('book.render'), ':book-admin' => \Drupal::url('book.admin'))) . '

        '; + return '

        ' . t('The outline feature allows you to include pages in the Book hierarchy, as well as move them within the hierarchy or to reorder an entire book.', [':book' => \Drupal::url('book.render'), ':book-admin' => \Drupal::url('book.admin')]) . '

        '; } } @@ -55,23 +55,23 @@ function book_help($route_name, RouteMatchInterface $route_match) { * Implements hook_theme(). */ function book_theme() { - return array( - 'book_navigation' => array( - 'variables' => array('book_link' => NULL), - ), - 'book_tree' => array( - 'variables' => array('items' => array(), 'attributes' => array()), - ), - 'book_export_html' => array( - 'variables' => array('title' => NULL, 'contents' => NULL, 'depth' => NULL), - ), - 'book_all_books_block' => array( + return [ + 'book_navigation' => [ + 'variables' => ['book_link' => NULL], + ], + 'book_tree' => [ + 'variables' => ['items' => [], 'attributes' => []], + ], + 'book_export_html' => [ + 'variables' => ['title' => NULL, 'contents' => NULL, 'depth' => NULL], + ], + 'book_all_books_block' => [ 'render element' => 'book_menus', - ), - 'book_node_export_html' => array( - 'variables' => array('node' => NULL, 'content' => NULL, 'children' => NULL), - ), - ); + ], + 'book_node_export_html' => [ + 'variables' => ['node' => NULL, 'content' => NULL, 'children' => NULL], + ], + ]; } /** @@ -97,31 +97,31 @@ function book_node_links_alter(array &$links, NodeInterface $node, array &$conte $child_type = \Drupal::config('book.settings')->get('child_type'); $access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node'); if (($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines')) && $access_control_handler->createAccess($child_type) && $node->isPublished() && $node->book['depth'] < BookManager::BOOK_MAX_DEPTH) { - $book_links['book_add_child'] = array( + $book_links['book_add_child'] = [ 'title' => t('Add child page'), 'url' => Url::fromRoute('node.add', ['node_type' => $child_type], ['query' => ['parent' => $node->id()]]), - ); + ]; } if ($account->hasPermission('access printer-friendly version')) { - $book_links['book_printer'] = array( + $book_links['book_printer'] = [ 'title' => t('Printer-friendly version'), 'url' => Url::fromRoute('book.export', [ 'type' => 'html', 'node' => $node->id(), ]), - 'attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.')) - ); + 'attributes' => ['title' => t('Show a printer-friendly version of this book page and its sub-pages.')] + ]; } } } if (!empty($book_links)) { - $links['book'] = array( + $links['book'] = [ '#theme' => 'links__node__book', '#links' => $book_links, - '#attributes' => array('class' => array('links', 'inline')), - ); + '#attributes' => ['class' => ['links', 'inline']], + ]; } } } @@ -148,17 +148,17 @@ function book_form_node_form_alter(&$form, FormStateInterface $form_state, $form $collapsed = !($node->isNew() && !empty($node->book['pid'])); $form = \Drupal::service('book.manager')->addFormElements($form, $form_state, $node, $account, $collapsed); // The "js-hide" class hides submit button when Javascript is enabled. - $form['book']['pick-book'] = array( + $form['book']['pick-book'] = [ '#type' => 'submit', '#value' => t('Change book (update list of parents)'), - '#submit' => array('book_pick_book_nojs_submit'), + '#submit' => ['book_pick_book_nojs_submit'], '#weight' => 20, - '#attributes' => array( - 'class' => array( + '#attributes' => [ + 'class' => [ 'js-hide', - ), - ), - ); + ], + ], + ]; $form['#entity_builders'][] = 'book_node_builder'; } } @@ -232,7 +232,7 @@ function book_node_view(array &$build, EntityInterface $node, EntityViewDisplayI if (!$book_node->access()) { return; } - $build['book_navigation'] = array( + $build['book_navigation'] = [ '#theme' => 'book_navigation', '#book_link' => $node->book, '#weight' => 100, @@ -241,7 +241,7 @@ function book_node_view(array &$build, EntityInterface $node, EntityViewDisplayI '#cache' => [ 'tags' => $node->getEntityType()->getListCacheTags(), ], - ); + ]; } } } @@ -295,7 +295,7 @@ function book_node_prepare_form(NodeInterface $node, $operation, FormStateInterf // Prepare defaults for the add/edit form. $account = \Drupal::currentUser(); if (empty($node->book) && ($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines'))) { - $node->book = array(); + $node->book = []; $query = \Drupal::request()->query; if ($node->isNew() && !is_null($query->get('parent')) && is_numeric($query->get('parent'))) { @@ -341,10 +341,10 @@ function book_form_node_confirm_form_alter(&$form, FormStateInterface $form_stat } if (isset($node->book) && $node->book['has_children']) { - $form['book_warning'] = array( - '#markup' => '

        ' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', array('%title' => $node->label())) . '

        ', + $form['book_warning'] = [ + '#markup' => '

        ' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', ['%title' => $node->label()]) . '

        ', '#weight' => -10, - ); + ]; } } @@ -365,13 +365,13 @@ function book_form_node_confirm_form_alter(&$form, FormStateInterface $form_stat function template_preprocess_book_all_books_block(&$variables) { // Remove all non-renderable elements. $elements = $variables['book_menus']; - $variables['book_menus'] = array(); + $variables['book_menus'] = []; foreach (Element::children($elements) as $index) { - $variables['book_menus'][] = array( + $variables['book_menus'][] = [ 'id' => $index, 'menu' => $elements[$index], 'title' => $elements[$index]['#book_title'], - ); + ]; } } @@ -391,7 +391,7 @@ function template_preprocess_book_navigation(&$variables) { // Provide extra variables for themers. Not needed by default. $variables['book_id'] = $book_link['bid']; $variables['book_title'] = $book_link['link_title']; - $variables['book_url'] = \Drupal::url('entity.node.canonical', array('node' => $book_link['bid'])); + $variables['book_url'] = \Drupal::url('entity.node.canonical', ['node' => $book_link['bid']]); $variables['current_depth'] = $book_link['depth']; $variables['tree'] = ''; @@ -401,14 +401,14 @@ function template_preprocess_book_navigation(&$variables) { if ($book_link['nid']) { $variables['tree'] = $book_outline->childrenLinks($book_link); - $build = array(); + $build = []; if ($prev = $book_outline->prevLink($book_link)) { - $prev_href = \Drupal::url('entity.node.canonical', array('node' => $prev['nid'])); - $build['#attached']['html_head_link'][][] = array( + $prev_href = \Drupal::url('entity.node.canonical', ['node' => $prev['nid']]); + $build['#attached']['html_head_link'][][] = [ 'rel' => 'prev', 'href' => $prev_href, - ); + ]; $variables['prev_url'] = $prev_href; $variables['prev_title'] = $prev['title']; } @@ -416,21 +416,21 @@ function template_preprocess_book_navigation(&$variables) { /** @var \Drupal\book\BookManagerInterface $book_manager */ $book_manager = \Drupal::service('book.manager'); if ($book_link['pid'] && $parent = $book_manager->loadBookLink($book_link['pid'])) { - $parent_href = \Drupal::url('entity.node.canonical', array('node' => $book_link['pid'])); - $build['#attached']['html_head_link'][][] = array( + $parent_href = \Drupal::url('entity.node.canonical', ['node' => $book_link['pid']]); + $build['#attached']['html_head_link'][][] = [ 'rel' => 'up', 'href' => $parent_href, - ); + ]; $variables['parent_url'] = $parent_href; $variables['parent_title'] = $parent['title']; } if ($next = $book_outline->nextLink($book_link)) { - $next_href = \Drupal::url('entity.node.canonical', array('node' => $next['nid'])); - $build['#attached']['html_head_link'][][] = array( + $next_href = \Drupal::url('entity.node.canonical', ['node' => $next['nid']]); + $build['#attached']['html_head_link'][][] = [ 'rel' => 'next', 'href' => $next_href, - ); + ]; $variables['next_url'] = $next_href; $variables['next_title'] = $next['title']; } @@ -442,7 +442,7 @@ function template_preprocess_book_navigation(&$variables) { $variables['has_links'] = FALSE; // Link variables to filter for values and set state of the flag variable. - $links = array('prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title'); + $links = ['prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title']; foreach ($links as $link) { if (isset($variables[$link])) { // Flag when there is a value. @@ -475,7 +475,7 @@ function template_preprocess_book_export_html(&$variables) { $variables['language_rtl'] = ($language_interface->getDirection() == LanguageInterface::DIRECTION_RTL); // HTML element attributes. - $attributes = array(); + $attributes = []; $attributes['lang'] = $language_interface->getId(); $attributes['dir'] = $language_interface->getDirection(); $variables['html_attributes'] = new Attribute($attributes); diff --git a/core/modules/book/src/BookBreadcrumbBuilder.php b/core/modules/book/src/BookBreadcrumbBuilder.php index ed39a53..90591d8 100644 --- a/core/modules/book/src/BookBreadcrumbBuilder.php +++ b/core/modules/book/src/BookBreadcrumbBuilder.php @@ -56,10 +56,10 @@ public function applies(RouteMatchInterface $route_match) { * {@inheritdoc} */ public function build(RouteMatchInterface $route_match) { - $book_nids = array(); + $book_nids = []; $breadcrumb = new Breadcrumb(); - $links = array(Link::createFromRoute($this->t('Home'), '')); + $links = [Link::createFromRoute($this->t('Home'), '')]; $book = $route_match->getParameter('node')->book; $depth = 1; // We skip the current node. @@ -76,7 +76,7 @@ public function build(RouteMatchInterface $route_match) { $breadcrumb->addCacheableDependency($access); if ($access->isAllowed()) { $breadcrumb->addCacheableDependency($parent_book); - $links[] = Link::createFromRoute($parent_book->label(), 'entity.node.canonical', array('node' => $parent_book->id())); + $links[] = Link::createFromRoute($parent_book->label(), 'entity.node.canonical', ['node' => $parent_book->id()]); } } $depth++; diff --git a/core/modules/book/src/BookExport.php b/core/modules/book/src/BookExport.php index 8261c42e..a323370 100644 --- a/core/modules/book/src/BookExport.php +++ b/core/modules/book/src/BookExport.php @@ -73,8 +73,8 @@ public function bookExportHtml(NodeInterface $node) { } $tree = $this->bookManager->bookSubtreeData($node->book); - $contents = $this->exportTraverse($tree, array($this, 'bookNodeExport')); - return array( + $contents = $this->exportTraverse($tree, [$this, 'bookNodeExport']); + return [ '#theme' => 'book_export_html', '#title' => $node->label(), '#contents' => $contents, @@ -82,7 +82,7 @@ public function bookExportHtml(NodeInterface $node) { '#cache' => [ 'tags' => $node->getEntityType()->getListCacheTags(), ], - ); + ]; } /** @@ -101,9 +101,9 @@ public function bookExportHtml(NodeInterface $node) { */ protected function exportTraverse(array $tree, $callable) { // If there is no valid callable, use the default callback. - $callable = !empty($callable) ? $callable : array($this, 'bookNodeExport'); + $callable = !empty($callable) ? $callable : [$this, 'bookNodeExport']; - $build = array(); + $build = []; foreach ($tree as $data) { // Note- access checking is already performed when building the tree. if ($node = $this->nodeStorage->load($data['link']['nid'])) { @@ -133,12 +133,12 @@ protected function bookNodeExport(NodeInterface $node, $children = '') { $build = $this->viewBuilder->view($node, 'print', NULL); unset($build['#theme']); - return array( + return [ '#theme' => 'book_node_export_html', '#content' => $build, '#node' => $node, '#children' => $children, - ); + ]; } } diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index 2942462..936e33d 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -92,7 +92,7 @@ public function getAllBooks() { * Loads Books Array. */ protected function loadBooks() { - $this->books = array(); + $this->books = []; $nids = $this->bookOutlineStorage->getBooks(); if ($nids) { @@ -117,15 +117,15 @@ protected function loadBooks() { * {@inheritdoc} */ public function getLinkDefaults($nid) { - return array( + return [ 'original_bid' => 0, 'nid' => $nid, 'bid' => 0, 'pid' => 0, 'has_children' => 0, 'weight' => 0, - 'options' => array(), - ); + 'options' => [], + ]; } /** @@ -159,40 +159,40 @@ public function addFormElements(array $form, FormStateInterface $form_state, Nod if ($form_state->hasValue('book')) { $node->book = $form_state->getValue('book'); } - $form['book'] = array( + $form['book'] = [ '#type' => 'details', '#title' => $this->t('Book outline'), '#weight' => 10, '#open' => !$collapsed, '#group' => 'advanced', - '#attributes' => array( - 'class' => array('book-outline-form'), - ), - '#attached' => array( - 'library' => array('book/drupal.book'), - ), + '#attributes' => [ + 'class' => ['book-outline-form'], + ], + '#attached' => [ + 'library' => ['book/drupal.book'], + ], '#tree' => TRUE, - ); - foreach (array('nid', 'has_children', 'original_bid', 'parent_depth_limit') as $key) { - $form['book'][$key] = array( + ]; + foreach (['nid', 'has_children', 'original_bid', 'parent_depth_limit'] as $key) { + $form['book'][$key] = [ '#type' => 'value', '#value' => $node->book[$key], - ); + ]; } $form['book']['pid'] = $this->addParentSelectFormElements($node->book); // @see \Drupal\book\Form\BookAdminEditForm::bookAdminTableTree(). The // weight may be larger than 15. - $form['book']['weight'] = array( + $form['book']['weight'] = [ '#type' => 'weight', '#title' => $this->t('Weight'), '#default_value' => $node->book['weight'], '#delta' => max(15, abs($node->book['weight'])), '#weight' => 5, '#description' => $this->t('Pages at a given level are ordered first by weight and then by title.'), - ); - $options = array(); + ]; + $options = []; $nid = !$node->isNew() ? $node->id() : 'new'; if ($node->id() && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) { // This is the top level node in a maximum depth book and thus cannot be @@ -207,15 +207,15 @@ public function addFormElements(array $form, FormStateInterface $form_state, Nod if ($account->hasPermission('create new books') && ($nid == 'new' || ($nid != $node->book['original_bid']))) { // The node can become a new book, if it is not one already. - $options = array($nid => $this->t('- Create a new book -')) + $options; + $options = [$nid => $this->t('- Create a new book -')] + $options; } if (!$node->book['bid']) { // The node is not currently in the hierarchy. - $options = array(0 => $this->t('- None -')) + $options; + $options = [0 => $this->t('- None -')] + $options; } // Add a drop-down to select the destination book. - $form['book']['bid'] = array( + $form['book']['bid'] = [ '#type' => 'select', '#title' => $this->t('Book'), '#default_value' => $node->book['bid'], @@ -223,14 +223,14 @@ public function addFormElements(array $form, FormStateInterface $form_state, Nod '#access' => (bool) $options, '#description' => $this->t('Your page will be a part of the selected book.'), '#weight' => -5, - '#attributes' => array('class' => array('book-title-select')), - '#ajax' => array( + '#attributes' => ['class' => ['book-title-select']], + '#ajax' => [ 'callback' => 'book_form_update', 'wrapper' => 'edit-book-plid-wrapper', 'effect' => 'fade', 'speed' => 'fast', - ), - ); + ], + ]; return $form; } @@ -281,8 +281,8 @@ public function updateOutline(NodeInterface $node) { /** * {@inheritdoc} */ - public function getBookParents(array $item, array $parent = array()) { - $book = array(); + public function getBookParents(array $item, array $parent = []) { + $book = []; if ($item['pid'] == 0) { $book['p1'] = $item['nid']; for ($i = 2; $i <= static::BOOK_MAX_DEPTH; $i++) { @@ -325,15 +325,15 @@ public function getBookParents(array $item, array $parent = array()) { protected function addParentSelectFormElements(array $book_link) { $config = $this->configFactory->get('book.settings'); if ($config->get('override_parent_selector')) { - return array(); + return []; } // Offer a message or a drop-down to choose a different parent page. - $form = array( + $form = [ '#type' => 'hidden', '#value' => -1, '#prefix' => '
        ', '#suffix' => '
        ', - ); + ]; if ($book_link['nid'] === $book_link['bid']) { // This is a book - at the top level. @@ -348,16 +348,16 @@ protected function addParentSelectFormElements(array $book_link) { $form['#prefix'] .= '' . $this->t('No book selected.') . ''; } else { - $form = array( + $form = [ '#type' => 'select', '#title' => $this->t('Parent item'), '#default_value' => $book_link['pid'], - '#description' => $this->t('The parent page in the book. The maximum depth for a book and all child pages is @maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.', array('@maxdepth' => static::BOOK_MAX_DEPTH)), - '#options' => $this->getTableOfContents($book_link['bid'], $book_link['parent_depth_limit'], array($book_link['nid'])), - '#attributes' => array('class' => array('book-title-select')), + '#description' => $this->t('The parent page in the book. The maximum depth for a book and all child pages is @maxdepth. Some pages in the selected book may not be available as parents if selecting them would exceed this limit.', ['@maxdepth' => static::BOOK_MAX_DEPTH]), + '#options' => $this->getTableOfContents($book_link['bid'], $book_link['parent_depth_limit'], [$book_link['nid']]), + '#attributes' => ['class' => ['book-title-select']], '#prefix' => '
        ', '#suffix' => '
        ', - ); + ]; } $this->renderer->addCacheableDependency($form, $config); @@ -388,7 +388,7 @@ protected function addParentSelectFormElements(array $book_link) { * children). */ protected function recurseTableOfContents(array $tree, $indent, array &$toc, array $exclude, $depth_limit) { - $nids = array(); + $nids = []; foreach ($tree as $data) { if ($data['link']['depth'] > $depth_limit) { // Don't iterate through any links on this level. @@ -417,9 +417,9 @@ protected function recurseTableOfContents(array $tree, $indent, array &$toc, arr /** * {@inheritdoc} */ - public function getTableOfContents($bid, $depth_limit, array $exclude = array()) { + public function getTableOfContents($bid, $depth_limit, array $exclude = []) { $tree = $this->bookTreeAllData($bid); - $toc = array(); + $toc = []; $this->recurseTableOfContents($tree, '', $toc, $exclude, $depth_limit); return $toc; @@ -443,14 +443,14 @@ public function deleteFromBook($nid) { } $this->updateOriginalParent($original); $this->books = NULL; - Cache::invalidateTags(array('bid:' . $original['bid'])); + Cache::invalidateTags(['bid:' . $original['bid']]); } /** * {@inheritdoc} */ public function bookTreeAllData($bid, $link = NULL, $max_depth = NULL) { - $tree = &drupal_static(__METHOD__, array()); + $tree = &drupal_static(__METHOD__, []); $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Use $nid as a flag for whether the data being loaded is for the whole @@ -462,10 +462,10 @@ public function bookTreeAllData($bid, $link = NULL, $max_depth = NULL) { if (!isset($tree[$cid])) { // If the tree data was not in the static cache, build $tree_parameters. - $tree_parameters = array( + $tree_parameters = [ 'min_depth' => 1, 'max_depth' => $max_depth, - ); + ]; if ($nid) { $active_trail = $this->getActiveTrailIds($bid, $link); $tree_parameters['expanded'] = $active_trail; @@ -486,7 +486,7 @@ public function bookTreeAllData($bid, $link = NULL, $max_depth = NULL) { public function getActiveTrailIds($bid, $link) { // The tree is for a single item, so we need to match the values in its // p columns and 0 (the top level) with the plid values of other links. - $active_trail = array(0); + $active_trail = [0]; for ($i = 1; $i < static::BOOK_MAX_DEPTH; $i++) { if (!empty($link["p$i"])) { $active_trail[] = $link["p$i"]; @@ -600,7 +600,7 @@ protected function buildItems(array $tree) { * @return array * A fully built book tree. */ - protected function bookTreeBuild($bid, array $parameters = array()) { + protected function bookTreeBuild($bid, array $parameters = []) { // Build the book tree. $data = $this->doBookTreeBuild($bid, $parameters); // Check access for the current user to each item in the tree. @@ -639,9 +639,9 @@ protected function bookTreeBuild($bid, array $parameters = array()) { * * @see \Drupal\book\BookOutlineStorageInterface::getBookMenuTree() */ - protected function doBookTreeBuild($bid, array $parameters = array()) { + protected function doBookTreeBuild($bid, array $parameters = []) { // Static cache of already built menu trees. - $trees = &drupal_static(__METHOD__, array()); + $trees = &drupal_static(__METHOD__, []); $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Build the cache id; sort parents to prevent duplicate storage and remove @@ -664,18 +664,18 @@ protected function doBookTreeBuild($bid, array $parameters = array()) { $result = $this->bookOutlineStorage->getBookMenuTree($bid, $parameters, $min_depth, static::BOOK_MAX_DEPTH); // Build an ordered array of links using the query result object. - $links = array(); + $links = []; foreach ($result as $link) { $link = (array) $link; $links[$link['nid']] = $link; } - $active_trail = (isset($parameters['active_trail']) ? $parameters['active_trail'] : array()); + $active_trail = (isset($parameters['active_trail']) ? $parameters['active_trail'] : []); $data['tree'] = $this->buildBookOutlineData($links, $active_trail, $min_depth); - $data['node_links'] = array(); + $data['node_links'] = []; $this->bookTreeCollectNodeLinks($data['tree'], $data['node_links']); // Cache the data, if it is not already in the cache. - \Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, array('bid:' . $bid)); + \Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, ['bid:' . $bid]); $trees[$tree_cid] = $data; } @@ -705,7 +705,7 @@ public function bookTreeGetFlat(array $book_link) { if (!isset($this->bookTreeFlattened[$book_link['nid']])) { // Call $this->bookTreeAllData() to take advantage of caching. $tree = $this->bookTreeAllData($book_link['bid'], $book_link, $book_link['depth'] + 1); - $this->bookTreeFlattened[$book_link['nid']] = array(); + $this->bookTreeFlattened[$book_link['nid']] = []; $this->flatBookTree($tree, $this->bookTreeFlattened[$book_link['nid']]); } @@ -735,7 +735,7 @@ protected function flatBookTree(array $tree, array &$flat) { * {@inheritdoc} */ public function loadBookLink($nid, $translate = TRUE) { - $links = $this->loadBookLinks(array($nid), $translate); + $links = $this->loadBookLinks([$nid], $translate); return isset($links[$nid]) ? $links[$nid] : FALSE; } @@ -744,7 +744,7 @@ public function loadBookLink($nid, $translate = TRUE) { */ public function loadBookLinks($nids, $translate = TRUE) { $result = $this->bookOutlineStorage->loadMultiple($nids, $translate); - $links = array(); + $links = []; foreach ($result as $link) { if ($translate) { $this->bookLinkTranslate($link); @@ -779,7 +779,7 @@ public function saveBookLink(array $link, $new) { // Update the bid for this page and all children. if ($link['pid'] == 0) { $link['depth'] = 1; - $parent = array(); + $parent = []; } // In case the form did not specify a proper PID we use the BID as new // parent. @@ -801,11 +801,11 @@ public function saveBookLink(array $link, $new) { $this->updateParent($link); } // Update the weight and pid. - $this->bookOutlineStorage->update($link['nid'], array( + $this->bookOutlineStorage->update($link['nid'], [ 'weight' => $link['weight'], 'pid' => $link['pid'], 'bid' => $link['bid'], - )); + ]); } $cache_tags = []; foreach ($affected_bids as $bid) { @@ -825,16 +825,16 @@ public function saveBookLink(array $link, $new) { */ protected function moveChildren(array $link, array $original) { $p = 'p1'; - $expressions = array(); + $expressions = []; for ($i = 1; $i <= $link['depth']; $p = 'p' . ++$i) { - $expressions[] = array($p, ":p_$i", array(":p_$i" => $link[$p])); + $expressions[] = [$p, ":p_$i", [":p_$i" => $link[$p]]]; } $j = $original['depth'] + 1; while ($i <= static::BOOK_MAX_DEPTH && $j <= static::BOOK_MAX_DEPTH) { - $expressions[] = array('p' . $i++, 'p' . $j++, array()); + $expressions[] = ['p' . $i++, 'p' . $j++, []]; } while ($i <= static::BOOK_MAX_DEPTH) { - $expressions[] = array('p' . $i++, 0, array()); + $expressions[] = ['p' . $i++, 0, []]; } $shift = $link['depth'] - $original['depth']; @@ -868,7 +868,7 @@ protected function updateParent(array $link) { // Nothing to update. return TRUE; } - return $this->bookOutlineStorage->update($link['pid'], array('has_children' => 1)); + return $this->bookOutlineStorage->update($link['pid'], ['has_children' => 1]); } /** @@ -897,7 +897,7 @@ protected function updateOriginalParent(array $original) { // Update the parent. If the original link did not have children, then the // parent now does not have children. If the original had children, then the // the parent has children now (still). - return $this->bookOutlineStorage->update($original['pid'], array('has_children' => $parent_has_children)); + return $this->bookOutlineStorage->update($original['pid'], ['has_children' => $parent_has_children]); } /** @@ -926,7 +926,7 @@ protected function setParents(array &$link, array $parent) { /** * {@inheritdoc} */ - public function bookTreeCheckAccess(&$tree, $node_links = array()) { + public function bookTreeCheckAccess(&$tree, $node_links = []) { if ($node_links) { // @todo Extract that into its own method. $nids = array_keys($node_links); @@ -954,7 +954,7 @@ public function bookTreeCheckAccess(&$tree, $node_links = array()) { * The book tree to operate on. */ protected function doBookTreeCheckAccess(&$tree) { - $new_tree = array(); + $new_tree = []; foreach ($tree as $key => $v) { $item = &$tree[$key]['link']; $this->bookLinkTranslate($item); @@ -993,7 +993,7 @@ public function bookLinkTranslate(&$link) { } // The node label will be the value for the current user's language. $link['title'] = $node->label(); - $link['options'] = array(); + $link['options'] = []; } return $link; } @@ -1021,7 +1021,7 @@ public function bookLinkTranslate(&$link) { * array will be empty if the book link has no items in its sub-tree * having a depth greater than or equal to $depth. */ - protected function buildBookOutlineData(array $links, array $parents = array(), $depth = 1) { + protected function buildBookOutlineData(array $links, array $parents = [], $depth = 1) { // Reverse the array so we can use the more efficient array_pop() function. $links = array_reverse($links); return $this->buildBookOutlineRecursive($links, $parents, $depth); @@ -1047,16 +1047,16 @@ protected function buildBookOutlineData(array $links, array $parents = array(), * Book tree. */ protected function buildBookOutlineRecursive(&$links, $parents, $depth) { - $tree = array(); + $tree = []; while ($item = array_pop($links)) { // We need to determine if we're on the path to root so we can later build // the correct active trail. $item['in_active_trail'] = in_array($item['nid'], $parents); // Add the current link to the tree. - $tree[$item['nid']] = array( + $tree[$item['nid']] = [ 'link' => $item, - 'below' => array(), - ); + 'below' => [], + ]; // Look ahead to the next link, but leave it on the array so it's // available to other recursive function calls if we return or build a // sub-tree. @@ -1080,7 +1080,7 @@ protected function buildBookOutlineRecursive(&$links, $parents, $depth) { * {@inheritdoc} */ public function bookSubtreeData($link) { - $tree = &drupal_static(__METHOD__, array()); + $tree = &drupal_static(__METHOD__, []); // Generate a cache ID (cid) specific for this $link. $cid = 'book-links:subtree-cid:' . $link['nid']; @@ -1101,23 +1101,23 @@ public function bookSubtreeData($link) { // If the subtree data was not in the cache, $data will be NULL. if (!isset($data)) { $result = $this->bookOutlineStorage->getBookSubtree($link, static::BOOK_MAX_DEPTH); - $links = array(); + $links = []; foreach ($result as $item) { $links[] = $item; } - $data['tree'] = $this->buildBookOutlineData($links, array(), $link['depth']); - $data['node_links'] = array(); + $data['tree'] = $this->buildBookOutlineData($links, [], $link['depth']); + $data['node_links'] = []; $this->bookTreeCollectNodeLinks($data['tree'], $data['node_links']); // Compute the real cid for book subtree data. $tree_cid = 'book-links:subtree-data:' . hash('sha256', serialize($data)); // Cache the data, if it is not already in the cache. if (!\Drupal::cache('data')->get($tree_cid)) { - \Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, array('bid:' . $link['bid'])); + \Drupal::cache('data')->set($tree_cid, $data, Cache::PERMANENT, ['bid:' . $link['bid']]); } // Cache the cid of the (shared) data using the book and item-specific // cid. - \Drupal::cache('data')->set($cid, $tree_cid, Cache::PERMANENT, array('bid:' . $link['bid'])); + \Drupal::cache('data')->set($cid, $tree_cid, Cache::PERMANENT, ['bid:' . $link['bid']]); } // Check access for the current user to each item in the tree. $this->bookTreeCheckAccess($data['tree'], $data['node_links']); diff --git a/core/modules/book/src/BookManagerInterface.php b/core/modules/book/src/BookManagerInterface.php index 70d0107..5402bf5 100644 --- a/core/modules/book/src/BookManagerInterface.php +++ b/core/modules/book/src/BookManagerInterface.php @@ -108,7 +108,7 @@ public function loadBookLinks($nids, $translate = TRUE); * An array of (menu link ID, title) pairs for use as options for selecting * a book page. */ - public function getTableOfContents($bid, $depth_limit, array $exclude = array()); + public function getTableOfContents($bid, $depth_limit, array $exclude = []); /** * Finds the depth limit for items in the parent select. @@ -207,7 +207,7 @@ public function saveBookLink(array $link, $new); */ public function getLinkDefaults($nid); - public function getBookParents(array $item, array $parent = array()); + public function getBookParents(array $item, array $parent = []); /** * Builds the common elements of the book form for the node and outline forms. @@ -262,7 +262,7 @@ public function bookTreeOutput(array $tree); * A collection of node link references generated from $tree by * menu_tree_collect_node_links(). */ - public function bookTreeCheckAccess(&$tree, $node_links = array()); + public function bookTreeCheckAccess(&$tree, $node_links = []); /** * Gets the data representing a subtree of the book hierarchy. diff --git a/core/modules/book/src/BookOutline.php b/core/modules/book/src/BookOutline.php index bc03b7c..ec28d50 100644 --- a/core/modules/book/src/BookOutline.php +++ b/core/modules/book/src/BookOutline.php @@ -105,7 +105,7 @@ public function nextLink(array $book_link) { public function childrenLinks(array $book_link) { $flat = $this->bookManager->bookTreeGetFlat($book_link); - $children = array(); + $children = []; if ($book_link['has_children']) { // Walk through the array until we find the current page. diff --git a/core/modules/book/src/BookOutlineStorage.php b/core/modules/book/src/BookOutlineStorage.php index 92076cb..4f61b5c 100644 --- a/core/modules/book/src/BookOutlineStorage.php +++ b/core/modules/book/src/BookOutlineStorage.php @@ -43,7 +43,7 @@ public function hasBooks() { * {@inheritdoc} */ public function loadMultiple($nids, $access = TRUE) { - $query = $this->connection->select('book', 'b', array('fetch' => \PDO::FETCH_ASSOC)); + $query = $this->connection->select('book', 'b', ['fetch' => \PDO::FETCH_ASSOC]); $query->fields('b'); $query->condition('b.nid', $nids, 'IN'); @@ -89,7 +89,7 @@ public function delete($nid) { */ public function loadBookChildren($pid) { return $this->connection - ->query("SELECT * FROM {book} WHERE pid = :pid", array(':pid' => $pid)) + ->query("SELECT * FROM {book} WHERE pid = :pid", [':pid' => $pid]) ->fetchAllAssoc('nid', \PDO::FETCH_ASSOC); } @@ -128,12 +128,12 @@ public function getBookMenuTree($bid, $parameters, $min_depth, $max_depth) { public function insert($link, $parents) { return $this->connection ->insert('book') - ->fields(array( + ->fields([ 'nid' => $link['nid'], 'bid' => $link['bid'], 'pid' => $link['pid'], 'weight' => $link['weight'], - ) + $parents + ] + $parents ) ->execute(); } @@ -154,13 +154,13 @@ public function update($nid, $fields) { */ public function updateMovedChildren($bid, $original, $expressions, $shift) { $query = $this->connection->update('book'); - $query->fields(array('bid' => $bid)); + $query->fields(['bid' => $bid]); foreach ($expressions as $expression) { $query->expression($expression[0], $expression[1], $expression[2]); } - $query->expression('depth', 'depth + :depth', array(':depth' => $shift)); + $query->expression('depth', 'depth + :depth', [':depth' => $shift]); $query->condition('bid', $original['bid']); $p = 'p1'; for ($i = 1; !empty($original[$p]); $p = 'p' . ++$i) { @@ -186,7 +186,7 @@ public function countOriginalLinkChildren($original) { * {@inheritdoc} */ public function getBookSubtree($link, $max_depth) { - $query = db_select('book', 'b', array('fetch' => \PDO::FETCH_ASSOC)); + $query = db_select('book', 'b', ['fetch' => \PDO::FETCH_ASSOC]); $query->fields('b'); $query->condition('b.bid', $link['bid']); diff --git a/core/modules/book/src/Controller/BookController.php b/core/modules/book/src/Controller/BookController.php index 920afeb..b92c3e3 100644 --- a/core/modules/book/src/Controller/BookController.php +++ b/core/modules/book/src/Controller/BookController.php @@ -73,9 +73,9 @@ public static function create(ContainerInterface $container) { * A render array representing the administrative page content. */ public function adminOverview() { - $rows = array(); + $rows = []; - $headers = array(t('Book'), t('Operations')); + $headers = [t('Book'), t('Operations')]; // Add any recognized books to the table list. foreach ($this->bookManager->getAllBooks() as $book) { /** @var \Drupal\Core\Url $url */ @@ -83,28 +83,28 @@ public function adminOverview() { if (isset($book['options'])) { $url->setOptions($book['options']); } - $row = array( + $row = [ $this->l($book['title'], $url), - ); - $links = array(); - $links['edit'] = array( + ]; + $links = []; + $links['edit'] = [ 'title' => t('Edit order and titles'), 'url' => Url::fromRoute('book.admin_edit', ['node' => $book['nid']]), - ); - $row[] = array( - 'data' => array( + ]; + $row[] = [ + 'data' => [ '#type' => 'operations', '#links' => $links, - ), - ); + ], + ]; $rows[] = $row; } - return array( + return [ '#type' => 'table', '#header' => $headers, '#rows' => $rows, '#empty' => t('No books available.'), - ); + ]; } /** @@ -114,17 +114,17 @@ public function adminOverview() { * A render array representing the listing of all books content. */ public function bookRender() { - $book_list = array(); + $book_list = []; foreach ($this->bookManager->getAllBooks() as $book) { $book_list[] = $this->l($book['title'], $book['url']); } - return array( + return [ '#theme' => 'item_list', '#items' => $book_list, '#cache' => [ 'tags' => \Drupal::entityManager()->getDefinition('node')->getListCacheTags(), ], - ); + ]; } /** diff --git a/core/modules/book/src/Form/BookAdminEditForm.php b/core/modules/book/src/Form/BookAdminEditForm.php index 1753944..e91f52e 100644 --- a/core/modules/book/src/Form/BookAdminEditForm.php +++ b/core/modules/book/src/Form/BookAdminEditForm.php @@ -70,10 +70,10 @@ public function buildForm(array $form, FormStateInterface $form_state, NodeInter $form['#title'] = $node->label(); $form['#node'] = $node; $this->bookAdminTable($node, $form); - $form['save'] = array( + $form['save'] = [ '#type' => 'submit', '#value' => $this->t('Save book pages'), - ); + ]; return $form; } @@ -101,7 +101,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { foreach (Element::children($form['table']) as $key) { if ($form['table'][$key]['#item']) { $row = $form['table'][$key]; - $values = $form_state->getValue(array('table', $key)); + $values = $form_state->getValue(['table', $key]); // Update menu item if moved. if ($row['parent']['pid']['#default_value'] != $values['pid'] || $row['weight']['#default_value'] != $values['weight']) { @@ -114,18 +114,18 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // Update the title if changed. if ($row['title']['#default_value'] != $values['title']) { $node = $this->nodeStorage->load($values['nid']); - $node->revision_log = $this->t('Title changed from %original to %current.', array('%original' => $node->label(), '%current' => $values['title'])); + $node->revision_log = $this->t('Title changed from %original to %current.', ['%original' => $node->label(), '%current' => $values['title']]); $node->title = $values['title']; $node->book['link_title'] = $values['title']; $node->setNewRevision(); $node->save(); - $this->logger('content')->notice('book: updated %title.', array('%title' => $node->label(), 'link' => $node->link($this->t('View')))); + $this->logger('content')->notice('book: updated %title.', ['%title' => $node->label(), 'link' => $node->link($this->t('View'))]); } } } } - drupal_set_message($this->t('Updated book %title.', array('%title' => $form['#node']->label()))); + drupal_set_message($this->t('Updated book %title.', ['%title' => $form['#node']->label()])); } /** @@ -139,7 +139,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { * @see self::buildForm() */ protected function bookAdminTable(NodeInterface $node, array &$form) { - $form['table'] = array( + $form['table'] = [ '#type' => 'table', '#header' => [ $this->t('Title'), @@ -164,7 +164,7 @@ protected function bookAdminTable(NodeInterface $node, array &$form) { 'group' => 'book-weight', ], ], - ); + ]; $tree = $this->bookManager->bookSubtreeData($node->book); // Do not include the book item itself. @@ -173,14 +173,14 @@ protected function bookAdminTable(NodeInterface $node, array &$form) { $hash = Crypt::hashBase64(serialize($tree['below'])); // Store the hash value as a hidden form element so that we can detect // if another user changed the book hierarchy. - $form['tree_hash'] = array( + $form['tree_hash'] = [ '#type' => 'hidden', '#default_value' => $hash, - ); - $form['tree_current_hash'] = array( + ]; + $form['tree_current_hash'] = [ '#type' => 'value', '#value' => $hash, - ); + ]; $this->bookAdminTableTree($tree['below'], $form['table']); } } diff --git a/core/modules/book/src/Form/BookOutlineForm.php b/core/modules/book/src/Form/BookOutlineForm.php index e304a2b..305b9fd 100644 --- a/core/modules/book/src/Form/BookOutlineForm.php +++ b/core/modules/book/src/Form/BookOutlineForm.php @@ -99,7 +99,7 @@ protected function actions(array $form, FormStateInterface $form_state) { public function save(array $form, FormStateInterface $form_state) { $form_state->setRedirect( 'entity.node.canonical', - array('node' => $this->entity->id()) + ['node' => $this->entity->id()] ); $book_link = $form_state->getValue('book'); if (!$book_link['bid']) { diff --git a/core/modules/book/src/Form/BookRemoveForm.php b/core/modules/book/src/Form/BookRemoveForm.php index 4848fa2..e31c094 100644 --- a/core/modules/book/src/Form/BookRemoveForm.php +++ b/core/modules/book/src/Form/BookRemoveForm.php @@ -65,7 +65,7 @@ public function buildForm(array $form, FormStateInterface $form_state, NodeInter * {@inheritdoc} */ public function getDescription() { - $title = array('%title' => $this->node->label()); + $title = ['%title' => $this->node->label()]; if ($this->node->book['has_children']) { return $this->t('%title has associated child pages, which will be relocated automatically to maintain their connection to the book. To recreate the hierarchy (as it was before removing this page), %title may be added again using the Outline tab, and each of its former child pages will need to be relocated manually.', $title); } @@ -85,7 +85,7 @@ public function getConfirmText() { * {@inheritdoc} */ public function getQuestion() { - return $this->t('Are you sure you want to remove %title from the book hierarchy?', array('%title' => $this->node->label())); + return $this->t('Are you sure you want to remove %title from the book hierarchy?', ['%title' => $this->node->label()]); } /** diff --git a/core/modules/book/src/Form/BookSettingsForm.php b/core/modules/book/src/Form/BookSettingsForm.php index 058d0cd..29590cc 100644 --- a/core/modules/book/src/Form/BookSettingsForm.php +++ b/core/modules/book/src/Form/BookSettingsForm.php @@ -30,22 +30,22 @@ protected function getEditableConfigNames() { public function buildForm(array $form, FormStateInterface $form_state) { $types = node_type_get_names(); $config = $this->config('book.settings'); - $form['book_allowed_types'] = array( + $form['book_allowed_types'] = [ '#type' => 'checkboxes', '#title' => $this->t('Content types allowed in book outlines'), '#default_value' => $config->get('allowed_types'), '#options' => $types, - '#description' => $this->t('Users with the %outline-perm permission can add all content types.', array('%outline-perm' => $this->t('Administer book outlines'))), + '#description' => $this->t('Users with the %outline-perm permission can add all content types.', ['%outline-perm' => $this->t('Administer book outlines')]), '#required' => TRUE, - ); - $form['book_child_type'] = array( + ]; + $form['book_child_type'] = [ '#type' => 'radios', '#title' => $this->t('Content type for the Add child page link'), '#default_value' => $config->get('child_type'), '#options' => $types, '#required' => TRUE, - ); - $form['array_filter'] = array('#type' => 'value', '#value' => TRUE); + ]; + $form['array_filter'] = ['#type' => 'value', '#value' => TRUE]; return parent::buildForm($form, $form_state); } @@ -55,8 +55,8 @@ public function buildForm(array $form, FormStateInterface $form_state) { */ public function validateForm(array &$form, FormStateInterface $form_state) { $child_type = $form_state->getValue('book_child_type'); - if ($form_state->isValueEmpty(array('book_allowed_types', $child_type))) { - $form_state->setErrorByName('book_child_type', $this->t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', array('%add-child' => $this->t('Add child page')))); + if ($form_state->isValueEmpty(['book_allowed_types', $child_type])) { + $form_state->setErrorByName('book_child_type', $this->t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', ['%add-child' => $this->t('Add child page')])); } parent::validateForm($form, $form_state); diff --git a/core/modules/book/src/Plugin/Block/BookNavigationBlock.php b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php index b232fbf..e050018 100644 --- a/core/modules/book/src/Plugin/Block/BookNavigationBlock.php +++ b/core/modules/book/src/Plugin/Block/BookNavigationBlock.php @@ -85,26 +85,26 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function defaultConfiguration() { - return array( + return [ 'block_mode' => "all pages", - ); + ]; } /** * {@inheritdoc} */ function blockForm($form, FormStateInterface $form_state) { - $options = array( + $options = [ 'all pages' => $this->t('Show block on all pages'), 'book pages' => $this->t('Show block only on book pages'), - ); - $form['book_block_mode'] = array( + ]; + $form['book_block_mode'] = [ '#type' => 'radios', '#title' => $this->t('Book navigation block display'), '#options' => $options, '#default_value' => $this->configuration['block_mode'], '#description' => $this->t("If Show block on all pages is selected, the block will contain the automatically generated menus for all of the site's books. If Show block only on book pages is selected, the block will contain only the one menu corresponding to the current page's book. In this case, if the current page is not in a book, no block will be displayed. The Page specific visibility settings or other visibility settings can be used in addition to selectively display this block."), - ); + ]; return $form; } @@ -126,8 +126,8 @@ public function build() { $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid']; } if ($this->configuration['block_mode'] == 'all pages') { - $book_menus = array(); - $pseudo_tree = array(0 => array('below' => FALSE)); + $book_menus = []; + $pseudo_tree = [0 => ['below' => FALSE]]; foreach ($this->bookManager->getAllBooks() as $book_id => $book) { if ($book['bid'] == $current_bid) { // If the current page is a node associated with a book, the menu @@ -145,14 +145,14 @@ public function build() { $pseudo_tree[0]['link'] = $book; $book_menus[$book_id] = $this->bookManager->bookTreeOutput($pseudo_tree); } - $book_menus[$book_id] += array( + $book_menus[$book_id] += [ '#book_title' => $book['title'], - ); + ]; } if ($book_menus) { - return array( + return [ '#theme' => 'book_all_books_block', - ) + $book_menus; + ] + $book_menus; } } elseif ($current_bid) { @@ -171,7 +171,7 @@ public function build() { } } } - return array(); + return []; } /** diff --git a/core/modules/book/src/Plugin/migrate/source/d6/Book.php b/core/modules/book/src/Plugin/migrate/source/d6/Book.php index 76833aa..f41bb42 100644 --- a/core/modules/book/src/Plugin/migrate/source/d6/Book.php +++ b/core/modules/book/src/Plugin/migrate/source/d6/Book.php @@ -17,9 +17,9 @@ class Book extends DrupalSqlBase { * {@inheritdoc} */ public function query() { - $query = $this->select('book', 'b')->fields('b', array('nid', 'bid')); + $query = $this->select('book', 'b')->fields('b', ['nid', 'bid']); $query->join('menu_links', 'ml', 'b.mlid = ml.mlid'); - $ml_fields = array('mlid', 'plid', 'weight', 'has_children', 'depth'); + $ml_fields = ['mlid', 'plid', 'weight', 'has_children', 'depth']; for ($i = 1; $i <= 9; $i++) { $field = "p$i"; $ml_fields[] = $field; @@ -42,7 +42,7 @@ public function getIds() { * {@inheritdoc} */ public function fields() { - return array( + return [ 'nid' => $this->t('Node ID'), 'bid' => $this->t('Book ID'), 'mlid' => $this->t('Menu link ID'), @@ -57,7 +57,7 @@ public function fields() { 'p7' => $this->t('The seventh mlid in the materialized path. See p1.'), 'p8' => $this->t('The eighth mlid in the materialized path. See p1.'), 'p9' => $this->t('The ninth mlid in the materialized path. See p1.'), - ); + ]; } } diff --git a/core/modules/book/src/Tests/BookBreadcrumbTest.php b/core/modules/book/src/Tests/BookBreadcrumbTest.php index 57e1b3d..d2f4d5d 100644 --- a/core/modules/book/src/Tests/BookBreadcrumbTest.php +++ b/core/modules/book/src/Tests/BookBreadcrumbTest.php @@ -16,7 +16,7 @@ class BookBreadcrumbTest extends WebTestBase { * * @var array */ - public static $modules = array('book', 'block', 'book_breadcrumb_test'); + public static $modules = ['book', 'block', 'book_breadcrumb_test']; /** * A book node. @@ -48,8 +48,8 @@ protected function setUp() { $this->drupalPlaceBlock('page_title_block'); // Create users. - $this->bookAuthor = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books')); - $this->adminUser = $this->drupalCreateUser(array('create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'administer content types', 'administer site configuration')); + $this->bookAuthor = $this->drupalCreateUser(['create new books', 'create book content', 'edit own book content', 'add content to books']); + $this->adminUser = $this->drupalCreateUser(['create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'administer content types', 'administer site configuration']); } /** @@ -76,7 +76,7 @@ protected function createBreadcrumbBook() { * |- Node 5 * |- Node 6 */ - $nodes = array(); + $nodes = []; $nodes[0] = $this->createBookNode($book->id()); $nodes[1] = $this->createBookNode($book->id(), $nodes[0]->id()); $nodes[2] = $this->createBookNode($book->id(), $nodes[0]->id()); @@ -107,7 +107,7 @@ protected function createBookNode($book_nid, $parent = NULL) { // that when sorted nodes stay in same order. static $number = 0; - $edit = array(); + $edit = []; $edit['title[0][value]'] = str_pad($number, 2, '0', STR_PAD_LEFT) . ' - SimpleTest test node ' . $this->randomMachineName(10); $edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32); $edit['book[bid]'] = $book_nid; @@ -146,7 +146,7 @@ public function testBreadcrumbTitleUpdates() { $this->drupalGet($nodes[4]->toUrl()); // Fetch each node title in the current breadcrumb. $links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a'); - $got_breadcrumb = array(); + $got_breadcrumb = []; foreach ($links as $link) { $got_breadcrumb[] = (string) $link; } @@ -160,7 +160,7 @@ public function testBreadcrumbTitleUpdates() { $this->drupalGet($nodes[4]->toUrl()); // Fetch each node title in the current breadcrumb. $links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a'); - $got_breadcrumb = array(); + $got_breadcrumb = []; foreach ($links as $link) { $got_breadcrumb[] = (string) $link; } @@ -181,7 +181,7 @@ public function testBreadcrumbAccessUpdates() { $this->drupalPostForm($nodes[3]->toUrl('edit-form'), $edit, 'Save'); $this->drupalGet($nodes[4]->toUrl()); $links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a'); - $got_breadcrumb = array(); + $got_breadcrumb = []; foreach ($links as $link) { $got_breadcrumb[] = (string) $link; } @@ -191,7 +191,7 @@ public function testBreadcrumbAccessUpdates() { $config->set('hide', TRUE)->save(); $this->drupalGet($nodes[4]->toUrl()); $links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a'); - $got_breadcrumb = array(); + $got_breadcrumb = []; foreach ($links as $link) { $got_breadcrumb[] = (string) $link; } diff --git a/core/modules/book/src/Tests/BookTest.php b/core/modules/book/src/Tests/BookTest.php index 7ebec63..e8559e6 100644 --- a/core/modules/book/src/Tests/BookTest.php +++ b/core/modules/book/src/Tests/BookTest.php @@ -20,7 +20,7 @@ class BookTest extends WebTestBase { * * @var array */ - public static $modules = array('book', 'block', 'node_access_test', 'book_test'); + public static $modules = ['book', 'block', 'node_access_test', 'book_test']; /** * A book node. @@ -69,10 +69,10 @@ protected function setUp() { node_access_rebuild(); // Create users. - $this->bookAuthor = $this->drupalCreateUser(array('create new books', 'create book content', 'edit own book content', 'add content to books')); - $this->webUser = $this->drupalCreateUser(array('access printer-friendly version', 'node test view')); - $this->webUserWithoutNodeAccess = $this->drupalCreateUser(array('access printer-friendly version')); - $this->adminUser = $this->drupalCreateUser(array('create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'node test view', 'administer content types', 'administer site configuration')); + $this->bookAuthor = $this->drupalCreateUser(['create new books', 'create book content', 'edit own book content', 'add content to books']); + $this->webUser = $this->drupalCreateUser(['access printer-friendly version', 'node test view']); + $this->webUserWithoutNodeAccess = $this->drupalCreateUser(['access printer-friendly version']); + $this->adminUser = $this->drupalCreateUser(['create new books', 'create book content', 'edit any book content', 'delete any book content', 'add content to books', 'administer blocks', 'administer permissions', 'administer book outlines', 'node test view', 'administer content types', 'administer site configuration']); } /** @@ -96,7 +96,7 @@ function createBook() { * |- Node 3 * |- Node 4 */ - $nodes = array(); + $nodes = []; $nodes[] = $this->createBookNode($book->id()); // Node 0. $nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['nid']); // Node 1. $nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['nid']); // Node 2. @@ -159,8 +159,8 @@ function testEmptyBook() { // Log in as a user with access to the book outline and save the form. $this->drupalLogin($this->adminUser); - $this->drupalPostForm('admin/structure/book/' . $book->id(), array(), t('Save book pages')); - $this->assertText(t('Updated book @book.', array('@book' => $book->label()))); + $this->drupalPostForm('admin/structure/book/' . $book->id(), [], t('Save book pages')); + $this->assertText(t('Updated book @book.', ['@book' => $book->label()])); } /** @@ -175,12 +175,12 @@ function testBook() { // Check that book pages display along with the correct outlines and // previous/next links. - $this->checkBookNode($book, array($nodes[0], $nodes[3], $nodes[4]), FALSE, FALSE, $nodes[0], array()); - $this->checkBookNode($nodes[0], array($nodes[1], $nodes[2]), $book, $book, $nodes[1], array($book)); - $this->checkBookNode($nodes[1], NULL, $nodes[0], $nodes[0], $nodes[2], array($book, $nodes[0])); - $this->checkBookNode($nodes[2], NULL, $nodes[1], $nodes[0], $nodes[3], array($book, $nodes[0])); - $this->checkBookNode($nodes[3], NULL, $nodes[2], $book, $nodes[4], array($book)); - $this->checkBookNode($nodes[4], NULL, $nodes[3], $book, FALSE, array($book)); + $this->checkBookNode($book, [$nodes[0], $nodes[3], $nodes[4]], FALSE, FALSE, $nodes[0], []); + $this->checkBookNode($nodes[0], [$nodes[1], $nodes[2]], $book, $book, $nodes[1], [$book]); + $this->checkBookNode($nodes[1], NULL, $nodes[0], $nodes[0], $nodes[2], [$book, $nodes[0]]); + $this->checkBookNode($nodes[2], NULL, $nodes[1], $nodes[0], $nodes[3], [$book, $nodes[0]]); + $this->checkBookNode($nodes[3], NULL, $nodes[2], $book, $nodes[4], [$book]); + $this->checkBookNode($nodes[4], NULL, $nodes[3], $book, FALSE, [$book]); $this->drupalLogout(); $this->drupalLogin($this->bookAuthor); @@ -203,14 +203,14 @@ function testBook() { $this->drupalLogout(); $this->drupalLogin($this->webUser); // Verify the new outline - make sure we don't get stale cached data. - $this->checkBookNode($nodes[3], array($nodes[5]), $nodes[2], $book, $nodes[5], array($book)); - $this->checkBookNode($nodes[4], NULL, $nodes[5], $book, FALSE, array($book)); + $this->checkBookNode($nodes[3], [$nodes[5]], $nodes[2], $book, $nodes[5], [$book]); + $this->checkBookNode($nodes[4], NULL, $nodes[5], $book, FALSE, [$book]); $this->drupalLogout(); // Create a second book, and move an existing book page into it. $this->drupalLogin($this->bookAuthor); $other_book = $this->createBookNode('new'); $node = $this->createBookNode($book->id()); - $edit = array('book[bid]' => $other_book->id()); + $edit = ['book[bid]' => $other_book->id()]; $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->drupalLogout(); @@ -220,8 +220,8 @@ function testBook() { // First we must set $this->book to the second book, so that the // correct regex will be generated for testing the outline. $this->book = $other_book; - $this->checkBookNode($other_book, array($node), FALSE, FALSE, $node, array()); - $this->checkBookNode($node, NULL, $other_book, $other_book, FALSE, array($other_book)); + $this->checkBookNode($other_book, [$node], FALSE, FALSE, $node, []); + $this->checkBookNode($node, NULL, $other_book, $other_book, FALSE, [$other_book]); // Test that we can save a book programatically. $this->drupalLogin($this->bookAuthor); @@ -255,38 +255,38 @@ function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = F // Check outline structure. if ($nodes !== NULL) { - $this->assertPattern($this->generateOutlinePattern($nodes), format_string('Node @number outline confirmed.', array('@number' => $number))); + $this->assertPattern($this->generateOutlinePattern($nodes), format_string('Node @number outline confirmed.', ['@number' => $number])); } else { - $this->pass(format_string('Node %number does not have outline.', array('%number' => $number))); + $this->pass(format_string('Node %number does not have outline.', ['%number' => $number])); } // Check previous, up, and next links. if ($previous) { /** @var \Drupal\Core\Url $url */ $url = $previous->urlInfo(); - $url->setOptions(array('attributes' => array('rel' => array('prev'), 'title' => t('Go to previous page')))); - $text = SafeMarkup::format(' @label', array('@label' => $previous->label())); + $url->setOptions(['attributes' => ['rel' => ['prev'], 'title' => t('Go to previous page')]]); + $text = SafeMarkup::format(' @label', ['@label' => $previous->label()]); $this->assertRaw(\Drupal::l($text, $url), 'Previous page link found.'); } if ($up) { /** @var \Drupal\Core\Url $url */ $url = $up->urlInfo(); - $url->setOptions(array('attributes' => array('title' => t('Go to parent page')))); + $url->setOptions(['attributes' => ['title' => t('Go to parent page')]]); $this->assertRaw(\Drupal::l('Up', $url), 'Up page link found.'); } if ($next) { /** @var \Drupal\Core\Url $url */ $url = $next->urlInfo(); - $url->setOptions(array('attributes' => array('rel' => array('next'), 'title' => t('Go to next page')))); - $text = SafeMarkup::format('@label ', array('@label' => $next->label())); + $url->setOptions(['attributes' => ['rel' => ['next'], 'title' => t('Go to next page')]]); + $text = SafeMarkup::format('@label ', ['@label' => $next->label()]); $this->assertRaw(\Drupal::l($text, $url), 'Next page link found.'); } // Compute the expected breadcrumb. - $expected_breadcrumb = array(); + $expected_breadcrumb = []; $expected_breadcrumb[] = \Drupal::url(''); foreach ($breadcrumb as $a_node) { $expected_breadcrumb[] = $a_node->url(); @@ -294,7 +294,7 @@ function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = F // Fetch links in the current breadcrumb. $links = $this->xpath('//nav[@class="breadcrumb"]/ol/li/a'); - $got_breadcrumb = array(); + $got_breadcrumb = []; foreach ($links as $link) { $got_breadcrumb[] = (string) $link['href']; } @@ -344,7 +344,7 @@ function createBookNode($book_nid, $parent = NULL) { // since it uniquely identifies each call to createBookNode(). static $number = 0; // Used to ensure that when sorted nodes stay in same order. - $edit = array(); + $edit = []; $edit['title[0][value]'] = str_pad($number, 2, '0', STR_PAD_LEFT) . ' - SimpleTest test node ' . $this->randomMachineName(10); $edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32); $edit['book[bid]'] = $book_nid; @@ -410,7 +410,7 @@ function testBookExport() { // Now grant anonymous users permission to view the printer-friendly // version and verify that node access restrictions still prevent them from // seeing it. - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access printer-friendly version')); + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access printer-friendly version']); $this->drupalGet('book/export/html/' . $this->book->id()); $this->assertResponse('403', 'Anonymous user properly forbidden from seeing the printer-friendly version when denied by node access.'); } @@ -425,7 +425,7 @@ function testBookNavigationBlock() { $block = $this->drupalPlaceBlock('book_navigation'); // Give anonymous users the permission 'node test view'. - $edit = array(); + $edit = []; $edit[RoleInterface::ANONYMOUS_ID . '[node test view]'] = TRUE; $this->drupalPostForm('admin/people/permissions/' . RoleInterface::ANONYMOUS_ID, $edit, t('Save permissions')); $this->assertText(t('The changes have been saved.'), "Permission 'node test view' successfully assigned to anonymous users."); @@ -434,7 +434,7 @@ function testBookNavigationBlock() { $nodes = $this->createBook(); $this->drupalGet(''); $this->assertText($block->label(), 'Book navigation block is displayed.'); - $this->assertText($this->book->label(), format_string('Link to book root (@title) is displayed.', array('@title' => $nodes[0]->label()))); + $this->assertText($this->book->label(), format_string('Link to book root (@title) is displayed.', ['@title' => $nodes[0]->label()])); $this->assertNoText($nodes[0]->label(), 'No links to individual book pages are displayed.'); } @@ -485,8 +485,8 @@ public function testGetTableOfContents() { $diff = array_diff($expected_nids, array_keys($options)); $this->assertTrue(empty($diff), 'Found all expected option keys'); // Exclude Node 3. - $options = $manager->getTableOfContents($book->id(), 3, array($nodes[3]->id())); - $expected_nids = array($book->id(), $nodes[0]->id(), $nodes[1]->id(), $nodes[2]->id(), $nodes[4]->id()); + $options = $manager->getTableOfContents($book->id(), 3, [$nodes[3]->id()]); + $expected_nids = [$book->id(), $nodes[0]->id(), $nodes[1]->id(), $nodes[2]->id(), $nodes[4]->id()]; $this->assertEqual(count($options), count($expected_nids)); $diff = array_diff($expected_nids, array_keys($options)); $this->assertTrue(empty($diff), 'Found all expected option keys after excluding Node 3'); @@ -497,10 +497,10 @@ public function testGetTableOfContents() { */ function testNavigationBlockOnAccessModuleInstalled() { $this->drupalLogin($this->adminUser); - $block = $this->drupalPlaceBlock('book_navigation', array('block_mode' => 'book pages')); + $block = $this->drupalPlaceBlock('book_navigation', ['block_mode' => 'book pages']); // Give anonymous users the permission 'node test view'. - $edit = array(); + $edit = []; $edit[RoleInterface::ANONYMOUS_ID . '[node test view]'] = TRUE; $this->drupalPostForm('admin/people/permissions/' . RoleInterface::ANONYMOUS_ID, $edit, t('Save permissions')); $this->assertText(t('The changes have been saved.'), "Permission 'node test view' successfully assigned to anonymous users."); @@ -530,13 +530,13 @@ function testBookDelete() { $node_storage = $this->container->get('entity.manager')->getStorage('node'); $nodes = $this->createBook(); $this->drupalLogin($this->adminUser); - $edit = array(); + $edit = []; // Test access to delete top-level and child book nodes. $this->drupalGet('node/' . $this->book->id() . '/outline/remove'); $this->assertResponse('403', 'Deleting top-level book node properly forbidden.'); $this->drupalPostForm('node/' . $nodes[4]->id() . '/outline/remove', $edit, t('Remove')); - $node_storage->resetCache(array($nodes[4]->id())); + $node_storage->resetCache([$nodes[4]->id()]); $node4 = $node_storage->load($nodes[4]->id()); $this->assertTrue(empty($node4->book), 'Deleting child book node properly allowed.'); @@ -546,7 +546,7 @@ function testBookDelete() { } entity_delete_multiple('node', $nids); $this->drupalPostForm('node/' . $this->book->id() . '/outline/remove', $edit, t('Remove')); - $node_storage->resetCache(array($this->book->id())); + $node_storage->resetCache([$this->book->id()]); $node = $node_storage->load($this->book->id()); $this->assertTrue(empty($node->book), 'Deleting childless top-level book node properly allowed.'); @@ -585,12 +585,12 @@ public function testBookOrdering() { // Head to admin screen and attempt to re-order. $this->drupalGet('admin/structure/book/' . $book->id()); - $edit = array( + $edit = [ "table[book-admin-{$node1->id()}][weight]" => 1, "table[book-admin-{$node2->id()}][weight]" => 2, // Put node 2 under node 1. "table[book-admin-{$node2->id()}][pid]" => $pid, - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save book pages')); // Verify weight was updated. $this->assertFieldByName("table[book-admin-{$node1->id()}][weight]", 1); @@ -605,7 +605,7 @@ public function testBookOutline() { $this->drupalLogin($this->bookAuthor); // Create new node not yet a book. - $empty_book = $this->drupalCreateNode(array('type' => 'book')); + $empty_book = $this->drupalCreateNode(['type' => 'book']); $this->drupalGet('node/' . $empty_book->id() . '/outline'); $this->assertNoLink(t('Book outline'), 'Book Author is not allowed to outline'); @@ -615,7 +615,7 @@ public function testBookOutline() { $this->assertOptionSelected('edit-book-bid', 0, 'Node does not belong to a book'); $this->assertNoLink(t('Remove from book outline')); - $edit = array(); + $edit = []; $edit['book[bid]'] = '1'; $this->drupalPostForm('node/' . $empty_book->id() . '/outline', $edit, t('Add to book outline')); $node = \Drupal::entityManager()->getStorage('node')->load($empty_book->id()); @@ -634,11 +634,11 @@ public function testBookOutline() { $this->drupalGet('node/' . $book->id() . '/outline'); $this->assertRaw(t('Book outline')); $this->clickLink(t('Remove from book outline')); - $this->assertRaw(t('Are you sure you want to remove %title from the book hierarchy?', array('%title' => $book->label()))); + $this->assertRaw(t('Are you sure you want to remove %title from the book hierarchy?', ['%title' => $book->label()])); // Create a new node and set the book after the node was created. - $node = $this->drupalCreateNode(array('type' => 'book')); - $edit = array(); + $node = $this->drupalCreateNode(['type' => 'book']); + $edit = []; $edit['book[bid]'] = $node->id(); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $node = \Drupal::entityManager()->getStorage('node')->load($node->id()); @@ -662,7 +662,7 @@ public function testSaveBookLink() { $book_manager = \Drupal::service('book.manager'); // Mock a link for a new book. - $link = array('nid' => 1, 'has_children' => 0, 'original_bid' => 0, 'parent_depth_limit' => 8, 'pid' => 0, 'weight' => 0, 'bid' => 1); + $link = ['nid' => 1, 'has_children' => 0, 'original_bid' => 0, 'parent_depth_limit' => 8, 'pid' => 0, 'weight' => 0, 'bid' => 1]; $new = TRUE; // Save the link. diff --git a/core/modules/book/src/Tests/Views/BookRelationshipTest.php b/core/modules/book/src/Tests/Views/BookRelationshipTest.php index 2302e8b..c1f8728 100644 --- a/core/modules/book/src/Tests/Views/BookRelationshipTest.php +++ b/core/modules/book/src/Tests/Views/BookRelationshipTest.php @@ -19,14 +19,14 @@ class BookRelationshipTest extends ViewTestBase { * * @var array */ - public static $testViews = array('test_book_view'); + public static $testViews = ['test_book_view']; /** * Modules to install. * * @var array */ - public static $modules = array('book_test_views', 'book', 'views'); + public static $modules = ['book_test_views', 'book', 'views']; /** * A book node. @@ -50,14 +50,14 @@ protected function setUp() { // Create users. $this->bookAuthor = $this->drupalCreateUser( - array( + [ 'create new books', 'create book content', 'edit own book content', 'add content to books', - ) + ] ); - ViewTestData::createTestViews(get_class($this), array('book_test_views')); + ViewTestData::createTestViews(get_class($this), ['book_test_views']); } /** @@ -70,7 +70,7 @@ protected function createBook() { $this->book = $this->createBookNode('new'); $book = $this->book; - $nodes = array(); + $nodes = []; // Node 0. $nodes[] = $this->createBookNode($book->id()); // Node 1. @@ -110,7 +110,7 @@ protected function createBookNode($book_nid, $parent = NULL) { // Used to ensure that when sorted nodes stay in same order. static $number = 0; - $edit = array(); + $edit = []; $edit['title[0][value]'] = $number . ' - SimpleTest test node ' . $this->randomMachineName(10); $edit['body[0][value]'] = 'SimpleTest test body ' . $this->randomMachineName(32) . ' ' . $this->randomMachineName(32); $edit['book[bid]'] = $book_nid; diff --git a/core/modules/book/tests/src/Kernel/BookUninstallTest.php b/core/modules/book/tests/src/Kernel/BookUninstallTest.php index bcd0812..9430991 100644 --- a/core/modules/book/tests/src/Kernel/BookUninstallTest.php +++ b/core/modules/book/tests/src/Kernel/BookUninstallTest.php @@ -27,11 +27,11 @@ protected function setUp() { parent::setUp(); $this->installEntitySchema('user'); $this->installEntitySchema('node'); - $this->installSchema('book', array('book')); - $this->installSchema('node', array('node_access')); - $this->installConfig(array('node', 'book', 'field')); + $this->installSchema('book', ['book']); + $this->installSchema('node', ['node_access']); + $this->installConfig(['node', 'book', 'field']); // For uninstall to work. - $this->installSchema('user', array('users_data')); + $this->installSchema('user', ['users_data']); } /** @@ -42,17 +42,17 @@ public function testBookUninstall() { $validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']); $this->assertEqual([], $validation_reasons, 'The book module is not required.'); - $content_type = NodeType::create(array( + $content_type = NodeType::create([ 'type' => $this->randomMachineName(), 'name' => $this->randomString(), - )); + ]); $content_type->save(); $book_config = $this->config('book.settings'); $allowed_types = $book_config->get('allowed_types'); $allowed_types[] = $content_type->id(); $book_config->set('allowed_types', $allowed_types)->save(); - $node = Node::create(array('title' => $this->randomString(), 'type' => $content_type->id())); + $node = Node::create(['title' => $this->randomString(), 'type' => $content_type->id()]); $node->book['bid'] = 'new'; $node->save(); @@ -60,7 +60,7 @@ public function testBookUninstall() { $validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']); $this->assertEqual(['To uninstall Book, delete all content that is part of a book'], $validation_reasons['book']); - $book_node = Node::create(array('title' => $this->randomString(), 'type' => 'book')); + $book_node = Node::create(['title' => $this->randomString(), 'type' => 'book']); $book_node->book['bid'] = FALSE; $book_node->save(); @@ -79,7 +79,7 @@ public function testBookUninstall() { $module_data = _system_rebuild_module_data(); $this->assertFalse(isset($module_data['book']->info['required']), 'The book module is not required.'); - $node = Node::create(array('title' => $this->randomString(), 'type' => $content_type->id())); + $node = Node::create(['title' => $this->randomString(), 'type' => $content_type->id()]); $node->save(); // One node exists but is not part of a book therefore the book module is // not required. @@ -87,7 +87,7 @@ public function testBookUninstall() { $this->assertEqual([], $validation_reasons, 'The book module is not required.'); // Uninstall the Book module and check the node type is deleted. - \Drupal::service('module_installer')->uninstall(array('book')); + \Drupal::service('module_installer')->uninstall(['book']); $this->assertNull(NodeType::load('book'), "The book node type does not exist."); } diff --git a/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookConfigsTest.php b/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookConfigsTest.php index a372e3a..f6fdc55 100644 --- a/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookConfigsTest.php +++ b/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookConfigsTest.php @@ -34,7 +34,7 @@ public function testBookSettings() { $config = $this->config('book.settings'); $this->assertIdentical('book', $config->get('child_type')); $this->assertIdentical('all pages', $config->get('block.navigation.mode')); - $this->assertIdentical(array('book'), $config->get('allowed_types')); + $this->assertIdentical(['book'], $config->get('allowed_types')); $this->assertConfigSchema(\Drupal::service('config.typed'), 'book.settings', $config->get()); } diff --git a/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookTest.php b/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookTest.php index ffcc3fe..f6f1730 100644 --- a/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookTest.php +++ b/core/modules/book/tests/src/Kernel/Migrate/d6/MigrateBookTest.php @@ -32,7 +32,7 @@ protected function setUp() { * Tests the Drupal 6 book structure to Drupal 8 migration. */ public function testBook() { - $nodes = Node::loadMultiple(array(4, 5, 6, 7, 8)); + $nodes = Node::loadMultiple([4, 5, 6, 7, 8]); $this->assertIdentical('4', $nodes[4]->book['bid']); $this->assertIdentical('0', $nodes[4]->book['pid']); @@ -53,8 +53,8 @@ public function testBook() { $this->assertIdentical('5', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['link']['nid']); $this->assertIdentical('6', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['link']['nid']); $this->assertIdentical('7', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['link']['nid']); - $this->assertIdentical(array(), $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['below']); - $this->assertIdentical(array(), $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['below']); + $this->assertIdentical([], $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['below']); + $this->assertIdentical([], $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['below']); } } diff --git a/core/modules/book/tests/src/Unit/BookManagerTest.php b/core/modules/book/tests/src/Unit/BookManagerTest.php index fdecbbe..abd6702 100644 --- a/core/modules/book/tests/src/Unit/BookManagerTest.php +++ b/core/modules/book/tests/src/Unit/BookManagerTest.php @@ -59,7 +59,7 @@ class BookManagerTest extends UnitTestCase { protected function setUp() { $this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $this->translation = $this->getStringTranslationStub(); - $this->configFactory = $this->getConfigFactoryStub(array()); + $this->configFactory = $this->getConfigFactoryStub([]); $this->bookOutlineStorage = $this->getMock('Drupal\book\BookOutlineStorageInterface'); $this->renderer = $this->getMock('\Drupal\Core\Render\RendererInterface'); $this->bookManager = new BookManager($this->entityManager, $this->translation, $this->configFactory, $this->bookOutlineStorage, $this->renderer); @@ -81,7 +81,7 @@ public function testGetBookParents($book, $parent, $expected) { * The test data. */ public function providerTestGetBookParents() { - $empty = array( + $empty = [ 'p1' => 0, 'p2' => 0, 'p3' => 0, @@ -91,27 +91,27 @@ public function providerTestGetBookParents() { 'p7' => 0, 'p8' => 0, 'p9' => 0, - ); - return array( + ]; + return [ // Provides a book without an existing parent. - array( - array('pid' => 0, 'nid' => 12), - array(), - array('depth' => 1, 'p1' => 12) + $empty, - ), + [ + ['pid' => 0, 'nid' => 12], + [], + ['depth' => 1, 'p1' => 12] + $empty, + ], // Provides a book with an existing parent. - array( - array('pid' => 11, 'nid' => 12), - array('nid' => 11, 'depth' => 1, 'p1' => 11,), - array('depth' => 2, 'p1' => 11, 'p2' => 12) + $empty, - ), + [ + ['pid' => 11, 'nid' => 12], + ['nid' => 11, 'depth' => 1, 'p1' => 11, ], + ['depth' => 2, 'p1' => 11, 'p2' => 12] + $empty, + ], // Provides a book with two existing parents. - array( - array('pid' => 11, 'nid' => 12), - array('nid' => 11, 'depth' => 2, 'p1' => 10, 'p2' => 11), - array('depth' => 3, 'p1' => 10, 'p2' => 11, 'p3' => 12) + $empty, - ), - ); + [ + ['pid' => 11, 'nid' => 12], + ['nid' => 11, 'depth' => 2, 'p1' => 10, 'p2' => 11], + ['depth' => 3, 'p1' => 10, 'p2' => 11, 'p3' => 12] + $empty, + ], + ]; } } diff --git a/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php b/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php index 927241f..682a031 100644 --- a/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php +++ b/core/modules/book/tests/src/Unit/Menu/BookLocalTasksTest.php @@ -12,10 +12,10 @@ class BookLocalTasksTest extends LocalTaskIntegrationTestBase { protected function setUp() { - $this->directoryList = array( + $this->directoryList = [ 'book' => 'core/modules/book', 'node' => 'core/modules/node', - ); + ]; parent::setUp(); } @@ -26,19 +26,19 @@ protected function setUp() { */ public function testBookAdminLocalTasks($route) { - $this->assertLocalTasks($route, array( - 0 => array('book.admin', 'book.settings'), - )); + $this->assertLocalTasks($route, [ + 0 => ['book.admin', 'book.settings'], + ]); } /** * Provides a list of routes to test. */ public function getBookAdminRoutes() { - return array( - array('book.admin'), - array('book.settings'), - ); + return [ + ['book.admin'], + ['book.settings'], + ]; } /** @@ -47,19 +47,19 @@ public function getBookAdminRoutes() { * @dataProvider getBookNodeRoutes */ public function testBookNodeLocalTasks($route) { - $this->assertLocalTasks($route, array( - 0 => array('entity.node.book_outline_form', 'entity.node.canonical', 'entity.node.edit_form', 'entity.node.delete_form', 'entity.node.version_history',), - )); + $this->assertLocalTasks($route, [ + 0 => ['entity.node.book_outline_form', 'entity.node.canonical', 'entity.node.edit_form', 'entity.node.delete_form', 'entity.node.version_history', ], + ]); } /** * Provides a list of routes to test. */ public function getBookNodeRoutes() { - return array( - array('entity.node.canonical'), - array('entity.node.book_outline_form'), - ); + return [ + ['entity.node.canonical'], + ['entity.node.book_outline_form'], + ]; } } diff --git a/core/modules/book/tests/src/Unit/Plugin/migrate/source/d6/BookTest.php b/core/modules/book/tests/src/Unit/Plugin/migrate/source/d6/BookTest.php index 6433cad..2c8b50d 100644 --- a/core/modules/book/tests/src/Unit/Plugin/migrate/source/d6/BookTest.php +++ b/core/modules/book/tests/src/Unit/Plugin/migrate/source/d6/BookTest.php @@ -13,15 +13,15 @@ class BookTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = Book::class; - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'd6_book', - ), - ); + ], + ]; - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'nid' => '4', 'bid' => '4', 'mlid' => '1', @@ -36,22 +36,22 @@ class BookTest extends MigrateSqlSourceTestCase { 'p7' => '0', 'p8' => '0', 'p9' => '0', - ), - ); + ], + ]; /** * {@inheritdoc} */ protected function setUp() { - $this->databaseContents['book'] = array( - array( + $this->databaseContents['book'] = [ + [ 'mlid' => '1', 'nid' => '4', 'bid' => '4', - ), - ); - $this->databaseContents['menu_links'] = array( - array( + ], + ]; + $this->databaseContents['menu_links'] = [ + [ 'menu_name' => 'book-toc-1', 'mlid' => '1', 'plid' => '0', @@ -77,8 +77,8 @@ protected function setUp() { 'p8' => '0', 'p9' => '0', 'updated' => '0', - ), - ); + ], + ]; parent::setUp(); } diff --git a/core/modules/breakpoint/breakpoint.module b/core/modules/breakpoint/breakpoint.module index 103edd9..a0fd468 100644 --- a/core/modules/breakpoint/breakpoint.module +++ b/core/modules/breakpoint/breakpoint.module @@ -15,13 +15,13 @@ function breakpoint_help($route_name, RouteMatchInterface $route_match) { case 'help.page.breakpoint': $output = ''; $output .= '

        ' . t('About') . '

        '; - $output .= '

        ' . t('The Breakpoint module keeps track of the height, width, and resolution breakpoints where a responsive design needs to change in order to respond to different devices being used to view the site. This module does not have a user interface. For more information, see the online documentation for the Breakpoint module.', array(':docs' => 'https://www.drupal.org/documentation/modules/breakpoint')) . '

        '; + $output .= '

        ' . t('The Breakpoint module keeps track of the height, width, and resolution breakpoints where a responsive design needs to change in order to respond to different devices being used to view the site. This module does not have a user interface. For more information, see the online documentation for the Breakpoint module.', [':docs' => 'https://www.drupal.org/documentation/modules/breakpoint']) . '

        '; $output .= '

        ' . t('Terminology') . '

        '; $output .= '
        '; $output .= '
        ' . t('Breakpoint') . '
        '; $output .= '
        ' . t('A breakpoint separates the height or width of viewports (screens, printers, and other media output types) into steps. For instance, a width breakpoint of 40em creates two steps: one for widths up to 40em and one for widths above 40em. Breakpoints can be used to define when layouts should shift from one form to another, when images should be resized, and other changes that need to respond to changes in viewport height or width.') . '
        '; $output .= '
        ' . t('Media query') . '
        '; - $output .= '
        ' . t('Media queries are a formal way to encode breakpoints. For instance, a width breakpoint at 40em would be written as the media query "(min-width: 40em)". Breakpoints are really just media queries with some additional meta-data, such as a name and multiplier information.', array(':w3' => 'http://www.w3.org/TR/css3-mediaqueries/')) . '
        '; + $output .= '
        ' . t('Media queries are a formal way to encode breakpoints. For instance, a width breakpoint at 40em would be written as the media query "(min-width: 40em)". Breakpoints are really just media queries with some additional meta-data, such as a name and multiplier information.', [':w3' => 'http://www.w3.org/TR/css3-mediaqueries/']) . '
        '; $output .= '
        ' . t('Resolution multiplier') . '
        '; $output .= '
        ' . t('Resolution multipliers are a measure of the viewport\'s device resolution, defined to be the ratio between the physical pixel size of the active device and the device-independent pixel size. The Breakpoint module defines multipliers of 1, 1.5, and 2; when defining breakpoints, modules and themes can define which multipliers apply to each breakpoint.') . '
        '; $output .= '
        ' . t('Breakpoint group') . '
        '; diff --git a/core/modules/breakpoint/src/Breakpoint.php b/core/modules/breakpoint/src/Breakpoint.php index 0c51e63..0928d55 100644 --- a/core/modules/breakpoint/src/Breakpoint.php +++ b/core/modules/breakpoint/src/Breakpoint.php @@ -16,7 +16,7 @@ class Breakpoint extends PluginBase implements BreakpointInterface { * {@inheritdoc} */ public function getLabel() { - return $this->t($this->pluginDefinition['label'], array(), array('context' => 'breakpoint')); + return $this->t($this->pluginDefinition['label'], [], ['context' => 'breakpoint']); } /** diff --git a/core/modules/breakpoint/src/BreakpointManager.php b/core/modules/breakpoint/src/BreakpointManager.php index 693ffa9..30caf27 100644 --- a/core/modules/breakpoint/src/BreakpointManager.php +++ b/core/modules/breakpoint/src/BreakpointManager.php @@ -50,7 +50,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage /** * {@inheritdoc} */ - protected $defaults = array( + protected $defaults = [ // Human readable label for breakpoint. 'label' => '', // The media query for the breakpoint. @@ -58,14 +58,14 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage // Weight used for ordering breakpoints. 'weight' => 0, // Breakpoint multipliers. - 'multipliers' => array(), + 'multipliers' => [], // The breakpoint group. 'group' => '', // Default class for breakpoint implementations. 'class' => 'Drupal\breakpoint\Breakpoint', // The plugin id. Set by the plugin system based on the top-level YAML key. 'id' => '', - ); + ]; /** * The theme handler. @@ -86,7 +86,7 @@ class BreakpointManager extends DefaultPluginManager implements BreakpointManage * * @var array */ - protected $instances = array(); + protected $instances = []; /** * Constructs a new BreakpointManager instance. @@ -106,7 +106,7 @@ public function __construct(ModuleHandlerInterface $module_handler, ThemeHandler $this->themeHandler = $theme_handler; $this->setStringTranslation($string_translation); $this->alterInfo('breakpoints'); - $this->setCacheBackend($cache_backend, 'breakpoints', array('breakpoints')); + $this->setCacheBackend($cache_backend, 'breakpoints', ['breakpoints']); } /** @@ -153,19 +153,19 @@ public function getBreakpointsByGroup($group) { $this->breakpointsByGroup[$group] = $cache->data; } else { - $breakpoints = array(); + $breakpoints = []; foreach ($this->getDefinitions() as $plugin_id => $plugin_definition) { if ($plugin_definition['group'] == $group) { $breakpoints[$plugin_id] = $plugin_definition; } } - uasort($breakpoints, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); - $this->cacheBackend->set($this->cacheKey . ':' . $group, $breakpoints, Cache::PERMANENT, array('breakpoints')); + uasort($breakpoints, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']); + $this->cacheBackend->set($this->cacheKey . ':' . $group, $breakpoints, Cache::PERMANENT, ['breakpoints']); $this->breakpointsByGroup[$group] = $breakpoints; } } - $instances = array(); + $instances = []; foreach ($this->breakpointsByGroup[$group] as $plugin_id => $definition) { if (!isset($this->instances[$plugin_id])) { $this->instances[$plugin_id] = $this->createInstance($plugin_id); @@ -184,16 +184,16 @@ public function getGroups() { $groups = $cache->data; } else { - $groups = array(); + $groups = []; foreach ($this->getDefinitions() as $plugin_definition) { if (!isset($groups[$plugin_definition['group']])) { $groups[$plugin_definition['group']] = $plugin_definition['group']; } } - $this->cacheBackend->set($this->cacheKey . '::groups', $groups, Cache::PERMANENT, array('breakpoints')); + $this->cacheBackend->set($this->cacheKey . '::groups', $groups, Cache::PERMANENT, ['breakpoints']); } // Get the labels. This is not cacheable due to translation. - $group_labels = array(); + $group_labels = []; foreach ($groups as $group) { $group_labels[$group] = $this->getGroupLabel($group); } @@ -205,7 +205,7 @@ public function getGroups() { * {@inheritdoc} */ public function getGroupProviders($group) { - $providers = array(); + $providers = []; $breakpoints = $this->getBreakpointsByGroup($group); foreach ($breakpoints as $breakpoint) { $provider = $breakpoint->getProvider(); @@ -229,7 +229,7 @@ public function getGroupProviders($group) { public function clearCachedDefinitions() { parent::clearCachedDefinitions(); $this->breakpointsByGroup = NULL; - $this->instances = array(); + $this->instances = []; } /** @@ -251,7 +251,7 @@ protected function getGroupLabel($group) { } else { // Custom group label that should be translatable. - $label = $this->t($group, array(), array('context' => 'breakpoint')); + $label = $this->t($group, [], ['context' => 'breakpoint']); } return $label; } diff --git a/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php b/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php index 7683ea1..dc81757 100644 --- a/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php +++ b/core/modules/breakpoint/tests/src/Kernel/BreakpointDiscoveryTest.php @@ -16,11 +16,11 @@ class BreakpointDiscoveryTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'breakpoint', 'breakpoint_module_test'); + public static $modules = ['system', 'breakpoint', 'breakpoint_module_test']; protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(array('breakpoint_theme_test')); + \Drupal::service('theme_handler')->install(['breakpoint_theme_test']); } /** @@ -28,56 +28,56 @@ protected function setUp() { */ public function testThemeBreakpoints() { // Verify the breakpoint group for breakpoint_theme_test was created. - $expected_breakpoints = array( - 'breakpoint_theme_test.mobile' => array( + $expected_breakpoints = [ + 'breakpoint_theme_test.mobile' => [ 'label' => 'mobile', 'mediaQuery' => '(min-width: 0px)', 'weight' => 0, - 'multipliers' => array( + 'multipliers' => [ '1x', - ), + ], 'provider' => 'breakpoint_theme_test', 'id' => 'breakpoint_theme_test.mobile', 'group' => 'breakpoint_theme_test', 'class' => 'Drupal\\breakpoint\\Breakpoint', - ), - 'breakpoint_theme_test.narrow' => array( + ], + 'breakpoint_theme_test.narrow' => [ 'label' => 'narrow', 'mediaQuery' => '(min-width: 560px)', 'weight' => 1, - 'multipliers' => array( + 'multipliers' => [ '1x', - ), + ], 'provider' => 'breakpoint_theme_test', 'id' => 'breakpoint_theme_test.narrow', 'group' => 'breakpoint_theme_test', 'class' => 'Drupal\\breakpoint\\Breakpoint', - ), - 'breakpoint_theme_test.wide' => array( + ], + 'breakpoint_theme_test.wide' => [ 'label' => 'wide', 'mediaQuery' => '(min-width: 851px)', 'weight' => 2, - 'multipliers' => array( + 'multipliers' => [ '1x', - ), + ], 'provider' => 'breakpoint_theme_test', 'id' => 'breakpoint_theme_test.wide', 'group' => 'breakpoint_theme_test', 'class' => 'Drupal\\breakpoint\\Breakpoint', - ), - 'breakpoint_theme_test.tv' => array( + ], + 'breakpoint_theme_test.tv' => [ 'label' => 'tv', 'mediaQuery' => 'only screen and (min-width: 1220px)', 'weight' => 3, - 'multipliers' => array( + 'multipliers' => [ '1x', - ), + ], 'provider' => 'breakpoint_theme_test', 'id' => 'breakpoint_theme_test.tv', 'group' => 'breakpoint_theme_test', 'class' => 'Drupal\\breakpoint\\Breakpoint', - ), - ); + ], + ]; $breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('breakpoint_theme_test'); foreach ($expected_breakpoints as $id => $expected_breakpoint) { @@ -93,46 +93,46 @@ public function testThemeBreakpoints() { */ public function testCustomBreakpointGroups() { // Verify the breakpoint group for breakpoint_theme_test.group2 was created. - $expected_breakpoints = array( - 'breakpoint_theme_test.group2.narrow' => array( + $expected_breakpoints = [ + 'breakpoint_theme_test.group2.narrow' => [ 'label' => 'narrow', 'mediaQuery' => '(min-width: 560px)', 'weight' => 0, - 'multipliers' => array( + 'multipliers' => [ '1x', '2x', - ), + ], 'provider' => 'breakpoint_theme_test', 'id' => 'breakpoint_theme_test.group2.narrow', 'group' => 'breakpoint_theme_test.group2', 'class' => 'Drupal\\breakpoint\\Breakpoint', - ), - 'breakpoint_theme_test.group2.wide' => array( + ], + 'breakpoint_theme_test.group2.wide' => [ 'label' => 'wide', 'mediaQuery' => '(min-width: 851px)', 'weight' => 1, - 'multipliers' => array( + 'multipliers' => [ '1x', '2x', - ), + ], 'provider' => 'breakpoint_theme_test', 'id' => 'breakpoint_theme_test.group2.wide', 'group' => 'breakpoint_theme_test.group2', 'class' => 'Drupal\\breakpoint\\Breakpoint', - ), - 'breakpoint_module_test.breakpoint_theme_test.group2.tv' => array( + ], + 'breakpoint_module_test.breakpoint_theme_test.group2.tv' => [ 'label' => 'tv', 'mediaQuery' => '(min-width: 6000px)', 'weight' => 2, - 'multipliers' => array( + 'multipliers' => [ '1x', - ), + ], 'provider' => 'breakpoint_module_test', 'id' => 'breakpoint_module_test.breakpoint_theme_test.group2.tv', 'group' => 'breakpoint_theme_test.group2', 'class' => 'Drupal\\breakpoint\\Breakpoint', - ), - ); + ], + ]; $breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('breakpoint_theme_test.group2'); foreach ($expected_breakpoints as $id => $expected_breakpoint) { @@ -144,33 +144,33 @@ public function testCustomBreakpointGroups() { * Test the breakpoint group created for a module. */ public function testModuleBreakpoints() { - $expected_breakpoints = array( - 'breakpoint_module_test.mobile' => array( + $expected_breakpoints = [ + 'breakpoint_module_test.mobile' => [ 'label' => 'mobile', 'mediaQuery' => '(min-width: 0px)', 'weight' => 0, - 'multipliers' => array( + 'multipliers' => [ '1x', - ), + ], 'provider' => 'breakpoint_module_test', 'id' => 'breakpoint_module_test.mobile', 'group' => 'breakpoint_module_test', 'class' => 'Drupal\\breakpoint\\Breakpoint', - ), - 'breakpoint_module_test.standard' => array( + ], + 'breakpoint_module_test.standard' => [ 'label' => 'standard', 'mediaQuery' => '(min-width: 560px)', 'weight' => 1, - 'multipliers' => array( + 'multipliers' => [ '1x', '2x', - ), + ], 'provider' => 'breakpoint_module_test', 'id' => 'breakpoint_module_test.standard', 'group' => 'breakpoint_module_test', 'class' => 'Drupal\\breakpoint\\Breakpoint', - ), - ); + ], + ]; $breakpoints = \Drupal::service('breakpoint.manager')->getBreakpointsByGroup('breakpoint_module_test'); $this->assertEqual(array_keys($expected_breakpoints), array_keys($breakpoints)); @@ -180,20 +180,20 @@ public function testModuleBreakpoints() { * Test the collection of breakpoint groups. */ public function testBreakpointGroups() { - $expected = array( + $expected = [ 'bartik' => 'Bartik', 'breakpoint_module_test' => 'Breakpoint test module', 'breakpoint_theme_test' => 'Breakpoint test theme', 'breakpoint_theme_test.group2' => 'breakpoint_theme_test.group2', - ); + ]; $breakpoint_groups = \Drupal::service('breakpoint.manager')->getGroups(); // Ensure the order is as expected. Should be sorted by label. $this->assertIdentical($expected, $this->castSafeStrings($breakpoint_groups)); - $expected = array( + $expected = [ 'breakpoint_theme_test' => 'theme', 'breakpoint_module_test' => 'module', - ); + ]; $breakpoint_group_providers = \Drupal::service('breakpoint.manager')->getGroupProviders('breakpoint_theme_test.group2'); $this->assertEqual($expected, $breakpoint_group_providers); } diff --git a/core/modules/breakpoint/tests/src/Unit/BreakpointTest.php b/core/modules/breakpoint/tests/src/Unit/BreakpointTest.php index bdd5cd9..4b8fd88 100644 --- a/core/modules/breakpoint/tests/src/Unit/BreakpointTest.php +++ b/core/modules/breakpoint/tests/src/Unit/BreakpointTest.php @@ -24,9 +24,9 @@ class BreakpointTest extends UnitTestCase { * * @var array */ - protected $pluginDefinition = array( + protected $pluginDefinition = [ 'id' => 'breakpoint', - ); + ]; /** * The breakpoint under test. @@ -52,7 +52,7 @@ protected function setUp() { * Sets up the breakpoint defaults. */ protected function setupBreakpoint() { - $this->breakpoint = new Breakpoint(array(), $this->pluginId, $this->pluginDefinition); + $this->breakpoint = new Breakpoint([], $this->pluginId, $this->pluginDefinition); $this->breakpoint->setStringTranslation($this->stringTranslation); } @@ -62,7 +62,7 @@ protected function setupBreakpoint() { public function testGetLabel() { $this->pluginDefinition['label'] = 'Test label'; $this->setupBreakpoint(); - $this->assertEquals(new TranslatableMarkup('Test label', array(), array('context' => 'breakpoint'), $this->stringTranslation), $this->breakpoint->getLabel()); + $this->assertEquals(new TranslatableMarkup('Test label', [], ['context' => 'breakpoint'], $this->stringTranslation), $this->breakpoint->getLabel()); } /** @@ -88,9 +88,9 @@ public function testGetMediaQuery() { * @covers ::getMultipliers */ public function testGetMultipliers() { - $this->pluginDefinition['multipliers'] = array('1x', '2x'); + $this->pluginDefinition['multipliers'] = ['1x', '2x']; $this->setupBreakpoint(); - $this->assertSame(array('1x', '2x'), $this->breakpoint->getMultipliers()); + $this->assertSame(['1x', '2x'], $this->breakpoint->getMultipliers()); } /** diff --git a/core/modules/ckeditor/ckeditor.admin.inc b/core/modules/ckeditor/ckeditor.admin.inc index 14b2fd7..8a8f68c 100644 --- a/core/modules/ckeditor/ckeditor.admin.inc +++ b/core/modules/ckeditor/ckeditor.admin.inc @@ -29,8 +29,8 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) { // Create lists of active and disabled buttons. $editor = $variables['editor']; $plugins = $variables['plugins']; - $buttons = array(); - $multiple_buttons = array(); + $buttons = []; + $multiple_buttons = []; foreach ($plugins as $plugin_buttons) { foreach ($plugin_buttons as $button_name => $button) { $button['name'] = $button_name; @@ -40,11 +40,11 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) { $buttons[$button_name] = $button; } } - $button_groups = array(); - $active_buttons = array(); + $button_groups = []; + $active_buttons = []; $settings = $editor->getSettings(); foreach ($settings['toolbar']['rows'] as $row_number => $row) { - $button_groups[$row_number] = array(); + $button_groups[$row_number] = []; foreach ($row as $group) { foreach ($group['items'] as $button_name) { if (isset($buttons[$button_name])) { @@ -75,31 +75,31 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) { $value = $button['image_alternative']; } elseif (isset($button['image']) || isset($button['image' . $rtl])) { - $value = array( + $value = [ '#theme' => 'image', '#uri' => isset($button['image' . $rtl]) ? $button['image' . $rtl] : $button['image'], '#title' => $button['label'], '#prefix' => '', '#suffix' => '', - ); + ]; } else { $value = '?'; } // Build the button attributes. - $attributes = array( + $attributes = [ 'data-drupal-ckeditor-button-name' => $button['name'], - ); + ]; if (!empty($button['attributes'])) { $attributes = array_merge($attributes, $button['attributes']); } // Build the button item. - $button_item = array( + $button_item = [ 'value' => $value, 'attributes' => new Attribute($attributes), - ); + ]; // If this button has group information, add it to the attributes. if (!empty($button['group'])) { $button_item['group'] = $button['group']; @@ -114,14 +114,14 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) { }; // Assemble list of disabled buttons (which are always a single row). - $variables['active_buttons'] = array(); + $variables['active_buttons'] = []; foreach ($active_buttons as $row_number => $button_row) { foreach ($button_groups[$row_number] as $group_name) { $group_name = (string) $group_name; - $variables['active_buttons'][$row_number][$group_name] = array( + $variables['active_buttons'][$row_number][$group_name] = [ 'group_name_class' => Html::getClass($group_name), - 'buttons' => array(), - ); + 'buttons' => [], + ]; $buttons = array_filter($button_row, function ($button) use ($group_name) { return (string) $button['group'] === $group_name; }); @@ -131,12 +131,12 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) { } } // Assemble list of disabled buttons (which are always a single row). - $variables['disabled_buttons'] = array(); + $variables['disabled_buttons'] = []; foreach ($disabled_buttons as $button) { $variables['disabled_buttons'][] = $build_button_item($button, $rtl); } // Assemble list of multiple buttons that may be added multiple times. - $variables['multiple_buttons'] = array(); + $variables['multiple_buttons'] = []; foreach ($multiple_buttons as $button) { $variables['multiple_buttons'][] = $build_button_item($button, $rtl); } diff --git a/core/modules/ckeditor/ckeditor.module b/core/modules/ckeditor/ckeditor.module index 115afe2..7905253 100644 --- a/core/modules/ckeditor/ckeditor.module +++ b/core/modules/ckeditor/ckeditor.module @@ -17,21 +17,21 @@ function ckeditor_help($route_name, RouteMatchInterface $route_match) { case 'help.page.ckeditor': $output = ''; $output .= '

        ' . t('About') . '

        '; - $output .= '

        ' . t('The CKEditor module provides a highly-accessible, highly-usable visual text editor and adds a toolbar to text fields. Users can use buttons to format content and to create semantically correct and valid HTML. The CKEditor module uses the framework provided by the Text Editor module. It requires JavaScript to be enabled in the browser. For more information, see the online documentation for the CKEditor module and the CKEditor website.', array( ':doc_url' => 'https://www.drupal.org/documentation/modules/ckeditor', ':cke_url' => 'http://ckeditor.com', ':text_editor' => \Drupal::url('help.page', array('name' => 'editor')))) . '

        '; + $output .= '

        ' . t('The CKEditor module provides a highly-accessible, highly-usable visual text editor and adds a toolbar to text fields. Users can use buttons to format content and to create semantically correct and valid HTML. The CKEditor module uses the framework provided by the Text Editor module. It requires JavaScript to be enabled in the browser. For more information, see the online documentation for the CKEditor module and the CKEditor website.', [ ':doc_url' => 'https://www.drupal.org/documentation/modules/ckeditor', ':cke_url' => 'http://ckeditor.com', ':text_editor' => \Drupal::url('help.page', ['name' => 'editor'])]) . '

        '; $output .= '

        ' . t('Uses') . '

        '; $output .= '
        '; $output .= '
        ' . t('Enabling CKEditor for individual text formats') . '
        '; - $output .= '
        ' . t('CKEditor has to be enabled and configured separately for individual text formats from the Text formats and editors page because the filter settings for each text format can be different. For more information, see the Text Editor help page and Filter help page.', array(':formats' => \Drupal::url('filter.admin_overview'), ':text_editor' => \Drupal::url('help.page', array('name' => 'editor')), ':filter' => \Drupal::url('help.page', array('name' => 'filter')))) . '
        '; + $output .= '
        ' . t('CKEditor has to be enabled and configured separately for individual text formats from the Text formats and editors page because the filter settings for each text format can be different. For more information, see the Text Editor help page and Filter help page.', [':formats' => \Drupal::url('filter.admin_overview'), ':text_editor' => \Drupal::url('help.page', ['name' => 'editor']), ':filter' => \Drupal::url('help.page', ['name' => 'filter'])]) . '
        '; $output .= '
        ' . t('Configuring the toolbar') . '
        '; $output .= '
        ' . t('When CKEditor is chosen from the Text editor drop-down menu, its toolbar configuration is displayed. You can add and remove buttons from the Active toolbar by dragging and dropping them, and additional rows can be added to organize the buttons.') . '
        '; $output .= '
        ' . t('Formatting content') . '
        '; - $output .= '
        ' . t('CKEditor only allow users to format content in accordance with the filter configuration of the specific text format. If a text format excludes certain HTML tags, the corresponding toolbar buttons are not displayed to users when they edit a text field in this format. For more information see the Filter help page.', array(':filter' => \Drupal::url('help.page', array('name' => 'filter')))) . '
        '; + $output .= '
        ' . t('CKEditor only allow users to format content in accordance with the filter configuration of the specific text format. If a text format excludes certain HTML tags, the corresponding toolbar buttons are not displayed to users when they edit a text field in this format. For more information see the Filter help page.', [':filter' => \Drupal::url('help.page', ['name' => 'filter'])]) . '
        '; $output .= '
        ' . t('Toggling between formatted text and HTML source') . '
        '; $output .= '
        ' . t('If the Source button is available in the toolbar, users can click this button to disable the visual editor and edit the HTML source directly. After toggling back, the visual editor uses the allowed HTML tags to format the text — independent of whether buttons for these tags are available in the toolbar. If the text format is set to limit the use of HTML tags, then all excluded tags will be stripped out of the HTML source when the user toggles back to the text editor.') . '
        '; $output .= '
        ' . t('Check my spelling as I type') . '
        '; $output .= '
        ' . t('By default, CKEditor is configured to leverage your browser\'s spell check capability. Make sure your browser\'s spell checker is enabled in your browser\'s settings. To access suggested corrections for misspelled words, it may be necessary to hold the Control or command (Mac) key while right-clicking the misspelling.') . '
        '; $output .= '
        ' . t('Accessibility features') . '
        '; - $output .= '
        ' . t('The built in WYSIWYG editor (CKEditor) comes with a number of accessibility features. CKEditor comes with built in keyboard shortcuts, which can be beneficial for both power users and keyboard only users.', array(':features' => 'http://docs.ckeditor.com/#!/guide/dev_a11y', ':shortcuts' => 'http://docs.ckeditor.com/#!/guide/dev_shortcuts')) . '
        '; + $output .= '
        ' . t('The built in WYSIWYG editor (CKEditor) comes with a number of accessibility features. CKEditor comes with built in keyboard shortcuts, which can be beneficial for both power users and keyboard only users.', [':features' => 'http://docs.ckeditor.com/#!/guide/dev_a11y', ':shortcuts' => 'http://docs.ckeditor.com/#!/guide/dev_shortcuts']) . '
        '; $output .= '
        ' . t('Generating accessible content') . '
        '; $output .= '
        ' . t('HTML tables can be created with both table headers as well as caption/summary elements. Alt text is required by default on images added through CKEditor (note that this can be overridden). Semantic HTML5 figure/figcaption are available to add captions to images.') . '
        '; $output .= '
        '; @@ -43,12 +43,12 @@ function ckeditor_help($route_name, RouteMatchInterface $route_match) { * Implements hook_theme(). */ function ckeditor_theme() { - return array( - 'ckeditor_settings_toolbar' => array( + return [ + 'ckeditor_settings_toolbar' => [ 'file' => 'ckeditor.admin.inc', - 'variables' => array('editor' => NULL, 'plugins' => NULL), - ), - ); + 'variables' => ['editor' => NULL, 'plugins' => NULL], + ], + ]; } /** @@ -79,7 +79,7 @@ function ckeditor_ckeditor_css_alter(array &$css, Editor $editor) { * @endcode */ function _ckeditor_theme_css($theme = NULL) { - $css = array(); + $css = []; if (!isset($theme)) { $theme = \Drupal::config('system.theme')->get('default'); } diff --git a/core/modules/ckeditor/src/CKEditorPluginBase.php b/core/modules/ckeditor/src/CKEditorPluginBase.php index 2fb4798..99f2663 100644 --- a/core/modules/ckeditor/src/CKEditorPluginBase.php +++ b/core/modules/ckeditor/src/CKEditorPluginBase.php @@ -41,14 +41,14 @@ function isInternal() { * {@inheritdoc} */ function getDependencies(Editor $editor) { - return array(); + return []; } /** * {@inheritdoc} */ function getLibraries(Editor $editor) { - return array(); + return []; } } diff --git a/core/modules/ckeditor/src/CKEditorPluginManager.php b/core/modules/ckeditor/src/CKEditorPluginManager.php index dd3315a..735cfa6 100644 --- a/core/modules/ckeditor/src/CKEditorPluginManager.php +++ b/core/modules/ckeditor/src/CKEditorPluginManager.php @@ -68,8 +68,8 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac public function getEnabledPluginFiles(Editor $editor, $include_internal_plugins = FALSE) { $plugins = array_keys($this->getDefinitions()); $toolbar_buttons = $this->getEnabledButtons($editor); - $enabled_plugins = array(); - $additional_plugins = array(); + $enabled_plugins = []; + $additional_plugins = []; foreach ($plugins as $plugin_id) { $plugin = $this->createInstance($plugin_id); @@ -139,7 +139,7 @@ public static function getEnabledButtons(Editor $editor) { */ public function getButtons() { $plugins = array_keys($this->getDefinitions()); - $buttons_plugins = array(); + $buttons_plugins = []; foreach ($plugins as $plugin_id) { $plugin = $this->createInstance($plugin_id); @@ -167,16 +167,16 @@ public function injectPluginSettingsForm(array &$form, FormStateInterface $form_ foreach (array_keys($definitions) as $plugin_id) { $plugin = $this->createInstance($plugin_id); if ($plugin instanceof CKEditorPluginConfigurableInterface) { - $plugin_settings_form = array(); - $form['plugins'][$plugin_id] = array( + $plugin_settings_form = []; + $form['plugins'][$plugin_id] = [ '#type' => 'details', '#title' => $definitions[$plugin_id]['label'], '#open' => TRUE, '#group' => 'editor][settings][plugin_settings', - '#attributes' => array( + '#attributes' => [ 'data-ckeditor-plugin-id' => $plugin_id, - ), - ); + ], + ]; // Provide enough metadata for the drupal.ckeditor.admin library to // allow it to automatically show/hide the vertical tab containing the // settings for this plugin. Only do this if it's a CKEditor plugin that @@ -206,7 +206,7 @@ public function injectPluginSettingsForm(array &$form, FormStateInterface $form_ */ public function getCssFiles(Editor $editor) { $enabled_plugins = array_keys($this->getEnabledPluginFiles($editor, TRUE)); - $css_files = array(); + $css_files = []; foreach ($enabled_plugins as $plugin_id) { $plugin = $this->createInstance($plugin_id); diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php index 273f1a0..5e3f722 100644 --- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php +++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImage.php @@ -29,31 +29,31 @@ public function getFile() { * {@inheritdoc} */ public function getLibraries(Editor $editor) { - return array( + return [ 'core/drupal.ajax', - ); + ]; } /** * {@inheritdoc} */ public function getConfig(Editor $editor) { - return array( + return [ 'drupalImage_dialogTitleAdd' => t('Insert Image'), 'drupalImage_dialogTitleEdit' => t('Edit Image'), - ); + ]; } /** * {@inheritdoc} */ public function getButtons() { - return array( - 'DrupalImage' => array( + return [ + 'DrupalImage' => [ 'label' => t('Image'), 'image' => drupal_get_path('module', 'ckeditor') . '/js/plugins/drupalimage/icons/drupalimage.png', - ), - ); + ], + ]; } /** @@ -66,7 +66,7 @@ public function settingsForm(array $form, FormStateInterface $form_state, Editor $form_state->loadInclude('editor', 'admin.inc'); $form['image_upload'] = editor_image_upload_settings_form($editor); $form['image_upload']['#attached']['library'][] = 'ckeditor/drupal.ckeditor.drupalimage.admin'; - $form['image_upload']['#element_validate'][] = array($this, 'validateImageUploadSettings'); + $form['image_upload']['#element_validate'][] = [$this, 'validateImageUploadSettings']; return $form; } @@ -80,9 +80,9 @@ public function settingsForm(array $form, FormStateInterface $form_state, Editor * @see editor_image_upload_settings_form() */ function validateImageUploadSettings(array $element, FormStateInterface $form_state) { - $settings = &$form_state->getValue(array('editor', 'settings', 'plugins', 'drupalimage', 'image_upload')); + $settings = &$form_state->getValue(['editor', 'settings', 'plugins', 'drupalimage', 'image_upload']); $form_state->get('editor')->setImageUploadSettings($settings); - $form_state->unsetValue(array('editor', 'settings', 'plugins', 'drupalimage')); + $form_state->unsetValue(['editor', 'settings', 'plugins', 'drupalimage']); } } diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php index d01748a..badf595 100644 --- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php +++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php @@ -30,16 +30,16 @@ public function isInternal() { * {@inheritdoc} */ public function getDependencies(Editor $editor) { - return array(); + return []; } /** * {@inheritdoc} */ public function getLibraries(Editor $editor) { - return array( + return [ 'ckeditor/drupal.ckeditor.plugins.drupalimagecaption', - ); + ]; } /** @@ -54,24 +54,24 @@ public function getFile() { */ public function getConfig(Editor $editor) { $format = $editor->getFilterFormat(); - return array( + return [ 'image2_captionedClass' => 'caption caption-img', - 'image2_alignClasses' => array('align-left', 'align-center', 'align-right'), + 'image2_alignClasses' => ['align-left', 'align-center', 'align-right'], 'drupalImageCaption_captionPlaceholderText' => t('Enter caption here'), // Only enable those parts of DrupalImageCaption for which the // corresponding Drupal text filters are enabled. 'drupalImageCaption_captionFilterEnabled' => $format->filters('filter_caption')->status, 'drupalImageCaption_alignFilterEnabled' => $format->filters('filter_align')->status, - ); + ]; } /** * {@inheritdoc} */ public function getCssFiles(Editor $editor) { - return array( + return [ drupal_get_path('module', 'ckeditor') . '/css/plugins/drupalimagecaption/ckeditor.drupalimagecaption.css' - ); + ]; } /** diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php index 83e52e1..67efb20 100644 --- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php +++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalLink.php @@ -27,19 +27,19 @@ public function getFile() { * {@inheritdoc} */ public function getLibraries(Editor $editor) { - return array( + return [ 'core/drupal.ajax', - ); + ]; } /** * {@inheritdoc} */ public function getConfig(Editor $editor) { - return array( + return [ 'drupalLink_dialogTitleAdd' => t('Add Link'), 'drupalLink_dialogTitleEdit' => t('Edit Link'), - ); + ]; } /** @@ -47,16 +47,16 @@ public function getConfig(Editor $editor) { */ public function getButtons() { $path = drupal_get_path('module', 'ckeditor') . '/js/plugins/drupallink'; - return array( - 'DrupalLink' => array( + return [ + 'DrupalLink' => [ 'label' => t('Link'), 'image' => $path . '/icons/drupallink.png', - ), - 'DrupalUnlink' => array( + ], + 'DrupalUnlink' => [ 'label' => t('Unlink'), 'image' => $path . '/icons/drupalunlink.png', - ), - ); + ], + ]; } } diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php index 3728790..cd1bff7 100644 --- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php +++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php @@ -99,14 +99,14 @@ public function getFile() { */ public function getConfig(Editor $editor) { // Reasonable defaults that provide expected basic behavior. - $config = array( + $config = [ 'customConfig' => '', // Don't load CKEditor's config.js file. 'pasteFromWordPromptCleanup' => TRUE, 'resize_dir' => 'vertical', - 'justifyClasses' => array('text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'), + 'justifyClasses' => ['text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'], 'entities' => FALSE, 'disableNativeSpellChecker' => FALSE, - ); + ]; // Add the allowedContent setting, which ensures CKEditor only allows tags // and attributes that are allowed by the text format for this text editor. @@ -143,145 +143,145 @@ public function getButtons() { ]; }; - return array( + return [ // "basicstyles" plugin. - 'Bold' => array( + 'Bold' => [ 'label' => t('Bold'), 'image_alternative' => $button('bold'), 'image_alternative_rtl' => $button('bold', 'rtl'), - ), - 'Italic' => array( + ], + 'Italic' => [ 'label' => t('Italic'), 'image_alternative' => $button('italic'), 'image_alternative_rtl' => $button('italic', 'rtl'), - ), - 'Underline' => array( + ], + 'Underline' => [ 'label' => t('Underline'), 'image_alternative' => $button('underline'), 'image_alternative_rtl' => $button('underline', 'rtl'), - ), - 'Strike' => array( + ], + 'Strike' => [ 'label' => t('Strike-through'), 'image_alternative' => $button('strike'), 'image_alternative_rtl' => $button('strike', 'rtl'), - ), - 'Superscript' => array( + ], + 'Superscript' => [ 'label' => t('Superscript'), 'image_alternative' => $button('super script'), 'image_alternative_rtl' => $button('super script', 'rtl'), - ), - 'Subscript' => array( + ], + 'Subscript' => [ 'label' => t('Subscript'), 'image_alternative' => $button('sub script'), 'image_alternative_rtl' => $button('sub script', 'rtl'), - ), + ], // "removeformat" plugin. - 'RemoveFormat' => array( + 'RemoveFormat' => [ 'label' => t('Remove format'), 'image_alternative' => $button('remove format'), 'image_alternative_rtl' => $button('remove format', 'rtl'), - ), + ], // "justify" plugin. - 'JustifyLeft' => array( + 'JustifyLeft' => [ 'label' => t('Align left'), 'image_alternative' => $button('justify left'), 'image_alternative_rtl' => $button('justify left', 'rtl'), - ), - 'JustifyCenter' => array( + ], + 'JustifyCenter' => [ 'label' => t('Align center'), 'image_alternative' => $button('justify center'), 'image_alternative_rtl' => $button('justify center', 'rtl'), - ), - 'JustifyRight' => array( + ], + 'JustifyRight' => [ 'label' => t('Align right'), 'image_alternative' => $button('justify right'), 'image_alternative_rtl' => $button('justify right', 'rtl'), - ), - 'JustifyBlock' => array( + ], + 'JustifyBlock' => [ 'label' => t('Justify'), 'image_alternative' => $button('justify block'), 'image_alternative_rtl' => $button('justify block', 'rtl'), - ), + ], // "list" plugin. - 'BulletedList' => array( + 'BulletedList' => [ 'label' => t('Bullet list'), 'image_alternative' => $button('bulleted list'), 'image_alternative_rtl' => $button('bulleted list', 'rtl'), - ), - 'NumberedList' => array( + ], + 'NumberedList' => [ 'label' => t('Numbered list'), 'image_alternative' => $button('numbered list'), 'image_alternative_rtl' => $button('numbered list', 'rtl'), - ), + ], // "indent" plugin. - 'Outdent' => array( + 'Outdent' => [ 'label' => t('Outdent'), 'image_alternative' => $button('outdent'), 'image_alternative_rtl' => $button('outdent', 'rtl'), - ), - 'Indent' => array( + ], + 'Indent' => [ 'label' => t('Indent'), 'image_alternative' => $button('indent'), 'image_alternative_rtl' => $button('indent', 'rtl'), - ), + ], // "undo" plugin. - 'Undo' => array( + 'Undo' => [ 'label' => t('Undo'), 'image_alternative' => $button('undo'), 'image_alternative_rtl' => $button('undo', 'rtl'), - ), - 'Redo' => array( + ], + 'Redo' => [ 'label' => t('Redo'), 'image_alternative' => $button('redo'), 'image_alternative_rtl' => $button('redo', 'rtl'), - ), + ], // "blockquote" plugin. - 'Blockquote' => array( + 'Blockquote' => [ 'label' => t('Blockquote'), 'image_alternative' => $button('blockquote'), 'image_alternative_rtl' => $button('blockquote', 'rtl'), - ), + ], // "horizontalrule" plugin - 'HorizontalRule' => array( + 'HorizontalRule' => [ 'label' => t('Horizontal rule'), 'image_alternative' => $button('horizontal rule'), 'image_alternative_rtl' => $button('horizontal rule', 'rtl'), - ), + ], // "clipboard" plugin. - 'Cut' => array( + 'Cut' => [ 'label' => t('Cut'), 'image_alternative' => $button('cut'), 'image_alternative_rtl' => $button('cut', 'rtl'), - ), - 'Copy' => array( + ], + 'Copy' => [ 'label' => t('Copy'), 'image_alternative' => $button('copy'), 'image_alternative_rtl' => $button('copy', 'rtl'), - ), - 'Paste' => array( + ], + 'Paste' => [ 'label' => t('Paste'), 'image_alternative' => $button('paste'), 'image_alternative_rtl' => $button('paste', 'rtl'), - ), + ], // "pastetext" plugin. - 'PasteText' => array( + 'PasteText' => [ 'label' => t('Paste Text'), 'image_alternative' => $button('paste text'), 'image_alternative_rtl' => $button('paste text', 'rtl'), - ), + ], // "pastefromword" plugin. - 'PasteFromWord' => array( + 'PasteFromWord' => [ 'label' => t('Paste from Word'), 'image_alternative' => $button('paste from word'), 'image_alternative_rtl' => $button('paste from word', 'rtl'), - ), + ], // "specialchar" plugin. - 'SpecialChar' => array( + 'SpecialChar' => [ 'label' => t('Character map'), 'image_alternative' => $button('special char'), 'image_alternative_rtl' => $button('special char', 'rtl'), - ), - 'Format' => array( + ], + 'Format' => [ 'label' => t('HTML block format'), 'image_alternative' => [ '#type' => 'inline_template', @@ -290,33 +290,33 @@ public function getButtons() { 'format_text' => t('Format'), ], ], - ), + ], // "table" plugin. - 'Table' => array( + 'Table' => [ 'label' => t('Table'), 'image_alternative' => $button('table'), 'image_alternative_rtl' => $button('table', 'rtl'), - ), + ], // "showblocks" plugin. - 'ShowBlocks' => array( + 'ShowBlocks' => [ 'label' => t('Show blocks'), 'image_alternative' => $button('show blocks'), 'image_alternative_rtl' => $button('show blocks', 'rtl'), - ), + ], // "sourcearea" plugin. - 'Source' => array( + 'Source' => [ 'label' => t('Source code'), 'image_alternative' => $button('source'), 'image_alternative_rtl' => $button('source', 'rtl'), - ), + ], // "maximize" plugin. - 'Maximize' => array( + 'Maximize' => [ 'label' => t('Maximize'), 'image_alternative' => $button('maximize'), 'image_alternative_rtl' => $button('maximize', 'rtl'), - ), + ], // No plugin, separator "button" for toolbar builder UI use only. - '-' => array( + '-' => [ 'label' => t('Separator'), 'image_alternative' => [ '#type' => 'inline_template', @@ -325,13 +325,13 @@ public function getButtons() { 'button_separator_text' => t('Button separator'), ], ], - 'attributes' => array( - 'class' => array('ckeditor-button-separator'), + 'attributes' => [ + 'class' => ['ckeditor-button-separator'], 'data-drupal-ckeditor-type' => 'separator', - ), + ], 'multiple' => TRUE, - ), - ); + ], + ]; } /** @@ -349,7 +349,7 @@ protected function generateFormatTagsSetting(Editor $editor) { // When no text format is associated yet, assume no tag is allowed. // @see \Drupal\Editor\EditorInterface::hasAssociatedFilterFormat() if (!$editor->hasAssociatedFilterFormat()) { - return array(); + return []; } $format = $editor->getFilterFormat(); @@ -415,7 +415,7 @@ protected function generateACFSettings(Editor $editor) { // When nothing is disallowed, set allowedContent to true. if (!in_array(FilterInterface::TYPE_HTML_RESTRICTOR, $filter_types)) { - return array(TRUE, FALSE); + return [TRUE, FALSE]; } // Generate setting that accurately reflects allowed tags and attributes. else { @@ -440,10 +440,10 @@ protected function generateACFSettings(Editor $editor) { // When all HTML is allowed, also set allowedContent to true and // disallowedContent to false. if ($html_restrictions === FALSE) { - return array(TRUE, FALSE); + return [TRUE, FALSE]; } - $allowed = array(); - $disallowed = array(); + $allowed = []; + $disallowed = []; if (isset($html_restrictions['forbidden_tags'])) { foreach ($html_restrictions['forbidden_tags'] as $tag) { $disallowed[$tag] = TRUE; @@ -452,11 +452,11 @@ protected function generateACFSettings(Editor $editor) { foreach ($html_restrictions['allowed'] as $tag => $attributes) { // Tell CKEditor the tag is allowed, but no attributes. if ($attributes === FALSE) { - $allowed[$tag] = array( + $allowed[$tag] = [ 'attributes' => FALSE, 'styles' => FALSE, 'classes' => FALSE, - ); + ]; } // Tell CKEditor the tag is allowed, as well as any attribute on it. The // "style" and "class" attributes are handled separately by CKEditor: @@ -464,11 +464,11 @@ protected function generateACFSettings(Editor $editor) { // attributes, unless you state specific values for them that are // allowed. Or, in this case: any value for them is allowed. elseif ($attributes === TRUE) { - $allowed[$tag] = array( + $allowed[$tag] = [ 'attributes' => TRUE, 'styles' => TRUE, 'classes' => TRUE, - ); + ]; // We've just marked that any value for the "style" and "class" // attributes is allowed. However, that may not be the case: the "*" // tag may still apply restrictions. @@ -517,11 +517,11 @@ protected function generateACFSettings(Editor $editor) { elseif (is_array($attributes)) { // Set defaults (these will be overridden below if more specific // values are present). - $allowed[$tag] = array( + $allowed[$tag] = [ 'attributes' => FALSE, 'styles' => FALSE, 'classes' => FALSE, - ); + ]; // Configure allowed attributes, allowed "style" attribute values and // allowed "class" attribute values. // CKEditor only allows specific values for the "class" and "style" @@ -599,7 +599,7 @@ protected function generateACFSettings(Editor $editor) { ksort($allowed); ksort($disallowed); - return array($allowed, $disallowed); + return [$allowed, $disallowed]; } } diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php index 145f741..d0d6c6a 100644 --- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php +++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Language.php @@ -105,7 +105,7 @@ public function settingsForm(array $form, FormStateInterface $form_state, Editor } $predefined_languages = LanguageManager::getStandardLanguageList(); - $form['language_list'] = array( + $form['language_list'] = [ '#title' => $this->t('Language list'), '#title_display' => 'invisible', '#type' => 'select', @@ -119,7 +119,7 @@ public function settingsForm(array $form, FormStateInterface $form_state, Editor '@count' => count($predefined_languages), ]), '#attached' => ['library' => ['ckeditor/drupal.ckeditor.language.admin']], - ); + ]; return $form; } @@ -128,9 +128,9 @@ public function settingsForm(array $form, FormStateInterface $form_state, Editor * {@inheritdoc} */ function getCssFiles(Editor $editor) { - return array( + return [ drupal_get_path('module', 'ckeditor') . '/css/plugins/language/ckeditor.language.css' - ); + ]; } } diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php index 888fec0..28668a5 100644 --- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php +++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/StylesCombo.php @@ -36,7 +36,7 @@ public function getFile() { * {@inheritdoc} */ public function getConfig(Editor $editor) { - $config = array(); + $config = []; $settings = $editor->getSettings(); if (!isset($settings['plugins']['stylescombo']['styles'])) { return $config; @@ -50,8 +50,8 @@ public function getConfig(Editor $editor) { * {@inheritdoc} */ public function getButtons() { - return array( - 'Styles' => array( + return [ + 'Styles' => [ 'label' => t('Font style'), 'image_alternative' => [ '#type' => 'inline_template', @@ -60,8 +60,8 @@ public function getButtons() { 'styles_text' => t('Styles'), ], ], - ), - ); + ], + ]; } /** @@ -69,25 +69,25 @@ public function getButtons() { */ public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) { // Defaults. - $config = array('styles' => ''); + $config = ['styles' => '']; $settings = $editor->getSettings(); if (isset($settings['plugins']['stylescombo'])) { $config = $settings['plugins']['stylescombo']; } - $form['styles'] = array( + $form['styles'] = [ '#title' => t('Styles'), '#title_display' => 'invisible', '#type' => 'textarea', '#default_value' => $config['styles'], '#description' => t('A list of classes that will be provided in the "Styles" dropdown. Enter one or more classes on each line in the format: element.classA.classB|Label. Example: h1.title|Title. Advanced example: h1.fancy.title|Fancy title.
        These styles should be available in your theme\'s CSS file.'), - '#attached' => array( - 'library' => array('ckeditor/drupal.ckeditor.stylescombo.admin'), - ), - '#element_validate' => array( - array($this, 'validateStylesValue'), - ), - ); + '#attached' => [ + 'library' => ['ckeditor/drupal.ckeditor.stylescombo.admin'], + ], + '#element_validate' => [ + [$this, 'validateStylesValue'], + ], + ]; return $form; } @@ -120,7 +120,7 @@ public function validateStylesValue(array $element, FormStateInterface $form_sta * syntax is invalid. */ protected function generateStylesSetSetting($styles) { - $styles_set = array(); + $styles_set = []; // Early-return when empty. $styles = trim($styles); @@ -128,7 +128,7 @@ protected function generateStylesSetSetting($styles) { return $styles_set; } - $styles = str_replace(array("\r\n", "\r"), "\n", $styles); + $styles = str_replace(["\r\n", "\r"], "\n", $styles); foreach (explode("\n", $styles) as $style) { $style = trim($style); @@ -149,14 +149,14 @@ protected function generateStylesSetSetting($styles) { // Build the data structure CKEditor's stylescombo plugin expects. // @see http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Styles - $configured_style = array( + $configured_style = [ 'name' => trim($label), 'element' => trim($element), - ); + ]; if (!empty($classes)) { - $configured_style['attributes'] = array( + $configured_style['attributes'] = [ 'class' => implode(' ', array_map('trim', $classes)) - ); + ]; } $styles_set[] = $configured_style; } diff --git a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php index 170305d..dbe280e 100644 --- a/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php +++ b/core/modules/ckeditor/src/Plugin/Editor/CKEditor.php @@ -102,36 +102,36 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function getDefaultSettings() { - return array( - 'toolbar' => array( - 'rows' => array( + return [ + 'toolbar' => [ + 'rows' => [ // Button groups. - array( - array( + [ + [ 'name' => t('Formatting'), - 'items' => array('Bold', 'Italic',), - ), - array( + 'items' => ['Bold', 'Italic', ], + ], + [ 'name' => t('Links'), - 'items' => array('DrupalLink', 'DrupalUnlink',), - ), - array( + 'items' => ['DrupalLink', 'DrupalUnlink', ], + ], + [ 'name' => t('Lists'), - 'items' => array('BulletedList', 'NumberedList',), - ), - array( + 'items' => ['BulletedList', 'NumberedList', ], + ], + [ 'name' => t('Media'), - 'items' => array('Blockquote', 'DrupalImage',), - ), - array( + 'items' => ['Blockquote', 'DrupalImage', ], + ], + [ 'name' => t('Tools'), - 'items' => array('Source',), - ), - ), - ), - ), + 'items' => ['Source', ], + ], + ], + ], + ], 'plugins' => ['language' => ['language_list' => 'un']], - ); + ]; } /** @@ -140,39 +140,39 @@ public function getDefaultSettings() { public function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) { $settings = $editor->getSettings(); - $ckeditor_settings_toolbar = array( + $ckeditor_settings_toolbar = [ '#theme' => 'ckeditor_settings_toolbar', '#editor' => $editor, '#plugins' => $this->ckeditorPluginManager->getButtons(), - ); - $form['toolbar'] = array( + ]; + $form['toolbar'] = [ '#type' => 'container', - '#attached' => array( - 'library' => array('ckeditor/drupal.ckeditor.admin'), + '#attached' => [ + 'library' => ['ckeditor/drupal.ckeditor.admin'], 'drupalSettings' => [ 'ckeditor' => [ 'toolbarAdmin' => (string) $this->renderer->renderPlain($ckeditor_settings_toolbar), ], ], - ), - '#attributes' => array('class' => array('ckeditor-toolbar-configuration')), - ); + ], + '#attributes' => ['class' => ['ckeditor-toolbar-configuration']], + ]; - $form['toolbar']['button_groups'] = array( + $form['toolbar']['button_groups'] = [ '#type' => 'textarea', '#title' => t('Toolbar buttons'), '#default_value' => json_encode($settings['toolbar']['rows']), - '#attributes' => array('class' => array('ckeditor-toolbar-textarea')), - ); + '#attributes' => ['class' => ['ckeditor-toolbar-textarea']], + ]; // CKEditor plugin settings, if any. - $form['plugin_settings'] = array( + $form['plugin_settings'] = [ '#type' => 'vertical_tabs', '#title' => t('CKEditor plugin settings'), - '#attributes' => array( + '#attributes' => [ 'id' => 'ckeditor-plugin-settings', - ), - ); + ], + ]; $this->ckeditorPluginManager->injectPluginSettingsForm($form, $form_state, $editor); if (count(Element::children($form['plugins'])) === 0) { unset($form['plugins']); @@ -186,7 +186,7 @@ public function settingsForm(array $form, FormStateInterface $form_state, Editor // settings to be updated accordingly. // Get a list of all external plugins and their corresponding files. $plugins = array_keys($this->ckeditorPluginManager->getDefinitions()); - $all_external_plugins = array(); + $all_external_plugins = []; foreach ($plugins as $plugin_id) { $plugin = $this->ckeditorPluginManager->createInstance($plugin_id); if (!$plugin->isInternal()) { @@ -196,37 +196,37 @@ public function settingsForm(array $form, FormStateInterface $form_state, Editor // Get a list of all buttons that are provided by all plugins. $all_buttons = array_reduce($this->ckeditorPluginManager->getButtons(), function($result, $item) { return array_merge($result, array_keys($item)); - }, array()); + }, []); // Build a fake Editor object, which we'll use to generate JavaScript // settings for this fake Editor instance. - $fake_editor = Editor::create(array( + $fake_editor = Editor::create([ 'format' => $editor->id(), 'editor' => 'ckeditor', - 'settings' => array( + 'settings' => [ // Single toolbar row, single button group, all existing buttons. - 'toolbar' => array( - 'rows' => array( - 0 => array( - 0 => array( + 'toolbar' => [ + 'rows' => [ + 0 => [ + 0 => [ 'name' => 'All existing buttons', 'items' => $all_buttons, - ) - ) - ), - ), + ] + ] + ], + ], 'plugins' => $settings['plugins'], - ), - )); + ], + ]); $config = $this->getJSSettings($fake_editor); // Remove the ACF configuration that is generated based on filter settings, // because otherwise we cannot retrieve per-feature metadata. unset($config['allowedContent']); - $form['hidden_ckeditor'] = array( + $form['hidden_ckeditor'] = [ '#markup' => '', - '#attached' => array( + '#attached' => [ 'drupalSettings' => ['ckeditor' => ['hiddenCKEditorConfig' => $config]], - ), - ); + ], + ]; return $form; } @@ -238,7 +238,7 @@ public function settingsFormSubmit(array $form, FormStateInterface $form_state) // Modify the toolbar settings by reference. The values in // $form_state->getValue(array('editor', 'settings')) will be saved directly // by editor_form_filter_admin_format_submit(). - $toolbar_settings = &$form_state->getValue(array('editor', 'settings', 'toolbar')); + $toolbar_settings = &$form_state->getValue(['editor', 'settings', 'toolbar']); // The rows key is not built into the form structure, so decode the button // groups data into this new key and remove the button_groups key. @@ -246,8 +246,8 @@ public function settingsFormSubmit(array $form, FormStateInterface $form_state) unset($toolbar_settings['button_groups']); // Remove the plugin settings' vertical tabs state; no need to save that. - if ($form_state->hasValue(array('editor', 'settings', 'plugins'))) { - $form_state->unsetValue(array('editor', 'settings', 'plugin_settings')); + if ($form_state->hasValue(['editor', 'settings', 'plugins'])) { + $form_state->unsetValue(['editor', 'settings', 'plugin_settings']); } } @@ -255,7 +255,7 @@ public function settingsFormSubmit(array $form, FormStateInterface $form_state) * {@inheritdoc} */ public function getJSSettings(Editor $editor) { - $settings = array(); + $settings = []; // Get the settings for all enabled plugins, even the internal ones. $enabled_plugins = array_keys($this->ckeditorPluginManager->getEnabledPluginFiles($editor, TRUE)); @@ -279,7 +279,7 @@ public function getJSSettings(Editor $editor) { // Next, set the most fundamental CKEditor settings. $external_plugin_files = $this->ckeditorPluginManager->getEnabledPluginFiles($editor); - $settings += array( + $settings += [ 'toolbar' => $this->buildToolbarJSSetting($editor), 'contentsCss' => $this->buildContentsCssJSSetting($editor), 'extraPlugins' => implode(',', array_keys($external_plugin_files)), @@ -290,15 +290,15 @@ public function getJSSettings(Editor $editor) { // styles.js by default. // See http://dev.ckeditor.com/ticket/9992#comment:9. 'stylesSet' => FALSE, - ); + ]; // Finally, set Drupal-specific CKEditor settings. $root_relative_file_url = function ($uri) { return file_url_transform_relative(file_create_url($uri)); }; - $settings += array( + $settings += [ 'drupalExternalPlugins' => array_map($root_relative_file_url, $external_plugin_files), - ); + ]; // Parse all CKEditor plugin JavaScript files for translations. if ($this->moduleHandler->moduleExists('locale')) { @@ -326,7 +326,7 @@ public function getLangcodes() { $langcodes = $langcode_cache->data; } if (empty($langcodes)) { - $langcodes = array(); + $langcodes = []; // Collect languages included with CKEditor based on file listing. $files = scandir('core/assets/vendor/ckeditor/lang'); foreach ($files as $file) { @@ -341,7 +341,7 @@ public function getLangcodes() { // Get language mapping if available to map to Drupal language codes. // This is configurable in the user interface and not expensive to get, so // we don't include it in the cached language list. - $language_mappings = $this->moduleHandler->moduleExists('language') ? language_get_browser_drupal_langcode_mappings() : array(); + $language_mappings = $this->moduleHandler->moduleExists('language') ? language_get_browser_drupal_langcode_mappings() : []; foreach ($langcodes as $langcode) { // If this language code is available in a Drupal mapping, use that to // compute a possibility for matching from the Drupal langcode to the @@ -363,9 +363,9 @@ public function getLangcodes() { * {@inheritdoc} */ public function getLibraries(Editor $editor) { - $libraries = array( + $libraries = [ 'ckeditor/drupal.ckeditor', - ); + ]; // Get the required libraries for any enabled plugins. $enabled_plugins = array_keys($this->ckeditorPluginManager->getEnabledPluginFiles($editor)); @@ -389,7 +389,7 @@ public function getLibraries(Editor $editor) { * An array containing the "toolbar" configuration. */ public function buildToolbarJSSetting(Editor $editor) { - $toolbar = array(); + $toolbar = []; $settings = $editor->getSettings(); foreach ($settings['toolbar']['rows'] as $row) { @@ -412,15 +412,15 @@ public function buildToolbarJSSetting(Editor $editor) { * An array containing the "contentsCss" configuration. */ public function buildContentsCssJSSetting(Editor $editor) { - $css = array( + $css = [ drupal_get_path('module', 'ckeditor') . '/css/ckeditor-iframe.css', drupal_get_path('module', 'system') . '/css/components/align.module.css', - ); + ]; $this->moduleHandler->alter('ckeditor_css', $css, $editor); // Get a list of all enabled plugins' iframe instance CSS files. $plugins_css = array_reduce($this->ckeditorPluginManager->getCssFiles($editor), function($result, $item) { return array_merge($result, array_values($item)); - }, array()); + }, []); $css = array_merge($css, $plugins_css); $css = array_merge($css, _ckeditor_theme_css()); $css = array_map('file_create_url', $css); diff --git a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php index d10180d..03063fe 100644 --- a/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php +++ b/core/modules/ckeditor/src/Tests/CKEditorAdminTest.php @@ -20,7 +20,7 @@ class CKEditorAdminTest extends WebTestBase { * * @var array */ - public static $modules = array('filter', 'editor', 'ckeditor'); + public static $modules = ['filter', 'editor', 'ckeditor']; /** * A user with the 'administer filters' permission. @@ -33,16 +33,16 @@ protected function setUp() { parent::setUp(); // Create text format. - $filtered_html_format = FilterFormat::create(array( + $filtered_html_format = FilterFormat::create([ 'format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, - 'filters' => array(), - )); + 'filters' => [], + ]); $filtered_html_format->save(); // Create admin user. - $this->adminUser = $this->drupalCreateUser(array('administer filters')); + $this->adminUser = $this->drupalCreateUser(['administer filters']); } /** @@ -70,43 +70,43 @@ function testExistingFormat() { $this->assertTrue(((string) $options[0]['selected']) === 'selected', 'Option 1 ("None") is selected.'); // Select the "CKEditor" editor and click the "Save configuration" button. - $edit = array( + $edit = [ 'editor[editor]' => 'ckeditor', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save configuration')); $this->assertRaw(t('You must configure the selected text editor.')); // Ensure the CKEditor editor returns the expected default settings. - $expected_default_settings = array( - 'toolbar' => array( - 'rows' => array( + $expected_default_settings = [ + 'toolbar' => [ + 'rows' => [ // Button groups - array( - array( + [ + [ 'name' => 'Formatting', - 'items' => array('Bold', 'Italic',), - ), - array( + 'items' => ['Bold', 'Italic', ], + ], + [ 'name' => 'Links', - 'items' => array('DrupalLink', 'DrupalUnlink',), - ), - array( + 'items' => ['DrupalLink', 'DrupalUnlink', ], + ], + [ 'name' => 'Lists', - 'items' => array('BulletedList', 'NumberedList',), - ), - array( + 'items' => ['BulletedList', 'NumberedList', ], + ], + [ 'name' => 'Media', - 'items' => array('Blockquote', 'DrupalImage',), - ), - array( + 'items' => ['Blockquote', 'DrupalImage', ], + ], + [ 'name' => 'Tools', - 'items' => array('Source',), - ), - ), - ), - ), + 'items' => ['Source', ], + ], + ], + ], + ], 'plugins' => ['language' => ['language_list' => 'un']], - ); + ]; $this->assertIdentical($this->castSafeStrings($ckeditor->getDefaultSettings()), $expected_default_settings); // Keep the "CKEditor" editor selected and click the "Configure" button. @@ -115,11 +115,11 @@ function testExistingFormat() { $this->assertFalse($editor, 'No Editor config entity exists yet.'); // Ensure that drupalSettings is correct. - $ckeditor_settings_toolbar = array( + $ckeditor_settings_toolbar = [ '#theme' => 'ckeditor_settings_toolbar', '#editor' => Editor::create(['editor' => 'ckeditor']), '#plugins' => $this->container->get('plugin.manager.ckeditor.plugin')->getButtons(), - ); + ]; $this->assertEqual( $this->drupalSettings['ckeditor']['toolbarAdmin'], $this->container->get('renderer')->renderPlain($ckeditor_settings_toolbar), @@ -148,9 +148,9 @@ function testExistingFormat() { // Configure the Styles plugin, and ensure the updated settings are saved. $this->drupalGet('admin/config/content/formats/manage/filtered_html'); - $edit = array( + $edit = [ 'editor[settings][plugins][stylescombo][styles]' => "h1.title|Title\np.callout|Callout\n\n", - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save configuration')); $expected_settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.callout|Callout\n\n"; $editor = Editor::load('filtered_html'); @@ -161,13 +161,13 @@ function testExistingFormat() { // done via drag and drop, but here we can only emulate the end result of // that interaction). Test multiple toolbar rows and a divider within a row. $this->drupalGet('admin/config/content/formats/manage/filtered_html'); - $expected_settings['toolbar']['rows'][0][] = array( + $expected_settings['toolbar']['rows'][0][] = [ 'name' => 'Action history', - 'items' => array('Undo', '|', 'Redo', 'JustifyCenter'), - ); - $edit = array( + 'items' => ['Undo', '|', 'Redo', 'JustifyCenter'], + ]; + $edit = [ 'editor[settings][toolbar][button_groups]' => json_encode($expected_settings['toolbar']['rows']), - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save configuration')); $editor = Editor::load('filtered_html'); $this->assertTrue($editor instanceof Editor, 'An Editor config entity exists.'); @@ -191,7 +191,7 @@ function testExistingFormat() { // Now enable the ckeditor_test module, which provides one configurable // CKEditor plugin — this should not affect the Editor config entity. - \Drupal::service('module_installer')->install(array('ckeditor_test')); + \Drupal::service('module_installer')->install(['ckeditor_test']); $this->resetAll(); $this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions(); $this->drupalGet('admin/config/content/formats/manage/filtered_html'); @@ -203,9 +203,9 @@ function testExistingFormat() { // Finally, check the "Ultra llama mode" checkbox. $this->drupalGet('admin/config/content/formats/manage/filtered_html'); - $edit = array( + $edit = [ 'editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]' => '1', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save configuration')); $this->drupalGet('admin/config/content/formats/manage/filtered_html'); $ultra_llama_mode_checkbox = $this->xpath('//input[@type="checkbox" and @name="editor[settings][plugins][llama_contextual_and_button][ultra_llama_mode]" and @checked="checked"]'); @@ -239,11 +239,11 @@ function testNewFormat() { // Name our fancy new text format, select the "CKEditor" editor and click // the "Configure" button. - $edit = array( + $edit = [ 'name' => 'My amazing text format', 'format' => 'amazing_format', 'editor[editor]' => 'ckeditor', - ); + ]; $this->drupalPostAjaxForm(NULL, $edit, 'editor_configure'); $filter_format = FilterFormat::load('amazing_format'); $this->assertFalse($filter_format, 'No FilterFormat config entity exists yet.'); diff --git a/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php b/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php index 6efe647..6de5467 100644 --- a/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php +++ b/core/modules/ckeditor/src/Tests/CKEditorLoadingTest.php @@ -18,7 +18,7 @@ class CKEditorLoadingTest extends WebTestBase { * * @var array */ - public static $modules = array('filter', 'editor', 'ckeditor', 'node'); + public static $modules = ['filter', 'editor', 'ckeditor', 'node']; /** * An untrusted user with access to only the 'plain_text' format. @@ -38,12 +38,12 @@ protected function setUp() { parent::setUp(); // Create text format, associate CKEditor. - $filtered_html_format = FilterFormat::create(array( + $filtered_html_format = FilterFormat::create([ 'format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, - 'filters' => array(), - )); + 'filters' => [], + ]); $filtered_html_format->save(); $editor = Editor::create([ 'format' => 'filtered_html', @@ -53,22 +53,22 @@ protected function setUp() { // Create a second format without an associated editor so a drop down select // list is created when selecting formats. - $full_html_format = FilterFormat::create(array( + $full_html_format = FilterFormat::create([ 'format' => 'full_html', 'name' => 'Full HTML', 'weight' => 1, - 'filters' => array(), - )); + 'filters' => [], + ]); $full_html_format->save(); // Create node type. - $this->drupalCreateContentType(array( + $this->drupalCreateContentType([ 'type' => 'article', 'name' => 'Article', - )); + ]); - $this->untrustedUser = $this->drupalCreateUser(array('create article content', 'edit any article content')); - $this->normalUser = $this->drupalCreateUser(array('create article content', 'edit any article content', 'use text format filtered_html', 'use text format full_html')); + $this->untrustedUser = $this->drupalCreateUser(['create article content', 'edit any article content']); + $this->normalUser = $this->drupalCreateUser(['create article content', 'edit any article content', 'use text format filtered_html', 'use text format full_html']); } /** @@ -101,13 +101,13 @@ function testLoading() { list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck(); $ckeditor_plugin = $this->container->get('plugin.manager.editor')->createInstance('ckeditor'); $editor = Editor::load('filtered_html'); - $expected = array('formats' => array('filtered_html' => array( + $expected = ['formats' => ['filtered_html' => [ 'format' => 'filtered_html', 'editor' => 'ckeditor', 'editorSettings' => $this->castSafeStrings($ckeditor_plugin->getJSSettings($editor)), 'editorSupportsContentFiltering' => TRUE, 'isXssSafe' => FALSE, - ))); + ]]]; $this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page."); $this->assertIdentical($expected, $this->castSafeStrings($settings['editor']), "Text Editor module's JavaScript settings on the page are correct."); $this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.'); @@ -122,7 +122,7 @@ function testLoading() { // NOTE: the tests in CKEditorTest already ensure that changing the // configuration also results in modified CKEditor configuration, so we // don't test that here. - \Drupal::service('module_installer')->install(array('ckeditor_test')); + \Drupal::service('module_installer')->install(['ckeditor_test']); $this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions(); $editor_settings = $editor->getSettings(); $editor_settings['toolbar']['rows'][0][0]['items'][] = 'Llama'; @@ -130,15 +130,15 @@ function testLoading() { $editor->save(); $this->drupalGet('node/add/article'); list($settings, $editor_settings_present, $editor_js_present, $body, $format_selector) = $this->getThingsToCheck(); - $expected = array( - 'formats' => array( - 'filtered_html' => array( + $expected = [ + 'formats' => [ + 'filtered_html' => [ 'format' => 'filtered_html', 'editor' => 'ckeditor', 'editorSettings' => $this->castSafeStrings($ckeditor_plugin->getJSSettings($editor)), 'editorSupportsContentFiltering' => TRUE, 'isXssSafe' => FALSE, - ))); + ]]]; $this->assertTrue($editor_settings_present, "Text Editor module's JavaScript settings are on the page."); $this->assertIdentical($expected, $this->castSafeStrings($settings['editor']), "Text Editor module's JavaScript settings on the page are correct."); $this->assertTrue($editor_js_present, 'Text Editor JavaScript is present.'); @@ -226,7 +226,7 @@ function testExternalStylesheets() { protected function getThingsToCheck() { $settings = $this->getDrupalSettings(); - return array( + return [ // JavaScript settings. $settings, // Editor.module's JS settings present. @@ -239,7 +239,7 @@ protected function getThingsToCheck() { $this->xpath('//textarea[@id="edit-body-0-value"]'), // Format selector. $this->xpath('//select[contains(@class, "filter-list")]'), - ); + ]; } } diff --git a/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorPluginManagerTest.php b/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorPluginManagerTest.php index 92c448b..fc79273 100644 --- a/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorPluginManagerTest.php +++ b/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorPluginManagerTest.php @@ -18,7 +18,7 @@ class CKEditorPluginManagerTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'user', 'filter', 'editor', 'ckeditor'); + public static $modules = ['system', 'user', 'filter', 'editor', 'ckeditor']; /** * The manager for "CKEditor plugin" plugins. @@ -33,12 +33,12 @@ protected function setUp() { // Install the Filter module. // Create text format, associate CKEditor. - $filtered_html_format = FilterFormat::create(array( + $filtered_html_format = FilterFormat::create([ 'format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, - 'filters' => array(), - )); + 'filters' => [], + ]); $filtered_html_format->save(); $editor = Editor::create([ 'format' => 'filtered_html', @@ -57,27 +57,27 @@ function testEnabledPlugins() { // Case 1: no CKEditor plugins. $definitions = array_keys($this->manager->getDefinitions()); sort($definitions); - $this->assertIdentical(array('drupalimage', 'drupalimagecaption', 'drupallink', 'internal', 'language', 'stylescombo'), $definitions, 'No CKEditor plugins found besides the built-in ones.'); - $enabled_plugins = array( + $this->assertIdentical(['drupalimage', 'drupalimagecaption', 'drupallink', 'internal', 'language', 'stylescombo'], $definitions, 'No CKEditor plugins found besides the built-in ones.'); + $enabled_plugins = [ 'drupalimage' => drupal_get_path('module', 'ckeditor') . '/js/plugins/drupalimage/plugin.js', 'drupallink' => drupal_get_path('module', 'ckeditor') . '/js/plugins/drupallink/plugin.js', - ); + ]; $this->assertIdentical($enabled_plugins, $this->manager->getEnabledPluginFiles($editor), 'Only built-in plugins are enabled.'); - $this->assertIdentical(array('internal' => NULL) + $enabled_plugins, $this->manager->getEnabledPluginFiles($editor, TRUE), 'Only the "internal" plugin is enabled.'); + $this->assertIdentical(['internal' => NULL] + $enabled_plugins, $this->manager->getEnabledPluginFiles($editor, TRUE), 'Only the "internal" plugin is enabled.'); // Enable the CKEditor Test module, which has the Llama plugin (plus four // variations of it, to cover all possible ways a plugin can be enabled) and // clear the editor manager's cache so it is picked up. - $this->enableModules(array('ckeditor_test')); + $this->enableModules(['ckeditor_test']); $this->manager = $this->container->get('plugin.manager.ckeditor.plugin'); $this->manager->clearCachedDefinitions(); // Case 2: CKEditor plugins are available. $plugin_ids = array_keys($this->manager->getDefinitions()); sort($plugin_ids); - $this->assertIdentical(array('drupalimage', 'drupalimagecaption', 'drupallink', 'internal', 'language', 'llama', 'llama_button', 'llama_contextual', 'llama_contextual_and_button', 'llama_css', 'stylescombo'), $plugin_ids, 'Additional CKEditor plugins found.'); + $this->assertIdentical(['drupalimage', 'drupalimagecaption', 'drupallink', 'internal', 'language', 'llama', 'llama_button', 'llama_contextual', 'llama_contextual_and_button', 'llama_css', 'stylescombo'], $plugin_ids, 'Additional CKEditor plugins found.'); $this->assertIdentical($enabled_plugins, $this->manager->getEnabledPluginFiles($editor), 'Only the internal plugins are enabled.'); - $this->assertIdentical(array('internal' => NULL) + $enabled_plugins, $this->manager->getEnabledPluginFiles($editor, TRUE), 'Only the "internal" plugin is enabled.'); + $this->assertIdentical(['internal' => NULL] + $enabled_plugins, $this->manager->getEnabledPluginFiles($editor, TRUE), 'Only the "internal" plugin is enabled.'); // Case 3: enable each of the newly available plugins, if possible: // a. Llama: cannot be enabled, since it does not implement @@ -100,33 +100,33 @@ function testEnabledPlugins() { $settings['toolbar']['rows'][0][0]['items'][] = 'Llama'; $editor->setSettings($settings); $editor->save(); - $file = array(); + $file = []; $file['b'] = drupal_get_path('module', 'ckeditor_test') . '/js/llama_button.js'; $file['c'] = drupal_get_path('module', 'ckeditor_test') . '/js/llama_contextual.js'; $file['cb'] = drupal_get_path('module', 'ckeditor_test') . '/js/llama_contextual_and_button.js'; $file['css'] = drupal_get_path('module', 'ckeditor_test') . '/js/llama_css.js'; - $expected = $enabled_plugins + array('llama_button' => $file['b'], 'llama_contextual_and_button' => $file['cb']); + $expected = $enabled_plugins + ['llama_button' => $file['b'], 'llama_contextual_and_button' => $file['cb']]; $this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LlamaButton and LlamaContextualAndButton plugins are enabled.'); - $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LlamaButton and LlamaContextualAndButton plugins are enabled.'); + $this->assertIdentical(['internal' => NULL] + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LlamaButton and LlamaContextualAndButton plugins are enabled.'); $settings['toolbar'] = $original_toolbar; $settings['toolbar']['rows'][0][0]['items'][] = 'Strike'; $editor->setSettings($settings); $editor->save(); - $expected = $enabled_plugins + array('llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb']); + $expected = $enabled_plugins + ['llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb']]; $this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LLamaContextual and LlamaContextualAndButton plugins are enabled.'); - $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LlamaContextual and LlamaContextualAndButton plugins are enabled.'); + $this->assertIdentical(['internal' => NULL] + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LlamaContextual and LlamaContextualAndButton plugins are enabled.'); $settings['toolbar']['rows'][0][0]['items'][] = 'Llama'; $editor->setSettings($settings); $editor->save(); - $expected = $enabled_plugins + array('llama_button' => $file['b'], 'llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb']); + $expected = $enabled_plugins + ['llama_button' => $file['b'], 'llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb']]; $this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LlamaButton, LlamaContextual and LlamaContextualAndButton plugins are enabled.'); - $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LLamaButton, LlamaContextual and LlamaContextualAndButton plugins are enabled.'); + $this->assertIdentical(['internal' => NULL] + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LLamaButton, LlamaContextual and LlamaContextualAndButton plugins are enabled.'); $settings['toolbar']['rows'][0][0]['items'][] = 'LlamaCSS'; $editor->setSettings($settings); $editor->save(); - $expected = $enabled_plugins + array('llama_button' => $file['b'], 'llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb'], 'llama_css' => $file['css']); + $expected = $enabled_plugins + ['llama_button' => $file['b'], 'llama_contextual' => $file['c'], 'llama_contextual_and_button' => $file['cb'], 'llama_css' => $file['css']]; $this->assertIdentical($expected, $this->manager->getEnabledPluginFiles($editor), 'The LlamaButton, LlamaContextual, LlamaContextualAndButton and LlamaCSS plugins are enabled.'); - $this->assertIdentical(array('internal' => NULL) + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LLamaButton, LlamaContextual, LlamaContextualAndButton and LlamaCSS plugins are enabled.'); + $this->assertIdentical(['internal' => NULL] + $expected, $this->manager->getEnabledPluginFiles($editor, TRUE), 'The LLamaButton, LlamaContextual, LlamaContextualAndButton and LlamaCSS plugins are enabled.'); } /** @@ -137,11 +137,11 @@ function testCssFiles() { $editor = Editor::load('filtered_html'); // Case 1: no CKEditor iframe instance CSS file. - $this->assertIdentical(array(), $this->manager->getCssFiles($editor), 'No iframe instance CSS file found.'); + $this->assertIdentical([], $this->manager->getCssFiles($editor), 'No iframe instance CSS file found.'); // Enable the CKEditor Test module, which has the LlamaCss plugin and // clear the editor manager's cache so it is picked up. - $this->enableModules(array('ckeditor_test')); + $this->enableModules(['ckeditor_test']); $this->manager = $this->container->get('plugin.manager.ckeditor.plugin'); $settings = $editor->getSettings(); // LlamaCss: automatically enabled by adding its 'LlamaCSS' button. @@ -150,9 +150,9 @@ function testCssFiles() { $editor->save(); // Case 2: CKEditor iframe instance CSS file. - $expected = array( - 'llama_css' => array(drupal_get_path('module', 'ckeditor_test') . '/css/llama.css') - ); + $expected = [ + 'llama_css' => [drupal_get_path('module', 'ckeditor_test') . '/css/llama.css'] + ]; $this->assertIdentical($expected, $this->manager->getCssFiles($editor), 'Iframe instance CSS file found.'); } diff --git a/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorTest.php b/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorTest.php index 3711a54..9e20002 100644 --- a/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorTest.php +++ b/core/modules/ckeditor/tests/modules/src/Kernel/CKEditorTest.php @@ -19,7 +19,7 @@ class CKEditorTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'user', 'filter', 'editor', 'ckeditor', 'filter_test'); + public static $modules = ['system', 'user', 'filter', 'editor', 'ckeditor', 'filter_test']; /** * An instance of the "CKEditor" text editor plugin. @@ -41,19 +41,19 @@ protected function setUp() { // Install the Filter module. // Create text format, associate CKEditor. - $filtered_html_format = FilterFormat::create(array( + $filtered_html_format = FilterFormat::create([ 'format' => 'filtered_html', 'name' => 'Filtered HTML', 'weight' => 0, - 'filters' => array( - 'filter_html' => array( + 'filters' => [ + 'filter_html' => [ 'status' => 1, - 'settings' => array( + 'settings' => [ 'allowed_html' => '


        ', - ) - ), - ), - )); + ] + ], + ], + ]); $filtered_html_format->save(); $editor = Editor::create([ 'format' => 'filtered_html', @@ -72,7 +72,7 @@ function testGetJSSettings() { $editor = Editor::load('filtered_html'); // Default toolbar. - $expected_config = $this->getDefaultInternalConfig() + array( + $expected_config = $this->getDefaultInternalConfig() + [ 'drupalImage_dialogTitleAdd' => 'Insert Image', 'drupalImage_dialogTitleEdit' => 'Edit Image', 'drupalLink_dialogTitleAdd' => 'Add Link', @@ -84,11 +84,11 @@ function testGetJSSettings() { 'extraPlugins' => 'drupalimage,drupallink', 'language' => 'en', 'stylesSet' => FALSE, - 'drupalExternalPlugins' => array( + 'drupalExternalPlugins' => [ 'drupalimage' => file_url_transform_relative(file_create_url('core/modules/ckeditor/js/plugins/drupalimage/plugin.js')), 'drupallink' => file_url_transform_relative(file_create_url('core/modules/ckeditor/js/plugins/drupallink/plugin.js')), - ), - ); + ], + ]; $expected_config = $this->castSafeStrings($expected_config); ksort($expected_config); ksort($expected_config['allowedContent']); @@ -96,7 +96,7 @@ function testGetJSSettings() { // Customize the configuration: add button, have two contextually enabled // buttons, and configure a CKEditor plugin setting. - $this->enableModules(array('ckeditor_test')); + $this->enableModules(['ckeditor_test']); $this->container->get('plugin.manager.editor')->clearCachedDefinitions(); $this->ckeditor = $this->container->get('plugin.manager.editor')->createInstance('ckeditor'); $this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions(); @@ -121,16 +121,16 @@ function testGetJSSettings() { $format->filters('filter_html')->settings['allowed_html'] .= '

         

        '; $format->save(); - $expected_config['allowedContent']['pre'] = array('attributes' => 'class', 'styles' => FALSE, 'classes' => TRUE); - $expected_config['allowedContent']['h1'] = array('attributes' => FALSE, 'styles' => FALSE, 'classes' => FALSE); - $expected_config['allowedContent']['blockquote'] = array('attributes' => 'class', 'styles' => FALSE, 'classes' => TRUE); - $expected_config['allowedContent']['address'] = array('attributes' => 'class', 'styles' => FALSE, 'classes' => 'foo,bar-*'); + $expected_config['allowedContent']['pre'] = ['attributes' => 'class', 'styles' => FALSE, 'classes' => TRUE]; + $expected_config['allowedContent']['h1'] = ['attributes' => FALSE, 'styles' => FALSE, 'classes' => FALSE]; + $expected_config['allowedContent']['blockquote'] = ['attributes' => 'class', 'styles' => FALSE, 'classes' => TRUE]; + $expected_config['allowedContent']['address'] = ['attributes' => 'class', 'styles' => FALSE, 'classes' => 'foo,bar-*']; $expected_config['format_tags'] = 'p;h1;h2;h3;h4;h5;h6;pre'; ksort($expected_config['allowedContent']); $this->assertIdentical($expected_config, $this->castSafeStrings($this->ckeditor->getJSSettings($editor)), 'Generated JS settings are correct for customized configuration.'); // Disable the filter_html filter: allow *all *tags. - $format->setFilterConfig('filter_html', array('status' => 0)); + $format->setFilterConfig('filter_html', ['status' => 0]); $format->save(); $expected_config['allowedContent'] = TRUE; @@ -139,73 +139,73 @@ function testGetJSSettings() { $this->assertIdentical($expected_config, $this->castSafeStrings($this->ckeditor->getJSSettings($editor)), 'Generated JS settings are correct for customized configuration.'); // Enable the filter_test_restrict_tags_and_attributes filter. - $format->setFilterConfig('filter_test_restrict_tags_and_attributes', array( + $format->setFilterConfig('filter_test_restrict_tags_and_attributes', [ 'status' => 1, - 'settings' => array( - 'restrictions' => array( - 'allowed' => array( + 'settings' => [ + 'restrictions' => [ + 'allowed' => [ 'p' => TRUE, - 'a' => array( + 'a' => [ 'href' => TRUE, - 'rel' => array('nofollow' => TRUE), - 'class' => array('external' => TRUE), - 'target' => array('_blank' => FALSE), - ), - 'span' => array( - 'class' => array('dodo' => FALSE), - 'property' => array('dc:*' => TRUE), - 'rel' => array('foaf:*' => FALSE), - 'style' => array('underline' => FALSE, 'color' => FALSE, 'font-size' => TRUE), - ), - '*' => array( + 'rel' => ['nofollow' => TRUE], + 'class' => ['external' => TRUE], + 'target' => ['_blank' => FALSE], + ], + 'span' => [ + 'class' => ['dodo' => FALSE], + 'property' => ['dc:*' => TRUE], + 'rel' => ['foaf:*' => FALSE], + 'style' => ['underline' => FALSE, 'color' => FALSE, 'font-size' => TRUE], + ], + '*' => [ 'style' => FALSE, 'on*' => FALSE, - 'class' => array('is-a-hipster-llama' => TRUE, 'and-more' => TRUE), + 'class' => ['is-a-hipster-llama' => TRUE, 'and-more' => TRUE], 'data-*' => TRUE, - ), + ], 'del' => FALSE, - ), - ), - ), - )); + ], + ], + ], + ]); $format->save(); - $expected_config['allowedContent'] = array( - 'p' => array( + $expected_config['allowedContent'] = [ + 'p' => [ 'attributes' => TRUE, 'styles' => FALSE, 'classes' => 'is-a-hipster-llama,and-more', - ), - 'a' => array( + ], + 'a' => [ 'attributes' => 'href,rel,class,target', 'styles' => FALSE, 'classes' => 'external', - ), - 'span' => array( + ], + 'span' => [ 'attributes' => 'class,property,rel,style', 'styles' => 'font-size', 'classes' => FALSE, - ), - '*' => array( + ], + '*' => [ 'attributes' => 'class,data-*', 'styles' => FALSE, 'classes' => 'is-a-hipster-llama,and-more', - ), - 'del' => array( + ], + 'del' => [ 'attributes' => FALSE, 'styles' => FALSE, 'classes' => FALSE, - ), - ); - $expected_config['disallowedContent'] = array( - 'span' => array( + ], + ]; + $expected_config['disallowedContent'] = [ + 'span' => [ 'styles' => 'underline,color', 'classes' => 'dodo', - ), - '*' => array( + ], + '*' => [ 'attributes' => 'on*', - ), - ); + ], + ]; $expected_config['format_tags'] = 'p'; ksort($expected_config); ksort($expected_config['allowedContent']); @@ -232,7 +232,7 @@ function testBuildToolbarJSSetting() { $this->assertIdentical($expected, $this->castSafeStrings($this->ckeditor->buildToolbarJSSetting($editor)), '"toolbar" configuration part of JS settings built correctly for customized toolbar.'); // Enable the editor_test module, customize further. - $this->enableModules(array('ckeditor_test')); + $this->enableModules(['ckeditor_test']); $this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions(); // Override the label of a toolbar component. $settings['toolbar']['rows'][0][0]['name'] = 'JunkScience'; @@ -255,7 +255,7 @@ function testBuildContentsCssJSSetting() { $this->assertIdentical($expected, $this->ckeditor->buildContentsCssJSSetting($editor), '"contentsCss" configuration part of JS settings built correctly for default toolbar.'); // Enable the editor_test module, which implements hook_ckeditor_css_alter(). - $this->enableModules(array('ckeditor_test')); + $this->enableModules(['ckeditor_test']); $expected[] = file_url_transform_relative(file_create_url(drupal_get_path('module', 'ckeditor_test') . '/ckeditor_test.css')); $this->assertIdentical($expected, $this->ckeditor->buildContentsCssJSSetting($editor), '"contentsCss" configuration part of JS settings built correctly while a hook_ckeditor_css_alter() implementation exists.'); @@ -315,7 +315,7 @@ function testStylesComboGetConfig() { $settings['plugins']['stylescombo']['styles'] = ''; $editor->setSettings($settings); $editor->save(); - $expected['stylesSet'] = array(); + $expected['stylesSet'] = []; $this->assertIdentical($expected, $stylescombo_plugin->getConfig($editor), '"StylesCombo" plugin configuration built correctly for customized toolbar.'); // Configure the optional "styles" setting in odd ways that shouldn't affect @@ -333,10 +333,10 @@ function testStylesComboGetConfig() { $settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.mAgical.Callout|Callout"; $editor->setSettings($settings); $editor->save(); - $expected['stylesSet'] = array( - array('name' => 'Title', 'element' => 'h1', 'attributes' => array('class' => 'title')), - array('name' => 'Callout', 'element' => 'p', 'attributes' => array('class' => 'mAgical Callout')), - ); + $expected['stylesSet'] = [ + ['name' => 'Title', 'element' => 'h1', 'attributes' => ['class' => 'title']], + ['name' => 'Callout', 'element' => 'p', 'attributes' => ['class' => 'mAgical Callout']], + ]; $this->assertIdentical($expected, $stylescombo_plugin->getConfig($editor), '"StylesCombo" plugin configuration built correctly for customized toolbar.'); // Same configuration, but now interspersed with nonsense. Should yield the @@ -350,7 +350,7 @@ function testStylesComboGetConfig() { $settings['plugins']['stylescombo']['styles'] = " h1 | Title "; $editor->setSettings($settings); $editor->save(); - $expected['stylesSet'] = array(array('name' => 'Title', 'element' => 'h1')); + $expected['stylesSet'] = [['name' => 'Title', 'element' => 'h1']]; $this->assertIdentical($expected, $stylescombo_plugin->getConfig($editor), '"StylesCombo" plugin configuration built correctly for customized toolbar.'); // Invalid syntax should cause stylesSet to be set to FALSE. @@ -366,8 +366,8 @@ function testStylesComboGetConfig() { */ function testLanguages() { // Get CKEditor supported language codes and spot-check. - $this->enableModules(array('language')); - $this->installConfig(array('language')); + $this->enableModules(['language']); + $this->installConfig(['language']); $langcodes = $this->ckeditor->getLangcodes(); // Language codes transformed with browser mappings. @@ -390,14 +390,14 @@ function testLanguages() { * Tests that CKEditor plugins participate in JS translation. */ function testJSTranslation() { - $this->enableModules(array('language', 'locale')); + $this->enableModules(['language', 'locale']); $this->installSchema('locale', 'locales_source'); $this->installSchema('locale', 'locales_location'); $this->installSchema('locale', 'locales_target'); $editor = Editor::load('filtered_html'); $this->ckeditor->getJSSettings($editor); $localeStorage = $this->container->get('locale.storage'); - $string = $localeStorage->findString(array('source' => 'Edit Link', 'context' => '')); + $string = $localeStorage->findString(['source' => 'Edit Link', 'context' => '']); $this->assertTrue(!empty($string), 'String from JavaScript file saved.'); // With locale module, CKEditor should not adhere to the language selected. @@ -428,14 +428,14 @@ protected function assertCKEditorLanguage($langcode = 'fr') { } protected function getDefaultInternalConfig() { - return array( + return [ 'customConfig' => '', 'pasteFromWordPromptCleanup' => TRUE, 'resize_dir' => 'vertical', - 'justifyClasses' => array('text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'), + 'justifyClasses' => ['text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'], 'entities' => FALSE, 'disableNativeSpellChecker' => FALSE, - ); + ]; } protected function getDefaultAllowedContentConfig() { @@ -454,42 +454,42 @@ protected function getDefaultAllowedContentConfig() { } protected function getDefaultDisallowedContentConfig() { - return array( - '*' => array('attributes' => 'on*'), - ); + return [ + '*' => ['attributes' => 'on*'], + ]; } protected function getDefaultToolbarConfig() { - return array( - array( + return [ + [ 'name' => 'Formatting', - 'items' => array('Bold', 'Italic',), - ), - array( + 'items' => ['Bold', 'Italic', ], + ], + [ 'name' => 'Links', - 'items' => array('DrupalLink', 'DrupalUnlink',), - ), - array( + 'items' => ['DrupalLink', 'DrupalUnlink', ], + ], + [ 'name' => 'Lists', - 'items' => array('BulletedList', 'NumberedList',), - ), - array( + 'items' => ['BulletedList', 'NumberedList', ], + ], + [ 'name' => 'Media', - 'items' => array('Blockquote', 'DrupalImage',), - ), - array( + 'items' => ['Blockquote', 'DrupalImage', ], + ], + [ 'name' => 'Tools', - 'items' => array('Source',), - ), + 'items' => ['Source', ], + ], '/', - ); + ]; } protected function getDefaultContentsCssConfig() { - return array( + return [ file_url_transform_relative(file_create_url('core/modules/ckeditor/css/ckeditor-iframe.css')), file_url_transform_relative(file_create_url('core/modules/system/css/components/align.module.css')), - ); + ]; } } diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php index 932b05c..012579d 100644 --- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php +++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php @@ -30,14 +30,14 @@ class Llama extends PluginBase implements CKEditorPluginInterface { * {@inheritdoc} */ function getDependencies(Editor $editor) { - return array(); + return []; } /** * {@inheritdoc} */ function getLibraries(Editor $editor) { - return array(); + return []; } /** @@ -58,7 +58,7 @@ function getFile() { * {@inheritdoc} */ public function getConfig(Editor $editor) { - return array(); + return []; } } diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php index 7520dfd..4568192 100644 --- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php +++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php @@ -18,11 +18,11 @@ class LlamaButton extends Llama implements CKEditorPluginButtonsInterface { * {@inheritdoc} */ function getButtons() { - return array( - 'Llama' => array( + return [ + 'Llama' => [ 'label' => t('Insert Llama'), - ), - ); + ], + ]; } /** diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php index 43060d9..5e1955f 100644 --- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php +++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php @@ -39,11 +39,11 @@ function isEnabled(Editor $editor) { * {@inheritdoc} */ function getButtons() { - return array( - 'Llama' => array( + return [ + 'Llama' => [ 'label' => t('Insert Llama'), - ), - ); + ], + ]; } /** @@ -58,17 +58,17 @@ function getFile() { */ function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) { // Defaults. - $config = array('ultra_llama_mode' => FALSE); + $config = ['ultra_llama_mode' => FALSE]; $settings = $editor->getSettings(); if (isset($settings['plugins']['llama_contextual_and_button'])) { $config = $settings['plugins']['llama_contextual_and_button']; } - $form['ultra_llama_mode'] = array( + $form['ultra_llama_mode'] = [ '#title' => t('Ultra llama mode'), '#type' => 'checkbox', '#default_value' => $config['ultra_llama_mode'], - ); + ]; return $form; } diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php index 294b39c..d3b9a7f 100644 --- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php +++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php @@ -20,20 +20,20 @@ class LlamaCss extends Llama implements CKEditorPluginButtonsInterface, CKEditor * {@inheritdoc} */ function getButtons() { - return array( - 'LlamaCSS' => array( + return [ + 'LlamaCSS' => [ 'label' => t('Insert Llama CSS'), - ), - ); + ], + ]; } /** * {@inheritdoc} */ function getCssFiles(Editor $editor) { - return array( + return [ drupal_get_path('module', 'ckeditor_test') . '/css/llama.css' - ); + ]; } /** diff --git a/core/modules/color/color.install b/core/modules/color/color.install index 7f61338..3cc098c 100644 --- a/core/modules/color/color.install +++ b/core/modules/color/color.install @@ -9,15 +9,15 @@ * Implements hook_requirements(). */ function color_requirements($phase) { - $requirements = array(); + $requirements = []; if ($phase == 'runtime') { // Check for the PHP GD library. if (function_exists('imagegd2')) { $info = gd_info(); - $requirements['color_gd'] = array( + $requirements['color_gd'] = [ 'value' => $info['GD Version'], - ); + ]; // Check for PNG support. if (!function_exists('imagecreatefrompng')) { @@ -26,11 +26,11 @@ function color_requirements($phase) { } } else { - $requirements['color_gd'] = array( + $requirements['color_gd'] = [ 'value' => t('Not installed'), 'severity' => REQUIREMENT_ERROR, 'description' => t('The GD library for PHP is missing or outdated. Check the PHP image documentation for information on how to correct this.'), - ); + ]; } $requirements['color_gd']['title'] = t('GD library PNG support'); } diff --git a/core/modules/color/color.module b/core/modules/color/color.module index ca0dc3a..a63e440 100644 --- a/core/modules/color/color.module +++ b/core/modules/color/color.module @@ -22,11 +22,11 @@ function color_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { case 'help.page.color': $output = '

        ' . t('About') . '

        '; - $output .= '

        ' . t('The Color module allows users with the Administer site configuration permission to change the color scheme (color of links, backgrounds, text, and other theme elements) of compatible themes. For more information, see the online documentation for the Color module.', array(':color_do' => 'https://www.drupal.org/documentation/modules/color')) . '

        '; + $output .= '

        ' . t('The Color module allows users with the Administer site configuration permission to change the color scheme (color of links, backgrounds, text, and other theme elements) of compatible themes. For more information, see the online documentation for the Color module.', [':color_do' => 'https://www.drupal.org/documentation/modules/color']) . '

        '; $output .= '

        ' . t('Uses') . '

        '; $output .= '
        '; $output .= '
        ' . t('Changing colors') . '
        '; - $output .= '

        ' . t('To change the color settings, select the Settings link for your theme on the Appearance page. If the color picker does not appear then the theme is not compatible with the Color module.', array(':appearance' => \Drupal::url('system.themes_page'))) . '

        '; + $output .= '

        ' . t('To change the color settings, select the Settings link for your theme on the Appearance page. If the color picker does not appear then the theme is not compatible with the Color module.', [':appearance' => \Drupal::url('system.themes_page')]) . '

        '; $output .= '

        ' . t('The Color module saves a modified copy of the theme\'s specified stylesheets in the files directory. If you make any manual changes to your theme\'s stylesheet, you must save your color settings again, even if you haven\'t changed the colors. This step is required because the module stylesheets in the files directory need to be recreated to reflect your changes.') . '

        '; $output .= '
        '; return $output; @@ -37,11 +37,11 @@ function color_help($route_name, RouteMatchInterface $route_match) { * Implements hook_theme(). */ function color_theme() { - return array( - 'color_scheme_form' => array( + return [ + 'color_scheme_form' => [ 'render element' => 'form', - ), - ); + ], + ]; } /** @@ -50,14 +50,14 @@ function color_theme() { function color_form_system_theme_settings_alter(&$form, FormStateInterface $form_state) { $build_info = $form_state->getBuildInfo(); if (isset($build_info['args'][0]) && ($theme = $build_info['args'][0]) && color_get_info($theme) && function_exists('gd_info')) { - $form['color'] = array( + $form['color'] = [ '#type' => 'details', '#title' => t('Color scheme'), '#open' => TRUE, '#weight' => -1, - '#attributes' => array('id' => 'color_scheme_form'), + '#attributes' => ['id' => 'color_scheme_form'], '#theme' => 'color_scheme_form', - ); + ]; $form['color'] += color_scheme_form($form, $form_state, $theme); $form['#validate'][] = 'color_scheme_form_validate'; // Ensure color submission happens first so we can unset extra values. @@ -136,7 +136,7 @@ function color_block_view_pre_render(array $build) { * Retrieves the Color module information for a particular theme. */ function color_get_info($theme) { - static $theme_info = array(); + static $theme_info = []; if (isset($theme_info[$theme])) { return $theme_info[$theme]; @@ -147,21 +147,21 @@ function color_get_info($theme) { if ($path && file_exists($file)) { include $file; // Add in default values. - $info += array( + $info += [ // CSS files (excluding @import) to rewrite with new color scheme. - 'css' => array(), + 'css' => [], // Files to copy. - 'copy' => array(), + 'copy' => [], // Gradient definitions. - 'gradients' => array(), + 'gradients' => [], // Color areas to fill (x, y, width, height). - 'fill' => array(), + 'fill' => [], // Coordinates of all the theme slices (x, y, width, height) with their // filename as used in the stylesheet. - 'slices' => array(), + 'slices' => [], // Reference color used for blending. 'blend_target' => '#ffffff', - ); + ]; $theme_info[$theme] = $info; return $info; } @@ -199,9 +199,9 @@ function color_get_palette($theme, $default = FALSE) { function color_scheme_form($complete_form, FormStateInterface $form_state, $theme) { $info = color_get_info($theme); - $info['schemes'][''] = array('title' => t('Custom'), 'colors' => array()); - $color_sets = array(); - $schemes = array(); + $info['schemes'][''] = ['title' => t('Custom'), 'colors' => []]; + $color_sets = []; + $schemes = []; foreach ($info['schemes'] as $key => $scheme) { $color_sets[$key] = $scheme['title']; $schemes[$key] = $scheme['colors']; @@ -232,16 +232,16 @@ function color_scheme_form($complete_form, FormStateInterface $form_state, $them // Add scheme selector. $default_palette = color_get_palette($theme, TRUE); - $form['scheme'] = array( + $form['scheme'] = [ '#type' => 'select', '#title' => t('Color set'), '#options' => $color_sets, '#default_value' => $scheme_name, - '#attached' => array( - 'library' => array( + '#attached' => [ + 'library' => [ 'color/drupal.color', 'color/admin', - ), + ], // Add custom JavaScript. 'drupalSettings' => [ 'color' => [ @@ -250,8 +250,8 @@ function color_scheme_form($complete_form, FormStateInterface $form_state, $them ], 'gradients' => $info['gradients'], ], - ), - ); + ], + ]; // Add palette fields. Use the configuration if available. $palette = $current_scheme ?: $default_palette; @@ -259,22 +259,22 @@ function color_scheme_form($complete_form, FormStateInterface $form_state, $them $form['palette']['#tree'] = TRUE; foreach ($palette as $name => $value) { if (isset($names[$name])) { - $form['palette'][$name] = array( + $form['palette'][$name] = [ '#type' => 'textfield', '#title' => $names[$name], '#value_callback' => 'color_palette_color_value', '#default_value' => $value, '#size' => 8, - '#attributes' => array('dir' => LanguageInterface::DIRECTION_LTR), - ); + '#attributes' => ['dir' => LanguageInterface::DIRECTION_LTR], + ]; } } - $form['theme'] = array('#type' => 'value', '#value' => $theme); + $form['theme'] = ['#type' => 'value', '#value' => $theme]; if (isset($info['#attached'])) { $form['#attached'] = $info['#attached']; unset($info['#attached']); } - $form['info'] = array('#type' => 'value', '#value' => $info); + $form['info'] = ['#type' => 'value', '#value' => $info]; return $form; } @@ -359,7 +359,7 @@ function color_scheme_form_validate($form, FormStateInterface $form_state) { // Only accept hexadecimal CSS color strings to avoid XSS upon use. foreach ($form_state->getValue('palette') as $key => $color) { if (!color_valid_hexadecimal_string($color)) { - $form_state->setErrorByName('palette][' . $key, t('You must enter a valid hexadecimal color value for %name.', array('%name' => $form['color']['palette'][$key]['#title']))); + $form_state->setErrorByName('palette][' . $key, t('You must enter a valid hexadecimal color value for %name.', ['%name' => $form['color']['palette'][$key]['#title']])); } } } @@ -372,7 +372,7 @@ function color_scheme_form_validate($form, FormStateInterface $form_state) { function color_scheme_form_submit($form, FormStateInterface $form_state) { // Avoid color settings spilling over to theme settings. - $color_settings = array('theme', 'palette', 'scheme'); + $color_settings = ['theme', 'palette', 'scheme']; if ($form_state->hasValue('info')) { $color_settings[] = 'info'; } @@ -413,7 +413,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) { $memory_limit = ini_get('memory_limit'); $size = Bytes::toInt($memory_limit); if (!Environment::checkMemoryLimit($usage + $required, $memory_limit)) { - drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the PHP documentation for more information.', array('%size' => format_size($usage + $required - $size))), 'error'); + drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the PHP documentation for more information.', ['%size' => format_size($usage + $required - $size)]), 'error'); return; } } @@ -445,7 +445,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) { $paths['target'] = $paths['target'] . '/'; $paths['id'] = $id; $paths['source'] = drupal_get_path('theme', $theme) . '/'; - $paths['files'] = $paths['map'] = array(); + $paths['files'] = $paths['map'] = []; // Save palette and logo location. $config @@ -468,10 +468,10 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) { } // Rewrite theme stylesheets. - $css = array(); + $css = []; foreach ($info['css'] as $stylesheet) { // Build a temporary array with CSS files. - $files = array(); + $files = []; if (file_exists($paths['source'] . $stylesheet)) { $files[] = $stylesheet; } @@ -488,7 +488,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) { $css_optimizer->rewriteFileURIBasePath = base_path() . dirname($paths['source'] . $file) . '/'; // Prefix all paths within this CSS file, ignoring absolute paths. - $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', array($css_optimizer, 'rewriteFileURI'), $style); + $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', [$css_optimizer, 'rewriteFileURI'], $style); // Rewrite stylesheet with new colors. $style = _color_rewrite_stylesheet($theme, $info, $paths, $palette, $style); @@ -728,7 +728,7 @@ function _color_shift($given, $ref1, $ref2, $target) { * Converts a hex triplet into a GD color. */ function _color_gd($img, $hex) { - $c = array_merge(array($img), _color_unpack($hex)); + $c = array_merge([$img], _color_unpack($hex)); return call_user_func_array('imagecolorallocate', $c); } @@ -738,7 +738,7 @@ function _color_gd($img, $hex) { function _color_blend($img, $hex1, $hex2, $alpha) { $in1 = _color_unpack($hex1); $in2 = _color_unpack($hex2); - $out = array($img); + $out = [$img]; for ($i = 0; $i < 3; ++$i) { $out[] = $in1[$i] + ($in2[$i] - $in1[$i]) * $alpha; } @@ -783,11 +783,11 @@ function _color_hsl2rgb($hsl) { $m2 = ($l <= 0.5) ? $l * ($s + 1) : $l + $s - $l * $s; $m1 = $l * 2 - $m2; - return array( + return [ _color_hue2rgb($m1, $m2, $h + 0.33333), _color_hue2rgb($m1, $m2, $h), _color_hue2rgb($m1, $m2, $h - 0.33333), - ); + ]; } /** @@ -827,5 +827,5 @@ function _color_rgb2hsl($rgb) { $h /= 6; } - return array($h, $s, $l); + return [$h, $s, $l]; } diff --git a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc index b88e8ea..ee77a5a 100644 --- a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc +++ b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc @@ -5,29 +5,29 @@ * Lists available colors and color schemes for the Color test theme. */ -$info = array( - 'fields' => array( +$info = [ + 'fields' => [ 'bg' => t('Main background'), 'text' => t('Text color'), - ), - 'schemes' => array( - 'default' => array( + ], + 'schemes' => [ + 'default' => [ 'title' => t('Default'), - 'colors' => array( + 'colors' => [ 'bg' => '#ff0000', 'text' => '#0000ff', - ), - ), - 'custom' => array( + ], + ], + 'custom' => [ 'title' => t('Custom'), - 'colors' => array( + 'colors' => [ 'bg' => '#ff0000', 'text' => '#3b3b3b', - ), - ), - ), - 'css' => array( + ], + ], + ], + 'css' => [ 'css/colors.css', - ), + ], 'preview_html' => 'color/preview.html', -); +]; diff --git a/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php b/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php index 157deb8..e55275d 100644 --- a/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php +++ b/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php @@ -16,7 +16,7 @@ class ColorConfigSchemaTest extends BrowserTestBase { * * @var array */ - public static $modules = array('color'); + public static $modules = ['color']; /** * A user with administrative permissions. @@ -30,10 +30,10 @@ class ColorConfigSchemaTest extends BrowserTestBase { */ protected function setUp() { parent::setUp(); - \Drupal::service('theme_handler')->install(array('bartik')); + \Drupal::service('theme_handler')->install(['bartik']); // Create user. - $this->adminUser = $this->drupalCreateUser(array('administer themes')); + $this->adminUser = $this->drupalCreateUser(['administer themes']); $this->drupalLogin($this->adminUser); } diff --git a/core/modules/color/tests/src/Functional/ColorTest.php b/core/modules/color/tests/src/Functional/ColorTest.php index dc44566..8416913 100644 --- a/core/modules/color/tests/src/Functional/ColorTest.php +++ b/core/modules/color/tests/src/Functional/ColorTest.php @@ -17,7 +17,7 @@ class ColorTest extends BrowserTestBase { * * @var array */ - public static $modules = array('color', 'color_test', 'block', 'file'); + public static $modules = ['color', 'color_test', 'block', 'file']; /** * A user with administrative permissions. @@ -50,25 +50,25 @@ protected function setUp() { parent::setUp(); // Create user. - $this->bigUser = $this->drupalCreateUser(array('administer themes')); + $this->bigUser = $this->drupalCreateUser(['administer themes']); // This tests the color module in Bartik. - $this->themes = array( - 'bartik' => array( + $this->themes = [ + 'bartik' => [ 'palette_input' => 'palette[bg]', 'scheme' => 'slate', 'scheme_color' => '#3b3b3b', - ), - 'color_test_theme' => array( + ], + 'color_test_theme' => [ 'palette_input' => 'palette[bg]', 'scheme' => 'custom', 'scheme_color' => '#3b3b3b', - ), - ); + ], + ]; \Drupal::service('theme_handler')->install(array_keys($this->themes)); // Array filled with valid and not valid color values. - $this->colorTests = array( + $this->colorTests = [ '#000' => TRUE, '#123456' => TRUE, '#abcdef' => TRUE, @@ -78,7 +78,7 @@ protected function setUp() { '#00000' => FALSE, '123456' => FALSE, '#00000g' => FALSE, - ); + ]; } /** @@ -138,7 +138,7 @@ function _testColor($theme, $test_values) { $config->set('css.preprocess', 1); $config->save(); $this->drupalGet(''); - $stylesheets = \Drupal::state()->get('drupal_css_cache_files') ?: array(); + $stylesheets = \Drupal::state()->get('drupal_css_cache_files') ?: []; $stylesheet_content = ''; foreach ($stylesheets as $uri) { $stylesheet_content .= join("\n", file(drupal_realpath($uri))); @@ -178,10 +178,10 @@ function testValidColor() { */ function testLogoSettingOverride() { $this->drupalLogin($this->bigUser); - $edit = array( + $edit = [ 'default_logo' => FALSE, 'logo_path' => 'core/misc/druplicon.png', - ); + ]; $this->drupalPostForm('admin/appearance/settings', $edit, t('Save configuration')); // Ensure that the overridden logo is present in Bartik, which is colorable. diff --git a/core/modules/comment/comment.api.php b/core/modules/comment/comment.api.php index 7b922cb..ec6b4ce 100644 --- a/core/modules/comment/comment.api.php +++ b/core/modules/comment/comment.api.php @@ -31,16 +31,16 @@ * @see \Drupal\comment\CommentViewBuilder::buildLinks() */ function hook_comment_links_alter(array &$links, CommentInterface $entity, array &$context) { - $links['mymodule'] = array( + $links['mymodule'] = [ '#theme' => 'links__comment__mymodule', - '#attributes' => array('class' => array('links', 'inline')), - '#links' => array( - 'comment-report' => array( + '#attributes' => ['class' => ['links', 'inline']], + '#links' => [ + 'comment-report' => [ 'title' => t('Report'), 'url' => Url::fromRoute('comment_test.report', ['comment' => $entity->id()], ['query' => ['token' => \Drupal::getContainer()->get('csrf_token')->get("comment/{$entity->id()}/report")]]), - ), - ), - ); + ], + ], + ]; } /** diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index b4fd6aa..24ca76e 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -15,7 +15,7 @@ */ function comment_uninstall() { // Remove the comment fields. - $fields = entity_load_multiple_by_properties('field_storage_config', array('type' => 'comment')); + $fields = entity_load_multiple_by_properties('field_storage_config', ['type' => 'comment']); foreach ($fields as $field) { $field->delete(); } @@ -37,78 +37,78 @@ function comment_install() { * Implements hook_schema(). */ function comment_schema() { - $schema['comment_entity_statistics'] = array( + $schema['comment_entity_statistics'] = [ 'description' => 'Maintains statistics of entity and comments posts to show "new" and "updated" flags.', - 'fields' => array( - 'entity_id' => array( + 'fields' => [ + 'entity_id' => [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The entity_id of the entity for which the statistics are compiled.', - ), - 'entity_type' => array( + ], + 'entity_type' => [ 'type' => 'varchar_ascii', 'not null' => TRUE, 'default' => 'node', 'length' => EntityTypeInterface::ID_MAX_LENGTH, 'description' => 'The entity_type of the entity to which this comment is a reply.', - ), - 'field_name' => array( + ], + 'field_name' => [ 'type' => 'varchar_ascii', 'not null' => TRUE, 'default' => '', 'length' => FieldStorageConfig::NAME_MAX_LENGTH, 'description' => 'The field_name of the field that was used to add this comment.', - ), - 'cid' => array( + ], + 'cid' => [ 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'The {comment}.cid of the last comment.', - ), - 'last_comment_timestamp' => array( + ], + 'last_comment_timestamp' => [ 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'The Unix timestamp of the last comment that was posted within this node, from {comment}.changed.', - ), - 'last_comment_name' => array( + ], + 'last_comment_name' => [ 'type' => 'varchar', 'length' => 60, 'not null' => FALSE, 'description' => 'The name of the latest author to post a comment on this node, from {comment}.name.', - ), - 'last_comment_uid' => array( + ], + 'last_comment_uid' => [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The user ID of the latest author to post a comment on this node, from {comment}.uid.', - ), - 'comment_count' => array( + ], + 'comment_count' => [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The total number of comments on this entity.', - ), - ), - 'primary key' => array('entity_id', 'entity_type', 'field_name'), - 'indexes' => array( - 'last_comment_timestamp' => array('last_comment_timestamp'), - 'comment_count' => array('comment_count'), - 'last_comment_uid' => array('last_comment_uid'), - ), - 'foreign keys' => array( - 'last_comment_author' => array( + ], + ], + 'primary key' => ['entity_id', 'entity_type', 'field_name'], + 'indexes' => [ + 'last_comment_timestamp' => ['last_comment_timestamp'], + 'comment_count' => ['comment_count'], + 'last_comment_uid' => ['last_comment_uid'], + ], + 'foreign keys' => [ + 'last_comment_author' => [ 'table' => 'users', - 'columns' => array( + 'columns' => [ 'last_comment_uid' => 'uid', - ), - ), - ), - ); + ], + ], + ], + ]; return $schema; } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 8a1febc..062e085 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -59,19 +59,19 @@ function comment_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { case 'help.page.comment': $output = '

        ' . t('About') . '

        '; - $output .= '

        ' . t('The Comment module allows users to comment on site content, set commenting defaults and permissions, and moderate comments. For more information, see the online documentation for the Comment module.', array(':comment' => 'https://www.drupal.org/documentation/modules/comment')) . '

        '; + $output .= '

        ' . t('The Comment module allows users to comment on site content, set commenting defaults and permissions, and moderate comments. For more information, see the online documentation for the Comment module.', [':comment' => 'https://www.drupal.org/documentation/modules/comment']) . '

        '; $output .= '

        ' . t('Uses') . '

        '; $output .= '
        '; $output .= '
        ' . t('Enabling commenting') . '
        '; - $output .= '
        ' . t('Comment functionality can be enabled for any entity sub-type (for example, a content type) by adding a Comments field on its Manage fields page. Adding or removing commenting for an entity through the user interface requires the Field UI module to be enabled, even though the commenting functionality works without it. For more information on fields and entities, see the Field module help page.', array(':content-type' => (\Drupal::moduleHandler()->moduleExists('node')) ? \Drupal::url('entity.node_type.collection') : '#', ':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '
        '; + $output .= '
        ' . t('Comment functionality can be enabled for any entity sub-type (for example, a content type) by adding a Comments field on its Manage fields page. Adding or removing commenting for an entity through the user interface requires the Field UI module to be enabled, even though the commenting functionality works without it. For more information on fields and entities, see the Field module help page.', [':content-type' => (\Drupal::moduleHandler()->moduleExists('node')) ? \Drupal::url('entity.node_type.collection') : '#', ':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#']) . '
        '; $output .= '
        ' . t('Configuring commenting settings') . '
        '; $output .= '
        ' . t('Commenting settings can be configured by editing the Comments field on the Manage fields page of an entity type if the Field UI module is enabled. Configuration includes the label of the comments field, the number of comments to be displayed, and whether they are shown in threaded list. Commenting can be be configured as: Open to allow new comments, Closed to view existing comments, but prevent new comments, or Hidden to hide existing comments and prevent new comments. Changing this configuration for an entity type will not change existing entity items.') . '
        '; $output .= '
        ' . t('Overriding default settings') . '
        '; $output .= '
        ' . t('Users with the appropriate permissions can override the default commenting settings of an entity type when they create an item of that type.') . '
        '; $output .= '
        ' . t('Adding comment types') . '
        '; - $output .= '
        ' . t('Additional comment types can be created per entity sub-type and added on the Comment types page. If there are multiple comment types available you can select the appropriate one after adding a Comments field.', array(':field' => \Drupal::url('entity.comment_type.collection'))) . '
        '; + $output .= '
        ' . t('Additional comment types can be created per entity sub-type and added on the Comment types page. If there are multiple comment types available you can select the appropriate one after adding a Comments field.', [':field' => \Drupal::url('entity.comment_type.collection')]) . '
        '; $output .= '
        ' . t('Approving and managing comments') . '
        '; - $output .= '
        ' . t('Comments from users who have the Skip comment approval permission are published immediately. All other comments are placed in the Unapproved comments queue, until a user who has permission to Administer comments and comment settings publishes or deletes them. Published comments can be bulk managed on the Published comments administration page. When a comment has no replies, it remains editable by its author, as long as the author has Edit own comments permission.', array(':comment-approval' => \Drupal::url('comment.admin_approval'), ':admin-comment' => \Drupal::url('comment.admin'))) . '
        '; + $output .= '
        ' . t('Comments from users who have the Skip comment approval permission are published immediately. All other comments are placed in the Unapproved comments queue, until a user who has permission to Administer comments and comment settings publishes or deletes them. Published comments can be bulk managed on the Published comments administration page. When a comment has no replies, it remains editable by its author, as long as the author has Edit own comments permission.', [':comment-approval' => \Drupal::url('comment.admin_approval'), ':admin-comment' => \Drupal::url('comment.admin')]) . '
        '; $output .= '
        '; return $output; @@ -87,10 +87,10 @@ function comment_help($route_name, RouteMatchInterface $route_match) { function comment_uri(CommentInterface $comment) { return new Url( 'entity.comment.canonical', - array( + [ 'comment' => $comment->id(), - ), - array('fragment' => 'comment-' . $comment->id()) + ], + ['fragment' => 'comment-' . $comment->id()] ); } @@ -98,23 +98,23 @@ function comment_uri(CommentInterface $comment) { * Implements hook_entity_extra_field_info(). */ function comment_entity_extra_field_info() { - $return = array(); + $return = []; foreach (CommentType::loadMultiple() as $comment_type) { - $return['comment'][$comment_type->id()] = array( - 'form' => array( - 'author' => array( + $return['comment'][$comment_type->id()] = [ + 'form' => [ + 'author' => [ 'label' => t('Author'), 'description' => t('Author textfield'), 'weight' => -2, - ), - ), - ); - $return['comment'][$comment_type->id()]['display']['links'] = array( + ], + ], + ]; + $return['comment'][$comment_type->id()]['display']['links'] = [ 'label' => t('Links'), 'description' => t('Comment operation links'), 'weight' => 100, 'visible' => TRUE, - ); + ]; } return $return; @@ -124,14 +124,14 @@ function comment_entity_extra_field_info() { * Implements hook_theme(). */ function comment_theme() { - return array( - 'comment' => array( + return [ + 'comment' => [ 'render element' => 'elements', - ), - 'field__comment' => array( + ], + 'field__comment' => [ 'base hook' => 'field', - ), - ); + ], + ]; } /** @@ -141,15 +141,15 @@ function comment_field_config_create(FieldConfigInterface $field) { if ($field->getType() == 'comment' && !$field->isSyncing()) { // Assign default values for the field. $default_value = $field->getDefaultValueLiteral(); - $default_value += array(array()); - $default_value[0] += array( + $default_value += [[]]; + $default_value[0] += [ 'status' => CommentItemInterface::OPEN, 'cid' => 0, 'last_comment_timestamp' => 0, 'last_comment_name' => '', 'last_comment_uid' => 0, 'comment_count' => 0, - ); + ]; $field->setDefaultValue($default_value); } } @@ -218,14 +218,14 @@ function comment_entity_view(array &$build, EntityInterface $entity, EntityViewD if ($entity->hasField($field_name) && $entity->get($field_name)->status != CommentItemInterface::HIDDEN) { // Add a comments RSS element which is a URL to the comments of this // entity. - $options = array( + $options = [ 'fragment' => 'comments', 'absolute' => TRUE, - ); - $entity->rss_elements[] = array( + ]; + $entity->rss_elements[] = [ 'key' => 'comments', 'value' => $entity->url('canonical', $options), - ); + ]; } } } @@ -448,7 +448,7 @@ function comment_node_update_index(EntityInterface $node) { } } - $build = array(); + $build = []; if ($index_comments) { foreach (\Drupal::service('comment.manager')->getFields('node') as $field_name => $info) { @@ -508,7 +508,7 @@ function comment_node_search_result(EntityInterface $node) { // Do not make a string if there are no comment fields, or no comments exist // or all comment fields are hidden. if ($comments > 0 || $open) { - return array('comment' => \Drupal::translation()->formatPlural($comments, '1 comment', '@count comments')); + return ['comment' => \Drupal::translation()->formatPlural($comments, '1 comment', '@count comments')]; } } @@ -518,7 +518,7 @@ function comment_node_search_result(EntityInterface $node) { function comment_user_cancel($edit, $account, $method) { switch ($method) { case 'user_cancel_block_unpublish': - $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->id())); + $comments = entity_load_multiple_by_properties('comment', ['uid' => $account->id()]); foreach ($comments as $comment) { $comment->setPublished(CommentInterface::NOT_PUBLISHED); $comment->save(); @@ -527,7 +527,7 @@ function comment_user_cancel($edit, $account, $method) { case 'user_cancel_reassign': /** @var \Drupal\comment\CommentInterface[] $comments */ - $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->id())); + $comments = entity_load_multiple_by_properties('comment', ['uid' => $account->id()]); foreach ($comments as $comment) { $comment->setOwnerId(0); $comment->setAuthorName(\Drupal::config('user.settings')->get('anonymous')); @@ -559,7 +559,7 @@ function comment_user_predelete($account) { * An array as expected by drupal_render(). */ function comment_preview(CommentInterface $comment, FormStateInterface $form_state) { - $preview_build = array(); + $preview_build = []; $entity = $comment->getCommentedEntity(); if (!$form_state->getErrors()) { @@ -571,7 +571,7 @@ function comment_preview(CommentInterface $comment, FormStateInterface $form_sta } if ($comment->hasParentComment()) { - $build = array(); + $build = []; $parent = $comment->getParentComment(); if ($parent && $parent->isPublished()) { $build = \Drupal::entityTypeManager()->getViewBuilder('comment')->view($parent); @@ -627,10 +627,10 @@ function template_preprocess_comment(&$variables) { $variables['threaded'] = $variables['elements']['#comment_threaded']; $account = $comment->getOwner(); - $username = array( + $username = [ '#theme' => 'username', '#account' => $account, - ); + ]; $variables['author'] = drupal_render($username); $variables['author_id'] = $comment->getOwnerId(); $variables['new_indicator_timestamp'] = $comment->getChangedTime(); @@ -649,7 +649,7 @@ function template_preprocess_comment(&$variables) { $variables['user_picture'] = user_view($account, 'compact'); } else { - $variables['user_picture'] = array(); + $variables['user_picture'] = []; } if (isset($comment->in_preview)) { @@ -658,25 +658,25 @@ function template_preprocess_comment(&$variables) { } else { $uri = $comment->urlInfo(); - $attributes = $uri->getOption('attributes') ?: array(); - $attributes += array('class' => array('permalink'), 'rel' => 'bookmark'); + $attributes = $uri->getOption('attributes') ?: []; + $attributes += ['class' => ['permalink'], 'rel' => 'bookmark']; $uri->setOption('attributes', $attributes); $variables['title'] = \Drupal::l($comment->getSubject(), $uri); $variables['permalink'] = \Drupal::l(t('Permalink'), $comment->permalink()); } - $variables['submitted'] = t('Submitted by @username on @datetime', array('@username' => $variables['author'], '@datetime' => $variables['created'])); + $variables['submitted'] = t('Submitted by @username on @datetime', ['@username' => $variables['author'], '@datetime' => $variables['created']]); if ($comment->hasParentComment()) { // Fetch and store the parent comment information for use in templates. $comment_parent = $comment->getParentComment(); $account_parent = $comment_parent->getOwner(); $variables['parent_comment'] = $comment_parent; - $username = array( + $username = [ '#theme' => 'username', '#account' => $account_parent, - ); + ]; $variables['parent_author'] = drupal_render($username); $variables['parent_created'] = format_date($comment_parent->getCreatedTime()); // Avoid calling format_date() twice on the same timestamp. @@ -687,13 +687,13 @@ function template_preprocess_comment(&$variables) { $variables['parent_changed'] = format_date($comment_parent->getChangedTime()); } $permalink_uri_parent = $comment_parent->permalink(); - $attributes = $permalink_uri_parent->getOption('attributes') ?: array(); - $attributes += array('class' => array('permalink'), 'rel' => 'bookmark'); + $attributes = $permalink_uri_parent->getOption('attributes') ?: []; + $attributes += ['class' => ['permalink'], 'rel' => 'bookmark']; $permalink_uri_parent->setOption('attributes', $attributes); $variables['parent_title'] = \Drupal::l($comment_parent->getSubject(), $permalink_uri_parent); $variables['parent_permalink'] = \Drupal::l(t('Parent permalink'), $permalink_uri_parent); $variables['parent'] = t('In reply to @parent_title by @parent_username', - array('@parent_username' => $variables['parent_author'], '@parent_title' => $variables['parent_title'])); + ['@parent_username' => $variables['parent_author'], '@parent_title' => $variables['parent_title']]); } else { $variables['parent_comment'] = ''; diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc index 4a935c2..01e5179 100644 --- a/core/modules/comment/comment.tokens.inc +++ b/core/modules/comment/comment.tokens.inc @@ -15,11 +15,11 @@ * Implements hook_token_info(). */ function comment_token_info() { - $type = array( + $type = [ 'name' => t('Comments'), 'description' => t('Tokens for comments posted on the site.'), 'needs-data' => 'comment', - ); + ]; $tokens = []; // Provide a integration for each entity type except comment. @@ -45,76 +45,76 @@ function comment_token_info() { } // Core comment tokens - $comment['cid'] = array( + $comment['cid'] = [ 'name' => t("Comment ID"), 'description' => t("The unique ID of the comment."), - ); - $comment['hostname'] = array( + ]; + $comment['hostname'] = [ 'name' => t("IP Address"), 'description' => t("The IP address of the computer the comment was posted from."), - ); - $comment['mail'] = array( + ]; + $comment['mail'] = [ 'name' => t("Email address"), 'description' => t("The email address left by the comment author."), - ); - $comment['homepage'] = array( + ]; + $comment['homepage'] = [ 'name' => t("Home page"), 'description' => t("The home page URL left by the comment author."), - ); - $comment['title'] = array( + ]; + $comment['title'] = [ 'name' => t("Title"), 'description' => t("The title of the comment."), - ); - $comment['body'] = array( + ]; + $comment['body'] = [ 'name' => t("Content"), 'description' => t("The formatted content of the comment itself."), - ); - $comment['langcode'] = array( + ]; + $comment['langcode'] = [ 'name' => t('Language code'), 'description' => t('The language code of the language the comment is written in.'), - ); - $comment['url'] = array( + ]; + $comment['url'] = [ 'name' => t("URL"), 'description' => t("The URL of the comment."), - ); - $comment['edit-url'] = array( + ]; + $comment['edit-url'] = [ 'name' => t("Edit URL"), 'description' => t("The URL of the comment's edit page."), - ); + ]; // Chained tokens for comments - $comment['created'] = array( + $comment['created'] = [ 'name' => t("Date created"), 'description' => t("The date the comment was posted."), 'type' => 'date', - ); - $comment['changed'] = array( + ]; + $comment['changed'] = [ 'name' => t("Date changed"), 'description' => t("The date the comment was most recently updated."), 'type' => 'date', - ); - $comment['parent'] = array( + ]; + $comment['parent'] = [ 'name' => t("Parent"), 'description' => t("The comment's parent, if comment threading is active."), 'type' => 'comment', - ); - $comment['entity'] = array( + ]; + $comment['entity'] = [ 'name' => t("Entity"), 'description' => t("The entity the comment was posted to."), 'type' => 'entity', - ); - $comment['author'] = array( + ]; + $comment['author'] = [ 'name' => t("Author"), 'description' => t("The author name of the comment."), 'type' => 'user', - ); + ]; - return array( - 'types' => array('comment' => $type), - 'tokens' => array( + return [ + 'types' => ['comment' => $type], + 'tokens' => [ 'comment' => $comment, - ) + $tokens, - ); + ] + $tokens, + ]; } /** @@ -123,7 +123,7 @@ function comment_token_info() { function comment_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) { $token_service = \Drupal::token(); - $url_options = array('absolute' => TRUE); + $url_options = ['absolute' => TRUE]; if (isset($options['langcode'])) { $url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']); $langcode = $options['langcode']; @@ -131,7 +131,7 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM else { $langcode = NULL; } - $replacements = array(); + $replacements = []; if ($type == 'comment' && !empty($data['comment'])) { /** @var \Drupal\comment\CommentInterface $comment */ @@ -230,23 +230,23 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM // Chained token relationships. if ($entity_tokens = $token_service->findwithPrefix($tokens, 'entity')) { $entity = $comment->getCommentedEntity(); - $replacements += $token_service->generate($comment->getCommentedEntityTypeId(), $entity_tokens, array($comment->getCommentedEntityTypeId() => $entity), $options, $bubbleable_metadata); + $replacements += $token_service->generate($comment->getCommentedEntityTypeId(), $entity_tokens, [$comment->getCommentedEntityTypeId() => $entity], $options, $bubbleable_metadata); } if ($date_tokens = $token_service->findwithPrefix($tokens, 'created')) { - $replacements += $token_service->generate('date', $date_tokens, array('date' => $comment->getCreatedTime()), $options, $bubbleable_metadata); + $replacements += $token_service->generate('date', $date_tokens, ['date' => $comment->getCreatedTime()], $options, $bubbleable_metadata); } if ($date_tokens = $token_service->findwithPrefix($tokens, 'changed')) { - $replacements += $token_service->generate('date', $date_tokens, array('date' => $comment->getChangedTime()), $options, $bubbleable_metadata); + $replacements += $token_service->generate('date', $date_tokens, ['date' => $comment->getChangedTime()], $options, $bubbleable_metadata); } if (($parent_tokens = $token_service->findwithPrefix($tokens, 'parent')) && $parent = $comment->getParentComment()) { - $replacements += $token_service->generate('comment', $parent_tokens, array('comment' => $parent), $options, $bubbleable_metadata); + $replacements += $token_service->generate('comment', $parent_tokens, ['comment' => $parent], $options, $bubbleable_metadata); } if (($author_tokens = $token_service->findwithPrefix($tokens, 'author')) && $account = $comment->getOwner()) { - $replacements += $token_service->generate('user', $author_tokens, array('user' => $account), $options, $bubbleable_metadata); + $replacements += $token_service->generate('user', $author_tokens, ['user' => $account], $options, $bubbleable_metadata); } } // Replacement tokens for any content entities that have comment field. diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc index 5e31876..f90d412 100644 --- a/core/modules/comment/comment.views.inc +++ b/core/modules/comment/comment.views.inc @@ -11,14 +11,14 @@ function comment_views_data_alter(&$data) { // New comments are only supported for node table because it requires the // history table. - $data['node']['new_comments'] = array( + $data['node']['new_comments'] = [ 'title' => t('New comments'), 'help' => t('The number of new comments on the node.'), - 'field' => array( + 'field' => [ 'id' => 'node_new_comments', 'no group by' => TRUE, - ), - ); + ], + ]; // Provide a integration for each entity type except comment. foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type) { @@ -27,25 +27,25 @@ function comment_views_data_alter(&$data) { } $fields = \Drupal::service('comment.manager')->getFields($entity_type_id); $base_table = $entity_type->getDataTable() ?: $entity_type->getBaseTable(); - $args = array('@entity_type' => $entity_type_id); + $args = ['@entity_type' => $entity_type_id]; if ($fields) { - $data[$base_table]['comments_link'] = array( - 'field' => array( + $data[$base_table]['comments_link'] = [ + 'field' => [ 'title' => t('Add comment link'), 'help' => t('Display the standard add comment link used on regular @entity_type, which will only display if the viewing user has access to add a comment.', $args), 'id' => 'comment_entity_link', - ), - ); + ], + ]; // Multilingual properties are stored in data table. if (!($table = $entity_type->getDataTable())) { $table = $entity_type->getBaseTable(); } - $data[$table]['uid_touch'] = array( + $data[$table]['uid_touch'] = [ 'title' => t('User posted or commented'), 'help' => t('Display nodes only if a user posted the @entity_type or commented on the @entity_type.', $args), - 'argument' => array( + 'argument' => [ 'field' => 'uid', 'name table' => 'users_field_data', 'name field' => 'name', @@ -53,40 +53,40 @@ function comment_views_data_alter(&$data) { 'no group by' => TRUE, 'entity_type' => $entity_type_id, 'entity_id' => $entity_type->getKey('id'), - ), - 'filter' => array( + ], + 'filter' => [ 'field' => 'uid', 'name table' => 'users_field_data', 'name field' => 'name', 'id' => 'comment_user_uid', 'entity_type' => $entity_type_id, 'entity_id' => $entity_type->getKey('id'), - ), - ); + ], + ]; foreach ($fields as $field_name => $field) { - $data[$base_table][$field_name . '_cid'] = array( - 'title' => t('Comments of the @entity_type using field: @field_name', $args + array('@field_name' => $field_name)), + $data[$base_table][$field_name . '_cid'] = [ + 'title' => t('Comments of the @entity_type using field: @field_name', $args + ['@field_name' => $field_name]), 'help' => t('Relate all comments on the @entity_type. This will create 1 duplicate record for every comment. Usually if you need this it is better to create a comment view.', $args), - 'relationship' => array( + 'relationship' => [ 'group' => t('Comment'), 'label' => t('Comments'), 'base' => 'comment_field_data', 'base field' => 'entity_id', 'relationship field' => $entity_type->getKey('id'), 'id' => 'standard', - 'extra' => array( - array( + 'extra' => [ + [ 'field' => 'entity_type', 'value' => $entity_type_id, - ), - array( + ], + [ 'field' => 'field_name', 'value' => $field_name, - ), - ), - ), - ); + ], + ], + ], + ]; } } } diff --git a/core/modules/comment/src/CommentAccessControlHandler.php b/core/modules/comment/src/CommentAccessControlHandler.php index ff6b3b9..cb822a3 100644 --- a/core/modules/comment/src/CommentAccessControlHandler.php +++ b/core/modules/comment/src/CommentAccessControlHandler.php @@ -62,23 +62,23 @@ protected function checkFieldAccess($operation, FieldDefinitionInterface $field_ if ($operation == 'edit') { // Only users with the "administer comments" permission can edit // administrative fields. - $administrative_fields = array( + $administrative_fields = [ 'uid', 'status', 'created', 'date', - ); + ]; if (in_array($field_definition->getName(), $administrative_fields, TRUE)) { return AccessResult::allowedIfHasPermission($account, 'administer comments'); } // No user can change read-only fields. - $read_only_fields = array( + $read_only_fields = [ 'hostname', 'changed', 'cid', 'thread', - ); + ]; // These fields can be edited during comment creation. $create_only_fields = [ 'comment_type', diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php index 75191a3..4bfd2dd 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php @@ -83,7 +83,7 @@ public function form(array $form, FormStateInterface $form_state) { // Use #comment-form as unique jump target, regardless of entity type. $form['#id'] = Html::getUniqueId('comment_form'); - $form['#theme'] = array('comment_form__' . $entity->getEntityTypeId() . '__' . $entity->bundle() . '__' . $field_name, 'comment_form'); + $form['#theme'] = ['comment_form__' . $entity->getEntityTypeId() . '__' . $entity->bundle() . '__' . $field_name, 'comment_form']; $anonymous_contact = $field_definition->getSetting('anonymous'); $is_admin = $comment->id() && $this->currentUser->hasPermission('administer comments'); @@ -96,7 +96,7 @@ public function form(array $form, FormStateInterface $form_state) { // If not replying to a comment, use our dedicated page callback for new // Comments on entities. if (!$comment->id() && !$comment->hasParentComment()) { - $form['#action'] = $this->url('comment.reply', array('entity_type' => $entity->getEntityTypeId(), 'entity' => $entity->id(), 'field_name' => $field_name)); + $form['#action'] = $this->url('comment.reply', ['entity_type' => $entity->getEntityTypeId(), 'entity' => $entity->id(), 'field_name' => $field_name]); } $comment_preview = $form_state->get('comment_preview'); @@ -104,13 +104,13 @@ public function form(array $form, FormStateInterface $form_state) { $form += $comment_preview; } - $form['author'] = array(); + $form['author'] = []; // Display author information in a details element for comment moderators. if ($is_admin) { - $form['author'] += array( + $form['author'] += [ '#type' => 'details', '#title' => $this->t('Administration'), - ); + ]; } // Prepare default values for form elements. @@ -121,9 +121,9 @@ public function form(array $form, FormStateInterface $form_state) { } $status = $comment->getStatus(); if (empty($comment_preview)) { - $form['#title'] = $this->t('Edit comment %title', array( + $form['#title'] = $this->t('Edit comment %title', [ '%title' => $comment->getSubject(), - )); + ]); } } else { @@ -154,7 +154,7 @@ public function form(array $form, FormStateInterface $form_state) { // The name field is displayed when an anonymous user is adding a comment or // when a user with the permission 'administer comments' is editing an // existing comment from an anonymous user. - $form['author']['name'] = array( + $form['author']['name'] = [ '#type' => 'textfield', '#title' => $is_admin ? $this->t('Name for @anonymous', ['@anonymous' => $config->get('anonymous')]) : $this->t('Your name'), '#default_value' => $author, @@ -165,20 +165,20 @@ public function form(array $form, FormStateInterface $form_state) { '#attributes' => [ 'data-drupal-default-value' => $config->get('anonymous'), ], - ); + ]; if ($is_admin) { // When editing a comment only display the name textfield if the uid field // is empty. $form['author']['name']['#states'] = [ 'visible' => [ - ':input[name="uid"]' => array('empty' => TRUE), + ':input[name="uid"]' => ['empty' => TRUE], ], ]; } // Add author email and homepage fields depending on the current user. - $form['author']['mail'] = array( + $form['author']['mail'] = [ '#type' => 'email', '#title' => $this->t('Email'), '#default_value' => $comment->getAuthorEmail(), @@ -187,36 +187,36 @@ public function form(array $form, FormStateInterface $form_state) { '#size' => 30, '#description' => $this->t('The content of this field is kept private and will not be shown publicly.'), '#access' => ($comment->getOwner()->isAnonymous() && $is_admin) || ($this->currentUser->isAnonymous() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT), - ); + ]; - $form['author']['homepage'] = array( + $form['author']['homepage'] = [ '#type' => 'url', '#title' => $this->t('Homepage'), '#default_value' => $comment->getHomepage(), '#maxlength' => 255, '#size' => 30, '#access' => $is_admin || ($this->currentUser->isAnonymous() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT), - ); + ]; // Add administrative comment publishing options. - $form['author']['date'] = array( + $form['author']['date'] = [ '#type' => 'datetime', '#title' => $this->t('Authored on'), '#default_value' => $date, '#size' => 20, '#access' => $is_admin, - ); + ]; - $form['author']['status'] = array( + $form['author']['status'] = [ '#type' => 'radios', '#title' => $this->t('Status'), '#default_value' => $status, - '#options' => array( + '#options' => [ CommentInterface::PUBLISHED => $this->t('Published'), CommentInterface::NOT_PUBLISHED => $this->t('Not published'), - ), + ], '#access' => $is_admin, - ); + ]; return parent::form($form, $form_state, $comment); } @@ -242,12 +242,12 @@ protected function actions(array $form, FormStateInterface $form_state) { // already previewing the submission. $element['submit']['#access'] = ($comment->id() && $this->currentUser->hasPermission('administer comments')) || $preview_mode != DRUPAL_REQUIRED || $form_state->get('comment_preview'); - $element['preview'] = array( + $element['preview'] = [ '#type' => 'submit', '#value' => $this->t('Preview'), '#access' => $preview_mode != DRUPAL_DISABLED, - '#submit' => array('::submitForm', '::preview'), - ); + '#submit' => ['::submitForm', '::preview'], + ]; return $element; } @@ -357,10 +357,10 @@ public function save(array $form, FormStateInterface $form_state) { $form_state->setValue('cid', $comment->id()); // Add a log entry. - $logger->notice('Comment posted: %subject.', array( + $logger->notice('Comment posted: %subject.', [ '%subject' => $comment->getSubject(), 'link' => $this->l(t('View'), $comment->urlInfo()->setOption('fragment', 'comment-' . $comment->id())) - )); + ]); // Explain the approval queue if necessary. if (!$comment->isPublished()) { @@ -371,7 +371,7 @@ public function save(array $form, FormStateInterface $form_state) { else { drupal_set_message($this->t('Your comment has been posted.')); } - $query = array(); + $query = []; // Find the current display page for this comment. $field_definition = $this->entityManager->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle())[$field_name]; $page = $this->entityManager->getStorage('comment')->getDisplayOrdinal($comment, $field_definition->getSetting('default_mode'), $field_definition->getSetting('per_page')); @@ -383,8 +383,8 @@ public function save(array $form, FormStateInterface $form_state) { $uri->setOption('fragment', 'comment-' . $comment->id()); } else { - $logger->warning('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->getSubject())); - drupal_set_message($this->t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->getSubject())), 'error'); + $logger->warning('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', ['%subject' => $comment->getSubject()]); + drupal_set_message($this->t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', ['%subject' => $comment->getSubject()]), 'error'); // Redirect the user to the entity they are commenting on. } $form_state->setRedirectUrl($uri); diff --git a/core/modules/comment/src/CommentLazyBuilders.php b/core/modules/comment/src/CommentLazyBuilders.php index 4eeeb59..730c840 100644 --- a/core/modules/comment/src/CommentLazyBuilders.php +++ b/core/modules/comment/src/CommentLazyBuilders.php @@ -99,13 +99,13 @@ public function __construct(EntityManagerInterface $entity_manager, EntityFormBu * A renderable array containing the comment form. */ public function renderForm($commented_entity_type_id, $commented_entity_id, $field_name, $comment_type_id) { - $values = array( + $values = [ 'entity_type' => $commented_entity_type_id, 'entity_id' => $commented_entity_id, 'field_name' => $field_name, 'comment_type' => $comment_type_id, 'pid' => NULL, - ); + ]; $comment = $this->entityManager->getStorage('comment')->create($values); return $this->entityFormBuilder->getForm($comment); } @@ -126,11 +126,11 @@ public function renderForm($commented_entity_type_id, $commented_entity_id, $fie * A renderable array representing the comment links. */ public function renderLinks($comment_entity_id, $view_mode, $langcode, $is_in_preview) { - $links = array( + $links = [ '#theme' => 'links__comment', - '#pre_render' => array('drupal_pre_render_links'), - '#attributes' => array('class' => array('links', 'inline')), - ); + '#pre_render' => ['drupal_pre_render_links'], + '#attributes' => ['class' => ['links', 'inline']], + ]; if (!$is_in_preview) { /** @var \Drupal\comment\CommentInterface $entity */ @@ -140,11 +140,11 @@ public function renderLinks($comment_entity_id, $view_mode, $langcode, $is_in_pr $links['comment'] = $this->buildLinks($entity, $commented_entity); // Allow other modules to alter the comment links. - $hook_context = array( + $hook_context = [ 'view_mode' => $view_mode, 'langcode' => $langcode, 'commented_entity' => $commented_entity, - ); + ]; $this->moduleHandler->alter('comment_links', $links, $entity, $hook_context); } return $links; @@ -162,25 +162,25 @@ public function renderLinks($comment_entity_id, $view_mode, $langcode, $is_in_pr * An array that can be processed by drupal_pre_render_links(). */ protected function buildLinks(CommentInterface $entity, EntityInterface $commented_entity) { - $links = array(); + $links = []; $status = $commented_entity->get($entity->getFieldName())->status; if ($status == CommentItemInterface::OPEN) { if ($entity->access('delete')) { - $links['comment-delete'] = array( + $links['comment-delete'] = [ 'title' => t('Delete'), 'url' => $entity->urlInfo('delete-form'), - ); + ]; } if ($entity->access('update')) { - $links['comment-edit'] = array( + $links['comment-edit'] = [ 'title' => t('Edit'), 'url' => $entity->urlInfo('edit-form'), - ); + ]; } if ($entity->access('create')) { - $links['comment-reply'] = array( + $links['comment-reply'] = [ 'title' => t('Reply'), 'url' => Url::fromRoute('comment.reply', [ 'entity_type' => $entity->getCommentedEntityTypeId(), @@ -188,13 +188,13 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment 'field_name' => $entity->getFieldName(), 'pid' => $entity->id(), ]), - ); + ]; } if (!$entity->isPublished() && $entity->access('approve')) { - $links['comment-approve'] = array( + $links['comment-approve'] = [ 'title' => t('Approve'), 'url' => Url::fromRoute('comment.approve', ['comment' => $entity->id()]), - ); + ]; } if (empty($links) && $this->currentUser->isAnonymous()) { $links['comment-forbidden']['title'] = $this->commentManager->forbiddenMessage($commented_entity, $entity->getFieldName()); @@ -203,18 +203,18 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment // Add translations link for translation-enabled comment bundles. if ($this->moduleHandler->moduleExists('content_translation') && $this->access($entity)->isAllowed()) { - $links['comment-translations'] = array( + $links['comment-translations'] = [ 'title' => t('Translate'), 'url' => $entity->urlInfo('drupal:content-translation-overview'), - ); + ]; } - return array( + return [ '#theme' => 'links__comment__comment', // The "entity" property is specified to be present, so no need to check. '#links' => $links, - '#attributes' => array('class' => array('links', 'inline')), - ); + '#attributes' => ['class' => ['links', 'inline']], + ]; } /** diff --git a/core/modules/comment/src/CommentLinkBuilder.php b/core/modules/comment/src/CommentLinkBuilder.php index 9998e3f..c7cbc18 100644 --- a/core/modules/comment/src/CommentLinkBuilder.php +++ b/core/modules/comment/src/CommentLinkBuilder.php @@ -75,7 +75,7 @@ public function __construct(AccountInterface $current_user, CommentManagerInterf * {@inheritdoc} */ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, array &$context) { - $entity_links = array(); + $entity_links = []; $view_mode = $context['view_mode']; if ($view_mode == 'search_index' || $view_mode == 'search_result' || $view_mode == 'print' || $view_mode == 'rss') { // Do not add any links if the entity is displayed for: @@ -83,7 +83,7 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra // - constructing a search result excerpt. // - print. // - rss. - return array(); + return []; } $fields = $this->commentManager->getFields($entity->getEntityTypeId()); @@ -92,7 +92,7 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra if (!$entity->hasField($field_name)) { continue; } - $links = array(); + $links = []; $commenting_status = $entity->get($field_name)->status; if ($commenting_status != CommentItemInterface::HIDDEN) { // Entity has commenting status open or closed. @@ -103,23 +103,23 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra // entity is open to new comments, and there currently are none. if ($this->currentUser->hasPermission('access comments')) { if (!empty($entity->get($field_name)->comment_count)) { - $links['comment-comments'] = array( + $links['comment-comments'] = [ 'title' => $this->formatPlural($entity->get($field_name)->comment_count, '1 comment', '@count comments'), - 'attributes' => array('title' => $this->t('Jump to the first comment.')), + 'attributes' => ['title' => $this->t('Jump to the first comment.')], 'fragment' => 'comments', 'url' => $entity->urlInfo(), - ); + ]; if ($this->moduleHandler->moduleExists('history')) { - $links['comment-new-comments'] = array( + $links['comment-new-comments'] = [ 'title' => '', 'url' => Url::fromRoute(''), - 'attributes' => array( + 'attributes' => [ 'class' => 'hidden', 'title' => $this->t('Jump to the first new comment.'), 'data-history-node-last-comment-timestamp' => $entity->get($field_name)->last_comment_timestamp, 'data-history-node-field-name' => $field_name, - ), - ); + ], + ]; } } } @@ -127,12 +127,12 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra if ($commenting_status == CommentItemInterface::OPEN) { $comment_form_location = $field_definition->getSetting('form_location'); if ($this->currentUser->hasPermission('post comments')) { - $links['comment-add'] = array( + $links['comment-add'] = [ 'title' => $this->t('Add new comment'), 'language' => $entity->language(), - 'attributes' => array('title' => $this->t('Share your thoughts and opinions.')), + 'attributes' => ['title' => $this->t('Share your thoughts and opinions.')], 'fragment' => 'comment-form', - ); + ]; if ($comment_form_location == CommentItemInterface::FORM_SEPARATE_PAGE) { $links['comment-add']['url'] = Url::fromRoute('comment.reply', [ 'entity_type' => $entity->getEntityTypeId(), @@ -145,9 +145,9 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra } } elseif ($this->currentUser->isAnonymous()) { - $links['comment-forbidden'] = array( + $links['comment-forbidden'] = [ 'title' => $this->commentManager->forbiddenMessage($entity, $field_name), - ); + ]; } } } @@ -161,11 +161,11 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra // Show the "post comment" link if the form is on another page, or // if there are existing comments that the link will skip past. if ($comment_form_location == CommentItemInterface::FORM_SEPARATE_PAGE || (!empty($entity->get($field_name)->comment_count) && $this->currentUser->hasPermission('access comments'))) { - $links['comment-add'] = array( + $links['comment-add'] = [ 'title' => $this->t('Add new comment'), - 'attributes' => array('title' => $this->t('Share your thoughts and opinions.')), + 'attributes' => ['title' => $this->t('Share your thoughts and opinions.')], 'fragment' => 'comment-form', - ); + ]; if ($comment_form_location == CommentItemInterface::FORM_SEPARATE_PAGE) { $links['comment-add']['url'] = Url::fromRoute('comment.reply', [ 'entity_type' => $entity->getEntityTypeId(), @@ -179,20 +179,20 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra } } elseif ($this->currentUser->isAnonymous()) { - $links['comment-forbidden'] = array( + $links['comment-forbidden'] = [ 'title' => $this->commentManager->forbiddenMessage($entity, $field_name), - ); + ]; } } } } if (!empty($links)) { - $entity_links['comment__' . $field_name] = array( + $entity_links['comment__' . $field_name] = [ '#theme' => 'links__entity__comment__' . $field_name, '#links' => $links, - '#attributes' => array('class' => array('links', 'inline')), - ); + '#attributes' => ['class' => ['links', 'inline']], + ]; if ($view_mode == 'teaser' && $this->moduleHandler->moduleExists('history') && $this->currentUser->isAuthenticated()) { $entity_links['comment__' . $field_name]['#cache']['contexts'][] = 'user'; $entity_links['comment__' . $field_name]['#attached']['library'][] = 'comment/drupal.node-new-comments-link'; diff --git a/core/modules/comment/src/CommentManager.php b/core/modules/comment/src/CommentManager.php index fcec230..965eac7 100644 --- a/core/modules/comment/src/CommentManager.php +++ b/core/modules/comment/src/CommentManager.php @@ -100,11 +100,11 @@ public function __construct(EntityManagerInterface $entity_manager, QueryFactory public function getFields($entity_type_id) { $entity_type = $this->entityManager->getDefinition($entity_type_id); if (!$entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { - return array(); + return []; } $map = $this->entityManager->getFieldMapByFieldType('comment'); - return isset($map[$entity_type_id]) ? $map[$entity_type_id] : array(); + return isset($map[$entity_type_id]) ? $map[$entity_type_id] : []; } /** @@ -113,28 +113,28 @@ public function getFields($entity_type_id) { public function addBodyField($comment_type_id) { if (!FieldConfig::loadByName('comment', $comment_type_id, 'comment_body')) { // Attaches the body field by default. - $field = $this->entityManager->getStorage('field_config')->create(array( + $field = $this->entityManager->getStorage('field_config')->create([ 'label' => 'Comment', 'bundle' => $comment_type_id, 'required' => TRUE, 'field_storage' => FieldStorageConfig::loadByName('comment', 'comment_body'), - )); + ]); $field->save(); // Assign widget settings for the 'default' form mode. entity_get_form_display('comment', $comment_type_id, 'default') - ->setComponent('comment_body', array( + ->setComponent('comment_body', [ 'type' => 'text_textarea', - )) + ]) ->save(); // Assign display settings for the 'default' view mode. entity_get_display('comment', $comment_type_id, 'default') - ->setComponent('comment_body', array( + ->setComponent('comment_body', [ 'label' => 'hidden', 'type' => 'text_default', 'weight' => 0, - )) + ]) ->save(); } } @@ -161,24 +161,24 @@ public function forbiddenMessage(EntityInterface $entity, $field_name) { 'entity' => $entity->id(), 'field_name' => $field_name, ]; - $destination = array('destination' => $this->url('comment.reply', $comment_reply_parameters, array('fragment' => 'comment-form'))); + $destination = ['destination' => $this->url('comment.reply', $comment_reply_parameters, ['fragment' => 'comment-form'])]; } else { - $destination = array('destination' => $entity->url('canonical', array('fragment' => 'comment-form'))); + $destination = ['destination' => $entity->url('canonical', ['fragment' => 'comment-form'])]; } if ($this->userConfig->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) { // Users can register themselves. - return $this->t('Log in or register to post comments', array( - ':login' => $this->urlGenerator->generateFromRoute('user.login', array(), array('query' => $destination)), - ':register' => $this->urlGenerator->generateFromRoute('user.register', array(), array('query' => $destination)), - )); + return $this->t('Log in or register to post comments', [ + ':login' => $this->urlGenerator->generateFromRoute('user.login', [], ['query' => $destination]), + ':register' => $this->urlGenerator->generateFromRoute('user.register', [], ['query' => $destination]), + ]); } else { // Only admins can add new users, no public registration. - return $this->t('Log in to post comments', array( - ':login' => $this->urlGenerator->generateFromRoute('user.login', array(), array('query' => $destination)), - )); + return $this->t('Log in to post comments', [ + ':login' => $this->urlGenerator->generateFromRoute('user.login', [], ['query' => $destination]), + ]); } } return ''; diff --git a/core/modules/comment/src/CommentStatistics.php b/core/modules/comment/src/CommentStatistics.php index 74061ee..3c6b571 100644 --- a/core/modules/comment/src/CommentStatistics.php +++ b/core/modules/comment/src/CommentStatistics.php @@ -65,14 +65,14 @@ public function __construct(Connection $database, AccountInterface $current_user * {@inheritdoc} */ public function read($entities, $entity_type, $accurate = TRUE) { - $options = $accurate ? array() : array('target' => 'replica'); + $options = $accurate ? [] : ['target' => 'replica']; $stats = $this->database->select('comment_entity_statistics', 'ces', $options) ->fields('ces') ->condition('ces.entity_id', array_keys($entities), 'IN') ->condition('ces.entity_type', $entity_type) ->execute(); - $statistics_records = array(); + $statistics_records = []; while ($entry = $stats->fetchObject()) { $statistics_records[] = $entry; } @@ -94,7 +94,7 @@ public function delete(EntityInterface $entity) { */ public function create(FieldableEntityInterface $entity, $fields) { $query = $this->database->insert('comment_entity_statistics') - ->fields(array( + ->fields([ 'entity_id', 'entity_type', 'field_name', @@ -103,7 +103,7 @@ public function create(FieldableEntityInterface $entity, $fields) { 'last_comment_name', 'last_comment_uid', 'comment_count', - )); + ]); foreach ($fields as $field_name => $detail) { // Skip fields that entity does not have. if (!$entity->hasField($field_name)) { @@ -127,7 +127,7 @@ public function create(FieldableEntityInterface $entity, $fields) { if ($entity instanceof EntityChangedInterface) { $last_comment_timestamp = $entity->getChangedTimeAcrossTranslations(); } - $query->values(array( + $query->values([ 'entity_id' => $entity->id(), 'entity_type' => $entity->getEntityTypeId(), 'field_name' => $field_name, @@ -136,7 +136,7 @@ public function create(FieldableEntityInterface $entity, $fields) { 'last_comment_name' => NULL, 'last_comment_uid' => $last_comment_uid, 'comment_count' => 0, - )); + ]); } $query->execute(); } @@ -145,24 +145,24 @@ public function create(FieldableEntityInterface $entity, $fields) { * {@inheritdoc} */ public function getMaximumCount($entity_type) { - return $this->database->query('SELECT MAX(comment_count) FROM {comment_entity_statistics} WHERE entity_type = :entity_type', array(':entity_type' => $entity_type))->fetchField(); + return $this->database->query('SELECT MAX(comment_count) FROM {comment_entity_statistics} WHERE entity_type = :entity_type', [':entity_type' => $entity_type])->fetchField(); } /** * {@inheritdoc} */ public function getRankingInfo() { - return array( - 'comments' => array( + return [ + 'comments' => [ 'title' => t('Number of comments'), - 'join' => array( + 'join' => [ 'type' => 'LEFT', 'table' => 'comment_entity_statistics', 'alias' => 'ces', // Default to comment field as this is the most common use case for // nodes. 'on' => "ces.entity_id = i.sid AND ces.entity_type = 'node' AND ces.field_name = 'comment'", - ), + ], // Inverse law that maps the highest view count on the site to 1 and 0 // to 0. Note that the ROUND here is necessary for PostgreSQL and SQLite // in order to ensure that the :comment_scale argument is treated as @@ -170,9 +170,9 @@ public function getRankingInfo() { // values in as strings instead of numbers in complex expressions like // this. 'score' => '2.0 - 2.0 / (1.0 + ces.comment_count * (ROUND(:comment_scale, 4)))', - 'arguments' => array(':comment_scale' => \Drupal::state()->get('comment.node_comment_statistics_scale') ?: 0), - ), - ); + 'arguments' => [':comment_scale' => \Drupal::state()->get('comment.node_comment_statistics_scale') ?: 0], + ], + ]; } /** @@ -198,7 +198,7 @@ public function update(CommentInterface $comment) { if ($count > 0) { // Comments exist. $last_reply = $this->database->select('comment_field_data', 'c') - ->fields('c', array('cid', 'name', 'changed', 'uid')) + ->fields('c', ['cid', 'name', 'changed', 'uid']) ->condition('c.entity_id', $comment->getCommentedEntityId()) ->condition('c.entity_type', $comment->getCommentedEntityTypeId()) ->condition('c.field_name', $comment->getFieldName()) @@ -210,18 +210,18 @@ public function update(CommentInterface $comment) { ->fetchObject(); // Use merge here because entity could be created before comment field. $this->database->merge('comment_entity_statistics') - ->fields(array( + ->fields([ 'cid' => $last_reply->cid, 'comment_count' => $count, 'last_comment_timestamp' => $last_reply->changed, 'last_comment_name' => $last_reply->uid ? '' : $last_reply->name, 'last_comment_uid' => $last_reply->uid, - )) - ->keys(array( + ]) + ->keys([ 'entity_id' => $comment->getCommentedEntityId(), 'entity_type' => $comment->getCommentedEntityTypeId(), 'field_name' => $comment->getFieldName(), - )) + ]) ->execute(); } else { @@ -238,7 +238,7 @@ public function update(CommentInterface $comment) { $last_comment_uid = $this->currentUser->id(); } $this->database->update('comment_entity_statistics') - ->fields(array( + ->fields([ 'cid' => 0, 'comment_count' => 0, // Use the changed date of the entity if it's set, or default to @@ -246,7 +246,7 @@ public function update(CommentInterface $comment) { 'last_comment_timestamp' => ($entity instanceof EntityChangedInterface) ? $entity->getChangedTimeAcrossTranslations() : REQUEST_TIME, 'last_comment_name' => '', 'last_comment_uid' => $last_comment_uid, - )) + ]) ->condition('entity_id', $comment->getCommentedEntityId()) ->condition('entity_type', $comment->getCommentedEntityTypeId()) ->condition('field_name', $comment->getFieldName()) @@ -255,7 +255,7 @@ public function update(CommentInterface $comment) { // Reset the cache of the commented entity so that when the entity is loaded // the next time, the statistics will be loaded again. - $this->entityManager->getStorage($comment->getCommentedEntityTypeId())->resetCache(array($comment->getCommentedEntityId())); + $this->entityManager->getStorage($comment->getCommentedEntityTypeId())->resetCache([$comment->getCommentedEntityId()]); } } diff --git a/core/modules/comment/src/CommentStorage.php b/core/modules/comment/src/CommentStorage.php index cc4fdcf..d164d8a 100644 --- a/core/modules/comment/src/CommentStorage.php +++ b/core/modules/comment/src/CommentStorage.php @@ -147,7 +147,7 @@ public function getNewCommentPageNumber($total_comments, $new_comments, Fieldabl // 1. Find all the threads with a new comment. $unread_threads_query = $this->database->select('comment_field_data', 'comment') - ->fields('comment', array('thread')) + ->fields('comment', ['thread']) ->condition('entity_id', $entity->id()) ->condition('entity_type', $entity->getEntityTypeId()) ->condition('field_name', $field_name) @@ -161,7 +161,7 @@ public function getNewCommentPageNumber($total_comments, $new_comments, Fieldabl $first_thread_query = $this->database->select($unread_threads_query, 'thread'); $first_thread_query->addExpression('SUBSTRING(thread, 1, (LENGTH(thread) - 1))', 'torder'); $first_thread = $first_thread_query - ->fields('thread', array('thread')) + ->fields('thread', ['thread']) ->orderBy('torder') ->range(0, 1) ->execute() @@ -176,13 +176,13 @@ public function getNewCommentPageNumber($total_comments, $new_comments, Fieldabl AND field_name = :field_name AND status = :status AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < :thread - AND default_langcode = 1', array( + AND default_langcode = 1', [ ':status' => CommentInterface::PUBLISHED, ':entity_id' => $entity->id(), ':field_name' => $field_name, ':entity_type' => $entity->getEntityTypeId(), ':thread' => $first_thread, - ))->fetchField(); + ])->fetchField(); } return $comments_per_page > 0 ? (int) ($count / $comments_per_page) : 0; @@ -193,7 +193,7 @@ public function getNewCommentPageNumber($total_comments, $new_comments, Fieldabl */ public function getChildCids(array $comments) { return $this->database->select('comment_field_data', 'c') - ->fields('c', array('cid')) + ->fields('c', ['cid']) ->condition('pid', array_keys($comments), 'IN') ->condition('default_langcode', 1) ->execute() @@ -312,7 +312,7 @@ public function loadThread(EntityInterface $entity, $field_name, $mode, $comment $cids = $query->execute()->fetchCol(); - $comments = array(); + $comments = []; if ($cids) { $comments = $this->loadMultiple($cids); } diff --git a/core/modules/comment/src/CommentStorageSchema.php b/core/modules/comment/src/CommentStorageSchema.php index ee663c0..2106a8e 100644 --- a/core/modules/comment/src/CommentStorageSchema.php +++ b/core/modules/comment/src/CommentStorageSchema.php @@ -17,9 +17,9 @@ class CommentStorageSchema extends SqlContentEntityStorageSchema { protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) { $schema = parent::getEntitySchema($entity_type, $reset); - $schema['comment_field_data']['indexes'] += array( - 'comment__status_pid' => array('pid', 'status'), - 'comment__num_new' => array( + $schema['comment_field_data']['indexes'] += [ + 'comment__status_pid' => ['pid', 'status'], + 'comment__num_new' => [ 'entity_id', 'entity_type', 'comment_type', @@ -27,14 +27,14 @@ protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $res 'created', 'cid', 'thread', - ), - 'comment__entity_langcode' => array( + ], + 'comment__entity_langcode' => [ 'entity_id', 'entity_type', 'comment_type', 'default_langcode', - ), - ); + ], + ]; return $schema; } diff --git a/core/modules/comment/src/CommentTranslationHandler.php b/core/modules/comment/src/CommentTranslationHandler.php index 98afe3b..a0abe4b 100644 --- a/core/modules/comment/src/CommentTranslationHandler.php +++ b/core/modules/comment/src/CommentTranslationHandler.php @@ -30,7 +30,7 @@ public function entityFormAlter(array &$form, FormStateInterface $form_state, En * {@inheritdoc} */ protected function entityFormTitle(EntityInterface $entity) { - return t('Edit comment @subject', array('@subject' => $entity->label())); + return t('Edit comment @subject', ['@subject' => $entity->label()]); } /** diff --git a/core/modules/comment/src/CommentTypeForm.php b/core/modules/comment/src/CommentTypeForm.php index 594726a..9cb147f 100644 --- a/core/modules/comment/src/CommentTypeForm.php +++ b/core/modules/comment/src/CommentTypeForm.php @@ -71,32 +71,32 @@ public function form(array $form, FormStateInterface $form_state) { $comment_type = $this->entity; - $form['label'] = array( + $form['label'] = [ '#type' => 'textfield', '#title' => t('Label'), '#maxlength' => 255, '#default_value' => $comment_type->label(), '#required' => TRUE, - ); - $form['id'] = array( + ]; + $form['id'] = [ '#type' => 'machine_name', '#default_value' => $comment_type->id(), - '#machine_name' => array( + '#machine_name' => [ 'exists' => '\Drupal\comment\Entity\CommentType::load', - ), + ], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#disabled' => !$comment_type->isNew(), - ); + ]; - $form['description'] = array( + $form['description'] = [ '#type' => 'textarea', '#default_value' => $comment_type->getDescription(), '#description' => t('Describe this comment type. The text will be displayed on the Comment types administration overview page.'), '#title' => t('Description'), - ); + ]; if ($comment_type->isNew()) { - $options = array(); + $options = []; foreach ($this->entityManager->getDefinitions() as $entity_type) { // Only expose entities that have field UI enabled, only those can // get comment fields added in the UI. @@ -104,47 +104,47 @@ public function form(array $form, FormStateInterface $form_state) { $options[$entity_type->id()] = $entity_type->getLabel(); } } - $form['target_entity_type_id'] = array( + $form['target_entity_type_id'] = [ '#type' => 'select', '#default_value' => $comment_type->getTargetEntityTypeId(), '#title' => t('Target entity type'), '#options' => $options, '#description' => t('The target entity type can not be changed after the comment type has been created.') - ); + ]; } else { - $form['target_entity_type_id_display'] = array( + $form['target_entity_type_id_display'] = [ '#type' => 'item', '#markup' => $this->entityManager->getDefinition($comment_type->getTargetEntityTypeId())->getLabel(), '#title' => t('Target entity type'), - ); + ]; } if ($this->moduleHandler->moduleExists('content_translation')) { - $form['language'] = array( + $form['language'] = [ '#type' => 'details', '#title' => t('Language settings'), '#group' => 'additional_settings', - ); + ]; $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('comment', $comment_type->id()); - $form['language']['language_configuration'] = array( + $form['language']['language_configuration'] = [ '#type' => 'language_configuration', - '#entity_information' => array( + '#entity_information' => [ 'entity_type' => 'comment', 'bundle' => $comment_type->id(), - ), + ], '#default_value' => $language_configuration, - ); + ]; $form['#submit'][] = 'language_configuration_element_submit'; } - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => t('Save'), - ); + ]; return $form; } @@ -158,13 +158,13 @@ public function save(array $form, FormStateInterface $form_state) { $edit_link = $this->entity->link($this->t('Edit')); if ($status == SAVED_UPDATED) { - drupal_set_message(t('Comment type %label has been updated.', array('%label' => $comment_type->label()))); - $this->logger->notice('Comment type %label has been updated.', array('%label' => $comment_type->label(), 'link' => $edit_link)); + drupal_set_message(t('Comment type %label has been updated.', ['%label' => $comment_type->label()])); + $this->logger->notice('Comment type %label has been updated.', ['%label' => $comment_type->label(), 'link' => $edit_link]); } else { $this->commentManager->addBodyField($comment_type->id()); - drupal_set_message(t('Comment type %label has been added.', array('%label' => $comment_type->label()))); - $this->logger->notice('Comment type %label has been added.', array('%label' => $comment_type->label(), 'link' => $edit_link)); + drupal_set_message(t('Comment type %label has been added.', ['%label' => $comment_type->label()])); + $this->logger->notice('Comment type %label has been added.', ['%label' => $comment_type->label(), 'link' => $edit_link]); } $form_state->setRedirectUrl($comment_type->urlInfo('collection')); diff --git a/core/modules/comment/src/CommentViewBuilder.php b/core/modules/comment/src/CommentViewBuilder.php index 5771ed5..ec6d49a 100644 --- a/core/modules/comment/src/CommentViewBuilder.php +++ b/core/modules/comment/src/CommentViewBuilder.php @@ -88,7 +88,7 @@ public function buildComponents(array &$build, array $entities, array $displays, } // Pre-load associated users into cache to leverage multiple loading. - $uids = array(); + $uids = []; foreach ($entities as $entity) { $uids[] = $entity->getOwnerId(); } @@ -125,7 +125,7 @@ public function buildComponents(array &$build, array $entities, array $displays, $display = $displays[$entity->bundle()]; if ($display->getComponent('links')) { - $build[$id]['links'] = array( + $build[$id]['links'] = [ '#lazy_builder' => ['comment.lazy_builders:renderLinks', [ $entity->id(), $view_mode, @@ -133,11 +133,11 @@ public function buildComponents(array &$build, array $entities, array $displays, !empty($entity->in_preview), ]], '#create_placeholder' => TRUE, - ); + ]; } if (!isset($build[$id]['#attached'])) { - $build[$id]['#attached'] = array(); + $build[$id]['#attached'] = []; } $build[$id]['#attached']['library'][] = 'comment/drupal.comment-by-viewer'; if ($this->moduleHandler->moduleExists('history') && $this->currentUser->isAuthenticated()) { diff --git a/core/modules/comment/src/CommentViewsData.php b/core/modules/comment/src/CommentViewsData.php index 2d9b021..7e4e93d 100644 --- a/core/modules/comment/src/CommentViewsData.php +++ b/core/modules/comment/src/CommentViewsData.php @@ -35,148 +35,148 @@ public function getViewsData() { $data['comment_field_data']['created']['title'] = $this->t('Post date'); $data['comment_field_data']['created']['help'] = $this->t('Date and time of when the comment was created.'); - $data['comment_field_data']['created_fulldata'] = array( + $data['comment_field_data']['created_fulldata'] = [ 'title' => $this->t('Created date'), 'help' => $this->t('Date in the form of CCYYMMDD.'), - 'argument' => array( + 'argument' => [ 'field' => 'created', 'id' => 'date_fulldate', - ), - ); + ], + ]; - $data['comment_field_data']['created_year_month'] = array( + $data['comment_field_data']['created_year_month'] = [ 'title' => $this->t('Created year + month'), 'help' => $this->t('Date in the form of YYYYMM.'), - 'argument' => array( + 'argument' => [ 'field' => 'created', 'id' => 'date_year_month', - ), - ); + ], + ]; - $data['comment_field_data']['created_year'] = array( + $data['comment_field_data']['created_year'] = [ 'title' => $this->t('Created year'), 'help' => $this->t('Date in the form of YYYY.'), - 'argument' => array( + 'argument' => [ 'field' => 'created', 'id' => 'date_year', - ), - ); + ], + ]; - $data['comment_field_data']['created_month'] = array( + $data['comment_field_data']['created_month'] = [ 'title' => $this->t('Created month'), 'help' => $this->t('Date in the form of MM (01 - 12).'), - 'argument' => array( + 'argument' => [ 'field' => 'created', 'id' => 'date_month', - ), - ); + ], + ]; - $data['comment_field_data']['created_day'] = array( + $data['comment_field_data']['created_day'] = [ 'title' => $this->t('Created day'), 'help' => $this->t('Date in the form of DD (01 - 31).'), - 'argument' => array( + 'argument' => [ 'field' => 'created', 'id' => 'date_day', - ), - ); + ], + ]; - $data['comment_field_data']['created_week'] = array( + $data['comment_field_data']['created_week'] = [ 'title' => $this->t('Created week'), 'help' => $this->t('Date in the form of WW (01 - 53).'), - 'argument' => array( + 'argument' => [ 'field' => 'created', 'id' => 'date_week', - ), - ); + ], + ]; $data['comment_field_data']['changed']['title'] = $this->t('Updated date'); $data['comment_field_data']['changed']['help'] = $this->t('Date and time of when the comment was last updated.'); - $data['comment_field_data']['changed_fulldata'] = array( + $data['comment_field_data']['changed_fulldata'] = [ 'title' => $this->t('Changed date'), 'help' => $this->t('Date in the form of CCYYMMDD.'), - 'argument' => array( + 'argument' => [ 'field' => 'changed', 'id' => 'date_fulldate', - ), - ); + ], + ]; - $data['comment_field_data']['changed_year_month'] = array( + $data['comment_field_data']['changed_year_month'] = [ 'title' => $this->t('Changed year + month'), 'help' => $this->t('Date in the form of YYYYMM.'), - 'argument' => array( + 'argument' => [ 'field' => 'changed', 'id' => 'date_year_month', - ), - ); + ], + ]; - $data['comment_field_data']['changed_year'] = array( + $data['comment_field_data']['changed_year'] = [ 'title' => $this->t('Changed year'), 'help' => $this->t('Date in the form of YYYY.'), - 'argument' => array( + 'argument' => [ 'field' => 'changed', 'id' => 'date_year', - ), - ); + ], + ]; - $data['comment_field_data']['changed_month'] = array( + $data['comment_field_data']['changed_month'] = [ 'title' => $this->t('Changed month'), 'help' => $this->t('Date in the form of MM (01 - 12).'), - 'argument' => array( + 'argument' => [ 'field' => 'changed', 'id' => 'date_month', - ), - ); + ], + ]; - $data['comment_field_data']['changed_day'] = array( + $data['comment_field_data']['changed_day'] = [ 'title' => $this->t('Changed day'), 'help' => $this->t('Date in the form of DD (01 - 31).'), - 'argument' => array( + 'argument' => [ 'field' => 'changed', 'id' => 'date_day', - ), - ); + ], + ]; - $data['comment_field_data']['changed_week'] = array( + $data['comment_field_data']['changed_week'] = [ 'title' => $this->t('Changed week'), 'help' => $this->t('Date in the form of WW (01 - 53).'), - 'argument' => array( + 'argument' => [ 'field' => 'changed', 'id' => 'date_week', - ), - ); + ], + ]; $data['comment_field_data']['status']['title'] = $this->t('Approved status'); $data['comment_field_data']['status']['help'] = $this->t('Whether the comment is approved (or still in the moderation queue).'); $data['comment_field_data']['status']['filter']['label'] = $this->t('Approved comment status'); $data['comment_field_data']['status']['filter']['type'] = 'yes-no'; - $data['comment']['approve_comment'] = array( - 'field' => array( + $data['comment']['approve_comment'] = [ + 'field' => [ 'title' => $this->t('Link to approve comment'), 'help' => $this->t('Provide a simple link to approve the comment.'), 'id' => 'comment_link_approve', - ), - ); + ], + ]; - $data['comment']['replyto_comment'] = array( - 'field' => array( + $data['comment']['replyto_comment'] = [ + 'field' => [ 'title' => $this->t('Link to reply-to comment'), 'help' => $this->t('Provide a simple link to reply to the comment.'), 'id' => 'comment_link_reply', - ), - ); + ], + ]; - $data['comment_field_data']['thread']['field'] = array( + $data['comment_field_data']['thread']['field'] = [ 'title' => $this->t('Depth'), 'help' => $this->t('Display the depth of the comment if it is threaded.'), 'id' => 'comment_depth', - ); - $data['comment_field_data']['thread']['sort'] = array( + ]; + $data['comment_field_data']['thread']['sort'] = [ 'title' => $this->t('Thread'), 'help' => $this->t('Sort by the threaded order. This will keep child comments together with their parents.'), 'id' => 'comment_thread', - ); + ]; unset($data['comment_field_data']['thread']['filter']); unset($data['comment_field_data']['thread']['argument']); @@ -188,24 +188,24 @@ public function getViewsData() { continue; } if ($fields = \Drupal::service('comment.manager')->getFields($type)) { - $data['comment_field_data'][$type] = array( - 'relationship' => array( + $data['comment_field_data'][$type] = [ + 'relationship' => [ 'title' => $entity_type->getLabel(), - 'help' => $this->t('The @entity_type to which the comment is a reply to.', array('@entity_type' => $entity_type->getLabel())), + 'help' => $this->t('The @entity_type to which the comment is a reply to.', ['@entity_type' => $entity_type->getLabel()]), 'base' => $entity_type->getDataTable() ?: $entity_type->getBaseTable(), 'base field' => $entity_type->getKey('id'), 'relationship field' => 'entity_id', 'id' => 'standard', 'label' => $entity_type->getLabel(), - 'extra' => array( - array( + 'extra' => [ + [ 'field' => 'entity_type', 'value' => $type, 'table' => 'comment_field_data' - ), - ), - ), - ); + ], + ], + ], + ]; } } @@ -236,84 +236,84 @@ public function getViewsData() { // {comment_entity_statistics} for each field as multiple joins between // the same two tables is not supported. if (\Drupal::service('comment.manager')->getFields($type)) { - $data['comment_entity_statistics']['table']['join'][$entity_type->getDataTable() ?: $entity_type->getBaseTable()] = array( + $data['comment_entity_statistics']['table']['join'][$entity_type->getDataTable() ?: $entity_type->getBaseTable()] = [ 'type' => 'INNER', 'left_field' => $entity_type->getKey('id'), 'field' => 'entity_id', - 'extra' => array( - array( + 'extra' => [ + [ 'field' => 'entity_type', 'value' => $type, - ), - ), - ); + ], + ], + ]; } } - $data['comment_entity_statistics']['last_comment_timestamp'] = array( + $data['comment_entity_statistics']['last_comment_timestamp'] = [ 'title' => $this->t('Last comment time'), 'help' => $this->t('Date and time of when the last comment was posted.'), - 'field' => array( + 'field' => [ 'id' => 'comment_last_timestamp', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'date', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'date', - ), - ); + ], + ]; - $data['comment_entity_statistics']['last_comment_name'] = array( + $data['comment_entity_statistics']['last_comment_name'] = [ 'title' => $this->t("Last comment author"), 'help' => $this->t('The name of the author of the last posted comment.'), - 'field' => array( + 'field' => [ 'id' => 'comment_ces_last_comment_name', 'no group by' => TRUE, - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'comment_ces_last_comment_name', 'no group by' => TRUE, - ), - ); + ], + ]; - $data['comment_entity_statistics']['comment_count'] = array( + $data['comment_entity_statistics']['comment_count'] = [ 'title' => $this->t('Comment count'), 'help' => $this->t('The number of comments an entity has.'), - 'field' => array( + 'field' => [ 'id' => 'numeric', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'numeric', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'standard', - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'standard', - ), - ); + ], + ]; - $data['comment_entity_statistics']['last_updated'] = array( + $data['comment_entity_statistics']['last_updated'] = [ 'title' => $this->t('Updated/commented date'), 'help' => $this->t('The most recent of last comment posted or entity updated time.'), - 'field' => array( + 'field' => [ 'id' => 'comment_ces_last_updated', 'no group by' => TRUE, - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'comment_ces_last_updated', 'no group by' => TRUE, - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'comment_ces_last_updated', - ), - ); + ], + ]; - $data['comment_entity_statistics']['cid'] = array( + $data['comment_entity_statistics']['cid'] = [ 'title' => $this->t('Last comment CID'), 'help' => $this->t('Display the last comment of an entity'), - 'relationship' => array( + 'relationship' => [ 'title' => $this->t('Last comment'), 'help' => $this->t('The last comment of an entity.'), 'group' => $this->t('Comment'), @@ -321,62 +321,62 @@ public function getViewsData() { 'base field' => 'cid', 'id' => 'standard', 'label' => $this->t('Last Comment'), - ), - ); + ], + ]; - $data['comment_entity_statistics']['last_comment_uid'] = array( + $data['comment_entity_statistics']['last_comment_uid'] = [ 'title' => $this->t('Last comment uid'), 'help' => $this->t('The User ID of the author of the last comment of an entity.'), - 'relationship' => array( + 'relationship' => [ 'title' => $this->t('Last comment author'), 'base' => 'users', 'base field' => 'uid', 'id' => 'standard', 'label' => $this->t('Last comment author'), - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'numeric', - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'numeric', - ), - 'field' => array( + ], + 'field' => [ 'id' => 'numeric', - ), - ); + ], + ]; - $data['comment_entity_statistics']['entity_type'] = array( + $data['comment_entity_statistics']['entity_type'] = [ 'title' => $this->t('Entity type'), 'help' => $this->t('The entity type to which the comment is a reply to.'), - 'field' => array( + 'field' => [ 'id' => 'standard', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'string', - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'string', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'standard', - ), - ); - $data['comment_entity_statistics']['field_name'] = array( + ], + ]; + $data['comment_entity_statistics']['field_name'] = [ 'title' => $this->t('Comment field name'), 'help' => $this->t('The field name from which the comment originated.'), - 'field' => array( + 'field' => [ 'id' => 'standard', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'string', - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'string', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'standard', - ), - ); + ], + ]; return $data; } diff --git a/core/modules/comment/src/Controller/CommentController.php b/core/modules/comment/src/Controller/CommentController.php index 0b682e8..09448f9 100644 --- a/core/modules/comment/src/Controller/CommentController.php +++ b/core/modules/comment/src/Controller/CommentController.php @@ -126,7 +126,7 @@ public function commentPermalink(Request $request, CommentInterface $comment) { $page = $this->entityManager()->getStorage('comment')->getDisplayOrdinal($comment, $field_definition->getSetting('default_mode'), $field_definition->getSetting('per_page')); // @todo: Cleaner sub request handling. $subrequest_url = $entity->urlInfo()->toString(TRUE); - $redirect_request = Request::create($subrequest_url->getGeneratedUrl(), 'GET', $request->query->all(), $request->cookies->all(), array(), $request->server->all()); + $redirect_request = Request::create($subrequest_url->getGeneratedUrl(), 'GET', $request->query->all(), $request->cookies->all(), [], $request->server->all()); $redirect_request->query->set('page', $page); // Carry over the session to the subrequest. if ($session = $request->getSession()) { @@ -176,11 +176,11 @@ public function redirectNode(EntityInterface $node) { // Legacy nodes only had a single comment field, so use the first comment // field on the entity. if (!empty($fields) && ($field_names = array_keys($fields)) && ($field_name = reset($field_names))) { - return $this->redirect('comment.reply', array( + return $this->redirect('comment.reply', [ 'entity_type' => 'node', 'entity' => $node->id(), 'field_name' => $field_name, - )); + ]); } throw new NotFoundHttpException(); } @@ -213,7 +213,7 @@ public function redirectNode(EntityInterface $node) { */ public function getReplyForm(Request $request, EntityInterface $entity, $field_name, $pid = NULL) { $account = $this->currentUser(); - $build = array(); + $build = []; // The user is not just previewing a comment. if ($request->request->get('op') != $this->t('Preview')) { @@ -242,12 +242,12 @@ public function getReplyForm(Request $request, EntityInterface $entity, $field_n } // Show the actual reply box. - $comment = $this->entityManager()->getStorage('comment')->create(array( + $comment = $this->entityManager()->getStorage('comment')->create([ 'entity_id' => $entity->id(), 'pid' => $pid, 'entity_type' => $entity->getEntityTypeId(), 'field_name' => $field_name, - )); + ]); $build['comment_form'] = $this->entityFormBuilder()->getForm($comment); return $build; @@ -326,17 +326,17 @@ public function renderNewCommentsNodeLinks(Request $request) { // Only handle up to 100 nodes. $nids = array_slice($nids, 0, 100); - $links = array(); + $links = []; foreach ($nids as $nid) { $node = $this->entityManager->getStorage('node')->load($nid); $new = $this->commentManager->getCountNewComments($node); $page_number = $this->entityManager()->getStorage('comment') ->getNewCommentPageNumber($node->{$field_name}->comment_count, $new, $node, $field_name); - $query = $page_number ? array('page' => $page_number) : NULL; - $links[$nid] = array( + $query = $page_number ? ['page' => $page_number] : NULL; + $links[$nid] = [ 'new_comment_count' => (int) $new, - 'first_new_comment_link' => $this->getUrlGenerator()->generateFromRoute('entity.node.canonical', array('node' => $node->id()), array('query' => $query, 'fragment' => 'new')), - ); + 'first_new_comment_link' => $this->getUrlGenerator()->generateFromRoute('entity.node.canonical', ['node' => $node->id()], ['query' => $query, 'fragment' => 'new']), + ]; } return new JsonResponse($links); diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php index d626be3..8a02b66 100644 --- a/core/modules/comment/src/Entity/Comment.php +++ b/core/modules/comment/src/Entity/Comment.php @@ -235,11 +235,11 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Subject')) ->setTranslatable(TRUE) ->setSetting('max_length', 64) - ->setDisplayOptions('form', array( + ->setDisplayOptions('form', [ 'type' => 'string_textfield', // Default comment body field has weight 20. 'weight' => 10, - )) + ]) ->setDisplayConfigurable('form', TRUE); $fields['uid'] = BaseFieldDefinition::create('entity_reference') @@ -320,7 +320,7 @@ public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $fields['entity_id']->setSetting('target_type', $comment_type->getTargetEntityTypeId()); return $fields; } - return array(); + return []; } /** diff --git a/core/modules/comment/src/Form/CommentAdminOverview.php b/core/modules/comment/src/Form/CommentAdminOverview.php index dac62bd..3b25591 100644 --- a/core/modules/comment/src/Form/CommentAdminOverview.php +++ b/core/modules/comment/src/Form/CommentAdminOverview.php @@ -99,12 +99,12 @@ public function getFormId() { public function buildForm(array $form, FormStateInterface $form_state, $type = 'new') { // Build an 'Update options' form. - $form['options'] = array( + $form['options'] = [ '#type' => 'details', '#title' => $this->t('Update options'), '#open' => TRUE, - '#attributes' => array('class' => array('container-inline')), - ); + '#attributes' => ['class' => ['container-inline']], + ]; if ($type == 'approval') { $options['publish'] = $this->t('Publish the selected comments'); @@ -114,42 +114,42 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = ' } $options['delete'] = $this->t('Delete the selected comments'); - $form['options']['operation'] = array( + $form['options']['operation'] = [ '#type' => 'select', '#title' => $this->t('Action'), '#title_display' => 'invisible', '#options' => $options, '#default_value' => 'publish', - ); - $form['options']['submit'] = array( + ]; + $form['options']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Update'), - ); + ]; // Load the comments that need to be displayed. $status = ($type == 'approval') ? CommentInterface::NOT_PUBLISHED : CommentInterface::PUBLISHED; - $header = array( - 'subject' => array( + $header = [ + 'subject' => [ 'data' => $this->t('Subject'), 'specifier' => 'subject', - ), - 'author' => array( + ], + 'author' => [ 'data' => $this->t('Author'), 'specifier' => 'name', - 'class' => array(RESPONSIVE_PRIORITY_MEDIUM), - ), - 'posted_in' => array( + 'class' => [RESPONSIVE_PRIORITY_MEDIUM], + ], + 'posted_in' => [ 'data' => $this->t('Posted in'), - 'class' => array(RESPONSIVE_PRIORITY_LOW), - ), - 'changed' => array( + 'class' => [RESPONSIVE_PRIORITY_LOW], + ], + 'changed' => [ 'data' => $this->t('Updated'), 'specifier' => 'changed', 'sort' => 'desc', - 'class' => array(RESPONSIVE_PRIORITY_LOW), - ), + 'class' => [RESPONSIVE_PRIORITY_LOW], + ], 'operations' => $this->t('Operations'), - ); + ]; $cids = $this->commentStorage->getQuery() ->condition('status', $status) ->tableSort($header) @@ -160,11 +160,11 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = ' $comments = $this->commentStorage->loadMultiple($cids); // Build a table listing the appropriate comments. - $options = array(); + $options = []; $destination = $this->getDestinationArray(); - $commented_entity_ids = array(); - $commented_entities = array(); + $commented_entity_ids = []; + $commented_entities = []; foreach ($comments as $comment) { $commented_entity_ids[$comment->getCommentedEntityTypeId()][] = $comment->getCommentedEntityId(); @@ -179,61 +179,61 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = ' $commented_entity = $commented_entities[$comment->getCommentedEntityTypeId()][$comment->getCommentedEntityId()]; $comment_permalink = $comment->permalink(); if ($comment->hasField('comment_body') && ($body = $comment->get('comment_body')->value)) { - $attributes = $comment_permalink->getOption('attributes') ?: array(); - $attributes += array('title' => Unicode::truncate($body, 128)); + $attributes = $comment_permalink->getOption('attributes') ?: []; + $attributes += ['title' => Unicode::truncate($body, 128)]; $comment_permalink->setOption('attributes', $attributes); } - $options[$comment->id()] = array( - 'title' => array('data' => array('#title' => $comment->getSubject() ?: $comment->id())), - 'subject' => array( - 'data' => array( + $options[$comment->id()] = [ + 'title' => ['data' => ['#title' => $comment->getSubject() ?: $comment->id()]], + 'subject' => [ + 'data' => [ '#type' => 'link', '#title' => $comment->getSubject(), '#url' => $comment_permalink, - ), - ), - 'author' => array( - 'data' => array( + ], + ], + 'author' => [ + 'data' => [ '#theme' => 'username', '#account' => $comment->getOwner(), - ), - ), - 'posted_in' => array( - 'data' => array( + ], + ], + 'posted_in' => [ + 'data' => [ '#type' => 'link', '#title' => $commented_entity->label(), '#access' => $commented_entity->access('view'), '#url' => $commented_entity->urlInfo(), - ), - ), + ], + ], 'changed' => $this->dateFormatter->format($comment->getChangedTimeAcrossTranslations(), 'short'), - ); + ]; $comment_uri_options = $comment->urlInfo()->getOptions() + ['query' => $destination]; - $links = array(); - $links['edit'] = array( + $links = []; + $links['edit'] = [ 'title' => $this->t('Edit'), 'url' => $comment->urlInfo('edit-form', $comment_uri_options), - ); - if ($this->moduleHandler->moduleExists('content_translation') && $this->moduleHandler->invoke('content_translation', 'translate_access', array($comment))->isAllowed()) { - $links['translate'] = array( + ]; + if ($this->moduleHandler->moduleExists('content_translation') && $this->moduleHandler->invoke('content_translation', 'translate_access', [$comment])->isAllowed()) { + $links['translate'] = [ 'title' => $this->t('Translate'), 'url' => $comment->urlInfo('drupal:content-translation-overview', $comment_uri_options), - ); + ]; } - $options[$comment->id()]['operations']['data'] = array( + $options[$comment->id()]['operations']['data'] = [ '#type' => 'operations', '#links' => $links, - ); + ]; } - $form['comments'] = array( + $form['comments'] = [ '#type' => 'tableselect', '#header' => $header, '#options' => $options, '#empty' => $this->t('No comments available.'), - ); + ]; - $form['pager'] = array('#type' => 'pager'); + $form['pager'] = ['#type' => 'pager']; return $form; } @@ -242,7 +242,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = ' * {@inheritdoc} */ public function validateForm(array &$form, FormStateInterface $form_state) { - $form_state->setValue('comments', array_diff($form_state->getValue('comments'), array(0))); + $form_state->setValue('comments', array_diff($form_state->getValue('comments'), [0])); // We can't execute any 'Update options' if no comments were selected. if (count($form_state->getValue('comments')) == 0) { $form_state->setErrorByName('', $this->t('Select one or more comments to perform the update on.')); diff --git a/core/modules/comment/src/Form/CommentTypeDeleteForm.php b/core/modules/comment/src/Form/CommentTypeDeleteForm.php index daadc92..ad4dd2b 100644 --- a/core/modules/comment/src/Form/CommentTypeDeleteForm.php +++ b/core/modules/comment/src/Form/CommentTypeDeleteForm.php @@ -92,18 +92,18 @@ public function buildForm(array $form, FormStateInterface $form_state) { foreach (array_keys($this->commentManager->getFields($entity_type)) as $field_name) { /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ if (($field_storage = FieldStorageConfig::loadByName($entity_type, $field_name)) && $field_storage->getSetting('comment_type') == $this->entity->id() && !$field_storage->isDeleted()) { - $caption .= '

        ' . $this->t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', array( + $caption .= '

        ' . $this->t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', [ '%label' => $this->entity->label(), '%field' => $field_storage->label(), - )) . '

        '; + ]) . '

        '; } } if (!empty($comments)) { - $caption .= '

        ' . $this->formatPlural(count($comments), '%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', '%label is used by @count comments on your site. You may not remove %label until you have removed all of the %label comments.', array('%label' => $this->entity->label())) . '

        '; + $caption .= '

        ' . $this->formatPlural(count($comments), '%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', '%label is used by @count comments on your site. You may not remove %label until you have removed all of the %label comments.', ['%label' => $this->entity->label()]) . '

        '; } if ($caption) { - $form['description'] = array('#markup' => $caption); + $form['description'] = ['#markup' => $caption]; return $form; } else { diff --git a/core/modules/comment/src/Form/ConfirmDeleteMultiple.php b/core/modules/comment/src/Form/ConfirmDeleteMultiple.php index 662cfa4..8c00305 100644 --- a/core/modules/comment/src/Form/ConfirmDeleteMultiple.php +++ b/core/modules/comment/src/Form/ConfirmDeleteMultiple.php @@ -81,25 +81,25 @@ public function getConfirmText() { public function buildForm(array $form, FormStateInterface $form_state) { $edit = $form_state->getUserInput(); - $form['comments'] = array( + $form['comments'] = [ '#prefix' => '
          ', '#suffix' => '
        ', '#tree' => TRUE, - ); + ]; // array_filter() returns only elements with actual values. $comment_counter = 0; $this->comments = $this->commentStorage->loadMultiple(array_keys(array_filter($edit['comments']))); foreach ($this->comments as $comment) { $cid = $comment->id(); - $form['comments'][$cid] = array( + $form['comments'][$cid] = [ '#type' => 'hidden', '#value' => $cid, '#prefix' => '
      • ', '#suffix' => Html::escape($comment->label()) . '
      • ' - ); + ]; $comment_counter++; } - $form['operation'] = array('#type' => 'hidden', '#value' => 'delete'); + $form['operation'] = ['#type' => 'hidden', '#value' => 'delete']; if (!$comment_counter) { drupal_set_message($this->t('There do not appear to be any comments to delete, or your selected comment was deleted by another administrator.')); @@ -116,7 +116,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { if ($form_state->getValue('confirm')) { $this->commentStorage->delete($this->comments); $count = count($form_state->getValue('comments')); - $this->logger('content')->notice('Deleted @count comments.', array('@count' => $count)); + $this->logger('content')->notice('Deleted @count comments.', ['@count' => $count]); drupal_set_message($this->formatPlural($count, 'Deleted 1 comment.', 'Deleted @count comments.')); } $form_state->setRedirectUrl($this->getCancelUrl()); diff --git a/core/modules/comment/src/Form/DeleteForm.php b/core/modules/comment/src/Form/DeleteForm.php index 6b2921e..8ab8e88 100644 --- a/core/modules/comment/src/Form/DeleteForm.php +++ b/core/modules/comment/src/Form/DeleteForm.php @@ -42,7 +42,7 @@ protected function getDeletionMessage() { * {@inheritdoc} */ public function logDeletionMessage() { - $this->logger('content')->notice('Deleted comment @cid and its replies.', array('@cid' => $this->entity->id())); + $this->logger('content')->notice('Deleted comment @cid and its replies.', ['@cid' => $this->entity->id()]); } } diff --git a/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php b/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php index cacac89..ec1b268 100644 --- a/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php +++ b/core/modules/comment/src/Plugin/Action/UnpublishByKeywordComment.php @@ -89,21 +89,21 @@ public function execute($comment = NULL) { * {@inheritdoc} */ public function defaultConfiguration() { - return array( - 'keywords' => array(), - ); + return [ + 'keywords' => [], + ]; } /** * {@inheritdoc} */ public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form['keywords'] = array( + $form['keywords'] = [ '#title' => $this->t('Keywords'), '#type' => 'textarea', '#description' => $this->t('The comment will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'), '#default_value' => Tags::implode($this->configuration['keywords']), - ); + ]; return $form; } diff --git a/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php b/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php index 43542a0..3e22ede 100644 --- a/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php +++ b/core/modules/comment/src/Plugin/Field/FieldFormatter/AuthorNameFormatter.php @@ -24,19 +24,19 @@ class AuthorNameFormatter extends FormatterBase { * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; foreach ($items as $delta => $item) { /** @var $comment \Drupal\comment\CommentInterface */ $comment = $item->getEntity(); $account = $comment->getOwner(); - $elements[$delta] = array( + $elements[$delta] = [ '#theme' => 'username', '#account' => $account, - '#cache' => array( + '#cache' => [ 'tags' => $account->getCacheTags() + $comment->getCacheTags(), - ), - ); + ], + ]; } return $elements; diff --git a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index c7d9bba..b03accc 100644 --- a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -36,10 +36,10 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'view_mode' => 'default', 'pager_id' => 0, - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** @@ -141,8 +141,8 @@ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInter * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); - $output = array(); + $elements = []; + $output = []; $field_name = $this->fieldDefinition->getName(); $entity = $items->getEntity(); @@ -153,7 +153,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { // Comments are added to the search results and search index by // comment_node_update_index() instead of by this formatter, so don't // return anything if the view mode is search_index or search_result. - !in_array($this->viewMode, array('search_result', 'search_index'))) { + !in_array($this->viewMode, ['search_result', 'search_index'])) { $comment_settings = $this->getFieldSettings(); // Only attempt to render comments if the entity has visible comments. @@ -203,12 +203,12 @@ public function viewElements(FieldItemListInterface $items, $langcode) { } } - $elements[] = $output + array( + $elements[] = $output + [ '#comment_type' => $this->getFieldSetting('comment_type'), '#comment_display_mode' => $this->getFieldSetting('default_mode'), - 'comments' => array(), - 'comment_form' => array(), - ); + 'comments' => [], + 'comment_form' => [], + ]; } return $elements; @@ -218,7 +218,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { - $element = array(); + $element = []; $view_modes = $this->getViewModes(); $element['view_mode'] = [ '#type' => 'select', @@ -229,13 +229,13 @@ public function settingsForm(array $form, FormStateInterface $form_state) { // Only show the select element when there are more than one options. '#access' => count($view_modes) > 1, ]; - $element['pager_id'] = array( + $element['pager_id'] = [ '#type' => 'select', '#title' => $this->t('Pager ID'), '#options' => range(0, 10), '#default_value' => $this->getSetting('pager_id'), '#description' => $this->t("Unless you're experiencing problems with pagers related to this field, you should leave this at 0. If using multiple pagers on one page you may need to set this number to a higher value so as not to conflict within the ?page= array. Large values will add a lot of commas to your URLs, so avoid if possible."), - ); + ]; return $element; } diff --git a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php index 888b64b..e3fd2b0 100644 --- a/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php @@ -31,22 +31,22 @@ class CommentItem extends FieldItemBase implements CommentItemInterface { * {@inheritdoc} */ public static function defaultStorageSettings() { - return array( + return [ 'comment_type' => '', - ) + parent::defaultStorageSettings(); + ] + parent::defaultStorageSettings(); } /** * {@inheritdoc} */ public static function defaultFieldSettings() { - return array( + return [ 'default_mode' => CommentManagerInterface::COMMENT_MODE_THREADED, 'per_page' => 50, 'form_location' => CommentItemInterface::FORM_BELOW, 'anonymous' => COMMENT_ANONYMOUS_MAYNOT_CONTACT, 'preview' => DRUPAL_OPTIONAL, - ) + parent::defaultFieldSettings(); + ] + parent::defaultFieldSettings(); } /** @@ -82,36 +82,36 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { - return array( - 'columns' => array( - 'status' => array( + return [ + 'columns' => [ + 'status' => [ 'description' => 'Whether comments are allowed on this entity: 0 = no, 1 = closed (read only), 2 = open (read/write).', 'type' => 'int', 'default' => 0, - ), - ), - 'indexes' => array(), - 'foreign keys' => array(), - ); + ], + ], + 'indexes' => [], + 'foreign keys' => [], + ]; } /** * {@inheritdoc} */ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { - $element = array(); + $element = []; $settings = $this->getSettings(); $anonymous_user = new AnonymousUserSession(); - $element['default_mode'] = array( + $element['default_mode'] = [ '#type' => 'checkbox', '#title' => t('Threading'), '#default_value' => $settings['default_mode'], '#description' => t('Show comment replies in a threaded list.'), - ); - $element['per_page'] = array( + ]; + $element['per_page'] = [ '#type' => 'number', '#title' => t('Comments per page'), '#default_value' => $settings['per_page'], @@ -119,33 +119,33 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { '#min' => 10, '#max' => 1000, '#step' => 10, - ); - $element['anonymous'] = array( + ]; + $element['anonymous'] = [ '#type' => 'select', '#title' => t('Anonymous commenting'), '#default_value' => $settings['anonymous'], - '#options' => array( + '#options' => [ COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'), COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'), COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information'), - ), + ], '#access' => $anonymous_user->hasPermission('post comments'), - ); - $element['form_location'] = array( + ]; + $element['form_location'] = [ '#type' => 'checkbox', '#title' => t('Show reply form on the same page as comments'), '#default_value' => $settings['form_location'], - ); - $element['preview'] = array( + ]; + $element['preview'] = [ '#type' => 'radios', '#title' => t('Preview comment'), '#default_value' => $settings['preview'], - '#options' => array( + '#options' => [ DRUPAL_DISABLED => t('Disabled'), DRUPAL_OPTIONAL => t('Optional'), DRUPAL_REQUIRED => t('Required'), - ), - ); + ], + ]; return $element; } @@ -171,27 +171,27 @@ public function isEmpty() { * {@inheritdoc} */ public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) { - $element = array(); + $element = []; // @todo Inject entity storage once typed-data supports container injection. // See https://www.drupal.org/node/2053415 for more details. $comment_types = CommentType::loadMultiple(); - $options = array(); + $options = []; $entity_type = $this->getEntity()->getEntityTypeId(); foreach ($comment_types as $comment_type) { if ($comment_type->getTargetEntityTypeId() == $entity_type) { $options[$comment_type->id()] = $comment_type->label(); } } - $element['comment_type'] = array( + $element['comment_type'] = [ '#type' => 'select', '#title' => t('Comment type'), '#options' => $options, '#required' => TRUE, - '#description' => $this->t('Select the Comment type to use for this comment field. Manage the comment types from the administration overview page.', array(':url' => $this->url('entity.comment_type.collection'))), + '#description' => $this->t('Select the Comment type to use for this comment field. Manage the comment types from the administration overview page.', [':url' => $this->url('entity.comment_type.collection')]), '#default_value' => $this->getSetting('comment_type'), '#disabled' => $has_data, - ); + ]; return $element; } diff --git a/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php b/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php index 818226d..c9478f6 100644 --- a/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php +++ b/core/modules/comment/src/Plugin/Field/FieldWidget/CommentWidget.php @@ -27,26 +27,26 @@ class CommentWidget extends WidgetBase { public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $entity = $items->getEntity(); - $element['status'] = array( + $element['status'] = [ '#type' => 'radios', '#title' => t('Comments'), '#title_display' => 'invisible', '#default_value' => $items->status, - '#options' => array( + '#options' => [ CommentItemInterface::OPEN => t('Open'), CommentItemInterface::CLOSED => t('Closed'), CommentItemInterface::HIDDEN => t('Hidden'), - ), - CommentItemInterface::OPEN => array( + ], + CommentItemInterface::OPEN => [ '#description' => t('Users with the "Post comments" permission can post comments.'), - ), - CommentItemInterface::CLOSED => array( + ], + CommentItemInterface::CLOSED => [ '#description' => t('Users cannot post comments, but existing comments will be displayed.'), - ), - CommentItemInterface::HIDDEN => array( + ], + CommentItemInterface::HIDDEN => [ '#description' => t('Comments are hidden from view.'), - ), - ); + ], + ]; // If the entity doesn't have any comments, the "hidden" option makes no // sense, so don't even bother presenting it to the user unless this is the // default value widget on the field settings form. @@ -65,19 +65,19 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // Override widget title to be helpful for end users. $element['#title'] = $this->t('Comment settings'); - $element += array( + $element += [ '#type' => 'details', // Open the details when the selected value is different to the stored // default values for the field. '#open' => ($items->status != $field_default_values[0]['status']), '#group' => 'advanced', - '#attributes' => array( - 'class' => array('comment-' . Html::getClass($entity->getEntityTypeId()) . '-settings-form'), - ), - '#attached' => array( - 'library' => array('comment/drupal.comment'), - ), - ); + '#attributes' => [ + 'class' => ['comment-' . Html::getClass($entity->getEntityTypeId()) . '-settings-form'], + ], + '#attached' => [ + 'library' => ['comment/drupal.comment'], + ], + ]; } return $element; @@ -90,13 +90,13 @@ public function massageFormValues(array $values, array $form, FormStateInterface // Add default values for statistics properties because we don't want to // have them in form. foreach ($values as &$value) { - $value += array( + $value += [ 'cid' => 0, 'last_comment_timestamp' => 0, 'last_comment_name' => '', 'last_comment_uid' => 0, 'comment_count' => 0, - ); + ]; } return $values; } diff --git a/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php b/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php index 5fa0193..89542d3 100644 --- a/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php +++ b/core/modules/comment/src/Plugin/Menu/LocalTask/UnapprovedComments.php @@ -54,7 +54,7 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function getTitle() { - return $this->t('Unapproved comments (@count)', array('@count' => $this->commentStorage->getUnapprovedCount())); + return $this->t('Unapproved comments (@count)', ['@count' => $this->commentStorage->getUnapprovedCount()]); } } diff --git a/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraintValidator.php b/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraintValidator.php index f06dfd8..87cdaf9 100644 --- a/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraintValidator.php +++ b/core/modules/comment/src/Plugin/Validation/Constraint/CommentNameConstraintValidator.php @@ -55,9 +55,9 @@ public function validate($entity, Constraint $constraint) { // Do not allow unauthenticated comment authors to use a name that is // taken by a registered user. if (isset($author_name) && $author_name !== '' && $owner_id === 0) { - $users = $this->userStorage->loadByProperties(array('name' => $author_name)); + $users = $this->userStorage->loadByProperties(['name' => $author_name]); if (!empty($users)) { - $this->context->buildViolation($constraint->messageNameTaken, array('%name' => $author_name)) + $this->context->buildViolation($constraint->messageNameTaken, ['%name' => $author_name]) ->atPath('name') ->addViolation(); } diff --git a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php index e3582c5..518eecd 100644 --- a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php +++ b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php @@ -92,7 +92,7 @@ public static function create(ContainerInterface $container, array $configuratio /** * {@inheritdoc} */ - public function import(Row $row, array $old_destination_id_values = array()) { + public function import(Row $row, array $old_destination_id_values = []) { if ($row->isStub() && ($state = $this->state->get('comment.maintain_entity_statistics', 0))) { $this->state->set('comment.maintain_entity_statistics', 0); } diff --git a/core/modules/comment/src/Plugin/migrate/destination/EntityCommentType.php b/core/modules/comment/src/Plugin/migrate/destination/EntityCommentType.php index b014af3..9bee87a 100644 --- a/core/modules/comment/src/Plugin/migrate/destination/EntityCommentType.php +++ b/core/modules/comment/src/Plugin/migrate/destination/EntityCommentType.php @@ -15,7 +15,7 @@ class EntityCommentType extends EntityConfigBase { /** * {@inheritdoc} */ - public function import(Row $row, array $old_destination_id_values = array()) { + public function import(Row $row, array $old_destination_id_values = []) { $entity_ids = parent::import($row, $old_destination_id_values); \Drupal::service('comment.manager')->addBodyField(reset($entity_ids)); return $entity_ids; diff --git a/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php b/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php index 6081f39..93f77a0 100644 --- a/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php +++ b/core/modules/comment/src/Plugin/migrate/source/d6/Comment.php @@ -20,11 +20,11 @@ class Comment extends DrupalSqlBase { */ public function query() { $query = $this->select('comments', 'c') - ->fields('c', array('cid', 'pid', 'nid', 'uid', 'subject', + ->fields('c', ['cid', 'pid', 'nid', 'uid', 'subject', 'comment', 'hostname', 'timestamp', 'status', 'thread', 'name', - 'mail', 'homepage', 'format')); + 'mail', 'homepage', 'format']); $query->innerJoin('node', 'n', 'c.nid = n.nid'); - $query->fields('n', array('type')); + $query->fields('n', ['type']); $query->orderBy('c.timestamp'); return $query; } @@ -52,7 +52,7 @@ public function prepareRow(Row $row) { * {@inheritdoc} */ public function fields() { - return array( + return [ 'cid' => $this->t('Comment ID.'), 'pid' => $this->t('Parent comment ID. If set to 0, this comment is not a reply to an existing comment.'), 'nid' => $this->t('The {node}.nid to which this comment is a reply.'), @@ -68,7 +68,7 @@ public function fields() { 'mail' => $this->t("The comment author's email address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."), 'homepage' => $this->t("The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."), 'type' => $this->t("The {node}.type to which this comment is a reply."), - ); + ]; } /** diff --git a/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php b/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php index 3294721..a56fb4d 100644 --- a/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php +++ b/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariable.php @@ -35,7 +35,7 @@ public function count() { */ protected function getCommentVariables() { $comment_prefixes = array_keys($this->commentPrefixes()); - $variables = array(); + $variables = []; $node_types = $this->select('node_type', 'nt') ->fields('nt', ['type']) ->execute() @@ -45,7 +45,7 @@ protected function getCommentVariables() { $variables[] = $prefix . '_' . $node_type; } } - $return = array(); + $return = []; $values = $this->select('variable', 'v') ->fields('v', ['name', 'value']) ->condition('name', $variables, 'IN') @@ -74,17 +74,17 @@ protected function getCommentVariables() { * {@inheritdoc} */ public function fields() { - return $this->commentPrefixes() + array( + return $this->commentPrefixes() + [ 'node_type' => $this->t('The node type'), 'comment_type' => $this->t('The comment type'), - ); + ]; } /** * Comment related data for fields. */ protected function commentPrefixes() { - return array( + return [ 'comment' => $this->t('Default comment setting'), 'comment_default_mode' => $this->t('Default display mode'), 'comment_default_order' => $this->t('Default display order'), @@ -94,7 +94,7 @@ protected function commentPrefixes() { 'comment_subject_field' => $this->t('Comment subject field'), 'comment_preview' => $this->t('Preview comment'), 'comment_form_location' => $this->t('Location of comment submission form'), - ); + ]; } /** diff --git a/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php b/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php index 5d16ed0..0eea686 100644 --- a/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php +++ b/core/modules/comment/src/Plugin/migrate/source/d6/CommentVariablePerCommentType.php @@ -17,24 +17,24 @@ class CommentVariablePerCommentType extends CommentVariable { protected function getCommentVariables() { $node_types = parent::getCommentVariables(); // The return key used to separate comment types with hidden subject field. - $return = array(); + $return = []; foreach ($node_types as $node_type => $data) { // Only 2 comment types depending on subject field visibility. if (!empty($data['comment_subject_field'])) { // Default label and description should be set in migration. - $return['comment'] = array( + $return['comment'] = [ 'comment_type' => 'comment', 'label' => $this->t('Default comments'), 'description' => $this->t('Allows commenting on content') - ); + ]; } else { // Provide a special comment type with hidden subject field. - $return['comment_no_subject'] = array( + $return['comment_no_subject'] = [ 'comment_type' => 'comment_no_subject', 'label' => $this->t('Comments without subject field'), 'description' => $this->t('Allows commenting on content, comments without subject field') - ); + ]; } } return $return; @@ -44,11 +44,11 @@ protected function getCommentVariables() { * {@inheritdoc} */ public function fields() { - return array( + return [ 'comment_type' => $this->t('The comment type'), 'label' => $this->t('The comment type label'), 'description' => $this->t('The comment type description'), - ); + ]; } /** diff --git a/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php b/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php index 5531f1d..e643eb1 100644 --- a/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php +++ b/core/modules/comment/src/Plugin/migrate/source/d7/Comment.php @@ -47,7 +47,7 @@ public function prepareRow(Row $row) { * {@inheritdoc} */ public function fields() { - return array( + return [ 'cid' => $this->t('Comment ID.'), 'pid' => $this->t('Parent comment ID. If set to 0, this comment is not a reply to an existing comment.'), 'nid' => $this->t('The {node}.nid to which this comment is a reply.'), @@ -64,7 +64,7 @@ public function fields() { 'mail' => $this->t("The comment author's email address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."), 'homepage' => $this->t("The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."), 'type' => $this->t("The {node}.type to which this comment is a reply."), - ); + ]; } /** diff --git a/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php b/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php index fc194b2..2ac7c97 100644 --- a/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php +++ b/core/modules/comment/src/Plugin/migrate/source/d7/CommentType.php @@ -21,7 +21,7 @@ class CommentType extends DrupalSqlBase { * * @var string[] */ - protected $nodeTypes = array(); + protected $nodeTypes = []; /** * {@inheritdoc} @@ -29,7 +29,7 @@ class CommentType extends DrupalSqlBase { public function query() { return $this->select('field_config_instance', 'fci') ->distinct() - ->fields('fci', array('bundle')) + ->fields('fci', ['bundle']) ->condition('fci.entity_type', 'comment'); } @@ -38,7 +38,7 @@ public function query() { */ protected function initializeIterator() { $this->nodeTypes = $this->select('node_type', 'nt') - ->fields('nt', array('type', 'name')) + ->fields('nt', ['type', 'name']) ->execute() ->fetchAllKeyed(); @@ -71,7 +71,7 @@ public function prepareRow(Row $row) { * {@inheritdoc} */ public function fields() { - return array( + return [ 'label' => $this->t('The label of the comment type.'), 'bundle' => $this->t('Bundle ID of the comment type.'), 'node_type' => $this->t('The node type to which this comment type is attached.'), @@ -81,18 +81,18 @@ public function fields() { 'form_location' => $this->t('Location of the comment form.'), 'preview' => $this->t('Whether previews are enabled for the comment type.'), 'subject' => $this->t('Whether a subject field is enabled for the comment type.'), - ); + ]; } /** * {@inheritdoc} */ public function getIds() { - return array( - 'bundle' => array( + return [ + 'bundle' => [ 'type' => 'string', - ), - ); + ], + ]; } } diff --git a/core/modules/comment/src/Plugin/views/argument/UserUid.php b/core/modules/comment/src/Plugin/views/argument/UserUid.php index cd384d5..c670d19 100644 --- a/core/modules/comment/src/Plugin/views/argument/UserUid.php +++ b/core/modules/comment/src/Plugin/views/argument/UserUid.php @@ -53,7 +53,7 @@ function title() { $title = \Drupal::config('user.settings')->get('anonymous'); } else { - $title = $this->database->query('SELECT name FROM {users_field_data} WHERE uid = :uid AND default_langcode = 1', array(':uid' => $this->argument))->fetchField(); + $title = $this->database->query('SELECT name FROM {users_field_data} WHERE uid = :uid AND default_langcode = 1', [':uid' => $this->argument])->fetchField(); } if (empty($title)) { return $this->t('No user'); @@ -102,7 +102,7 @@ public function query($group_by = FALSE) { * {@inheritdoc} */ public function getSortName() { - return $this->t('Numerical', array(), array('context' => 'Sort order')); + return $this->t('Numerical', [], ['context' => 'Sort order']); } } diff --git a/core/modules/comment/src/Plugin/views/field/EntityLink.php b/core/modules/comment/src/Plugin/views/field/EntityLink.php index dc4f8cf..03e6f6c 100644 --- a/core/modules/comment/src/Plugin/views/field/EntityLink.php +++ b/core/modules/comment/src/Plugin/views/field/EntityLink.php @@ -27,7 +27,7 @@ class EntityLink extends FieldPluginBase { */ protected function defineOptions() { $options = parent::defineOptions(); - $options['teaser'] = array('default' => FALSE); + $options['teaser'] = ['default' => FALSE]; return $options; } @@ -35,12 +35,12 @@ protected function defineOptions() { * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { - $form['teaser'] = array( + $form['teaser'] = [ '#type' => 'checkbox', '#title' => $this->t('Show teaser-style link'), '#default_value' => $this->options['teaser'], '#description' => $this->t('Show the comment link in the form used on standard entity teasers, rather than the full entity form.'), - ); + ]; parent::buildOptionsForm($form, $form_state); } @@ -55,7 +55,7 @@ public function query() {} */ public function preRender(&$values) { // Render all nodes, so you can grep the comment links. - $entities = array(); + $entities = []; foreach ($values as $row) { $entity = $row->_entity; $entities[$entity->id()] = $entity; diff --git a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php index 5a9f5b3..c53b52e 100644 --- a/core/modules/comment/src/Plugin/views/field/NodeNewComments.php +++ b/core/modules/comment/src/Plugin/views/field/NodeNewComments.php @@ -68,7 +68,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o $this->additional_fields['entity_id'] = 'nid'; $this->additional_fields['type'] = 'type'; - $this->additional_fields['comment_count'] = array('table' => 'comment_entity_statistics', 'field' => 'comment_count'); + $this->additional_fields['comment_count'] = ['table' => 'comment_entity_statistics', 'field' => 'comment_count']; } /** @@ -77,7 +77,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o protected function defineOptions() { $options = parent::defineOptions(); - $options['link_to_comment'] = array('default' => TRUE); + $options['link_to_comment'] = ['default' => TRUE]; return $options; } @@ -86,12 +86,12 @@ protected function defineOptions() { * {@inheritdoc} */ public function buildOptionsForm(&$form, FormStateInterface $form_state) { - $form['link_to_comment'] = array( + $form['link_to_comment'] = [ '#title' => $this->t('Link this field to new comments'), '#description' => $this->t("Enable to override this field's links."), '#type' => 'checkbox', '#default_value' => $this->options['link_to_comment'], - ); + ]; parent::buildOptionsForm($form, $form_state); } @@ -114,14 +114,14 @@ public function preRender(&$values) { return; } - $nids = array(); - $ids = array(); + $nids = []; + $ids = []; foreach ($values as $id => $result) { $nids[] = $result->{$this->aliases['nid']}; $values[$id]->{$this->field_alias} = 0; // Create a reference so we can find this record in the values again. if (empty($ids[$result->{$this->aliases['nid']}])) { - $ids[$result->{$this->aliases['nid']}] = array(); + $ids[$result->{$this->aliases['nid']}] = []; } $ids[$result->{$this->aliases['nid']}][] = $id; } @@ -129,13 +129,13 @@ public function preRender(&$values) { if ($nids) { $result = $this->database->query("SELECT n.nid, COUNT(c.cid) as num_comments FROM {node} n INNER JOIN {comment_field_data} c ON n.nid = c.entity_id AND c.entity_type = 'node' AND c.default_langcode = 1 LEFT JOIN {history} h ON h.nid = n.nid AND h.uid = :h_uid WHERE n.nid IN ( :nids[] ) - AND c.changed > GREATEST(COALESCE(h.timestamp, :timestamp1), :timestamp2) AND c.status = :status GROUP BY n.nid", array( + AND c.changed > GREATEST(COALESCE(h.timestamp, :timestamp1), :timestamp2) AND c.status = :status GROUP BY n.nid", [ ':status' => CommentInterface::PUBLISHED, ':h_uid' => $user->id(), ':nids[]' => $nids, ':timestamp1' => HISTORY_READ_LIMIT, ':timestamp2' => HISTORY_READ_LIMIT, - )); + ]); foreach ($result as $node) { foreach ($ids[$node->nid] as $id) { $values[$id]->{$this->field_alias} = $node->num_comments; @@ -181,7 +181,7 @@ protected function renderLink($data, ResultRow $values) { ->getNewCommentPageNumber($this->getValue($values, 'comment_count'), $this->getValue($values), $node, $comment_field_name); $this->options['alter']['make_link'] = TRUE; $this->options['alter']['url'] = $node->urlInfo(); - $this->options['alter']['query'] = $page_number ? array('page' => $page_number) : NULL; + $this->options['alter']['query'] = $page_number ? ['page' => $page_number] : NULL; $this->options['alter']['fragment'] = 'new'; } diff --git a/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php b/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php index 61a5d17..fa24c3f 100644 --- a/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php +++ b/core/modules/comment/src/Plugin/views/field/StatisticsLastCommentName.php @@ -23,19 +23,19 @@ public function query() { // have to join in a specially related user table. $this->ensureMyTable(); // join 'users' to this table via vid - $definition = array( + $definition = [ 'table' => 'users_field_data', 'field' => 'uid', 'left_table' => 'comment_entity_statistics', 'left_field' => 'last_comment_uid', - 'extra' => array( - array( + 'extra' => [ + [ 'field' => 'uid', 'operator' => '!=', 'value' => '0' - ) - ) - ); + ] + ] + ]; $join = \Drupal::service('plugin.manager.views.join')->createInstance('standard', $definition); // nes_user alias so this can work with the sort handler, below. @@ -53,7 +53,7 @@ public function query() { protected function defineOptions() { $options = parent::defineOptions(); - $options['link_to_user'] = array('default' => TRUE); + $options['link_to_user'] = ['default' => TRUE]; return $options; } @@ -66,10 +66,10 @@ public function render(ResultRow $values) { $account = User::create(); $account->name = $this->getValue($values); $account->uid = $values->{$this->uid}; - $username = array( + $username = [ '#theme' => 'username', '#account' => $account, - ); + ]; return drupal_render($username); } else { diff --git a/core/modules/comment/src/Plugin/views/filter/NodeComment.php b/core/modules/comment/src/Plugin/views/filter/NodeComment.php index e34584f..238c05e 100644 --- a/core/modules/comment/src/Plugin/views/filter/NodeComment.php +++ b/core/modules/comment/src/Plugin/views/filter/NodeComment.php @@ -15,11 +15,11 @@ class NodeComment extends InOperator { public function getValueOptions() { - $this->valueOptions = array( + $this->valueOptions = [ CommentItemInterface::HIDDEN => $this->t('Hidden'), CommentItemInterface::CLOSED => $this->t('Closed'), CommentItemInterface::OPEN => $this->t('Open'), - ); + ]; return $this->valueOptions; } diff --git a/core/modules/comment/src/Plugin/views/row/Rss.php b/core/modules/comment/src/Plugin/views/row/Rss.php index d528040..cb9c104 100644 --- a/core/modules/comment/src/Plugin/views/row/Rss.php +++ b/core/modules/comment/src/Plugin/views/row/Rss.php @@ -40,7 +40,7 @@ class Rss extends RssPluginBase { protected $entityTypeId = 'comment'; public function preRender($result) { - $cids = array(); + $cids = []; foreach ($result as $row) { $cids[] = $row->cid; @@ -79,23 +79,23 @@ public function render($row) { return; } - $comment->link = $comment->url('canonical', array('absolute' => TRUE)); - $comment->rss_namespaces = array(); - $comment->rss_elements = array( - array( + $comment->link = $comment->url('canonical', ['absolute' => TRUE]); + $comment->rss_namespaces = []; + $comment->rss_elements = [ + [ 'key' => 'pubDate', 'value' => gmdate('r', $comment->getCreatedTime()), - ), - array( + ], + [ 'key' => 'dc:creator', 'value' => $comment->getAuthorName(), - ), - array( + ], + [ 'key' => 'guid', 'value' => 'comment ' . $comment->id() . ' at ' . $base_url, - 'attributes' => array('isPermaLink' => 'false'), - ), - ); + 'attributes' => ['isPermaLink' => 'false'], + ], + ]; // The comment gets built and modules add to or modify // $comment->rss_elements and $comment->rss_namespaces. @@ -118,12 +118,12 @@ public function render($row) { $item->elements = &$comment->rss_elements; $item->cid = $comment->id(); - $build = array( + $build = [ '#theme' => $this->themeFunctions(), '#view' => $this->view, '#options' => $this->options, '#row' => $item, - ); + ]; return $build; } diff --git a/core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php b/core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php index 863b3a4..48f556e 100644 --- a/core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php +++ b/core/modules/comment/src/Plugin/views/sort/StatisticsLastCommentName.php @@ -16,12 +16,12 @@ class StatisticsLastCommentName extends SortPluginBase { public function query() { $this->ensureMyTable(); - $definition = array( + $definition = [ 'table' => 'users_field_data', 'field' => 'uid', 'left_table' => 'comment_entity_statistics', 'left_field' => 'last_comment_uid', - ); + ]; $join = \Drupal::service('plugin.manager.views.join')->createInstance('standard', $definition); // @todo this might be safer if we had an ensure_relationship rather than guessing diff --git a/core/modules/comment/src/Plugin/views/wizard/Comment.php b/core/modules/comment/src/Plugin/views/wizard/Comment.php index 1f0d4aa..61d92c5 100644 --- a/core/modules/comment/src/Plugin/views/wizard/Comment.php +++ b/core/modules/comment/src/Plugin/views/wizard/Comment.php @@ -27,16 +27,16 @@ class Comment extends WizardPluginBase { /** * Set default values for the filters. */ - protected $filters = array( - 'status' => array( + protected $filters = [ + 'status' => [ 'value' => TRUE, 'table' => 'comment_field_data', 'field' => 'status', 'plugin_id' => 'boolean', 'entity_type' => 'comment', 'entity_field' => 'status', - ), - 'status_node' => array( + ], + 'status_node' => [ 'value' => TRUE, 'table' => 'node_field_data', 'field' => 'status', @@ -44,14 +44,14 @@ class Comment extends WizardPluginBase { 'relationship' => 'node', 'entity_type' => 'node', 'entity_field' => 'status', - ), - ); + ], + ]; /** * {@inheritdoc} */ protected function rowStyleOptions() { - $options = array(); + $options = []; $options['entity:comment'] = $this->t('comments'); $options['fields'] = $this->t('fields'); return $options; diff --git a/core/modules/comment/src/Tests/CommentActionsTest.php b/core/modules/comment/src/Tests/CommentActionsTest.php index 220be20..8b741e7 100644 --- a/core/modules/comment/src/Tests/CommentActionsTest.php +++ b/core/modules/comment/src/Tests/CommentActionsTest.php @@ -17,7 +17,7 @@ class CommentActionsTest extends CommentTestBase { * * @var array */ - public static $modules = array('dblog', 'action'); + public static $modules = ['dblog', 'action']; /** * Tests comment publish and unpublish actions. @@ -30,12 +30,12 @@ function testCommentPublishUnpublishActions() { // Unpublish a comment. $action = Action::load('comment_unpublish_action'); - $action->execute(array($comment)); + $action->execute([$comment]); $this->assertTrue($comment->isPublished() === FALSE, 'Comment was unpublished'); // Publish a comment. $action = Action::load('comment_publish_action'); - $action->execute(array($comment)); + $action->execute([$comment]); $this->assertTrue($comment->isPublished() === TRUE, 'Comment was published'); } @@ -46,15 +46,15 @@ function testCommentUnpublishByKeyword() { $this->drupalLogin($this->adminUser); $keyword_1 = $this->randomMachineName(); $keyword_2 = $this->randomMachineName(); - $action = Action::create(array( + $action = Action::create([ 'id' => 'comment_unpublish_by_keyword_action', 'label' => $this->randomMachineName(), 'type' => 'comment', - 'configuration' => array( - 'keywords' => array($keyword_1, $keyword_2), - ), + 'configuration' => [ + 'keywords' => [$keyword_1, $keyword_2], + ], 'plugin' => 'comment_unpublish_by_keyword_action', - )); + ]); $action->save(); $comment = $this->postComment($this->node, $keyword_2, $this->randomMachineName()); @@ -64,7 +64,7 @@ function testCommentUnpublishByKeyword() { $this->assertTrue($comment->isPublished() === TRUE, 'The comment status was set to published.'); - $action->execute(array($comment)); + $action->execute([$comment]); $this->assertTrue($comment->isPublished() === FALSE, 'The comment status was set to not published.'); } diff --git a/core/modules/comment/src/Tests/CommentAdminTest.php b/core/modules/comment/src/Tests/CommentAdminTest.php index 5ae57cb..74e6e45 100644 --- a/core/modules/comment/src/Tests/CommentAdminTest.php +++ b/core/modules/comment/src/Tests/CommentAdminTest.php @@ -23,11 +23,11 @@ protected function setUp() { */ function testApprovalAdminInterface() { // Set anonymous comments to require approval. - user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments' => TRUE, 'post comments' => TRUE, 'skip comment approval' => FALSE, - )); + ]); $this->drupalLogin($this->adminUser); $this->setCommentAnonymous('0'); // Ensure that doesn't require contact info. @@ -46,14 +46,14 @@ function testApprovalAdminInterface() { // Get unapproved comment id. $this->drupalLogin($this->adminUser); $anonymous_comment4 = $this->getUnapprovedComment($subject); - $anonymous_comment4 = Comment::create(array( + $anonymous_comment4 = Comment::create([ 'cid' => $anonymous_comment4, 'subject' => $subject, 'comment_body' => $body, 'entity_id' => $this->node->id(), 'entity_type' => 'node', 'field_name' => 'comment' - )); + ]); $this->drupalLogout(); $this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.'); @@ -73,29 +73,29 @@ function testApprovalAdminInterface() { // Publish multiple comments in one operation. $this->drupalLogin($this->adminUser); $this->drupalGet('admin/content/comment/approval'); - $this->assertText(t('Unapproved comments (@count)', array('@count' => 2)), 'Two unapproved comments waiting for approval.'); - $edit = array( + $this->assertText(t('Unapproved comments (@count)', ['@count' => 2]), 'Two unapproved comments waiting for approval.'); + $edit = [ "comments[{$comments[0]->id()}]" => 1, "comments[{$comments[1]->id()}]" => 1, - ); + ]; $this->drupalPostForm(NULL, $edit, t('Update')); - $this->assertText(t('Unapproved comments (@count)', array('@count' => 0)), 'All comments were approved.'); + $this->assertText(t('Unapproved comments (@count)', ['@count' => 0]), 'All comments were approved.'); // Delete multiple comments in one operation. - $edit = array( + $edit = [ 'operation' => 'delete', "comments[{$comments[0]->id()}]" => 1, "comments[{$comments[1]->id()}]" => 1, "comments[{$anonymous_comment4->id()}]" => 1, - ); + ]; $this->drupalPostForm(NULL, $edit, t('Update')); $this->assertText(t('Are you sure you want to delete these comments and all their children?'), 'Confirmation required.'); $this->drupalPostForm(NULL, $edit, t('Delete comments')); $this->assertText(t('No comments available.'), 'All comments were deleted.'); // Test message when no comments selected. - $edit = array( + $edit = [ 'operation' => 'delete', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Update')); $this->assertText(t('Select one or more comments to perform the update on.')); } @@ -105,11 +105,11 @@ function testApprovalAdminInterface() { */ function testApprovalNodeInterface() { // Set anonymous comments to require approval. - user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments' => TRUE, 'post comments' => TRUE, 'skip comment approval' => FALSE, - )); + ]); $this->drupalLogin($this->adminUser); $this->setCommentAnonymous('0'); // Ensure that doesn't require contact info. $this->drupalLogout(); @@ -123,14 +123,14 @@ function testApprovalNodeInterface() { // Get unapproved comment id. $this->drupalLogin($this->adminUser); $anonymous_comment4 = $this->getUnapprovedComment($subject); - $anonymous_comment4 = Comment::create(array( + $anonymous_comment4 = Comment::create([ 'cid' => $anonymous_comment4, 'subject' => $subject, 'comment_body' => $body, 'entity_id' => $this->node->id(), 'entity_type' => 'node', 'field_name' => 'comment' - )); + ]); $this->drupalLogout(); $this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.'); @@ -139,7 +139,7 @@ function testApprovalNodeInterface() { $this->drupalLogin($this->adminUser); $this->drupalGet('comment/1/approve'); $this->assertResponse(403, 'Forged comment approval was denied.'); - $this->drupalGet('comment/1/approve', array('query' => array('token' => 'forged'))); + $this->drupalGet('comment/1/approve', ['query' => ['token' => 'forged']]); $this->assertResponse(403, 'Forged comment approval was denied.'); $this->drupalGet('comment/1/edit'); $this->assertFieldChecked('edit-status-0'); @@ -178,11 +178,11 @@ public function testCommentAdmin() { */ public function testEditComment() { // Enable anonymous user comments. - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments', 'post comments', 'skip comment approval', - )); + ]); // Log in as a web user. $this->drupalLogin($this->webUser); @@ -199,7 +199,7 @@ public function testEditComment() { // Post comment with contact info (required). $author_name = $this->randomMachineName(); $author_mail = $this->randomMachineName() . '@example.com'; - $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), array('name' => $author_name, 'mail' => $author_mail)); + $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), ['name' => $author_name, 'mail' => $author_mail]); // Log in as an admin user. $this->drupalLogin($this->adminUser); diff --git a/core/modules/comment/src/Tests/CommentAnonymousTest.php b/core/modules/comment/src/Tests/CommentAnonymousTest.php index 660d754..b8cbc1c 100644 --- a/core/modules/comment/src/Tests/CommentAnonymousTest.php +++ b/core/modules/comment/src/Tests/CommentAnonymousTest.php @@ -15,16 +15,16 @@ protected function setUp() { parent::setUp(); // Enable anonymous and authenticated user comments. - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments', 'post comments', 'skip comment approval', - )); - user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array( + ]); + user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, [ 'access comments', 'post comments', 'skip comment approval', - )); + ]); } /** @@ -87,12 +87,12 @@ function testAnonymous() { $this->assertTrue($this->commentExists($anonymous_comment2), 'Anonymous comment with contact info (optional) found.'); // Ensure anonymous users cannot post in the name of registered users. - $edit = array( + $edit = [ 'name' => $this->adminUser->getUsername(), 'mail' => $this->randomMachineName() . '@example.com', 'subject[0][value]' => $this->randomMachineName(), 'comment_body[0][value]' => $this->randomMachineName(), - ); + ]; $this->drupalPostForm('comment/reply/node/' . $this->node->id() . '/comment', $edit, t('Save')); $this->assertRaw(t('The name you used (%name) belongs to a registered user.', [ '%name' => $this->adminUser->getUsername(), @@ -115,7 +115,7 @@ function testAnonymous() { // Post comment with contact info (required). $author_name = $this->randomMachineName(); $author_mail = $this->randomMachineName() . '@example.com'; - $anonymous_comment3 = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), array('name' => $author_name, 'mail' => $author_mail)); + $anonymous_comment3 = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), ['name' => $author_name, 'mail' => $author_mail]); $this->assertTrue($this->commentExists($anonymous_comment3), 'Anonymous comment with contact info (required) found.'); // Make sure the user data appears correctly when editing the comment. @@ -149,11 +149,11 @@ function testAnonymous() { $this->assertResponse(403); // Reset. - user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments' => FALSE, 'post comments' => FALSE, 'skip comment approval' => FALSE, - )); + ]); // Attempt to view comments while disallowed. // NOTE: if authenticated user has permission to post comments, then a @@ -166,21 +166,21 @@ function testAnonymous() { $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); $this->assertResponse(403); - user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments' => TRUE, 'post comments' => FALSE, 'skip comment approval' => FALSE, - )); + ]); $this->drupalGet('node/' . $this->node->id()); $this->assertPattern('@]*>Comments

        @', 'Comments were displayed.'); $this->assertLink('Log in', 1, 'Link to login was found.'); $this->assertLink('register', 1, 'Link to register was found.'); - user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments' => FALSE, 'post comments' => TRUE, 'skip comment approval' => TRUE, - )); + ]); $this->drupalGet('node/' . $this->node->id()); $this->assertNoPattern('@]*>Comments
        @', 'Comments were not displayed.'); $this->assertFieldByName('subject[0][value]', '', 'Subject field found.'); diff --git a/core/modules/comment/src/Tests/CommentBlockTest.php b/core/modules/comment/src/Tests/CommentBlockTest.php index de92238..fca7223 100644 --- a/core/modules/comment/src/Tests/CommentBlockTest.php +++ b/core/modules/comment/src/Tests/CommentBlockTest.php @@ -17,12 +17,12 @@ class CommentBlockTest extends CommentTestBase { * * @var array */ - public static $modules = array('block', 'views'); + public static $modules = ['block', 'views']; protected function setUp() { parent::setUp(); // Update admin user to have the 'administer blocks' permission. - $this->adminUser = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser([ 'administer content types', 'administer comments', 'skip comment approval', @@ -30,7 +30,7 @@ protected function setUp() { 'access comments', 'access content', 'administer blocks', - )); + ]); } /** @@ -54,10 +54,10 @@ function testRecentCommentBlock() { // Test that a user without the 'access comments' permission cannot see the // block. $this->drupalLogout(); - user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, array('access comments')); + user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, ['access comments']); $this->drupalGet(''); $this->assertNoText(t('Recent comments')); - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access comments')); + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access comments']); // Test that a user with the 'access comments' permission can see the // block. @@ -68,11 +68,11 @@ function testRecentCommentBlock() { // Test the only the 10 latest comments are shown and in the proper order. $this->assertNoText($comments[10]->getSubject(), 'Comment 11 not found in block.'); for ($i = 0; $i < 10; $i++) { - $this->assertText($comments[$i]->getSubject(), SafeMarkup::format('Comment @number found in block.', array('@number' => 10 - $i))); + $this->assertText($comments[$i]->getSubject(), SafeMarkup::format('Comment @number found in block.', ['@number' => 10 - $i])); if ($i > 1) { $previous_position = $position; $position = strpos($this->getRawContent(), $comments[$i]->getSubject()); - $this->assertTrue($position > $previous_position, SafeMarkup::format('Comment @a appears after comment @b', array('@a' => 10 - $i, '@b' => 11 - $i))); + $this->assertTrue($position > $previous_position, SafeMarkup::format('Comment @a appears after comment @b', ['@a' => 10 - $i, '@b' => 11 - $i])); } $position = strpos($this->getRawContent(), $comments[$i]->getSubject()); } diff --git a/core/modules/comment/src/Tests/CommentBookTest.php b/core/modules/comment/src/Tests/CommentBookTest.php index b23028b..4afd07e 100644 --- a/core/modules/comment/src/Tests/CommentBookTest.php +++ b/core/modules/comment/src/Tests/CommentBookTest.php @@ -21,7 +21,7 @@ class CommentBookTest extends WebTestBase { * * @var array */ - public static $modules = array('book', 'comment'); + public static $modules = ['book', 'comment']; protected function setUp() { parent::setUp(); @@ -44,17 +44,17 @@ public function testBookCommentPrint() { $comment_subject = $this->randomMachineName(8); $comment_body = $this->randomMachineName(8); - $comment = Comment::create(array( + $comment = Comment::create([ 'subject' => $comment_subject, 'comment_body' => $comment_body, 'entity_id' => $book_node->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'status' => CommentInterface::PUBLISHED, - )); + ]); $comment->save(); - $commenting_user = $this->drupalCreateUser(array('access printer-friendly version', 'access comments', 'post comments')); + $commenting_user = $this->drupalCreateUser(['access printer-friendly version', 'access comments', 'post comments']); $this->drupalLogin($commenting_user); $this->drupalGet('node/' . $book_node->id()); diff --git a/core/modules/comment/src/Tests/CommentCSSTest.php b/core/modules/comment/src/Tests/CommentCSSTest.php index f015f3f..3c48f69 100644 --- a/core/modules/comment/src/Tests/CommentCSSTest.php +++ b/core/modules/comment/src/Tests/CommentCSSTest.php @@ -18,10 +18,10 @@ protected function setUp() { parent::setUp(); // Allow anonymous users to see comments. - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments', 'access content' - )); + ]); } /** @@ -29,21 +29,21 @@ protected function setUp() { */ function testCommentClasses() { // Create all permutations for comments, users, and nodes. - $parameters = array( - 'node_uid' => array(0, $this->webUser->id()), - 'comment_uid' => array(0, $this->webUser->id(), $this->adminUser->id()), - 'comment_status' => array(CommentInterface::PUBLISHED, CommentInterface::NOT_PUBLISHED), - 'user' => array('anonymous', 'authenticated', 'admin'), - ); + $parameters = [ + 'node_uid' => [0, $this->webUser->id()], + 'comment_uid' => [0, $this->webUser->id(), $this->adminUser->id()], + 'comment_status' => [CommentInterface::PUBLISHED, CommentInterface::NOT_PUBLISHED], + 'user' => ['anonymous', 'authenticated', 'admin'], + ]; $permutations = $this->generatePermutations($parameters); foreach ($permutations as $case) { // Create a new node. - $node = $this->drupalCreateNode(array('type' => 'article', 'uid' => $case['node_uid'])); + $node = $this->drupalCreateNode(['type' => 'article', 'uid' => $case['node_uid']]); // Add a comment. /** @var \Drupal\comment\CommentInterface $comment */ - $comment = Comment::create(array( + $comment = Comment::create([ 'entity_id' => $node->id(), 'entity_type' => 'node', 'field_name' => 'comment', @@ -51,8 +51,8 @@ function testCommentClasses() { 'status' => $case['comment_status'], 'subject' => $this->randomMachineName(), 'language' => LanguageInterface::LANGCODE_NOT_SPECIFIED, - 'comment_body' => array(LanguageInterface::LANGCODE_NOT_SPECIFIED => array($this->randomMachineName())), - )); + 'comment_body' => [LanguageInterface::LANGCODE_NOT_SPECIFIED => [$this->randomMachineName()]], + ]); $comment->save(); // Adjust the current/viewing user. diff --git a/core/modules/comment/src/Tests/CommentCacheTagsTest.php b/core/modules/comment/src/Tests/CommentCacheTagsTest.php index 3c7ab00..12e0ef8 100644 --- a/core/modules/comment/src/Tests/CommentCacheTagsTest.php +++ b/core/modules/comment/src/Tests/CommentCacheTagsTest.php @@ -24,7 +24,7 @@ class CommentCacheTagsTest extends EntityWithUriCacheTagsTestBase { /** * {@inheritdoc} */ - public static $modules = array('comment'); + public static $modules = ['comment']; /** * @var \Drupal\entity_test\Entity\EntityTest @@ -66,24 +66,24 @@ protected function createEntity() { $field->save(); // Create a "Camelids" test entity that the comment will be assigned to. - $this->entityTestCamelid = EntityTest::create(array( + $this->entityTestCamelid = EntityTest::create([ 'name' => 'Camelids', 'type' => 'bar', - )); + ]); $this->entityTestCamelid->save(); // Create a "Llama" comment. - $comment = Comment::create(array( + $comment = Comment::create([ 'subject' => 'Llama', - 'comment_body' => array( + 'comment_body' => [ 'value' => 'The name "llama" was adopted by European settlers from native Peruvians.', 'format' => 'plain_text', - ), + ], 'entity_id' => $this->entityTestCamelid->id(), 'entity_type' => 'entity_test', 'field_name' => 'comment', 'status' => CommentInterface::PUBLISHED, - )); + ]); $comment->save(); return $comment; @@ -97,26 +97,26 @@ public function testCommentEntity() { $this->verifyPageCache($this->entityTestCamelid->urlInfo(), 'HIT'); // Create a "Hippopotamus" comment. - $this->entityTestHippopotamidae = EntityTest::create(array( + $this->entityTestHippopotamidae = EntityTest::create([ 'name' => 'Hippopotamus', 'type' => 'bar', - )); + ]); $this->entityTestHippopotamidae->save(); $this->verifyPageCache($this->entityTestHippopotamidae->urlInfo(), 'MISS'); $this->verifyPageCache($this->entityTestHippopotamidae->urlInfo(), 'HIT'); - $hippo_comment = Comment::create(array( + $hippo_comment = Comment::create([ 'subject' => 'Hippopotamus', - 'comment_body' => array( + 'comment_body' => [ 'value' => 'The common hippopotamus (Hippopotamus amphibius), or hippo, is a large, mostly herbivorous mammal in sub-Saharan Africa', 'format' => 'plain_text', - ), + ], 'entity_id' => $this->entityTestHippopotamidae->id(), 'entity_type' => 'entity_test', 'field_name' => 'comment', 'status' => CommentInterface::PUBLISHED, - )); + ]); $hippo_comment->save(); // Ensure that a new comment only invalidates the commented entity. @@ -145,11 +145,11 @@ protected function getAdditionalCacheContextsForEntity(EntityInterface $entity) */ protected function getAdditionalCacheTagsForEntity(EntityInterface $entity) { /** @var \Drupal\comment\CommentInterface $entity */ - return array( + return [ 'config:filter.format.plain_text', 'user:' . $entity->getOwnerId(), 'user_view', - ); + ]; } } diff --git a/core/modules/comment/src/Tests/CommentFieldsTest.php b/core/modules/comment/src/Tests/CommentFieldsTest.php index 46de1be..fe994d9 100644 --- a/core/modules/comment/src/Tests/CommentFieldsTest.php +++ b/core/modules/comment/src/Tests/CommentFieldsTest.php @@ -19,7 +19,7 @@ class CommentFieldsTest extends CommentTestBase { * * @var array */ - public static $modules = array('field_ui'); + public static $modules = ['field_ui']; /** * Tests that the default 'comment_body' field is correctly added. @@ -27,7 +27,7 @@ class CommentFieldsTest extends CommentTestBase { function testCommentDefaultFields() { // Do not make assumptions on default node types created by the test // installation profile, and create our own. - $this->drupalCreateContentType(array('type' => 'test_node_type')); + $this->drupalCreateContentType(['type' => 'test_node_type']); $this->addDefaultCommentField('node', 'test_node_type'); // Check that the 'comment_body' field is present on the comment bundle. @@ -43,7 +43,7 @@ function testCommentDefaultFields() { // Create a new content type. $type_name = 'test_node_type_2'; - $this->drupalCreateContentType(array('type' => $type_name)); + $this->drupalCreateContentType(['type' => $type_name]); $this->addDefaultCommentField('node', $type_name); // Check that the 'comment_body' field exists and has an instance on the @@ -51,7 +51,7 @@ function testCommentDefaultFields() { $field_storage = FieldStorageConfig::loadByName('comment', 'comment_body'); $this->assertTrue($field_storage, 'The comment_body field exists'); $field = FieldConfig::loadByName('comment', 'comment', 'comment_body'); - $this->assertTrue(isset($field), format_string('The comment_body field is present for comments on type @type', array('@type' => $type_name))); + $this->assertTrue(isset($field), format_string('The comment_body field is present for comments on type @type', ['@type' => $type_name])); // Test adding a field that defaults to CommentItemInterface::CLOSED. $this->addDefaultCommentField('node', 'test_node_type', 'who_likes_ponies', CommentItemInterface::CLOSED, 'who_likes_ponies'); @@ -63,7 +63,7 @@ function testCommentDefaultFields() { * Tests that you can remove a comment field. */ public function testCommentFieldDelete() { - $this->drupalCreateContentType(array('type' => 'test_node_type')); + $this->drupalCreateContentType(['type' => 'test_node_type']); $this->addDefaultCommentField('node', 'test_node_type'); // We want to test the handling of removing the primary comment field, so we // ensure there is at least one other comment field attached to a node type @@ -71,10 +71,10 @@ public function testCommentFieldDelete() { $this->addDefaultCommentField('node', 'test_node_type', 'comment2'); // Create a sample node. - $node = $this->drupalCreateNode(array( + $node = $this->drupalCreateNode([ 'title' => 'Baloney', 'type' => 'test_node_type', - )); + ]); $this->drupalLogin($this->webUser); @@ -143,38 +143,38 @@ public function testCommentFieldLinksNonDefaultName() { */ public function testCommentFieldCreate() { // Create user who can administer user fields. - $user = $this->drupalCreateUser(array( + $user = $this->drupalCreateUser([ 'administer user fields', - )); + ]); $this->drupalLogin($user); // Create comment field in account settings. - $edit = array( + $edit = [ 'new_storage_type' => 'comment', 'label' => 'User comment', 'field_name' => 'user_comment', - ); + ]; $this->drupalPostForm('admin/config/people/accounts/fields/add-field', $edit, 'Save and continue'); // Try to save the comment field without selecting a comment type. - $edit = array(); + $edit = []; $this->drupalPostForm('admin/config/people/accounts/fields/user.user.field_user_comment/storage', $edit, t('Save field settings')); // We should get an error message. $this->assertText(t('An illegal choice has been detected. Please contact the site administrator.')); // Create a comment type for users. - $bundle = CommentType::create(array( + $bundle = CommentType::create([ 'id' => 'user_comment_type', 'label' => 'user_comment_type', 'description' => '', 'target_entity_type_id' => 'user', - )); + ]); $bundle->save(); // Select a comment type and try to save again. - $edit = array( + $edit = [ 'settings[comment_type]' => 'user_comment_type', - ); + ]; $this->drupalPostForm('admin/config/people/accounts/fields/user.user.field_user_comment/storage', $edit, t('Save field settings')); // We shouldn't get an error message. $this->assertNoText(t('An illegal choice has been detected. Please contact the site administrator.')); @@ -185,7 +185,7 @@ public function testCommentFieldCreate() { */ function testCommentInstallAfterContentModule() { // Create a user to do module administration. - $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'administer modules')); + $this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer modules']); $this->drupalLogin($this->adminUser); // Drop default comment field added in CommentTestBase::setup(). @@ -199,20 +199,20 @@ function testCommentInstallAfterContentModule() { field_purge_batch(10); // Uninstall the comment module. - $edit = array(); + $edit = []; $edit['uninstall[comment]'] = TRUE; $this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall')); - $this->drupalPostForm(NULL, array(), t('Uninstall')); + $this->drupalPostForm(NULL, [], t('Uninstall')); $this->rebuildContainer(); $this->assertFalse($this->container->get('module_handler')->moduleExists('comment'), 'Comment module uninstalled.'); // Install core content type module (book). - $edit = array(); + $edit = []; $edit['modules[Core][book][enable]'] = 'book'; $this->drupalPostForm('admin/modules', $edit, t('Install')); // Now install the comment module. - $edit = array(); + $edit = []; $edit['modules[Core][comment][enable]'] = 'comment'; $this->drupalPostForm('admin/modules', $edit, t('Install')); $this->rebuildContainer(); @@ -220,14 +220,14 @@ function testCommentInstallAfterContentModule() { // Create nodes of each type. $this->addDefaultCommentField('node', 'book'); - $book_node = $this->drupalCreateNode(array('type' => 'book')); + $book_node = $this->drupalCreateNode(['type' => 'book']); $this->drupalLogout(); // Try to post a comment on each node. A failure will be triggered if the // comment body is missing on one of these forms, due to postComment() // asserting that the body is actually posted correctly. - $this->webUser = $this->drupalCreateUser(array('access content', 'access comments', 'post comments', 'skip comment approval')); + $this->webUser = $this->drupalCreateUser(['access content', 'access comments', 'post comments', 'skip comment approval']); $this->drupalLogin($this->webUser); $this->postComment($book_node, $this->randomMachineName(), $this->randomMachineName()); } diff --git a/core/modules/comment/src/Tests/CommentInterfaceTest.php b/core/modules/comment/src/Tests/CommentInterfaceTest.php index ba43224..6f67ca8 100644 --- a/core/modules/comment/src/Tests/CommentInterfaceTest.php +++ b/core/modules/comment/src/Tests/CommentInterfaceTest.php @@ -68,7 +68,7 @@ public function testCommentInterface() { // Comment as anonymous with preview required. $this->drupalLogout(); - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access content', 'access comments', 'post comments', 'skip comment approval')); + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access content', 'access comments', 'post comments', 'skip comment approval']); $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), TRUE); $this->assertTrue($this->commentExists($anonymous_comment), 'Comment found.'); $anonymous_comment->delete(); @@ -92,24 +92,24 @@ public function testCommentInterface() { $this->setCommentPreview(DRUPAL_OPTIONAL); $this->drupalGet('comment/' . $comment->id() . '/edit'); - $this->assertTitle(t('Edit comment @title | Drupal', array( + $this->assertTitle(t('Edit comment @title | Drupal', [ '@title' => $comment->getSubject(), - ))); + ])); // Test changing the comment author to "Anonymous". - $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('uid' => '')); + $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), ['uid' => '']); $this->assertTrue($comment->getAuthorName() == t('Anonymous') && $comment->getOwnerId() == 0, 'Comment author successfully changed to anonymous.'); // Test changing the comment author to an unverified user. $random_name = $this->randomMachineName(); $this->drupalGet('comment/' . $comment->id() . '/edit'); - $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('name' => $random_name)); + $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), ['name' => $random_name]); $this->drupalGet('node/' . $this->node->id()); $this->assertText($random_name . ' (' . t('not verified') . ')', 'Comment author successfully changed to an unverified user.'); // Test changing the comment author to a verified user. $this->drupalGet('comment/' . $comment->id() . '/edit'); - $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), array('uid' => $this->webUser->getUsername() . ' (' . $this->webUser->id() . ')')); + $comment = $this->postComment(NULL, $comment->comment_body->value, $comment->getSubject(), ['uid' => $this->webUser->getUsername() . ' (' . $this->webUser->id() . ')']); $this->assertTrue($comment->getAuthorName() == $this->webUser->getUsername() && $comment->getOwnerId() == $this->webUser->id(), 'Comment author successfully changed to a registered user.'); $this->drupalLogout(); @@ -121,7 +121,7 @@ public function testCommentInterface() { // \Drupal\comment\Controller\CommentController::redirectNode(). $this->drupalGet('comment/' . $this->node->id() . '/reply'); // Verify we were correctly redirected. - $this->assertUrl(\Drupal::url('comment.reply', array('entity_type' => 'node', 'entity' => $this->node->id(), 'field_name' => 'comment'), array('absolute' => TRUE))); + $this->assertUrl(\Drupal::url('comment.reply', ['entity_type' => 'node', 'entity' => $this->node->id(), 'field_name' => 'comment'], ['absolute' => TRUE])); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment/' . $comment->id()); $this->assertText($subject_text, 'Individual comment-reply subject found.'); $this->assertText($comment_text, 'Individual comment-reply body found.'); @@ -161,7 +161,7 @@ public function testCommentInterface() { $this->setCommentsPerPage(2); $comment_new_page = $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName(), TRUE); $this->assertTrue($this->commentExists($comment_new_page), 'Page one exists. %s'); - $this->drupalGet('node/' . $this->node->id(), array('query' => array('page' => 2))); + $this->drupalGet('node/' . $this->node->id(), ['query' => ['page' => 2]]); $this->assertTrue($this->commentExists($reply, TRUE), 'Page two exists. %s'); $this->setCommentsPerPage(50); @@ -172,21 +172,21 @@ public function testCommentInterface() { $this->assertResponse(403); // Attempt to post to node with comments disabled. - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => CommentItemInterface::HIDDEN)))); + $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::HIDDEN]]]); $this->assertTrue($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); $this->assertResponse(403); $this->assertNoField('edit-comment', 'Comment body field found.'); // Attempt to post to node with read-only comments. - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => CommentItemInterface::CLOSED)))); + $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::CLOSED]]]); $this->assertTrue($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); $this->assertResponse(403); $this->assertNoField('edit-comment', 'Comment body field found.'); // Attempt to post to node with comments enabled (check field names etc). - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(array('status' => CommentItemInterface::OPEN)))); + $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'comment' => [['status' => CommentItemInterface::OPEN]]]); $this->assertTrue($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); $this->assertNoText('This discussion is closed', 'Posting to node with comments enabled'); @@ -254,17 +254,17 @@ public function testAutoFilledHtmlSubject() { // can select one of them. Then create a user that can use these formats, // log the user in, and then GET the node page on which to test the // comments. - $filtered_html_format = FilterFormat::create(array( + $filtered_html_format = FilterFormat::create([ 'format' => 'filtered_html', 'name' => 'Filtered HTML', - )); + ]); $filtered_html_format->save(); - $full_html_format = FilterFormat::create(array( + $full_html_format = FilterFormat::create([ 'format' => 'full_html', 'name' => 'Full HTML', - )); + ]); $full_html_format->save(); - $html_user = $this->drupalCreateUser(array( + $html_user = $this->drupalCreateUser([ 'access comments', 'post comments', 'edit own comments', @@ -272,25 +272,25 @@ public function testAutoFilledHtmlSubject() { 'access content', $filtered_html_format->getPermissionName(), $full_html_format->getPermissionName(), - )); + ]); $this->drupalLogin($html_user); $this->drupalGet('node/' . $this->node->id()); // HTML should not be included in the character count. $body_text1 = ' Hello World
        '; - $edit1 = array( + $edit1 = [ 'comment_body[0][value]' => $body_text1, 'comment_body[0][format]' => 'filtered_html', - ); + ]; $this->drupalPostForm(NULL, $edit1, t('Save')); $this->assertEqual('Hello World', Comment::load(1)->getSubject()); // If there's nothing other than HTML, the subject should be '(No subject)'. $body_text2 = '
        '; - $edit2 = array( + $edit2 = [ 'comment_body[0][value]' => $body_text2, 'comment_body[0][format]' => 'filtered_html', - ); + ]; $this->drupalPostForm(NULL, $edit2, t('Save')); $this->assertEqual('(No subject)', Comment::load(2)->getSubject()); } diff --git a/core/modules/comment/src/Tests/CommentLanguageTest.php b/core/modules/comment/src/Tests/CommentLanguageTest.php index c60f827..b047b40 100644 --- a/core/modules/comment/src/Tests/CommentLanguageTest.php +++ b/core/modules/comment/src/Tests/CommentLanguageTest.php @@ -25,23 +25,23 @@ class CommentLanguageTest extends WebTestBase { * * @var array */ - public static $modules = array('node', 'language', 'language_test', 'comment_test'); + public static $modules = ['node', 'language', 'language_test', 'comment_test']; protected function setUp() { parent::setUp(); - $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); + $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); // Create and log in user. - $admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer languages', 'access administration pages', 'administer content types', 'administer comments', 'create article content', 'access comments', 'post comments', 'skip comment approval')); + $admin_user = $this->drupalCreateUser(['administer site configuration', 'administer languages', 'access administration pages', 'administer content types', 'administer comments', 'create article content', 'access comments', 'post comments', 'skip comment approval']); $this->drupalLogin($admin_user); // Add language. - $edit = array('predefined_langcode' => 'fr'); + $edit = ['predefined_langcode' => 'fr']; $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); // Set "Article" content type to use multilingual support. - $edit = array('language_configuration[language_alterable]' => TRUE); + $edit = ['language_configuration[language_alterable]' => TRUE]; $this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type')); // Enable content language negotiation UI. @@ -51,16 +51,16 @@ protected function setUp() { // to URL. Disable inheritance from interface language to ensure content // language will fall back to the default language if no URL language can be // detected. - $edit = array( + $edit = [ 'language_interface[enabled][language-user]' => TRUE, 'language_content[enabled][language-url]' => TRUE, 'language_content[enabled][language-interface]' => FALSE, - ); + ]; $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); // Change user language preference, this way interface language is always // French no matter what path prefix the URLs have. - $edit = array('preferred_langcode' => 'fr'); + $edit = ['preferred_langcode' => 'fr']; $this->drupalPostForm("user/" . $admin_user->id() . "/edit", $edit, t('Save')); // Create comment field on article. @@ -87,12 +87,12 @@ function testCommentLanguage() { foreach ($this->container->get('language_manager')->getLanguages() as $node_langcode => $node_language) { // Create "Article" content. $title = $this->randomMachineName(); - $edit = array( + $edit = [ 'title[0][value]' => $title, 'body[0][value]' => $this->randomMachineName(), 'langcode[0][value]' => $node_langcode, 'comment[0][status]' => CommentItemInterface::OPEN, - ); + ]; $this->drupalPostForm("node/add/article", $edit, t('Save')); $node = $this->drupalGetNodeByTitle($title); @@ -101,10 +101,10 @@ function testCommentLanguage() { // Post a comment with content language $langcode. $prefix = empty($prefixes[$langcode]) ? '' : $prefixes[$langcode] . '/'; $comment_values[$node_langcode][$langcode] = $this->randomMachineName(); - $edit = array( + $edit = [ 'subject[0][value]' => $this->randomMachineName(), 'comment_body[0][value]' => $comment_values[$node_langcode][$langcode], - ); + ]; $this->drupalPostForm($prefix . 'node/' . $node->id(), $edit, t('Preview')); $this->drupalPostForm(NULL, $edit, t('Save')); @@ -117,7 +117,7 @@ function testCommentLanguage() { ->range(0, 1) ->execute(); $comment = Comment::load(reset($cids)); - $args = array('%node_language' => $node_langcode, '%comment_language' => $comment->langcode->value, '%langcode' => $langcode); + $args = ['%node_language' => $node_langcode, '%comment_language' => $comment->langcode->value, '%langcode' => $langcode]; $this->assertEqual($comment->langcode->value, $langcode, format_string('The comment posted with content language %langcode and belonging to the node with language %node_language has language %comment_language', $args)); $this->assertEqual($comment->comment_body->value, $comment_values[$node_langcode][$langcode], 'Comment body correctly stored.'); } diff --git a/core/modules/comment/src/Tests/CommentLinksAlterTest.php b/core/modules/comment/src/Tests/CommentLinksAlterTest.php index 22ff587..88e092f 100644 --- a/core/modules/comment/src/Tests/CommentLinksAlterTest.php +++ b/core/modules/comment/src/Tests/CommentLinksAlterTest.php @@ -9,7 +9,7 @@ */ class CommentLinksAlterTest extends CommentTestBase { - public static $modules = array('comment_test'); + public static $modules = ['comment_test']; protected function setUp() { parent::setUp(); diff --git a/core/modules/comment/src/Tests/CommentLinksTest.php b/core/modules/comment/src/Tests/CommentLinksTest.php index e961691..e16fe8d 100644 --- a/core/modules/comment/src/Tests/CommentLinksTest.php +++ b/core/modules/comment/src/Tests/CommentLinksTest.php @@ -27,7 +27,7 @@ class CommentLinksTest extends CommentTestBase { * * @var array */ - protected $seen = array(); + protected $seen = []; /** * Use the main node listing to test rendering on teasers. @@ -36,14 +36,14 @@ class CommentLinksTest extends CommentTestBase { * * @todo Remove this dependency. */ - public static $modules = array('views'); + public static $modules = ['views']; /** * Tests that comment links are output and can be hidden. */ public function testCommentLinks() { // Bartik theme alters comment links, so use a different theme. - \Drupal::service('theme_handler')->install(array('stark')); + \Drupal::service('theme_handler')->install(['stark']); $this->config('system.theme') ->set('default', 'stark') ->save(); @@ -51,11 +51,11 @@ public function testCommentLinks() { // Remove additional user permissions from $this->webUser added by setUp(), // since this test is limited to anonymous and authenticated roles only. $roles = $this->webUser->getRoles(); - entity_delete_multiple('user_role', array(reset($roles))); + entity_delete_multiple('user_role', [reset($roles)]); // Create a comment via CRUD API functionality, since // $this->postComment() relies on actual user permissions. - $comment = Comment::create(array( + $comment = Comment::create([ 'cid' => NULL, 'entity_id' => $this->node->id(), 'entity_type' => 'node', @@ -66,8 +66,8 @@ public function testCommentLinks() { 'subject' => $this->randomMachineName(), 'hostname' => '127.0.0.1', 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, - 'comment_body' => array(LanguageInterface::LANGCODE_NOT_SPECIFIED => array($this->randomMachineName())), - )); + 'comment_body' => [LanguageInterface::LANGCODE_NOT_SPECIFIED => [$this->randomMachineName()]], + ]); $comment->save(); $this->comment = $comment; @@ -78,19 +78,19 @@ public function testCommentLinks() { $this->node->save(); // Change user permissions. - $perms = array( + $perms = [ 'access comments' => 1, 'post comments' => 1, 'skip comment approval' => 1, 'edit own comments' => 1, - ); + ]; user_role_change_permissions(RoleInterface::ANONYMOUS_ID, $perms); $nid = $this->node->id(); // Assert basic link is output, actual functionality is unit-tested in // \Drupal\comment\Tests\CommentLinkBuilderTest. - foreach (array('node', "node/$nid") as $path) { + foreach (['node', "node/$nid"] as $path) { $this->drupalGet($path); // In teaser view, a link containing the comment count is always diff --git a/core/modules/comment/src/Tests/CommentNewIndicatorTest.php b/core/modules/comment/src/Tests/CommentNewIndicatorTest.php index 6d89d4a..55609e3 100644 --- a/core/modules/comment/src/Tests/CommentNewIndicatorTest.php +++ b/core/modules/comment/src/Tests/CommentNewIndicatorTest.php @@ -22,7 +22,7 @@ class CommentNewIndicatorTest extends CommentTestBase { * * @todo Remove this dependency. */ - public static $modules = array('views'); + public static $modules = ['views']; /** * Get node "x new comments" metadata from the server for the current user. @@ -35,7 +35,7 @@ class CommentNewIndicatorTest extends CommentTestBase { */ protected function renderNewCommentsNodeLinks(array $node_ids) { // Build POST values. - $post = array(); + $post = []; for ($i = 0; $i < count($node_ids); $i++) { $post['node_ids[' . $i . ']'] = $node_ids[$i]; } @@ -51,15 +51,15 @@ protected function renderNewCommentsNodeLinks(array $node_ids) { $post = implode('&', $post); // Perform HTTP request. - return $this->curlExec(array( - CURLOPT_URL => \Drupal::url('comment.new_comments_node_links', array(), array('absolute' => TRUE)), + return $this->curlExec([ + CURLOPT_URL => \Drupal::url('comment.new_comments_node_links', [], ['absolute' => TRUE]), CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, - CURLOPT_HTTPHEADER => array( + CURLOPT_HTTPHEADER => [ 'Accept: application/json', 'Content-Type: application/x-www-form-urlencoded', - ), - )); + ], + ]); } /** @@ -70,7 +70,7 @@ public function testCommentNewCommentsIndicator() { // node. $this->drupalLogin($this->adminUser); $this->drupalGet('node'); - $this->assertNoLink(t('@count comments', array('@count' => 0))); + $this->assertNoLink(t('@count comments', ['@count' => 0])); $this->assertLink(t('Read more')); // Verify the data-history-node-last-comment-timestamp attribute, which is // used by the drupal.node-new-comments-link library to determine whether @@ -81,7 +81,7 @@ public function testCommentNewCommentsIndicator() { // Create a new comment. This helper function may be run with different // comment settings so use $comment->save() to avoid complex setup. /** @var \Drupal\comment\CommentInterface $comment */ - $comment = Comment::create(array( + $comment = Comment::create([ 'cid' => NULL, 'entity_id' => $this->node->id(), 'entity_type' => 'node', @@ -92,8 +92,8 @@ public function testCommentNewCommentsIndicator() { 'subject' => $this->randomMachineName(), 'hostname' => '127.0.0.1', 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, - 'comment_body' => array(LanguageInterface::LANGCODE_NOT_SPECIFIED => array($this->randomMachineName())), - )); + 'comment_body' => [LanguageInterface::LANGCODE_NOT_SPECIFIED => [$this->randomMachineName()]], + ]); $comment->save(); $this->drupalLogout(); @@ -126,24 +126,24 @@ public function testCommentNewCommentsIndicator() { ]); // Pretend the data was not present in drupalSettings, i.e. test the // separate request to the server. - $response = $this->renderNewCommentsNodeLinks(array($this->node->id())); + $response = $this->renderNewCommentsNodeLinks([$this->node->id()]); $this->assertResponse(200); $json = Json::decode($response); - $expected = array($this->node->id() => array( + $expected = [$this->node->id() => [ 'new_comment_count' => 1, - 'first_new_comment_link' => $this->node->url('canonical', array('fragment' => 'new')), - )); + 'first_new_comment_link' => $this->node->url('canonical', ['fragment' => 'new']), + ]]; $this->assertIdentical($expected, $json); // Failing to specify node IDs for the endpoint should return a 404. - $this->renderNewCommentsNodeLinks(array()); + $this->renderNewCommentsNodeLinks([]); $this->assertResponse(404); // Accessing the endpoint as the anonymous user should return a 403. $this->drupalLogout(); - $this->renderNewCommentsNodeLinks(array($this->node->id())); + $this->renderNewCommentsNodeLinks([$this->node->id()]); $this->assertResponse(403); - $this->renderNewCommentsNodeLinks(array()); + $this->renderNewCommentsNodeLinks([]); $this->assertResponse(403); } diff --git a/core/modules/comment/src/Tests/CommentNodeAccessTest.php b/core/modules/comment/src/Tests/CommentNodeAccessTest.php index e69bfde..60f8bbd 100644 --- a/core/modules/comment/src/Tests/CommentNodeAccessTest.php +++ b/core/modules/comment/src/Tests/CommentNodeAccessTest.php @@ -19,7 +19,7 @@ class CommentNodeAccessTest extends CommentTestBase { * * @var array */ - public static $modules = array('node_access_test'); + public static $modules = ['node_access_test']; protected function setUp() { parent::setUp(); @@ -27,14 +27,14 @@ protected function setUp() { node_access_rebuild(); // Re-create user. - $this->webUser = $this->drupalCreateUser(array( + $this->webUser = $this->drupalCreateUser([ 'access comments', 'post comments', 'create article content', 'edit own comments', 'node test view', 'skip comment approval', - )); + ]); // Set the author of the created node to the web_user uid. $this->node->setOwnerId($this->webUser->id())->save(); diff --git a/core/modules/comment/src/Tests/CommentNodeChangesTest.php b/core/modules/comment/src/Tests/CommentNodeChangesTest.php index 9fed4df..7724f99 100644 --- a/core/modules/comment/src/Tests/CommentNodeChangesTest.php +++ b/core/modules/comment/src/Tests/CommentNodeChangesTest.php @@ -27,7 +27,7 @@ function testNodeDeletion() { $this->assertNotNull(FieldStorageConfig::load('node.comment'), 'Comment field storage exists'); $this->assertNotNull(FieldConfig::load('node.article.comment'), 'Comment field exists'); // Delete the node type. - entity_delete_multiple('node_type', array($this->node->bundle())); + entity_delete_multiple('node_type', [$this->node->bundle()]); $this->assertNull(FieldStorageConfig::load('node.comment'), 'Comment field storage deleted'); $this->assertNull(FieldConfig::load('node.article.comment'), 'Comment field deleted'); } diff --git a/core/modules/comment/src/Tests/CommentNonNodeTest.php b/core/modules/comment/src/Tests/CommentNonNodeTest.php index 1b37c1f..45547d8 100644 --- a/core/modules/comment/src/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/src/Tests/CommentNonNodeTest.php @@ -24,7 +24,7 @@ class CommentNonNodeTest extends WebTestBase { use FieldUiTestTrait; use CommentTestTrait; - public static $modules = array('comment', 'user', 'field_ui', 'entity_test', 'block'); + public static $modules = ['comment', 'user', 'field_ui', 'entity_test', 'block']; /** * An administrative user with permission to configure comment settings. @@ -50,12 +50,12 @@ protected function setUp() { // Create a bundle for entity_test. entity_test_create_bundle('entity_test', 'Entity Test', 'entity_test'); - CommentType::create(array( + CommentType::create([ 'id' => 'comment', 'label' => 'Comment settings', 'description' => 'Comment settings', 'target_entity_type_id' => 'entity_test', - ))->save(); + ])->save(); // Create comment field on entity_test bundle. $this->addDefaultCommentField('entity_test', 'entity_test'); @@ -64,30 +64,30 @@ protected function setUp() { $this->assertEqual($bundles['comment']['label'], 'Comment settings'); // Create test user. - $this->adminUser = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser([ 'administer comments', 'skip comment approval', 'post comments', 'access comments', 'view test entity', 'administer entity_test content', - )); + ]); // Enable anonymous and authenticated user comments. - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments', 'post comments', 'skip comment approval', - )); - user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array( + ]); + user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, [ 'access comments', 'post comments', 'skip comment approval', - )); + ]); // Create a test entity. $random_label = $this->randomMachineName(); - $data = array('type' => 'entity_test', 'name' => $random_label); + $data = ['type' => 'entity_test', 'name' => $random_label]; $this->entity = EntityTest::create($data); $this->entity->save(); } @@ -109,7 +109,7 @@ protected function setUp() { * The new comment entity. */ function postComment(EntityInterface $entity, $comment, $subject = '', $contact = NULL) { - $edit = array(); + $edit = []; $edit['comment_body[0][value]'] = $comment; $field = FieldConfig::loadByName('entity_test', 'entity_test', 'comment'); @@ -151,7 +151,7 @@ function postComment(EntityInterface $entity, $comment, $subject = '', $contact $this->drupalPostForm(NULL, $edit, t('Save')); break; } - $match = array(); + $match = []; // Get comment ID preg_match('/#comment-([0-9]+)/', $this->getURL(), $match); @@ -216,17 +216,17 @@ function commentContactInfoAvailable() { * Operation is found on approval page. */ function performCommentOperation($comment, $operation, $approval = FALSE) { - $edit = array(); + $edit = []; $edit['operation'] = $operation; $edit['comments[' . $comment->id() . ']'] = TRUE; $this->drupalPostForm('admin/content/comment' . ($approval ? '/approval' : ''), $edit, t('Update')); if ($operation == 'delete') { - $this->drupalPostForm(NULL, array(), t('Delete comments')); - $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation))); + $this->drupalPostForm(NULL, [], t('Delete comments')); + $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', ['@operation' => $operation])); } else { - $this->assertText(t('The update has been performed.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation))); + $this->assertText(t('The update has been performed.'), format_string('Operation "@operation" was performed on comment.', ['@operation' => $operation])); } } @@ -250,9 +250,9 @@ function getUnapprovedComment($subject) { * Tests anonymous comment functionality. */ function testCommentFunctionality() { - $limited_user = $this->drupalCreateUser(array( + $limited_user = $this->drupalCreateUser([ 'administer entity_test fields' - )); + ]); $this->drupalLogin($limited_user); // Test that default field exists. $this->drupalGet('entity_test/structure/entity_test/fields'); @@ -320,9 +320,9 @@ function testCommentFunctionality() { // Check that entity access applies to administrative page. $this->assertText($this->entity->label(), 'Name of commented account found.'); - $limited_user = $this->drupalCreateUser(array( + $limited_user = $this->drupalCreateUser([ 'administer comments', - )); + ]); $this->drupalLogin($limited_user); $this->drupalGet('admin/content/comment'); $this->assertNoText($this->entity->label(), 'No commented account name found.'); @@ -330,12 +330,12 @@ function testCommentFunctionality() { $this->drupalLogout(); // Deny anonymous users access to comments. - user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments' => FALSE, 'post comments' => FALSE, 'skip comment approval' => FALSE, 'view test entity' => TRUE, - )); + ]); // Attempt to view comments while disallowed. $this->drupalGet('entity-test/' . $this->entity->id()); @@ -348,12 +348,12 @@ function testCommentFunctionality() { $this->assertNoFieldByName('subject[0][value]', '', 'Subject field not found.'); $this->assertNoFieldByName('comment_body[0][value]', '', 'Comment field not found.'); - user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments' => TRUE, 'post comments' => FALSE, 'view test entity' => TRUE, 'skip comment approval' => FALSE, - )); + ]); $this->drupalGet('entity_test/' . $this->entity->id()); $this->assertPattern('@]*>Comments@', 'Comments were displayed.'); $this->assertLink('Log in', 0, 'Link to login was found.'); @@ -364,12 +364,12 @@ function testCommentFunctionality() { // Test the combination of anonymous users being able to post, but not view // comments, to ensure that access to post comments doesn't grant access to // view them. - user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments' => FALSE, 'post comments' => TRUE, 'skip comment approval' => TRUE, 'view test entity' => TRUE, - )); + ]); $this->drupalGet('entity_test/' . $this->entity->id()); $this->assertNoPattern('@]*>Comments@', 'Comments were not displayed.'); $this->assertFieldByName('subject[0][value]', '', 'Subject field found.'); @@ -380,21 +380,21 @@ function testCommentFunctionality() { $this->assertNoText($comment1->getSubject(), 'Comment not displayed.'); // Test comment field widget changes. - $limited_user = $this->drupalCreateUser(array( + $limited_user = $this->drupalCreateUser([ 'administer entity_test fields', 'view test entity', 'administer entity_test content', - )); + ]); $this->drupalLogin($limited_user); $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0'); $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-1'); $this->assertFieldChecked('edit-default-value-input-comment-0-status-2'); // Test comment option change in field settings. - $edit = array( + $edit = [ 'default_value_input[comment][0][status]' => CommentItemInterface::CLOSED, 'settings[anonymous]' => COMMENT_ANONYMOUS_MAY_CONTACT, - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save settings')); $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0'); @@ -403,18 +403,18 @@ function testCommentFunctionality() { $this->assertFieldByName('settings[anonymous]', COMMENT_ANONYMOUS_MAY_CONTACT); // Add a new comment-type. - $bundle = CommentType::create(array( + $bundle = CommentType::create([ 'id' => 'foobar', 'label' => 'Foobar', 'description' => '', 'target_entity_type_id' => 'entity_test', - )); + ]); $bundle->save(); // Add a new comment field. - $storage_edit = array( + $storage_edit = [ 'settings[comment_type]' => 'foobar', - ); + ]; $this->fieldUIAddNewField('entity_test/structure/entity_test', 'foobar', 'Foobar', 'comment', $storage_edit); // Add a third comment field. @@ -428,7 +428,7 @@ function testCommentFunctionality() { // Test the new entity commenting inherits default. $random_label = $this->randomMachineName(); - $data = array('bundle' => 'entity_test', 'name' => $random_label); + $data = ['bundle' => 'entity_test', 'name' => $random_label]; $new_entity = EntityTest::create($data); $new_entity->save(); $this->drupalGet('entity_test/manage/' . $new_entity->id() . '/edit'); @@ -442,12 +442,12 @@ function testCommentFunctionality() { $this->assertNoFieldByName('comment_body[0][value]', '', 'Comment field found.'); // Test removal of comment_body field. - $limited_user = $this->drupalCreateUser(array( + $limited_user = $this->drupalCreateUser([ 'administer entity_test fields', 'post comments', 'administer comment fields', 'administer comment types', - )); + ]); $this->drupalLogin($limited_user); $this->drupalGet('comment/reply/entity_test/' . $this->entity->id() . '/comment'); @@ -466,9 +466,9 @@ function testCommentFunctionality() { public function testsNonIntegerIdEntities() { // Create a bundle for entity_test_string_id. entity_test_create_bundle('entity_test', 'Entity Test', 'entity_test_string_id'); - $limited_user = $this->drupalCreateUser(array( + $limited_user = $this->drupalCreateUser([ 'administer entity_test_string_id fields', - )); + ]); $this->drupalLogin($limited_user); // Visit the Field UI field add page. $this->drupalGet('entity_test_string_id/structure/entity_test/fields/add-field'); @@ -479,9 +479,9 @@ public function testsNonIntegerIdEntities() { // Create a bundle for entity_test_no_id. entity_test_create_bundle('entity_test', 'Entity Test', 'entity_test_no_id'); - $this->drupalLogin($this->drupalCreateUser(array( + $this->drupalLogin($this->drupalCreateUser([ 'administer entity_test_no_id fields', - ))); + ])); // Visit the Field UI field add page. $this->drupalGet('entity_test_no_id/structure/entity_test/fields/add-field'); // Ensure field isn't shown for empty IDs. diff --git a/core/modules/comment/src/Tests/CommentPagerTest.php b/core/modules/comment/src/Tests/CommentPagerTest.php index f07f322..05eb565 100644 --- a/core/modules/comment/src/Tests/CommentPagerTest.php +++ b/core/modules/comment/src/Tests/CommentPagerTest.php @@ -24,8 +24,8 @@ function testCommentPaging() { $this->setCommentPreview(DRUPAL_DISABLED); // Create a node and three comments. - $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1)); - $comments = array(); + $node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]); + $comments = []; $comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE); $comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE); $comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE); @@ -45,13 +45,13 @@ function testCommentPaging() { $this->assertFalse($this->commentExists($comments[2]), 'Comment 3 does not appear on page 1.'); // Check the second page. - $this->drupalGet('node/' . $node->id(), array('query' => array('page' => 1))); + $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 1]]); $this->assertTrue($this->commentExists($comments[1]), 'Comment 2 appears on page 2.'); $this->assertFalse($this->commentExists($comments[0]), 'Comment 1 does not appear on page 2.'); $this->assertFalse($this->commentExists($comments[2]), 'Comment 3 does not appear on page 2.'); // Check the third page. - $this->drupalGet('node/' . $node->id(), array('query' => array('page' => 2))); + $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 2]]); $this->assertTrue($this->commentExists($comments[2]), 'Comment 3 appears on page 3.'); $this->assertFalse($this->commentExists($comments[0]), 'Comment 1 does not appear on page 3.'); $this->assertFalse($this->commentExists($comments[1]), 'Comment 2 does not appear on page 3.'); @@ -64,27 +64,27 @@ function testCommentPaging() { $this->setCommentsPerPage(2); // We are still in flat view - the replies should not be on the first page, // even though they are replies to the oldest comment. - $this->drupalGet('node/' . $node->id(), array('query' => array('page' => 0))); + $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 0]]); $this->assertFalse($this->commentExists($reply, TRUE), 'In flat mode, reply does not appear on page 1.'); // If we switch to threaded mode, the replies on the oldest comment // should be bumped to the first page and comment 6 should be bumped // to the second page. $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Switched to threaded mode.'); - $this->drupalGet('node/' . $node->id(), array('query' => array('page' => 0))); + $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 0]]); $this->assertTrue($this->commentExists($reply, TRUE), 'In threaded mode, reply appears on page 1.'); $this->assertFalse($this->commentExists($comments[1]), 'In threaded mode, comment 2 has been bumped off of page 1.'); // If (# replies > # comments per page) in threaded expanded view, // the overage should be bumped. $reply2 = $this->postComment(NULL, $this->randomMachineName(), $this->randomMachineName(), TRUE); - $this->drupalGet('node/' . $node->id(), array('query' => array('page' => 0))); + $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 0]]); $this->assertFalse($this->commentExists($reply2, TRUE), 'In threaded mode where # replies > # comments per page, the newest reply does not appear on page 1.'); // Test that the page build process does not somehow generate errors when // # comments per page is set to 0. $this->setCommentsPerPage(0); - $this->drupalGet('node/' . $node->id(), array('query' => array('page' => 0))); + $this->drupalGet('node/' . $node->id(), ['query' => ['page' => 0]]); $this->assertFalse($this->commentExists($reply2, TRUE), 'Threaded mode works correctly when comments per page is 0.'); $this->drupalLogout(); @@ -105,8 +105,8 @@ function testCommentOrderingThreading() { $this->setCommentsPerPage(1000); // Create a node and three comments. - $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1)); - $comments = array(); + $node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]); + $comments = []; $comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE); $comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE); $comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE); @@ -138,7 +138,7 @@ function testCommentOrderingThreading() { $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.'); - $expected_order = array( + $expected_order = [ 0, 1, 2, @@ -146,13 +146,13 @@ function testCommentOrderingThreading() { 4, 5, 6, - ); + ]; $this->drupalGet('node/' . $node->id()); $this->assertCommentOrder($comments, $expected_order); $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Switched to threaded mode.'); - $expected_order = array( + $expected_order = [ 0, 4, 1, @@ -160,7 +160,7 @@ function testCommentOrderingThreading() { 6, 2, 5, - ); + ]; $this->drupalGet('node/' . $node->id()); $this->assertCommentOrder($comments, $expected_order); } @@ -174,7 +174,7 @@ function testCommentOrderingThreading() { * An array of keys from $comments describing the expected order. */ function assertCommentOrder(array $comments, array $expected_order) { - $expected_cids = array(); + $expected_cids = []; // First, rekey the expected order by cid. foreach ($expected_order as $key) { @@ -182,11 +182,11 @@ function assertCommentOrder(array $comments, array $expected_order) { } $comment_anchors = $this->xpath('//a[starts-with(@id,"comment-")]'); - $result_order = array(); + $result_order = []; foreach ($comment_anchors as $anchor) { $result_order[] = substr($anchor['id'], 8); } - return $this->assertEqual($expected_cids, $result_order, format_string('Comment order: expected @expected, returned @returned.', array('@expected' => implode(',', $expected_cids), '@returned' => implode(',', $result_order)))); + return $this->assertEqual($expected_cids, $result_order, format_string('Comment order: expected @expected, returned @returned.', ['@expected' => implode(',', $expected_cids), '@returned' => implode(',', $result_order)])); } /** @@ -205,8 +205,8 @@ function testCommentNewPageIndicator() { $this->setCommentsPerPage(1); // Create a node and three comments. - $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1)); - $comments = array(); + $node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]); + $comments = []; $comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE); $comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE); $comments[] = $this->postComment($node, $this->randomMachineName(), $this->randomMachineName(), TRUE); @@ -233,39 +233,39 @@ function testCommentNewPageIndicator() { $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.'); - $expected_pages = array( + $expected_pages = [ 1 => 5, // Page of comment 5 2 => 4, // Page of comment 4 3 => 3, // Page of comment 3 4 => 2, // Page of comment 2 5 => 1, // Page of comment 1 6 => 0, // Page of comment 0 - ); + ]; $node = Node::load($node->id()); foreach ($expected_pages as $new_replies => $expected_page) { $returned_page = \Drupal::entityManager()->getStorage('comment') ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment'); - $this->assertIdentical($expected_page, $returned_page, format_string('Flat mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page))); + $this->assertIdentical($expected_page, $returned_page, format_string('Flat mode, @new replies: expected page @expected, returned page @returned.', ['@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page])); } $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Switched to threaded mode.'); - $expected_pages = array( + $expected_pages = [ 1 => 5, // Page of comment 5 2 => 1, // Page of comment 4 3 => 1, // Page of comment 4 4 => 1, // Page of comment 4 5 => 1, // Page of comment 4 6 => 0, // Page of comment 0 - ); + ]; - \Drupal::entityManager()->getStorage('node')->resetCache(array($node->id())); + \Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]); $node = Node::load($node->id()); foreach ($expected_pages as $new_replies => $expected_page) { $returned_page = \Drupal::entityManager()->getStorage('comment') ->getNewCommentPageNumber($node->get('comment')->comment_count, $new_replies, $node, 'comment'); - $this->assertEqual($expected_page, $returned_page, format_string('Threaded mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page))); + $this->assertEqual($expected_page, $returned_page, format_string('Threaded mode, @new replies: expected page @expected, returned page @returned.', ['@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page])); } } @@ -277,39 +277,39 @@ function testTwoPagers() { $this->addDefaultCommentField('node', 'article', 'comment_2'); // Set default to display comment list with unique pager id. entity_get_display('node', 'article', 'default') - ->setComponent('comment_2', array( + ->setComponent('comment_2', [ 'label' => 'hidden', 'type' => 'comment_default', 'weight' => 30, - 'settings' => array( + 'settings' => [ 'pager_id' => 1, 'view_mode' => 'default', - ) - )) + ] + ]) ->save(); // Make sure pager appears in formatter summary and settings form. - $account = $this->drupalCreateUser(array('administer node display')); + $account = $this->drupalCreateUser(['administer node display']); $this->drupalLogin($account); $this->drupalGet('admin/structure/types/manage/article/display'); - $this->assertNoText(t('Pager ID: @id', array('@id' => 0)), 'No summary for standard pager'); - $this->assertText(t('Pager ID: @id', array('@id' => 1))); - $this->drupalPostAjaxForm(NULL, array(), 'comment_settings_edit'); + $this->assertNoText(t('Pager ID: @id', ['@id' => 0]), 'No summary for standard pager'); + $this->assertText(t('Pager ID: @id', ['@id' => 1])); + $this->drupalPostAjaxForm(NULL, [], 'comment_settings_edit'); // Change default pager to 2. - $this->drupalPostForm(NULL, array('fields[comment][settings_edit_form][settings][pager_id]' => 2), t('Save')); - $this->assertText(t('Pager ID: @id', array('@id' => 2))); + $this->drupalPostForm(NULL, ['fields[comment][settings_edit_form][settings][pager_id]' => 2], t('Save')); + $this->assertText(t('Pager ID: @id', ['@id' => 2])); // Revert the changes. - $this->drupalPostAjaxForm(NULL, array(), 'comment_settings_edit'); - $this->drupalPostForm(NULL, array('fields[comment][settings_edit_form][settings][pager_id]' => 0), t('Save')); - $this->assertNoText(t('Pager ID: @id', array('@id' => 0)), 'No summary for standard pager'); + $this->drupalPostAjaxForm(NULL, [], 'comment_settings_edit'); + $this->drupalPostForm(NULL, ['fields[comment][settings_edit_form][settings][pager_id]' => 0], t('Save')); + $this->assertNoText(t('Pager ID: @id', ['@id' => 0]), 'No summary for standard pager'); $this->drupalLogin($this->adminUser); // Add a new node with both comment fields open. - $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id())); + $node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]); // Set comment options. - $comments = array(); - foreach (array('comment', 'comment_2') as $field_name) { + $comments = []; + foreach (['comment', 'comment_2'] as $field_name) { $this->setCommentForm(TRUE, $field_name); $this->setCommentPreview(DRUPAL_OPTIONAL, $field_name); $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_FLAT, 'Comment paging changed.', $field_name); @@ -318,10 +318,10 @@ function testTwoPagers() { // needing to insert large numbers of comments. $this->setCommentsPerPage(1, $field_name); for ($i = 0; $i < 3; $i++) { - $comment = t('Comment @count on field @field', array( + $comment = t('Comment @count on field @field', [ '@count' => $i + 1, '@field' => $field_name, - )); + ]); $comments[] = $this->postComment($node, $comment, $comment, TRUE, $field_name); } } @@ -333,19 +333,19 @@ function testTwoPagers() { $this->assertRaw('Comment 1 on field comment'); $this->assertRaw('Comment 1 on field comment_2'); // Navigate to next page of field 1. - $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', array(':label' => 'Comment 1 on field comment')); + $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', [':label' => 'Comment 1 on field comment']); // Check only one pager updated. $this->assertRaw('Comment 2 on field comment'); $this->assertRaw('Comment 1 on field comment_2'); // Return to page 1. $this->drupalGet('node/' . $node->id()); // Navigate to next page of field 2. - $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', array(':label' => 'Comment 1 on field comment_2')); + $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', [':label' => 'Comment 1 on field comment_2']); // Check only one pager updated. $this->assertRaw('Comment 1 on field comment'); $this->assertRaw('Comment 2 on field comment_2'); // Navigate to next page of field 1. - $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', array(':label' => 'Comment 1 on field comment')); + $this->clickLinkWithXPath('//h3/a[normalize-space(text())=:label]/ancestor::section[1]//a[@rel="next"]', [':label' => 'Comment 1 on field comment']); // Check only one pager updated. $this->assertRaw('Comment 2 on field comment'); $this->assertRaw('Comment 2 on field comment_2'); @@ -373,15 +373,15 @@ function testTwoPagers() { * * @see WebTestBase::clickLink() */ - protected function clickLinkWithXPath($xpath, $arguments = array(), $index = 0) { + protected function clickLinkWithXPath($xpath, $arguments = [], $index = 0) { $url_before = $this->getUrl(); $urls = $this->xpath($xpath, $arguments); if (isset($urls[$index])) { $url_target = $this->getAbsoluteUrl($urls[$index]['href']); - $this->pass(SafeMarkup::format('Clicked link %label (@url_target) from @url_before', array('%label' => $xpath, '@url_target' => $url_target, '@url_before' => $url_before)), 'Browser'); + $this->pass(SafeMarkup::format('Clicked link %label (@url_target) from @url_before', ['%label' => $xpath, '@url_target' => $url_target, '@url_before' => $url_before]), 'Browser'); return $this->drupalGet($url_target); } - $this->fail(SafeMarkup::format('Link %label does not exist on @url_before', array('%label' => $xpath, '@url_before' => $url_before)), 'Browser'); + $this->fail(SafeMarkup::format('Link %label does not exist on @url_before', ['%label' => $xpath, '@url_before' => $url_before]), 'Browser'); return FALSE; } diff --git a/core/modules/comment/src/Tests/CommentPreviewTest.php b/core/modules/comment/src/Tests/CommentPreviewTest.php index 837a78a..039c6ab 100644 --- a/core/modules/comment/src/Tests/CommentPreviewTest.php +++ b/core/modules/comment/src/Tests/CommentPreviewTest.php @@ -41,7 +41,7 @@ function testCommentPreview() { // Test escaping of the username on the preview form. \Drupal::service('module_installer')->install(['user_hooks_test']); \Drupal::state()->set('user_hooks_test_user_format_name_alter', TRUE); - $edit = array(); + $edit = []; $edit['subject[0][value]'] = $this->randomMachineName(8); $edit['comment_body[0][value]'] = $this->randomMachineName(16); $this->drupalPostForm('node/' . $this->node->id(), $edit, t('Preview')); @@ -90,7 +90,7 @@ public function testCommentPreviewDuplicateSubmission() { $this->drupalLogin($this->webUser); // As the web user, fill in the comment form and preview the comment. - $edit = array(); + $edit = []; $edit['subject[0][value]'] = $this->randomMachineName(8); $edit['comment_body[0][value]'] = $this->randomMachineName(16); $this->drupalPostForm('node/' . $this->node->id(), $edit, t('Preview')); @@ -124,14 +124,14 @@ public function testCommentPreviewDuplicateSubmission() { * Tests comment edit, preview, and save. */ function testCommentEditPreviewSave() { - $web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval', 'edit own comments')); + $web_user = $this->drupalCreateUser(['access comments', 'post comments', 'skip comment approval', 'edit own comments']); $this->drupalLogin($this->adminUser); $this->setCommentPreview(DRUPAL_OPTIONAL); $this->setCommentForm(TRUE); $this->setCommentSubject(TRUE); $this->setCommentSettings('default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.'); - $edit = array(); + $edit = []; $date = new DrupalDateTime('2008-03-02 17:23'); $edit['subject[0][value]'] = $this->randomMachineName(8); $edit['comment_body[0][value]'] = $this->randomMachineName(16); @@ -172,7 +172,7 @@ function testCommentEditPreviewSave() { $this->assertFieldByName('date[time]', $expected_form_time, 'Time field displayed.'); // Submit the form using the displayed values. - $displayed = array(); + $displayed = []; $displayed['subject[0][value]'] = (string) current($this->xpath("//input[@id='edit-subject-0-value']/@value")); $displayed['comment_body[0][value]'] = (string) current($this->xpath("//textarea[@id='edit-comment-body-0-value']")); $displayed['uid'] = (string) current($this->xpath("//input[@id='edit-uid']/@value")); @@ -182,7 +182,7 @@ function testCommentEditPreviewSave() { // Check that the saved comment is still correct. $comment_storage = \Drupal::entityManager()->getStorage('comment'); - $comment_storage->resetCache(array($comment->id())); + $comment_storage->resetCache([$comment->id()]); /** @var \Drupal\comment\CommentInterface $comment_loaded */ $comment_loaded = Comment::load($comment->id()); $this->assertEqual($comment_loaded->getSubject(), $edit['subject[0][value]'], 'Subject loaded.'); @@ -193,13 +193,13 @@ function testCommentEditPreviewSave() { // Check that the date and time of the comment are correct when edited by // non-admin users. - $user_edit = array(); + $user_edit = []; $expected_created_time = $comment_loaded->getCreatedTime(); $this->drupalLogin($web_user); // Web user cannot change the comment author. unset($edit['uid']); $this->drupalPostForm('comment/' . $comment->id() . '/edit', $user_edit, t('Save')); - $comment_storage->resetCache(array($comment->id())); + $comment_storage->resetCache([$comment->id()]); $comment_loaded = Comment::load($comment->id()); $this->assertEqual($comment_loaded->getCreatedTime(), $expected_created_time, 'Expected date and time for comment edited.'); $this->drupalLogout(); diff --git a/core/modules/comment/src/Tests/CommentRssTest.php b/core/modules/comment/src/Tests/CommentRssTest.php index ec673df..5c9fe3d 100644 --- a/core/modules/comment/src/Tests/CommentRssTest.php +++ b/core/modules/comment/src/Tests/CommentRssTest.php @@ -21,7 +21,7 @@ class CommentRssTest extends CommentTestBase { * * @var array */ - public static $modules = array('views'); + public static $modules = ['views']; /** * {@inheritdoc} @@ -66,7 +66,7 @@ function testCommentRss() { 'user:3', ])); - $raw = '' . $this->node->url('canonical', array('fragment' => 'comments', 'absolute' => TRUE)) . ''; + $raw = '' . $this->node->url('canonical', ['fragment' => 'comments', 'absolute' => TRUE]) . ''; $this->assertRaw($raw, 'Comments as part of RSS feed.'); // Hide comments from RSS feed and check presence. diff --git a/core/modules/comment/src/Tests/CommentStatisticsTest.php b/core/modules/comment/src/Tests/CommentStatisticsTest.php index 0c370d1..bd0838c 100644 --- a/core/modules/comment/src/Tests/CommentStatisticsTest.php +++ b/core/modules/comment/src/Tests/CommentStatisticsTest.php @@ -24,7 +24,7 @@ protected function setUp() { parent::setUp(); // Create a second user to post comments. - $this->webUser2 = $this->drupalCreateUser(array( + $this->webUser2 = $this->drupalCreateUser([ 'post comments', 'create article content', 'edit own comments', @@ -32,7 +32,7 @@ protected function setUp() { 'skip comment approval', 'access comments', 'access content', - )); + ]); } /** @@ -62,7 +62,7 @@ function testCommentNodeCommentStatistics() { // Checks the new values of node comment statistics with comment #1. // The node cache needs to be reset before reload. - $node_storage->resetCache(array($this->node->id())); + $node_storage->resetCache([$this->node->id()]); $node = $node_storage->load($this->node->id()); $this->assertEqual($node->get('comment')->last_comment_name, NULL, 'The value of node last_comment_name is NULL.'); $this->assertEqual($node->get('comment')->last_comment_uid, $this->webUser2->id(), 'The value of node last_comment_uid is the comment #1 uid.'); @@ -70,11 +70,11 @@ function testCommentNodeCommentStatistics() { // Prepare for anonymous comment submission (comment approval enabled). $this->drupalLogin($this->adminUser); - user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments' => TRUE, 'post comments' => TRUE, 'skip comment approval' => FALSE, - )); + ]); // Ensure that the poster can leave some contact info. $this->setCommentAnonymous('1'); $this->drupalLogout(); @@ -86,7 +86,7 @@ function testCommentNodeCommentStatistics() { // Checks the new values of node comment statistics with comment #2 and // ensure they haven't changed since the comment has not been moderated. // The node needs to be reloaded with the cache reset. - $node_storage->resetCache(array($this->node->id())); + $node_storage->resetCache([$this->node->id()]); $node = $node_storage->load($this->node->id()); $this->assertEqual($node->get('comment')->last_comment_name, NULL, 'The value of node last_comment_name is still NULL.'); $this->assertEqual($node->get('comment')->last_comment_uid, $this->webUser2->id(), 'The value of node last_comment_uid is still the comment #1 uid.'); @@ -94,21 +94,21 @@ function testCommentNodeCommentStatistics() { // Prepare for anonymous comment submission (no approval required). $this->drupalLogin($this->adminUser); - user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array( + user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [ 'access comments' => TRUE, 'post comments' => TRUE, 'skip comment approval' => TRUE, - )); + ]); $this->drupalLogout(); // Post comment #3 as anonymous. $this->drupalGet('comment/reply/node/' . $this->node->id() . '/comment'); - $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), '', array('name' => $this->randomMachineName())); + $anonymous_comment = $this->postComment($this->node, $this->randomMachineName(), '', ['name' => $this->randomMachineName()]); $comment_loaded = Comment::load($anonymous_comment->id()); // Checks the new values of node comment statistics with comment #3. // The node needs to be reloaded with the cache reset. - $node_storage->resetCache(array($this->node->id())); + $node_storage->resetCache([$this->node->id()]); $node = $node_storage->load($this->node->id()); $this->assertEqual($node->get('comment')->last_comment_name, $comment_loaded->getAuthorName(), 'The value of node last_comment_name is the name of the anonymous user.'); $this->assertEqual($node->get('comment')->last_comment_uid, 0, 'The value of node last_comment_uid is zero.'); diff --git a/core/modules/comment/src/Tests/CommentTestBase.php b/core/modules/comment/src/Tests/CommentTestBase.php index c99dd32..716b3bd 100644 --- a/core/modules/comment/src/Tests/CommentTestBase.php +++ b/core/modules/comment/src/Tests/CommentTestBase.php @@ -52,11 +52,11 @@ protected function setUp() { // child classes may specify the standard profile. $types = NodeType::loadMultiple(); if (empty($types['article'])) { - $this->drupalCreateContentType(array('type' => 'article', 'name' => t('Article'))); + $this->drupalCreateContentType(['type' => 'article', 'name' => t('Article')]); } // Create two test users. - $this->adminUser = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser([ 'administer content types', 'administer comments', 'administer comment types', @@ -69,21 +69,21 @@ protected function setUp() { // permission is granted. 'access user profiles', 'access content', - )); - $this->webUser = $this->drupalCreateUser(array( + ]); + $this->webUser = $this->drupalCreateUser([ 'access comments', 'post comments', 'create article content', 'edit own comments', 'skip comment approval', 'access content', - )); + ]); // Create comment field on article. $this->addDefaultCommentField('node', 'article'); // Create a test node authored by the web user. - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id())); + $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]); $this->drupalPlaceBlock('local_tasks_block'); } @@ -107,7 +107,7 @@ protected function setUp() { * The posted comment or NULL when posted comment was not found. */ public function postComment($entity, $comment, $subject = '', $contact = NULL, $field_name = 'comment') { - $edit = array(); + $edit = []; $edit['comment_body[0][value]'] = $comment; if ($entity !== NULL) { @@ -154,7 +154,7 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $ $this->drupalPostForm(NULL, $edit, t('Save')); break; } - $match = array(); + $match = []; // Get comment ID preg_match('/#comment-([0-9]+)/', $this->getURL(), $match); @@ -168,7 +168,7 @@ public function postComment($entity, $comment, $subject = '', $contact = NULL, $ } if (isset($match[1])) { - \Drupal::entityManager()->getStorage('comment')->resetCache(array($match[1])); + \Drupal::entityManager()->getStorage('comment')->resetCache([$match[1]]); return Comment::load($match[1]); } } @@ -215,7 +215,7 @@ function commentExists(CommentInterface $comment = NULL, $reply = FALSE) { * Comment to delete. */ function deleteComment(CommentInterface $comment) { - $this->drupalPostForm('comment/' . $comment->id() . '/delete', array(), t('Delete')); + $this->drupalPostForm('comment/' . $comment->id() . '/delete', [], t('Delete')); $this->assertText(t('The comment and all its replies have been deleted.'), 'Comment deleted.'); } @@ -228,9 +228,9 @@ function deleteComment(CommentInterface $comment) { public function setCommentSubject($enabled) { $form_display = entity_get_form_display('comment', 'comment', 'default'); if ($enabled) { - $form_display->setComponent('subject', array( + $form_display->setComponent('subject', [ 'type' => 'string_textfield', - )); + ]); } else { $form_display->removeComponent('subject'); @@ -263,7 +263,7 @@ public function setCommentPreview($mode, $field_name = 'comment') { $mode_text = 'required'; break; } - $this->setCommentSettings('preview', $mode, format_string('Comment preview @mode_text.', array('@mode_text' => $mode_text)), $field_name); + $this->setCommentSettings('preview', $mode, format_string('Comment preview @mode_text.', ['@mode_text' => $mode_text]), $field_name); } /** @@ -290,7 +290,7 @@ public function setCommentForm($enabled, $field_name = 'comment') { * - 2: Contact information required. */ function setCommentAnonymous($level) { - $this->setCommentSettings('anonymous', $level, format_string('Anonymous commenting set to level @level.', array('@level' => $level))); + $this->setCommentSettings('anonymous', $level, format_string('Anonymous commenting set to level @level.', ['@level' => $level])); } /** @@ -303,7 +303,7 @@ function setCommentAnonymous($level) { * Defaults to 'comment'. */ public function setCommentsPerPage($number, $field_name = 'comment') { - $this->setCommentSettings('per_page', $number, format_string('Number of comments per page set to @number.', array('@number' => $number)), $field_name); + $this->setCommentSettings('per_page', $number, format_string('Number of comments per page set to @number.', ['@number' => $number]), $field_name); } /** @@ -348,17 +348,17 @@ function commentContactInfoAvailable() { * Operation is found on approval page. */ function performCommentOperation(CommentInterface $comment, $operation, $approval = FALSE) { - $edit = array(); + $edit = []; $edit['operation'] = $operation; $edit['comments[' . $comment->id() . ']'] = TRUE; $this->drupalPostForm('admin/content/comment' . ($approval ? '/approval' : ''), $edit, t('Update')); if ($operation == 'delete') { - $this->drupalPostForm(NULL, array(), t('Delete comments')); - $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation))); + $this->drupalPostForm(NULL, [], t('Delete comments')); + $this->assertRaw(\Drupal::translation()->formatPlural(1, 'Deleted 1 comment.', 'Deleted @count comments.'), format_string('Operation "@operation" was performed on comment.', ['@operation' => $operation])); } else { - $this->assertText(t('The update has been performed.'), format_string('Operation "@operation" was performed on comment.', array('@operation' => $operation))); + $this->assertText(t('The update has been performed.'), format_string('Operation "@operation" was performed on comment.', ['@operation' => $operation])); } } @@ -388,12 +388,12 @@ function getUnapprovedComment($subject) { * Created comment type. */ protected function createCommentType($label) { - $bundle = CommentType::create(array( + $bundle = CommentType::create([ 'id' => $label, 'label' => $label, 'description' => '', 'target_entity_type_id' => 'node', - )); + ]); $bundle->save(); return $bundle; } diff --git a/core/modules/comment/src/Tests/CommentTestTrait.php b/core/modules/comment/src/Tests/CommentTestTrait.php index f22d80f..038a3df 100644 --- a/core/modules/comment/src/Tests/CommentTestTrait.php +++ b/core/modules/comment/src/Tests/CommentTestTrait.php @@ -43,12 +43,12 @@ public function addDefaultCommentField($entity_type, $bundle, $field_name = 'com } } else { - $comment_type_storage->create(array( + $comment_type_storage->create([ 'id' => $comment_type_id, 'label' => Unicode::ucfirst($comment_type_id), 'target_entity_type_id' => $entity_type, 'description' => 'Default comment field', - ))->save(); + ])->save(); } // Add a body field to the comment type. \Drupal::service('comment.manager')->addBodyField($comment_type_id); @@ -56,43 +56,43 @@ public function addDefaultCommentField($entity_type, $bundle, $field_name = 'com // Add a comment field to the host entity type. Create the field storage if // needed. if (!array_key_exists($field_name, $entity_manager->getFieldStorageDefinitions($entity_type))) { - $entity_manager->getStorage('field_storage_config')->create(array( + $entity_manager->getStorage('field_storage_config')->create([ 'entity_type' => $entity_type, 'field_name' => $field_name, 'type' => 'comment', 'translatable' => TRUE, - 'settings' => array( + 'settings' => [ 'comment_type' => $comment_type_id, - ), - ))->save(); + ], + ])->save(); } // Create the field if needed, and configure its form and view displays. if (!array_key_exists($field_name, $entity_manager->getFieldDefinitions($entity_type, $bundle))) { - $entity_manager->getStorage('field_config')->create(array( + $entity_manager->getStorage('field_config')->create([ 'label' => 'Comments', 'description' => '', 'field_name' => $field_name, 'entity_type' => $entity_type, 'bundle' => $bundle, 'required' => 1, - 'default_value' => array( - array( + 'default_value' => [ + [ 'status' => $default_value, 'cid' => 0, 'last_comment_name' => '', 'last_comment_timestamp' => 0, 'last_comment_uid' => 0, - ), - ), - ))->save(); + ], + ], + ])->save(); // Entity form displays: assign widget settings for the 'default' form // mode, and hide the field in all other form modes. entity_get_form_display($entity_type, $bundle, 'default') - ->setComponent($field_name, array( + ->setComponent($field_name, [ 'type' => 'comment_default', 'weight' => 20, - )) + ]) ->save(); foreach ($entity_manager->getFormModes($entity_type) as $id => $form_mode) { $display = entity_get_form_display($entity_type, $bundle, $id); @@ -105,12 +105,12 @@ public function addDefaultCommentField($entity_type, $bundle, $field_name = 'com // Entity view displays: assign widget settings for the 'default' view // mode, and hide the field in all other view modes. entity_get_display($entity_type, $bundle, 'default') - ->setComponent($field_name, array( + ->setComponent($field_name, [ 'label' => 'above', 'type' => 'comment_default', 'weight' => 20, - 'settings' => array('view_mode' => $comment_view_mode), - )) + 'settings' => ['view_mode' => $comment_view_mode], + ]) ->save(); foreach ($entity_manager->getViewModes($entity_type) as $id => $view_mode) { $display = entity_get_display($entity_type, $bundle, $id); diff --git a/core/modules/comment/src/Tests/CommentThreadingTest.php b/core/modules/comment/src/Tests/CommentThreadingTest.php index c8ea93e..2dbf5bd 100644 --- a/core/modules/comment/src/Tests/CommentThreadingTest.php +++ b/core/modules/comment/src/Tests/CommentThreadingTest.php @@ -24,7 +24,7 @@ function testCommentThreading() { // Create a node. $this->drupalLogin($this->webUser); - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id())); + $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]); // Post comment #1. $this->drupalLogin($this->webUser); @@ -139,10 +139,10 @@ protected function assertParentLink($cid, $pid) { $this->assertFieldByXpath($pattern, NULL, format_string( 'Comment %cid has a link to parent %pid.', - array( + [ '%cid' => $cid, '%pid' => $pid, - ) + ] )); } @@ -162,9 +162,9 @@ protected function assertNoParentLink($cid) { $pattern = "//a[@id='comment-$cid']/following-sibling::article//p[contains(@class, 'parent')]"; $this->assertNoFieldByXpath($pattern, NULL, format_string( 'Comment %cid does not have a link to a parent.', - array( + [ '%cid' => $cid, - ) + ] )); } diff --git a/core/modules/comment/src/Tests/CommentTitleTest.php b/core/modules/comment/src/Tests/CommentTitleTest.php index 0546cb6..7026c05 100644 --- a/core/modules/comment/src/Tests/CommentTitleTest.php +++ b/core/modules/comment/src/Tests/CommentTitleTest.php @@ -14,7 +14,7 @@ class CommentTitleTest extends CommentTestBase { */ public function testCommentEmptyTitles() { // Installs module that sets comments to an empty string. - \Drupal::service('module_installer')->install(array('comment_empty_title_test')); + \Drupal::service('module_installer')->install(['comment_empty_title_test']); // Set comments to have a subject with preview disabled. $this->setCommentPreview(DRUPAL_DISABLED); @@ -23,7 +23,7 @@ public function testCommentEmptyTitles() { // Create a node. $this->drupalLogin($this->webUser); - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id())); + $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]); // Post comment #1 and verify that h3's are not rendered. $subject_text = $this->randomMachineName(); @@ -49,7 +49,7 @@ public function testCommentPopulatedTitles() { // Create a node. $this->drupalLogin($this->webUser); - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id())); + $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]); // Post comment #1 and verify that title is rendered in h3. $subject_text = $this->randomMachineName(); diff --git a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php index c7b7227..325aecb 100644 --- a/core/modules/comment/src/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/src/Tests/CommentTokenReplaceTest.php @@ -32,10 +32,10 @@ class CommentTokenReplaceTest extends CommentTestBase { function testCommentTokenReplacement() { $token_service = \Drupal::token(); $language_interface = \Drupal::languageManager()->getCurrentLanguage(); - $url_options = array( + $url_options = [ 'absolute' => TRUE, 'language' => $language_interface, - ); + ]; // Setup vocabulary. Vocabulary::create([ @@ -65,7 +65,7 @@ function testCommentTokenReplacement() { $comment->setSubject('Blinking Comment'); // Generate and test tokens. - $tests = array(); + $tests = []; $tests['[comment:cid]'] = $comment->id(); $tests['[comment:hostname]'] = $comment->getHostname(); $tests['[comment:author]'] = Html::escape($comment->getAuthorName()); @@ -74,11 +74,11 @@ function testCommentTokenReplacement() { $tests['[comment:title]'] = Html::escape($comment->getSubject()); $tests['[comment:body]'] = $comment->comment_body->processed; $tests['[comment:langcode]'] = $comment->language()->getId(); - $tests['[comment:url]'] = $comment->url('canonical', $url_options + array('fragment' => 'comment-' . $comment->id())); + $tests['[comment:url]'] = $comment->url('canonical', $url_options + ['fragment' => 'comment-' . $comment->id()]); $tests['[comment:edit-url]'] = $comment->url('edit-form', $url_options); - $tests['[comment:created]'] = \Drupal::service('date.formatter')->format($comment->getCreatedTime(), 'medium', array('langcode' => $language_interface->getId())); - $tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getCreatedTime(), array('langcode' => $language_interface->getId())); - $tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getChangedTimeAcrossTranslations(), array('langcode' => $language_interface->getId())); + $tests['[comment:created]'] = \Drupal::service('date.formatter')->format($comment->getCreatedTime(), 'medium', ['langcode' => $language_interface->getId()]); + $tests['[comment:created:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getCreatedTime(), ['langcode' => $language_interface->getId()]); + $tests['[comment:changed:since]'] = \Drupal::service('date.formatter')->formatTimeDiffSince($comment->getChangedTimeAcrossTranslations(), ['langcode' => $language_interface->getId()]); $tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL; $tests['[comment:parent:title]'] = $parent_comment->getSubject(); $tests['[comment:entity]'] = Html::escape($node->getTitle()); @@ -127,7 +127,7 @@ function testCommentTokenReplacement() { foreach ($tests as $input => $expected) { $bubbleable_metadata = new BubbleableMetadata(); - $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId()), $bubbleable_metadata); + $output = $token_service->replace($input, ['comment' => $comment], ['langcode' => $language_interface->getId()], $bubbleable_metadata); $this->assertEqual($output, $expected, new FormattableMarkup('Comment token %token replaced.', ['%token' => $input])); $this->assertEqual($bubbleable_metadata, $metadata_tests[$input]); } @@ -136,8 +136,8 @@ function testCommentTokenReplacement() { $author_name = 'This is a random & " > string'; $comment->setOwnerId(0)->setAuthorName($author_name); $input = '[comment:author]'; - $output = $token_service->replace($input, array('comment' => $comment), array('langcode' => $language_interface->getId())); - $this->assertEqual($output, Html::escape($author_name), format_string('Comment author token %token replaced.', array('%token' => $input))); + $output = $token_service->replace($input, ['comment' => $comment], ['langcode' => $language_interface->getId()]); + $this->assertEqual($output, Html::escape($author_name), format_string('Comment author token %token replaced.', ['%token' => $input])); // Add comment field to user and term entities. $this->addDefaultCommentField('user', 'user', 'comment', CommentItemInterface::OPEN, 'comment_user'); $this->addDefaultCommentField('taxonomy_term', 'tags', 'comment', CommentItemInterface::OPEN, 'comment_term'); @@ -162,7 +162,7 @@ function testCommentTokenReplacement() { // Generate comment tokens for node (it has 2 comments, both new), // user and term. - $tests = array(); + $tests = []; $tests['[entity:comment-count]'] = 2; $tests['[entity:comment-count-new]'] = 2; $tests['[node:comment-count]'] = 2; diff --git a/core/modules/comment/src/Tests/CommentTranslationUITest.php b/core/modules/comment/src/Tests/CommentTranslationUITest.php index e89bd3f..3157e23 100644 --- a/core/modules/comment/src/Tests/CommentTranslationUITest.php +++ b/core/modules/comment/src/Tests/CommentTranslationUITest.php @@ -46,7 +46,7 @@ class CommentTranslationUITest extends ContentTranslationUITestBase { * * @var array */ - public static $modules = array('language', 'content_translation', 'node', 'comment'); + public static $modules = ['language', 'content_translation', 'node', 'comment']; protected function setUp() { $this->entityTypeId = 'comment'; @@ -62,11 +62,11 @@ protected function setUp() { */ function setupBundle() { parent::setupBundle(); - $this->drupalCreateContentType(array('type' => $this->nodeBundle, 'name' => $this->nodeBundle)); + $this->drupalCreateContentType(['type' => $this->nodeBundle, 'name' => $this->nodeBundle]); // Add a comment field to the article content type. $this->addDefaultCommentField('node', 'article', 'comment_article', CommentItemInterface::OPEN, 'comment_article'); // Create a page content type. - $this->drupalCreateContentType(array('type' => 'page', 'name' => 'page')); + $this->drupalCreateContentType(['type' => 'page', 'name' => 'page']); // Add a comment field to the page content type - this one won't be // translatable. $this->addDefaultCommentField('node', 'page', 'comment'); @@ -78,7 +78,7 @@ function setupBundle() { * {@inheritdoc} */ protected function getTranslatorPermissions() { - return array_merge(parent::getTranslatorPermissions(), array('post comments', 'administer comments', 'access comments')); + return array_merge(parent::getTranslatorPermissions(), ['post comments', 'administer comments', 'access comments']); } /** @@ -95,12 +95,12 @@ protected function createEntity($values, $langcode, $comment_type = 'comment_art $node_type = 'page'; $field_name = 'comment'; } - $node = $this->drupalCreateNode(array( + $node = $this->drupalCreateNode([ 'type' => $node_type, - $field_name => array( - array('status' => CommentItemInterface::OPEN) - ), - )); + $field_name => [ + ['status' => CommentItemInterface::OPEN] + ], + ]); $values['entity_id'] = $node->id(); $values['entity_type'] = 'node'; $values['field_name'] = $field_name; @@ -113,10 +113,10 @@ protected function createEntity($values, $langcode, $comment_type = 'comment_art */ protected function getNewEntityValues($langcode) { // Comment subject is not translatable hence we use a fixed value. - return array( - 'subject' => array(array('value' => $this->subject)), - 'comment_body' => array(array('value' => $this->randomMachineName(16))), - ) + parent::getNewEntityValues($langcode); + return [ + 'subject' => [['value' => $this->subject]], + 'comment_body' => [['value' => $this->randomMachineName(16)]], + ] + parent::getNewEntityValues($langcode); } /** @@ -132,8 +132,8 @@ protected function doTestPublishedStatus() { // Unpublish translations. foreach ($this->langcodes as $index => $langcode) { if ($index > 0) { - $edit = array('status' => 0); - $url = $entity->urlInfo('edit-form', array('language' => ConfigurableLanguage::load($langcode))); + $edit = ['status' => 0]; + $url = $entity->urlInfo('edit-form', ['language' => ConfigurableLanguage::load($langcode)]); $this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode)); $storage->resetCache(); $entity = $storage->load($this->entityId); @@ -151,21 +151,21 @@ protected function doTestAuthoringInfo() { $storage->resetCache([$this->entityId]); $entity = $storage->load($this->entityId); $languages = $this->container->get('language_manager')->getLanguages(); - $values = array(); + $values = []; // Post different authoring information for each translation. foreach ($this->langcodes as $langcode) { $url = $entity->urlInfo('edit-form', ['language' => $languages[$langcode]]); $user = $this->drupalCreateUser(); - $values[$langcode] = array( + $values[$langcode] = [ 'uid' => $user->id(), 'created' => REQUEST_TIME - mt_rand(0, 1000), - ); - $edit = array( + ]; + $edit = [ 'uid' => $user->getUsername() . ' (' . $user->id() . ')', 'date[date]' => format_date($values[$langcode]['created'], 'custom', 'Y-m-d'), 'date[time]' => format_date($values[$langcode]['created'], 'custom', 'H:i:s'), - ); + ]; $this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode)); } @@ -182,11 +182,11 @@ protected function doTestAuthoringInfo() { * Tests translate link on comment content admin page. */ function testTranslateLinkCommentAdminPage() { - $this->adminUser = $this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), array('access administration pages', 'administer comments', 'skip comment approval'))); + $this->adminUser = $this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), ['access administration pages', 'administer comments', 'skip comment approval'])); $this->drupalLogin($this->adminUser); - $cid_translatable = $this->createEntity(array(), $this->langcodes[0]); - $cid_untranslatable = $this->createEntity(array(), $this->langcodes[0], 'comment'); + $cid_translatable = $this->createEntity([], $this->langcodes[0]); + $cid_untranslatable = $this->createEntity([], $this->langcodes[0], 'comment'); // Verify translation links. $this->drupalGet('admin/content/comment'); @@ -208,15 +208,15 @@ protected function doTestTranslationEdit() { foreach ($this->langcodes as $langcode) { // We only want to test the title for non-english translations. if ($langcode != 'en') { - $options = array('language' => $languages[$langcode]); + $options = ['language' => $languages[$langcode]]; $url = $entity->urlInfo('edit-form', $options); $this->drupalGet($url); - $title = t('Edit @type @title [%language translation]', array( + $title = t('Edit @type @title [%language translation]', [ '@type' => $this->entityTypeId, '@title' => $entity->getTranslation($langcode)->label(), '%language' => $languages[$langcode]->getName(), - )); + ]); $this->assertRaw($title); } } diff --git a/core/modules/comment/src/Tests/CommentTypeTest.php b/core/modules/comment/src/Tests/CommentTypeTest.php index fb5028f..343bb91 100644 --- a/core/modules/comment/src/Tests/CommentTypeTest.php +++ b/core/modules/comment/src/Tests/CommentTypeTest.php @@ -27,11 +27,11 @@ class CommentTypeTest extends CommentTestBase { * * @var array */ - protected $permissions = array( + protected $permissions = [ 'administer comments', 'administer comment fields', 'administer comment types', - ); + ]; /** * Sets the test up. @@ -61,12 +61,12 @@ public function testCommentTypeCreation() { $this->assertResponse(200, 'The new comment type can be accessed at the edit form.'); // Create a comment type via the user interface. - $edit = array( + $edit = [ 'id' => 'foo', 'label' => 'title for foo', 'description' => '', 'target_entity_type_id' => 'node', - ); + ]; $this->drupalPostForm('admin/structure/comment/types/add', $edit, t('Save')); $comment_type = CommentType::load('foo'); $this->assertTrue($comment_type, 'The new comment type has been created.'); @@ -81,8 +81,8 @@ public function testCommentTypeCreation() { $this->assertText(t('Target entity type')); // Save the form and ensure the entity-type value is preserved even though // the field isn't present. - $this->drupalPostForm(NULL, array(), t('Save')); - \Drupal::entityManager()->getStorage('comment_type')->resetCache(array('foo')); + $this->drupalPostForm(NULL, [], t('Save')); + \Drupal::entityManager()->getStorage('comment_type')->resetCache(['foo']); $comment_type = CommentType::load('foo'); $this->assertEqual($comment_type->getTargetEntityTypeId(), 'node'); } @@ -98,9 +98,9 @@ public function testCommentTypeEditing() { // Change the comment type name. $this->drupalGet('admin/structure/comment'); - $edit = array( + $edit = [ 'label' => 'Bar', - ); + ]; $this->drupalPostForm('admin/structure/comment/manage/comment', $edit, t('Save')); $this->drupalGet('admin/structure/comment'); @@ -110,9 +110,9 @@ public function testCommentTypeEditing() { $this->assertTrue($this->cssSelect('tr#comment-body'), 'Body field exists.'); // Remove the body field. - $this->drupalPostForm('admin/structure/comment/manage/comment/fields/comment.comment.comment_body/delete', array(), t('Delete')); + $this->drupalPostForm('admin/structure/comment/manage/comment/fields/comment.comment.comment_body/delete', [], t('Delete')); // Resave the settings for this type. - $this->drupalPostForm('admin/structure/comment/manage/comment', array(), t('Save')); + $this->drupalPostForm('admin/structure/comment/manage/comment', [], t('Save')); // Check that the body field doesn't exist. $this->drupalGet('admin/structure/comment/manage/comment/fields'); $this->assertFalse($this->cssSelect('tr#comment-body'), 'Body field does not exist.'); @@ -124,39 +124,39 @@ public function testCommentTypeEditing() { public function testCommentTypeDeletion() { // Create a comment type programmatically. $type = $this->createCommentType('foo'); - $this->drupalCreateContentType(array('type' => 'page')); + $this->drupalCreateContentType(['type' => 'page']); $this->addDefaultCommentField('node', 'page', 'foo', CommentItemInterface::OPEN, 'foo'); $field_storage = FieldStorageConfig::loadByName('node', 'foo'); $this->drupalLogin($this->adminUser); // Create a node. - $node = Node::create(array( + $node = Node::create([ 'type' => 'page', 'title' => 'foo', - )); + ]); $node->save(); // Add a new comment of this type. - $comment = Comment::create(array( + $comment = Comment::create([ 'comment_type' => 'foo', 'entity_type' => 'node', 'field_name' => 'foo', 'entity_id' => $node->id(), - )); + ]); $comment->save(); // Attempt to delete the comment type, which should not be allowed. $this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete'); $this->assertRaw( - t('%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', array('%label' => $type->label())), + t('%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', ['%label' => $type->label()]), 'The comment type will not be deleted until all comments of that type are removed.' ); $this->assertRaw( - t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', array( + t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', [ '%label' => 'foo', '%field' => 'node.foo', - )), + ]), 'The comment type will not be deleted until all fields of that type are removed.' ); $this->assertNoText(t('This action cannot be undone.'), 'The comment type deletion confirmation form is not available.'); @@ -167,7 +167,7 @@ public function testCommentTypeDeletion() { // Attempt to delete the comment type, which should now be allowed. $this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete'); $this->assertRaw( - t('Are you sure you want to delete the comment type %type?', array('%type' => $type->id())), + t('Are you sure you want to delete the comment type %type?', ['%type' => $type->id()]), 'The comment type is available for deletion.' ); $this->assertText(t('This action cannot be undone.'), 'The comment type deletion confirmation form is available.'); @@ -182,9 +182,9 @@ public function testCommentTypeDeletion() { } // Delete the comment type. - $this->drupalPostForm('admin/structure/comment/manage/' . $type->id() . '/delete', array(), t('Delete')); + $this->drupalPostForm('admin/structure/comment/manage/' . $type->id() . '/delete', [], t('Delete')); $this->assertNull(CommentType::load($type->id()), 'Comment type deleted.'); - $this->assertRaw(t('The comment type %label has been deleted.', array('%label' => $type->label()))); + $this->assertRaw(t('The comment type %label has been deleted.', ['%label' => $type->label()])); } } diff --git a/core/modules/comment/src/Tests/CommentUninstallTest.php b/core/modules/comment/src/Tests/CommentUninstallTest.php index 4d86df9..9f9d36a 100644 --- a/core/modules/comment/src/Tests/CommentUninstallTest.php +++ b/core/modules/comment/src/Tests/CommentUninstallTest.php @@ -20,13 +20,13 @@ class CommentUninstallTest extends WebTestBase { * * @var array */ - public static $modules = array('comment', 'node'); + public static $modules = ['comment', 'node']; protected function setUp() { parent::setup(); // Create an article content type. - $this->drupalCreateContentType(array('type' => 'article', 'name' => t('Article'))); + $this->drupalCreateContentType(['type' => 'article', 'name' => t('Article')]); // Create comment field on article so that adds 'comment_body' field. $this->addDefaultCommentField('node', 'article'); } @@ -43,7 +43,7 @@ function testCommentUninstallWithField() { // Uninstall the comment module which should trigger an exception. try { - $this->container->get('module_installer')->uninstall(array('comment')); + $this->container->get('module_installer')->uninstall(['comment']); $this->fail("Expected an exception when uninstall was attempted."); } catch (ModuleUninstallValidatorException $e) { @@ -77,7 +77,7 @@ function testCommentUninstallWithoutField() { field_purge_batch(10); // Ensure that uninstallation succeeds even if the field has already been // deleted manually beforehand. - $this->container->get('module_installer')->uninstall(array('comment')); + $this->container->get('module_installer')->uninstall(['comment']); } } diff --git a/core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php b/core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php index 63a0082..3365918 100644 --- a/core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php +++ b/core/modules/comment/src/Tests/Views/ArgumentUserUIDTest.php @@ -18,7 +18,7 @@ class ArgumentUserUIDTest extends CommentTestBase { * * @var array */ - public static $testViews = array('test_comment_user_uid'); + public static $testViews = ['test_comment_user_uid']; function testCommentUserUIDTest() { // Add an additional comment which is not created by the user. @@ -35,16 +35,16 @@ function testCommentUserUIDTest() { $comment->save(); $view = Views::getView('test_comment_user_uid'); - $this->executeView($view, array($this->account->id())); - $result_set = array( - array( + $this->executeView($view, [$this->account->id()]); + $result_set = [ + [ 'nid' => $this->nodeUserPosted->id(), - ), - array( + ], + [ 'nid' => $this->nodeUserCommented->id(), - ), - ); - $column_map = array('nid' => 'nid'); + ], + ]; + $column_map = ['nid' => 'nid']; $this->assertIdenticalResultset($view, $result_set, $column_map); } diff --git a/core/modules/comment/src/Tests/Views/CommentFieldFilterTest.php b/core/modules/comment/src/Tests/Views/CommentFieldFilterTest.php index c0cf374..040fc7d 100644 --- a/core/modules/comment/src/Tests/Views/CommentFieldFilterTest.php +++ b/core/modules/comment/src/Tests/Views/CommentFieldFilterTest.php @@ -15,21 +15,21 @@ class CommentFieldFilterTest extends CommentTestBase { /** * {@inheritdoc} */ - public static $modules = array('language'); + public static $modules = ['language']; /** * Views used by this test. * * @var array */ - public static $testViews = array('test_field_filters'); + public static $testViews = ['test_field_filters']; /** * List of comment titles by language. * * @var array */ - public $commentTitles = array(); + public $commentTitles = []; function setUp() { parent::setUp(); @@ -40,15 +40,15 @@ function setUp() { ConfigurableLanguage::createFromLangcode('es')->save(); // Set up comment titles. - $this->commentTitles = array( + $this->commentTitles = [ 'en' => 'Food in Paris', 'es' => 'Comida en Paris', 'fr' => 'Nouriture en Paris', - ); + ]; // Create a new comment. Using the one created earlier will not work, // as it predates the language set-up. - $comment = array( + $comment = [ 'uid' => $this->loggedInUser->id(), 'entity_id' => $this->nodeUserCommented->id(), 'entity_type' => 'node', @@ -56,7 +56,7 @@ function setUp() { 'cid' => '', 'pid' => '', 'node_type' => '', - ); + ]; $this->comment = Comment::create($comment); // Add field values and translate the comment. @@ -64,8 +64,8 @@ function setUp() { $this->comment->comment_body->value = $this->commentTitles['en']; $this->comment->langcode = 'en'; $this->comment->save(); - foreach (array('es', 'fr') as $langcode) { - $translation = $this->comment->addTranslation($langcode, array()); + foreach (['es', 'fr'] as $langcode) { + $translation = $this->comment->addTranslation($langcode, []); $translation->comment_body->value = $this->commentTitles[$langcode]; $translation->subject->value = $this->commentTitles[$langcode]; } @@ -78,19 +78,19 @@ function setUp() { public function testFilters() { // Test the title filter page, which filters for title contains 'Comida'. // Should show just the Spanish translation, once. - $this->assertPageCounts('test-title-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida title filter'); + $this->assertPageCounts('test-title-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida title filter'); // Test the body filter page, which filters for body contains 'Comida'. // Should show just the Spanish translation, once. - $this->assertPageCounts('test-body-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida body filter'); + $this->assertPageCounts('test-body-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida body filter'); // Test the title Paris filter page, which filters for title contains // 'Paris'. Should show each translation once. - $this->assertPageCounts('test-title-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris title filter'); + $this->assertPageCounts('test-title-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris title filter'); // Test the body Paris filter page, which filters for body contains // 'Paris'. Should show each translation once. - $this->assertPageCounts('test-body-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris body filter'); + $this->assertPageCounts('test-body-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris body filter'); } /** diff --git a/core/modules/comment/src/Tests/Views/CommentRestExportTest.php b/core/modules/comment/src/Tests/Views/CommentRestExportTest.php index a3d7e2d..ed7ce55 100644 --- a/core/modules/comment/src/Tests/Views/CommentRestExportTest.php +++ b/core/modules/comment/src/Tests/Views/CommentRestExportTest.php @@ -27,7 +27,7 @@ class CommentRestExportTest extends CommentTestBase { protected function setUp() { parent::setUp(); // Add another anonymous comment. - $comment = array( + $comment = [ 'uid' => 0, 'entity_id' => $this->nodeUserCommented->id(), 'entity_type' => 'node', @@ -38,7 +38,7 @@ protected function setUp() { 'mail' => 'someone@example.com', 'name' => 'bobby tables', 'hostname' => 'public.example.com', - ); + ]; $this->comment = Comment::create($comment); $this->comment->save(); diff --git a/core/modules/comment/src/Tests/Views/CommentRowTest.php b/core/modules/comment/src/Tests/Views/CommentRowTest.php index e96869c..d73811e 100644 --- a/core/modules/comment/src/Tests/Views/CommentRowTest.php +++ b/core/modules/comment/src/Tests/Views/CommentRowTest.php @@ -14,7 +14,7 @@ class CommentRowTest extends CommentTestBase { * * @var array */ - public static $testViews = array('test_comment_row'); + public static $testViews = ['test_comment_row']; /** * Test comment row. diff --git a/core/modules/comment/src/Tests/Views/CommentTestBase.php b/core/modules/comment/src/Tests/Views/CommentTestBase.php index d687488..d7bec04 100644 --- a/core/modules/comment/src/Tests/Views/CommentTestBase.php +++ b/core/modules/comment/src/Tests/Views/CommentTestBase.php @@ -19,7 +19,7 @@ * * @var array */ - public static $modules = array('node', 'comment', 'comment_test_views'); + public static $modules = ['node', 'comment', 'comment_test_views']; /** * A normal user with permission to post comments (without approval). @@ -59,21 +59,21 @@ protected function setUp() { parent::setUp(); - ViewTestData::createTestViews(get_class($this), array('comment_test_views')); + ViewTestData::createTestViews(get_class($this), ['comment_test_views']); // Add two users, create a node with the user1 as author and another node // with user2 as author. For the second node add a comment from user1. - $this->account = $this->drupalCreateUser(array('skip comment approval')); + $this->account = $this->drupalCreateUser(['skip comment approval']); $this->account2 = $this->drupalCreateUser(); $this->drupalLogin($this->account); - $this->drupalCreateContentType(array('type' => 'page', 'name' => t('Basic page'))); + $this->drupalCreateContentType(['type' => 'page', 'name' => t('Basic page')]); $this->addDefaultCommentField('node', 'page'); $this->nodeUserPosted = $this->drupalCreateNode(); - $this->nodeUserCommented = $this->drupalCreateNode(array('uid' => $this->account2->id())); + $this->nodeUserCommented = $this->drupalCreateNode(['uid' => $this->account2->id()]); - $comment = array( + $comment = [ 'uid' => $this->loggedInUser->id(), 'entity_id' => $this->nodeUserCommented->id(), 'entity_type' => 'node', @@ -82,7 +82,7 @@ protected function setUp() { 'cid' => '', 'pid' => '', 'mail' => 'someone@example.com', - ); + ]; $this->comment = Comment::create($comment); $this->comment->save(); } diff --git a/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php b/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php index ff151c6..3e5f26b 100644 --- a/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php +++ b/core/modules/comment/src/Tests/Views/DefaultViewRecentCommentsTest.php @@ -22,7 +22,7 @@ class DefaultViewRecentCommentsTest extends ViewTestBase { * * @var array */ - public static $modules = array('node', 'comment', 'block'); + public static $modules = ['node', 'comment', 'block']; /** * Number of results for the Master display. @@ -50,7 +50,7 @@ class DefaultViewRecentCommentsTest extends ViewTestBase { * * @var array */ - protected $commentsCreated = array(); + protected $commentsCreated = []; /** * Contains the node object used for comments of this test. @@ -66,9 +66,9 @@ protected function setUp() { $content_type = $this->drupalCreateContentType(); // Add a node of the new content type. - $node_data = array( + $node_data = [ 'type' => $content_type->id(), - ); + ]; $this->addDefaultCommentField('node', $content_type->id()); $this->node = $this->drupalCreateNode($node_data); @@ -79,12 +79,12 @@ protected function setUp() { // Create some comments and attach them to the created node. for ($i = 0; $i < $this->masterDisplayResults; $i++) { /** @var \Drupal\comment\CommentInterface $comment */ - $comment = Comment::create(array( + $comment = Comment::create([ 'status' => CommentInterface::PUBLISHED, 'field_name' => 'comment', 'entity_type' => 'node', 'entity_id' => $this->node->id(), - )); + ]); $comment->setOwnerId(0); $comment->setSubject('Test comment ' . $i); $comment->comment_body->value = 'Test body ' . $i; @@ -116,12 +116,12 @@ public function testBlockDisplay() { $view->setDisplay('block_1'); $this->executeView($view); - $map = array( + $map = [ 'subject' => 'subject', 'cid' => 'cid', 'comment_field_data_created' => 'created' - ); - $expected_result = array(); + ]; + $expected_result = []; foreach (array_values($this->commentsCreated) as $key => $comment) { $expected_result[$key]['subject'] = $comment->getSubject(); $expected_result[$key]['cid'] = $comment->id(); @@ -132,7 +132,7 @@ public function testBlockDisplay() { // Check the number of results given by the display is the expected. $this->assertEqual(sizeof($view->result), $this->blockDisplayResults, format_string('There are exactly @results comments. Expected @expected', - array('@results' => count($view->result), '@expected' => $this->blockDisplayResults) + ['@results' => count($view->result), '@expected' => $this->blockDisplayResults] ) ); } diff --git a/core/modules/comment/src/Tests/Views/FilterUserUIDTest.php b/core/modules/comment/src/Tests/Views/FilterUserUIDTest.php index ee8281b..c4570ce 100644 --- a/core/modules/comment/src/Tests/Views/FilterUserUIDTest.php +++ b/core/modules/comment/src/Tests/Views/FilterUserUIDTest.php @@ -20,7 +20,7 @@ class FilterUserUIDTest extends CommentTestBase { * * @var array */ - public static $testViews = array('test_comment_user_uid'); + public static $testViews = ['test_comment_user_uid']; function testCommentUserUIDTest() { $view = Views::getView('test_comment_user_uid'); @@ -40,23 +40,23 @@ function testCommentUserUIDTest() { ]); $comment->save(); - $options = array( + $options = [ 'id' => 'uid_touch', 'table' => 'node_field_data', 'field' => 'uid_touch', - 'value' => array($this->loggedInUser->id()), - ); + 'value' => [$this->loggedInUser->id()], + ]; $view->addHandler('default', 'filter', 'node_field_data', 'uid_touch', $options); - $this->executeView($view, array($this->account->id())); - $result_set = array( - array( + $this->executeView($view, [$this->account->id()]); + $result_set = [ + [ 'nid' => $this->nodeUserPosted->id(), - ), - array( + ], + [ 'nid' => $this->nodeUserCommented->id(), - ), - ); - $column_map = array('nid' => 'nid'); + ], + ]; + $column_map = ['nid' => 'nid']; $this->assertIdenticalResultset($view, $result_set, $column_map); } diff --git a/core/modules/comment/src/Tests/Views/RowRssTest.php b/core/modules/comment/src/Tests/Views/RowRssTest.php index 85bd34f..343b797 100644 --- a/core/modules/comment/src/Tests/Views/RowRssTest.php +++ b/core/modules/comment/src/Tests/Views/RowRssTest.php @@ -15,7 +15,7 @@ class RowRssTest extends CommentTestBase { * * @var array */ - public static $testViews = array('test_comment_rss'); + public static $testViews = ['test_comment_rss']; /** * Test comment rss output. diff --git a/core/modules/comment/src/Tests/Views/WizardTest.php b/core/modules/comment/src/Tests/Views/WizardTest.php index 885ce2c..a7f14c8 100644 --- a/core/modules/comment/src/Tests/Views/WizardTest.php +++ b/core/modules/comment/src/Tests/Views/WizardTest.php @@ -21,7 +21,7 @@ class WizardTest extends WizardTestBase { * * @var array */ - public static $modules = array('node', 'comment'); + public static $modules = ['node', 'comment']; /** @@ -29,7 +29,7 @@ class WizardTest extends WizardTestBase { */ protected function setUp() { parent::setUp(); - $this->drupalCreateContentType(array('type' => 'page', 'name' => t('Basic page'))); + $this->drupalCreateContentType(['type' => 'page', 'name' => t('Basic page')]); // Add comment field to page node type. $this->addDefaultCommentField('node', 'page'); } @@ -38,7 +38,7 @@ protected function setUp() { * Tests adding a view of comments. */ public function testCommentWizard() { - $view = array(); + $view = []; $view['label'] = $this->randomMachineName(16); $view['id'] = strtolower($this->randomMachineName(16)); $view['show[wizard_key]'] = 'comment'; @@ -48,7 +48,7 @@ public function testCommentWizard() { // Just triggering the saving should automatically choose a proper row // plugin. $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit')); - $this->assertUrl('admin/structure/views/view/' . $view['id'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.'); + $this->assertUrl('admin/structure/views/view/' . $view['id'], [], 'Make sure the view saving was successful and the browser got redirected to the edit page.'); // If we update the type first we should get a selection of comment valid // row plugins as the select field. @@ -59,19 +59,19 @@ public function testCommentWizard() { // Check for available options of the row plugin. $xpath = $this->constructFieldXpath('name', 'page[style][row_plugin]'); $fields = $this->xpath($xpath); - $options = array(); + $options = []; foreach ($fields as $field) { $items = $this->getAllOptions($field); foreach ($items as $item) { $options[] = $item->attributes()->value; } } - $expected_options = array('entity:comment', 'fields'); + $expected_options = ['entity:comment', 'fields']; $this->assertEqual($options, $expected_options); $view['id'] = strtolower($this->randomMachineName(16)); $this->drupalPostForm(NULL, $view, t('Save and edit')); - $this->assertUrl('admin/structure/views/view/' . $view['id'], array(), 'Make sure the view saving was successful and the browser got redirected to the edit page.'); + $this->assertUrl('admin/structure/views/view/' . $view['id'], [], 'Make sure the view saving was successful and the browser got redirected to the edit page.'); $user = $this->drupalCreateUser(['access comments']); $this->drupalLogin($user); diff --git a/core/modules/comment/tests/modules/comment_test/comment_test.module b/core/modules/comment/tests/modules/comment_test/comment_test.module index d54814b..b1cca02 100644 --- a/core/modules/comment/tests/modules/comment_test/comment_test.module +++ b/core/modules/comment/tests/modules/comment_test/comment_test.module @@ -31,14 +31,14 @@ function comment_test_comment_links_alter(array &$links, CommentInterface &$enti return; } - $links['comment_test'] = array( + $links['comment_test'] = [ '#theme' => 'links__comment__comment_test', - '#attributes' => array('class' => array('links', 'inline')), - '#links' => array( - 'comment-report' => array( + '#attributes' => ['class' => ['links', 'inline']], + '#links' => [ + 'comment-report' => [ 'title' => t('Report'), 'url' => Url::fromRoute('comment_test.report', ['comment' => $entity->id()], ['query' => ['token' => \Drupal::getContainer()->get('csrf_token')->get("comment/{$entity->id()}/report")]]), - ), - ), - ); + ], + ], + ]; } diff --git a/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php b/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php index a95088e..bdea71d 100644 --- a/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php +++ b/core/modules/comment/tests/src/Kernel/CommentDefaultFormatterCacheTagsTest.php @@ -26,7 +26,7 @@ class CommentDefaultFormatterCacheTagsTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('entity_test', 'comment'); + public static $modules = ['entity_test', 'comment']; /** * {@inheritdoc} @@ -48,11 +48,11 @@ protected function setUp() { // user does not have access to the 'administer comments' permission, to // ensure only published comments are visible to the end user. $current_user = $this->container->get('current_user'); - $current_user->setAccount($this->createUser(array(), array('access comments'))); + $current_user->setAccount($this->createUser([], ['access comments'])); // Install tables and config needed to render comments. - $this->installSchema('comment', array('comment_entity_statistics')); - $this->installConfig(array('system', 'filter', 'comment')); + $this->installSchema('comment', ['comment_entity_statistics']); + $this->installConfig(['system', 'filter', 'comment']); // Comment rendering generates links, so build the router. $this->container->get('router.builder')->rebuild(); @@ -70,7 +70,7 @@ public function testCacheTags() { $renderer = $this->container->get('renderer'); // Create the entity that will be commented upon. - $commented_entity = EntityTest::create(array('name' => $this->randomMachineName())); + $commented_entity = EntityTest::create(['name' => $this->randomMachineName()]); $commented_entity->save(); // Verify cache tags on the rendered entity before it has comments. @@ -94,19 +94,19 @@ public function testCacheTags() { // also exists in the {users} table. $user = $this->createUser(); $user->save(); - $comment = Comment::create(array( + $comment = Comment::create([ 'subject' => 'Llama', - 'comment_body' => array( + 'comment_body' => [ 'value' => 'Llamas are cool!', 'format' => 'plain_text', - ), + ], 'entity_id' => $commented_entity->id(), 'entity_type' => 'entity_test', 'field_name' => 'comment', 'comment_type' => 'comment', 'status' => CommentInterface::PUBLISHED, 'uid' => $user->id(), - )); + ]); $comment->save(); // Load commented entity so comment_count gets computed. diff --git a/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php b/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php index 674c7f3..5046353 100644 --- a/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php +++ b/core/modules/comment/tests/src/Kernel/CommentFieldAccessTest.php @@ -29,30 +29,30 @@ class CommentFieldAccessTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('comment', 'entity_test', 'user'); + public static $modules = ['comment', 'entity_test', 'user']; /** * Fields that only users with administer comments permissions can change. * * @var array */ - protected $administrativeFields = array( + protected $administrativeFields = [ 'uid', 'status', 'created', - ); + ]; /** * These fields are automatically managed and can not be changed by any user. * * @var array */ - protected $readOnlyFields = array( + protected $readOnlyFields = [ 'changed', 'hostname', 'cid', 'thread', - ); + ]; /** * These fields can be edited on create only. @@ -73,19 +73,19 @@ class CommentFieldAccessTest extends EntityKernelTestBase { * * @var array */ - protected $contactFields = array( + protected $contactFields = [ 'name', 'mail', 'homepage', - ); + ]; /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); - $this->installConfig(array('user', 'comment')); - $this->installSchema('comment', array('comment_entity_statistics')); + $this->installConfig(['user', 'comment']); + $this->installSchema('comment', ['comment_entity_statistics']); } /** diff --git a/core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php b/core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php index ed56cc9..adbe1b0 100644 --- a/core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php +++ b/core/modules/comment/tests/src/Kernel/CommentStringIdEntitiesTest.php @@ -18,21 +18,21 @@ class CommentStringIdEntitiesTest extends KernelTestBase { * * @var array */ - public static $modules = array( + public static $modules = [ 'comment', 'user', 'field', 'field_ui', 'entity_test', 'text', - ); + ]; protected function setUp() { parent::setUp(); $this->installEntitySchema('comment'); - $this->installSchema('comment', array('comment_entity_statistics')); + $this->installSchema('comment', ['comment_entity_statistics']); // Create the comment body field storage. - $this->installConfig(array('field')); + $this->installConfig(['field']); } /** @@ -40,21 +40,21 @@ protected function setUp() { */ public function testCommentFieldNonStringId() { try { - $bundle = CommentType::create(array( + $bundle = CommentType::create([ 'id' => 'foo', 'label' => 'foo', 'description' => '', 'target_entity_type_id' => 'entity_test_string_id', - )); + ]); $bundle->save(); - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'field_name' => 'foo', 'entity_type' => 'entity_test_string_id', - 'settings' => array( + 'settings' => [ 'comment_type' => 'entity_test_string_id', - ), + ], 'type' => 'comment', - )); + ]); $field_storage->save(); $this->fail('Did not throw an exception as expected.'); } diff --git a/core/modules/comment/tests/src/Kernel/CommentValidationTest.php b/core/modules/comment/tests/src/Kernel/CommentValidationTest.php index eb37006..98b7715 100644 --- a/core/modules/comment/tests/src/Kernel/CommentValidationTest.php +++ b/core/modules/comment/tests/src/Kernel/CommentValidationTest.php @@ -19,14 +19,14 @@ class CommentValidationTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('comment', 'node'); + public static $modules = ['comment', 'node']; /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); - $this->installSchema('comment', array('comment_entity_statistics')); + $this->installSchema('comment', ['comment_entity_statistics']); } /** @@ -34,54 +34,54 @@ protected function setUp() { */ public function testValidation() { // Add a user. - $user = User::create(array('name' => 'test', 'status' => TRUE)); + $user = User::create(['name' => 'test', 'status' => TRUE]); $user->save(); // Add comment type. - $this->entityManager->getStorage('comment_type')->create(array( + $this->entityManager->getStorage('comment_type')->create([ 'id' => 'comment', 'label' => 'comment', 'target_entity_type_id' => 'node', - ))->save(); + ])->save(); // Add comment field to content. - $this->entityManager->getStorage('field_storage_config')->create(array( + $this->entityManager->getStorage('field_storage_config')->create([ 'entity_type' => 'node', 'field_name' => 'comment', 'type' => 'comment', - 'settings' => array( + 'settings' => [ 'comment_type' => 'comment', - ) - ))->save(); + ] + ])->save(); // Create a page node type. - $this->entityManager->getStorage('node_type')->create(array( + $this->entityManager->getStorage('node_type')->create([ 'type' => 'page', 'name' => 'page', - ))->save(); + ])->save(); // Add comment field to page content. /** @var \Drupal\field\FieldConfigInterface $field */ - $field = $this->entityManager->getStorage('field_config')->create(array( + $field = $this->entityManager->getStorage('field_config')->create([ 'field_name' => 'comment', 'entity_type' => 'node', 'bundle' => 'page', 'label' => 'Comment settings', - )); + ]); $field->save(); - $node = $this->entityManager->getStorage('node')->create(array( + $node = $this->entityManager->getStorage('node')->create([ 'type' => 'page', 'title' => 'test', - )); + ]); $node->save(); - $comment = $this->entityManager->getStorage('comment')->create(array( + $comment = $this->entityManager->getStorage('comment')->create([ 'entity_id' => $node->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'comment_body' => $this->randomMachineName(), - )); + ]); $violations = $comment->validate(); $this->assertEqual(count($violations), 0, 'No violations when validating a default comment.'); @@ -101,7 +101,7 @@ public function testValidation() { $violations = $comment->validate(); $this->assertEqual(count($violations), 1, "Violation found on author name collision"); $this->assertEqual($violations[0]->getPropertyPath(), "name"); - $this->assertEqual($violations[0]->getMessage(), t('The name you used (%name) belongs to a registered user.', array('%name' => 'test'))); + $this->assertEqual($violations[0]->getMessage(), t('The name you used (%name) belongs to a registered user.', ['%name' => 'test'])); // Make the name valid. $comment->set('name', 'valid unused name'); @@ -141,39 +141,39 @@ public function testValidation() { \Drupal::entityManager()->getStorage('node')->resetCache([$node->id()]); $node = Node::load($node->id()); // Create a new comment with the new field. - $comment = $this->entityManager->getStorage('comment')->create(array( + $comment = $this->entityManager->getStorage('comment')->create([ 'entity_id' => $node->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'comment_body' => $this->randomMachineName(), 'uid' => 0, 'name' => '', - )); + ]); $violations = $comment->validate(); $this->assertEqual(count($violations), 1, 'Violation found when name is required, but empty and UID is anonymous.'); $this->assertEqual($violations[0]->getPropertyPath(), 'name'); $this->assertEqual($violations[0]->getMessage(), t('You have to specify a valid author.')); // Test creating a default comment with a given user id works. - $comment = $this->entityManager->getStorage('comment')->create(array( + $comment = $this->entityManager->getStorage('comment')->create([ 'entity_id' => $node->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'comment_body' => $this->randomMachineName(), 'uid' => $user->id(), - )); + ]); $violations = $comment->validate(); $this->assertEqual(count($violations), 0, 'No violations when validating a default comment with an author.'); // Test specifying a wrong author name does not work. - $comment = $this->entityManager->getStorage('comment')->create(array( + $comment = $this->entityManager->getStorage('comment')->create([ 'entity_id' => $node->id(), 'entity_type' => 'node', 'field_name' => 'comment', 'comment_body' => $this->randomMachineName(), 'uid' => $user->id(), 'name' => 'not-test', - )); + ]); $violations = $comment->validate(); $this->assertEqual(count($violations), 1, 'Violation found when author name and comment author do not match.'); $this->assertEqual($violations[0]->getPropertyPath(), 'name'); @@ -195,7 +195,7 @@ protected function assertLengthViolation(CommentInterface $comment, $field_name, $this->assertEqual(count($violations), 1, "Violation found when $field_name is too long."); $this->assertEqual($violations[0]->getPropertyPath(), "$field_name.0.value"); $field_label = $comment->get($field_name)->getFieldDefinition()->getLabel(); - $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', array('%name' => $field_label, '@max' => $length))); + $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', ['%name' => $field_label, '@max' => $length])); } } diff --git a/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php b/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php index b5fc4fe..0b256ea 100644 --- a/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php +++ b/core/modules/comment/tests/src/Kernel/Migrate/MigrateCommentStubTest.php @@ -33,11 +33,11 @@ protected function setUp() { $storage = \Drupal::entityManager()->getStorage('user'); // Insert a row for the anonymous user. $storage - ->create(array( + ->create([ 'uid' => 0, 'status' => 0, 'name' => '', - )) + ]) ->save(); // Need at least one node type and comment type present. NodeType::create([ diff --git a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php index ed19178..add18eb 100644 --- a/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php +++ b/core/modules/comment/tests/src/Kernel/Migrate/d7/MigrateCommentTest.php @@ -34,11 +34,11 @@ protected function setUp() { $this->executeMigration('d7_node_type'); // We only need the test_content_type node migration to run for real, so // mock all the others. - $this->prepareMigrations(array( - 'd7_node' => array( - array(array(0), array(0)), - ), - )); + $this->prepareMigrations([ + 'd7_node' => [ + [[0], [0]], + ], + ]); $this->executeMigrations([ 'd7_node:test_content_type', 'd7_comment_type', diff --git a/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php b/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php index dae2c48..cad7b2b 100644 --- a/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php +++ b/core/modules/comment/tests/src/Kernel/Views/CommentUserNameTest.php @@ -43,11 +43,11 @@ protected function setUp($import_test_views = TRUE) { $storage = \Drupal::entityManager()->getStorage('user'); // Insert a row for the anonymous user. $storage - ->create(array( + ->create([ 'uid' => 0, 'name' => '', 'status' => 0, - )) + ]) ->save(); $admin_role = Role::create([ diff --git a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php index 898e0ab..d244291 100644 --- a/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php +++ b/core/modules/comment/tests/src/Unit/CommentLinkBuilderTest.php @@ -75,9 +75,9 @@ protected function setUp() { $this->commentManager->expects($this->any()) ->method('getFields') ->with('node') - ->willReturn(array( - 'comment' => array(), - )); + ->willReturn([ + 'comment' => [], + ]); $this->commentManager->expects($this->any()) ->method('forbiddenMessage') ->willReturn("Can't let you do that Dave."); @@ -116,10 +116,10 @@ public function testCommentLinkBuilder(NodeInterface $node, $context, $has_acces ->willReturn($history_exists); $this->currentUser->expects($this->any()) ->method('hasPermission') - ->willReturnMap(array( - array('access comments', $has_access_comments), - array('post comments', $has_post_comments), - )); + ->willReturnMap([ + ['access comments', $has_access_comments], + ['post comments', $has_post_comments], + ]); $this->currentUser->expects($this->any()) ->method('isAuthenticated') ->willReturn(!$is_anonymous); @@ -155,57 +155,57 @@ public function testCommentLinkBuilder(NodeInterface $node, $context, $has_acces * Data provider for ::testCommentLinkBuilder. */ public function getLinkCombinations() { - $cases = array(); + $cases = []; // No links should be created if the entity doesn't have the field. - $cases[] = array( + $cases[] = [ $this->getMockNode(FALSE, CommentItemInterface::OPEN, CommentItemInterface::FORM_BELOW, 1), - array('view_mode' => 'teaser'), + ['view_mode' => 'teaser'], TRUE, TRUE, TRUE, TRUE, - array(), - ); - foreach (array('search_result', 'search_index', 'print') as $view_mode) { + [], + ]; + foreach (['search_result', 'search_index', 'print'] as $view_mode) { // Nothing should be output in these view modes. - $cases[] = array( + $cases[] = [ $this->getMockNode(TRUE, CommentItemInterface::OPEN, CommentItemInterface::FORM_BELOW, 1), - array('view_mode' => $view_mode), + ['view_mode' => $view_mode], TRUE, TRUE, TRUE, TRUE, - array(), - ); + [], + ]; } // All other combinations. - $combinations = array( - 'is_anonymous' => array(FALSE, TRUE), - 'comment_count' => array(0, 1), - 'has_access_comments' => array(0, 1), - 'history_exists' => array(FALSE, TRUE), - 'has_post_comments' => array(0, 1), - 'form_location' => array(CommentItemInterface::FORM_BELOW, CommentItemInterface::FORM_SEPARATE_PAGE), - 'comments' => array( + $combinations = [ + 'is_anonymous' => [FALSE, TRUE], + 'comment_count' => [0, 1], + 'has_access_comments' => [0, 1], + 'history_exists' => [FALSE, TRUE], + 'has_post_comments' => [0, 1], + 'form_location' => [CommentItemInterface::FORM_BELOW, CommentItemInterface::FORM_SEPARATE_PAGE], + 'comments' => [ CommentItemInterface::OPEN, CommentItemInterface::CLOSED, CommentItemInterface::HIDDEN, - ), - 'view_mode' => array( + ], + 'view_mode' => [ 'teaser', 'rss', 'full', - ), - ); + ], + ]; $permutations = TestBase::generatePermutations($combinations); foreach ($permutations as $combination) { - $case = array( + $case = [ $this->getMockNode(TRUE, $combination['comments'], $combination['form_location'], $combination['comment_count']), - array('view_mode' => $combination['view_mode']), + ['view_mode' => $combination['view_mode']], $combination['has_access_comments'], $combination['history_exists'], $combination['has_post_comments'], $combination['is_anonymous'], - ); - $expected = array(); + ]; + $expected = []; // When comments are enabled in teaser mode, and comments exist, and the // user has access - we can output the comment count. if ($combination['comments'] && $combination['view_mode'] == 'teaser' && $combination['comment_count'] && $combination['has_access_comments']) { @@ -225,7 +225,7 @@ public function getLinkCombinations() { // comments exist or the form is on a separate page. if ($combination['view_mode'] == 'teaser' || ($combination['has_access_comments'] && $combination['comment_count']) || $combination['form_location'] == CommentItemInterface::FORM_SEPARATE_PAGE) { // There should be a add comment link. - $expected['comment-add'] = array('title' => 'Add new comment'); + $expected['comment-add'] = ['title' => 'Add new comment']; if ($combination['form_location'] == CommentItemInterface::FORM_BELOW) { // On the same page. $expected['comment-add']['url'] = Url::fromRoute('node.view'); @@ -274,11 +274,11 @@ protected function getMockNode($has_field, $comment_status, $form_location, $com if (empty($this->timestamp)) { $this->timestamp = time(); } - $field_item = (object) array( + $field_item = (object) [ 'status' => $comment_status, 'comment_count' => $comment_count, 'last_comment_timestamp' => $this->timestamp, - ); + ]; $node->expects($this->any()) ->method('get') ->with('comment') @@ -312,7 +312,7 @@ protected function getMockNode($has_field, $comment_status, $form_location, $com ->willReturn($url); $node->expects($this->any()) ->method('url') - ->willReturn(array('route_name' => 'node.view')); + ->willReturn(['route_name' => 'node.view']); return $node; } diff --git a/core/modules/comment/tests/src/Unit/CommentManagerTest.php b/core/modules/comment/tests/src/Unit/CommentManagerTest.php index 7fe1c16..cf23cf8 100644 --- a/core/modules/comment/tests/src/Unit/CommentManagerTest.php +++ b/core/modules/comment/tests/src/Unit/CommentManagerTest.php @@ -31,13 +31,13 @@ public function testGetFields() { $entity_manager->expects($this->once()) ->method('getFieldMapByFieldType') - ->will($this->returnValue(array( - 'node' => array( - 'field_foobar' => array( + ->will($this->returnValue([ + 'node' => [ + 'field_foobar' => [ 'type' => 'comment', - ), - ), - ))); + ], + ], + ])); $entity_manager->expects($this->any()) ->method('getDefinition') diff --git a/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php b/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php index e904754..158990b 100644 --- a/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php +++ b/core/modules/comment/tests/src/Unit/CommentStatisticsUnitTest.php @@ -56,7 +56,7 @@ protected function setUp() { $this->statement->expects($this->any()) ->method('fetchObject') - ->will($this->returnCallback(array($this, 'fetchObjectCallback'))); + ->will($this->returnCallback([$this, 'fetchObjectCallback'])); $this->select = $this->getMockBuilder('Drupal\Core\Database\Query\Select') ->disableOriginalConstructor() @@ -95,8 +95,8 @@ protected function setUp() { */ public function testRead() { $this->calls_to_fetch = 0; - $results = $this->commentStatistics->read(array('1' => 'boo', '2' => 'foo'), 'snafoos'); - $this->assertEquals($results, array('something', 'something-else')); + $results = $this->commentStatistics->read(['1' => 'boo', '2' => 'foo'], 'snafoos'); + $this->assertEquals($results, ['something', 'something-else']); } /** diff --git a/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php b/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php index 97c109f..e724dc6 100644 --- a/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php +++ b/core/modules/comment/tests/src/Unit/Entity/CommentLockTest.php @@ -26,7 +26,7 @@ public function testLocks() { $request_stack = new RequestStack(); $request_stack->push(Request::create('/')); $container->set('request_stack', $request_stack); - $container->setParameter('cache_bins', array('cache.test' => 'test')); + $container->setParameter('cache_bins', ['cache.test' => 'test']); $lock = $this->getMock('Drupal\Core\Lock\LockBackendInterface'); $cid = 2; $lock_name = "comment:$cid:.00/"; @@ -84,7 +84,7 @@ public function testLocks() { $comment->expects($this->at(1)) ->method('get') ->with('status') - ->will($this->returnValue((object) array('value' => NULL))); + ->will($this->returnValue((object) ['value' => NULL])); $storage = $this->getMock('Drupal\comment\CommentStorageInterface'); // preSave() should acquire the lock. (This is what's really being tested.) diff --git a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTestBase.php b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTestBase.php index 79bae3e..220328b 100644 --- a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTestBase.php +++ b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentTestBase.php @@ -14,20 +14,20 @@ const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d6\Comment'; // The fake Migration configuration entity. - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ // The ID of the entity, can be any string. 'id' => 'test', // This needs to be the identifier of the actual key: cid for comment, nid // for node and so on. - 'source' => array( + 'source' => [ 'plugin' => 'd6_comment', - ), - ); + ], + ]; // We need to set up the database contents; it's easier to do that below. - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'cid' => 1, 'pid' => 0, 'nid' => 2, @@ -43,8 +43,8 @@ 'homepage' => '', 'format' => 'testformat1', 'type' => 'story', - ), - array( + ], + [ 'cid' => 2, 'pid' => 1, 'nid' => 3, @@ -60,8 +60,8 @@ 'homepage' => '', 'format' => 'testformat2', 'type' => 'page', - ), - ); + ], + ]; /** * {@inheritdoc} @@ -72,8 +72,8 @@ protected function setUp() { $this->databaseContents['comments'][$k]['status'] = 1 - $this->databaseContents['comments'][$k]['status']; } // Add node table data. - $this->databaseContents['node'][] = array('nid' => 2, 'type' => 'story'); - $this->databaseContents['node'][] = array('nid' => 3, 'type' => 'page'); + $this->databaseContents['node'][] = ['nid' => 2, 'type' => 'story']; + $this->databaseContents['node'][] = ['nid' => 3, 'type' => 'page']; parent::setUp(); } diff --git a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariablePerCommentTypeTest.php b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariablePerCommentTypeTest.php index 75d0932..892319a 100644 --- a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariablePerCommentTypeTest.php +++ b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariablePerCommentTypeTest.php @@ -13,46 +13,46 @@ class CommentVariablePerCommentTypeTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = CommentVariablePerCommentType::class; - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'd6_comment_variable_per_comment_type', - ), - ); + ], + ]; - protected $expectedResults = array( + protected $expectedResults = [ // Each result will also include a label and description, but those are // static values set by the source plugin and don't need to be asserted. - array( + [ 'comment_type' => 'comment', - ), - array( + ], + [ 'comment_type' => 'comment_no_subject', - ), - ); + ], + ]; /** * {@inheritdoc} */ protected function setUp() { - $this->databaseContents['node_type'] = array( - array( + $this->databaseContents['node_type'] = [ + [ 'type' => 'page', - ), - array( + ], + [ 'type' => 'story', - ), - ); - $this->databaseContents['variable'] = array( - array( + ], + ]; + $this->databaseContents['variable'] = [ + [ 'name' => 'comment_subject_field_page', 'value' => serialize(1), - ), - array( + ], + [ 'name' => 'comment_subject_field_story', 'value' => serialize(0), - ), - ); + ], + ]; parent::setUp(); } diff --git a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariableTest.php b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariableTest.php index 6d25a2b..406cd11 100644 --- a/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariableTest.php +++ b/core/modules/comment/tests/src/Unit/Migrate/d6/CommentVariableTest.php @@ -13,15 +13,15 @@ class CommentVariableTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = CommentVariable::class; - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'd6_comment_variable', - ), - ); + ], + ]; - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'comment' => '1', 'comment_default_mode' => '1', 'comment_default_order' => '1', @@ -33,56 +33,56 @@ class CommentVariableTest extends MigrateSqlSourceTestCase { 'comment_form_location' => '1', 'node_type' => 'page', 'comment_type' => 'comment', - ), - ); + ], + ]; /** * {@inheritdoc} */ protected function setUp() { - $this->databaseContents['node_type'] = array( - array( + $this->databaseContents['node_type'] = [ + [ 'type' => 'page', - ), - ); - $this->databaseContents['variable'] = array( - array( + ], + ]; + $this->databaseContents['variable'] = [ + [ 'name' => 'comment_page', 'value' => serialize(1), - ), - array( + ], + [ 'name' => 'comment_default_mode_page', 'value' => serialize(1), - ), - array( + ], + [ 'name' => 'comment_default_order_page', 'value' => serialize(1), - ), - array( + ], + [ 'name' => 'comment_default_per_page_page', 'value' => serialize(50), - ), - array( + ], + [ 'name' => 'comment_controls_page', 'value' => serialize(1), - ), - array( + ], + [ 'name' => 'comment_anonymous_page', 'value' => serialize(1), - ), - array( + ], + [ 'name' => 'comment_subject_field_page', 'value' => serialize(1), - ), - array( + ], + [ 'name' => 'comment_preview_page', 'value' => serialize(1), - ), - array( + ], + [ 'name' => 'comment_form_location_page', 'value' => serialize(1), - ), - ); + ], + ]; parent::setUp(); } diff --git a/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php b/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php index 7793348..aed2f28 100644 --- a/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php +++ b/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTest.php @@ -13,15 +13,15 @@ class CommentTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d7\Comment'; - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'd7_comment', - ), - ); + ], + ]; - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'cid' => '1', 'pid' => '0', 'nid' => '1', @@ -36,14 +36,14 @@ class CommentTest extends MigrateSqlSourceTestCase { 'mail' => '', 'homepage' => '', 'language' => 'und', - 'comment_body' => array( - array( + 'comment_body' => [ + [ 'value' => 'This is a comment', 'format' => 'filtered_html', - ), - ), - ), - ); + ], + ], + ], + ]; /** * {@inheritdoc} @@ -52,8 +52,8 @@ protected function setUp() { $this->databaseContents['comment'] = $this->expectedResults; unset($this->databaseContents['comment'][0]['comment_body']); - $this->databaseContents['node'] = array( - array( + $this->databaseContents['node'] = [ + [ 'nid' => '1', 'vid' => '1', 'type' => 'test_content_type', @@ -68,10 +68,10 @@ protected function setUp() { 'sticky' => '0', 'tnid' => '0', 'translate' => '0', - ), - ); - $this->databaseContents['field_config_instance'] = array( - array( + ], + ]; + $this->databaseContents['field_config_instance'] = [ + [ 'id' => '14', 'field_id' => '1', 'field_name' => 'comment_body', @@ -79,10 +79,10 @@ protected function setUp() { 'bundle' => 'comment_node_test_content_type', 'data' => 'a:0:{}', 'deleted' => '0', - ), - ); - $this->databaseContents['field_data_comment_body'] = array( - array( + ], + ]; + $this->databaseContents['field_data_comment_body'] = [ + [ 'entity_type' => 'comment', 'bundle' => 'comment_node_test_content_type', 'deleted' => '0', @@ -92,8 +92,8 @@ protected function setUp() { 'delta' => '0', 'comment_body_value' => 'This is a comment', 'comment_body_format' => 'filtered_html', - ), - ); + ], + ]; parent::setUp(); } diff --git a/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTypeTest.php b/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTypeTest.php index 71c651b..106716d 100644 --- a/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTypeTest.php +++ b/core/modules/comment/tests/src/Unit/Migrate/d7/CommentTypeTest.php @@ -13,15 +13,15 @@ class CommentTypeTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = 'Drupal\comment\Plugin\migrate\source\d7\CommentType'; - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'd7_comment_type', - ), - ); + ], + ]; - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'bundle' => 'comment_node_article', 'node_type' => 'article', 'default_mode' => '1', @@ -31,15 +31,15 @@ class CommentTypeTest extends MigrateSqlSourceTestCase { 'preview' => '0', 'subject' => '1', 'label' => 'Article comment', - ), - ); + ], + ]; /** * {@inheritdoc} */ protected function setUp() { - $this->databaseContents['node_type'] = array( - array( + $this->databaseContents['node_type'] = [ + [ 'type' => 'article', 'name' => 'Article', 'base' => 'node_content', @@ -53,10 +53,10 @@ protected function setUp() { 'locked' => '0', 'disabled' => '0', 'orig_type' => 'article', - ), - ); - $this->databaseContents['field_config_instance'] = array( - array( + ], + ]; + $this->databaseContents['field_config_instance'] = [ + [ 'id' => '14', 'field_id' => '1', 'field_name' => 'comment_body', @@ -64,34 +64,34 @@ protected function setUp() { 'bundle' => 'comment_node_article', 'data' => 'a:0:{}', 'deleted' => '0', - ), - ); - $this->databaseContents['variable'] = array( - array( + ], + ]; + $this->databaseContents['variable'] = [ + [ 'name' => 'comment_default_mode_article', 'value' => serialize(1), - ), - array( + ], + [ 'name' => 'comment_per_page_article', 'value' => serialize(50), - ), - array( + ], + [ 'name' => 'comment_anonymous_article', 'value' => serialize(0), - ), - array( + ], + [ 'name' => 'comment_form_location_article', 'value' => serialize(1), - ), - array( + ], + [ 'name' => 'comment_preview_article', 'value' => serialize(0), - ), - array( + ], + [ 'name' => 'comment_subject_article', 'value' => serialize(1), - ), - ); + ], + ]; parent::setUp(); } diff --git a/core/modules/config/config.module b/core/modules/config/config.module index 4f31e08..2327f98 100644 --- a/core/modules/config/config.module +++ b/core/modules/config/config.module @@ -15,19 +15,19 @@ function config_help($route_name, RouteMatchInterface $route_match) { case 'help.page.config': $output = ''; $output .= '

        ' . t('About') . '

        '; - $output .= '

        ' . t('The Configuration Manager module provides a user interface for importing and exporting configuration changes between installations of your website in different environments. Configuration is stored in YAML format. For more information, see the online documentation for the Configuration Manager module.', array(':url' => 'https://www.drupal.org/documentation/administer/config')) . '

        '; + $output .= '

        ' . t('The Configuration Manager module provides a user interface for importing and exporting configuration changes between installations of your website in different environments. Configuration is stored in YAML format. For more information, see the online documentation for the Configuration Manager module.', [':url' => 'https://www.drupal.org/documentation/administer/config']) . '

        '; $output .= '

        ' . t('Uses') . '

        '; $output .= '
        '; $output .= '
        ' . t('Exporting the full configuration') . '
        '; - $output .= '
        ' . t('You can create and download an archive consisting of all your site\'s configuration exported as *.yml files on the Export page.', array(':url' => \Drupal::url('config.export_full'))) . '
        '; + $output .= '
        ' . t('You can create and download an archive consisting of all your site\'s configuration exported as *.yml files on the Export page.', [':url' => \Drupal::url('config.export_full')]) . '
        '; $output .= '
        ' . t('Importing a full configuration') . '
        '; - $output .= '
        ' . t('You can upload a full site configuration from an archive file on the Import page. When importing data from a different environment, the site and import files must have matching configuration values for UUID in the system.site configuration item. That means that your other environments should initially be set up as clones of the target site. Migrations are not supported.', array(':url' => \Drupal::url('config.import_full'))) . '
        '; + $output .= '
        ' . t('You can upload a full site configuration from an archive file on the Import page. When importing data from a different environment, the site and import files must have matching configuration values for UUID in the system.site configuration item. That means that your other environments should initially be set up as clones of the target site. Migrations are not supported.', [':url' => \Drupal::url('config.import_full')]) . '
        '; $output .= '
        ' . t('Synchronizing configuration') . '
        '; - $output .= '
        ' . t('You can review differences between the active configuration and an imported configuration archive on the Synchronize page to ensure that the changes are as expected, before finalizing the import. The Synchronize page also shows configuration items that would be added or removed.', array(':synchronize' => \Drupal::url('config.sync'))) . '
        '; + $output .= '
        ' . t('You can review differences between the active configuration and an imported configuration archive on the Synchronize page to ensure that the changes are as expected, before finalizing the import. The Synchronize page also shows configuration items that would be added or removed.', [':synchronize' => \Drupal::url('config.sync')]) . '
        '; $output .= '
        ' . t('Exporting a single configuration item') . '
        '; - $output .= '
        ' . t('You can export a single configuration item by selecting a Configuration type and Configuration name on the Single export page. The configuration and its corresponding *.yml file name are then displayed on the page for you to copy.', array(':single-export' => \Drupal::url('config.export_single'))) . '
        '; + $output .= '
        ' . t('You can export a single configuration item by selecting a Configuration type and Configuration name on the Single export page. The configuration and its corresponding *.yml file name are then displayed on the page for you to copy.', [':single-export' => \Drupal::url('config.export_single')]) . '
        '; $output .= '
        ' . t('Importing a single configuration item') . '
        '; - $output .= '
        ' . t('You can import a single configuration item by pasting it in YAML format into the form on the Single import page.', array(':single-import' => \Drupal::url('config.import_single'))) . '
        '; + $output .= '
        ' . t('You can import a single configuration item by pasting it in YAML format into the form on the Single import page.', [':single-import' => \Drupal::url('config.import_single')]) . '
        '; $output .= '
        '; return $output; @@ -71,8 +71,8 @@ function config_file_download($uri) { $hostname = str_replace('.', '-', $request->getHttpHost()); $filename = 'config' . '-' . $hostname . '-' . $date_string . '.tar.gz'; $disposition = 'attachment; filename="' . $filename . '"'; - return array( + return [ 'Content-disposition' => $disposition, - ); + ]; } } diff --git a/core/modules/config/src/ConfigSubscriber.php b/core/modules/config/src/ConfigSubscriber.php index 9b6c842..aebc86e 100644 --- a/core/modules/config/src/ConfigSubscriber.php +++ b/core/modules/config/src/ConfigSubscriber.php @@ -30,7 +30,7 @@ public function onConfigImporterValidate(ConfigImporterEvent $event) { * {@inheritdoc} */ static function getSubscribedEvents() { - $events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidate', 20); + $events[ConfigEvents::IMPORT_VALIDATE][] = ['onConfigImporterValidate', 20]; return $events; } diff --git a/core/modules/config/src/Controller/ConfigController.php b/core/modules/config/src/Controller/ConfigController.php index 8b9dc25..bf47f72 100644 --- a/core/modules/config/src/Controller/ConfigController.php +++ b/core/modules/config/src/Controller/ConfigController.php @@ -103,7 +103,7 @@ public function downloadExport() { } } - $request = new Request(array('file' => 'config.tar.gz')); + $request = new Request(['file' => 'config.tar.gz']); return $this->fileDownloadController->download($request, 'temporary'); } @@ -129,34 +129,34 @@ public function diff($source_name, $target_name = NULL, $collection = NULL) { $diff = $this->configManager->diff($this->targetStorage, $this->sourceStorage, $source_name, $target_name, $collection); $this->diffFormatter->show_header = FALSE; - $build = array(); + $build = []; - $build['#title'] = t('View changes of @config_file', array('@config_file' => $source_name)); + $build['#title'] = t('View changes of @config_file', ['@config_file' => $source_name]); // Add the CSS for the inline diff. $build['#attached']['library'][] = 'system/diff'; - $build['diff'] = array( + $build['diff'] = [ '#type' => 'table', - '#attributes' => array( - 'class' => array('diff'), - ), - '#header' => array( - array('data' => t('Active'), 'colspan' => '2'), - array('data' => t('Staged'), 'colspan' => '2'), - ), + '#attributes' => [ + 'class' => ['diff'], + ], + '#header' => [ + ['data' => t('Active'), 'colspan' => '2'], + ['data' => t('Staged'), 'colspan' => '2'], + ], '#rows' => $this->diffFormatter->format($diff), - ); + ]; - $build['back'] = array( + $build['back'] = [ '#type' => 'link', - '#attributes' => array( - 'class' => array( + '#attributes' => [ + 'class' => [ 'dialog-cancel', - ), - ), + ], + ], '#title' => "Back to 'Synchronize configuration' page.", '#url' => Url::fromRoute('config.sync'), - ); + ]; return $build; } diff --git a/core/modules/config/src/Form/ConfigExportForm.php b/core/modules/config/src/Form/ConfigExportForm.php index 0da43ff..e822f7f 100644 --- a/core/modules/config/src/Form/ConfigExportForm.php +++ b/core/modules/config/src/Form/ConfigExportForm.php @@ -21,10 +21,10 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $form['submit'] = array( + $form['submit'] = [ '#type' => 'submit', '#value' => $this->t('Export'), - ); + ]; return $form; } diff --git a/core/modules/config/src/Form/ConfigImportForm.php b/core/modules/config/src/Form/ConfigImportForm.php index 1d651d8..0c3def8 100644 --- a/core/modules/config/src/Form/ConfigImportForm.php +++ b/core/modules/config/src/Form/ConfigImportForm.php @@ -55,17 +55,17 @@ public function buildForm(array $form, FormStateInterface $form_state) { if (!$directory_is_writable) { drupal_set_message($this->t('The directory %directory is not writable.', ['%directory' => $directory]), 'error'); } - $form['import_tarball'] = array( + $form['import_tarball'] = [ '#type' => 'file', '#title' => $this->t('Configuration archive'), - '#description' => $this->t('Allowed types: @extensions.', array('@extensions' => 'tar.gz tgz tar.bz2')), - ); + '#description' => $this->t('Allowed types: @extensions.', ['@extensions' => 'tar.gz tgz tar.bz2']), + ]; - $form['submit'] = array( + $form['submit'] = [ '#type' => 'submit', '#value' => $this->t('Upload'), '#disabled' => !$directory_is_writable, - ); + ]; return $form; } @@ -93,7 +93,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->configStorage->deleteAll(); try { $archiver = new ArchiveTar($path, 'gz'); - $files = array(); + $files = []; foreach ($archiver->listContent() as $file) { $files[] = $file['filename']; } @@ -102,7 +102,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $form_state->setRedirect('config.sync'); } catch (\Exception $e) { - drupal_set_message($this->t('Could not extract the contents of the tar file. The error message is @message', array('@message' => $e->getMessage())), 'error'); + drupal_set_message($this->t('Could not extract the contents of the tar file. The error message is @message', ['@message' => $e->getMessage()]), 'error'); } drupal_unlink($path); } diff --git a/core/modules/config/src/Form/ConfigSingleExportForm.php b/core/modules/config/src/Form/ConfigSingleExportForm.php index 9df8069..25e7fb9 100644 --- a/core/modules/config/src/Form/ConfigSingleExportForm.php +++ b/core/modules/config/src/Form/ConfigSingleExportForm.php @@ -36,7 +36,7 @@ class ConfigSingleExportForm extends FormBase { * * @var \Drupal\Core\Entity\EntityTypeInterface[] */ - protected $definitions = array(); + protected $definitions = []; /** * Constructs a new ConfigSingleImportForm. @@ -82,40 +82,40 @@ public function buildForm(array $form, FormStateInterface $form_state, $config_t }, $this->definitions); // Sort the entity types by label, then add the simple config to the top. uasort($entity_types, 'strnatcasecmp'); - $config_types = array( + $config_types = [ 'system.simple' => $this->t('Simple configuration'), - ) + $entity_types; - $form['config_type'] = array( + ] + $entity_types; + $form['config_type'] = [ '#title' => $this->t('Configuration type'), '#type' => 'select', '#options' => $config_types, '#default_value' => $config_type, - '#ajax' => array( + '#ajax' => [ 'callback' => '::updateConfigurationType', 'wrapper' => 'edit-config-type-wrapper', - ), - ); + ], + ]; $default_type = $form_state->getValue('config_type', $config_type); - $form['config_name'] = array( + $form['config_name'] = [ '#title' => $this->t('Configuration name'), '#type' => 'select', '#options' => $this->findConfiguration($default_type), '#default_value' => $config_name, '#prefix' => '
        ', '#suffix' => '
        ', - '#ajax' => array( + '#ajax' => [ 'callback' => '::updateExport', 'wrapper' => 'edit-export-wrapper', - ), - ); + ], + ]; - $form['export'] = array( + $form['export'] = [ '#title' => $this->t('Here is your configuration:'), '#type' => 'textarea', '#rows' => 24, '#prefix' => '
        ', '#suffix' => '
        ', - ); + ]; if ($config_type && $config_name) { $fake_form_state = (new FormState())->setValues([ 'config_type' => $config_type, @@ -149,7 +149,7 @@ public function updateExport($form, FormStateInterface $form_state) { } // Read the raw data for this config name, encode it, and display it. $form['export']['#value'] = Yaml::encode($this->configStorage->read($name)); - $form['export']['#description'] = $this->t('Filename: %name', array('%name' => $name . '.yml')); + $form['export']['#description'] = $this->t('Filename: %name', ['%name' => $name . '.yml']); return $form['export']; } @@ -157,9 +157,9 @@ public function updateExport($form, FormStateInterface $form_state) { * Handles switching the configuration type selector. */ protected function findConfiguration($config_type) { - $names = array( + $names = [ '' => $this->t('- Select -'), - ); + ]; // For a given entity type, load all entities. if ($config_type && $config_type !== 'system.simple') { $entity_storage = $this->entityManager->getStorage($config_type); diff --git a/core/modules/config/src/Form/ConfigSingleImportForm.php b/core/modules/config/src/Form/ConfigSingleImportForm.php index 1393906..0255b16 100644 --- a/core/modules/config/src/Form/ConfigSingleImportForm.php +++ b/core/modules/config/src/Form/ConfigSingleImportForm.php @@ -110,7 +110,7 @@ class ConfigSingleImportForm extends ConfirmFormBase { * * @var array */ - protected $data = array(); + protected $data = []; /** * Constructs a new ConfigSingleImportForm. @@ -197,10 +197,10 @@ public function getQuestion() { $type = $definition->getLowercaseLabel(); } - $args = array( + $args = [ '%name' => $name, '@type' => strtolower($type), - ); + ]; if ($this->configExists) { $question = $this->t('Are you sure you want to update the %name @type?', $args); } @@ -219,7 +219,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { return parent::buildForm($form, $form_state); } - $entity_types = array(); + $entity_types = []; foreach ($this->entityManager->getDefinitions() as $entity_type => $definition) { if ($definition->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface')) { $entity_types[$entity_type] = $definition->getLabel(); @@ -227,49 +227,49 @@ public function buildForm(array $form, FormStateInterface $form_state) { } // Sort the entity types by label, then add the simple config to the top. uasort($entity_types, 'strnatcasecmp'); - $config_types = array( + $config_types = [ 'system.simple' => $this->t('Simple configuration'), - ) + $entity_types; - $form['config_type'] = array( + ] + $entity_types; + $form['config_type'] = [ '#title' => $this->t('Configuration type'), '#type' => 'select', '#options' => $config_types, '#required' => TRUE, - ); - $form['config_name'] = array( + ]; + $form['config_name'] = [ '#title' => $this->t('Configuration name'), '#description' => $this->t('Enter the name of the configuration file without the .yml extension. (e.g. system.site)'), '#type' => 'textfield', - '#states' => array( - 'required' => array( - ':input[name="config_type"]' => array('value' => 'system.simple'), - ), - 'visible' => array( - ':input[name="config_type"]' => array('value' => 'system.simple'), - ), - ), - ); - $form['import'] = array( + '#states' => [ + 'required' => [ + ':input[name="config_type"]' => ['value' => 'system.simple'], + ], + 'visible' => [ + ':input[name="config_type"]' => ['value' => 'system.simple'], + ], + ], + ]; + $form['import'] = [ '#title' => $this->t('Paste your configuration here'), '#type' => 'textarea', '#rows' => 24, '#required' => TRUE, - ); - $form['advanced'] = array( + ]; + $form['advanced'] = [ '#type' => 'details', '#title' => $this->t('Advanced'), - ); - $form['advanced']['custom_entity_id'] = array( + ]; + $form['advanced']['custom_entity_id'] = [ '#title' => $this->t('Custom Entity ID'), '#type' => 'textfield', '#description' => $this->t('Specify a custom entity ID. This will override the entity ID in the configuration above.'), - ); - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( + ]; + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Import'), '#button_type' => 'primary', - ); + ]; return $form; } @@ -304,7 +304,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { $entity_storage = $this->entityManager->getStorage($form_state->getValue('config_type')); // If an entity ID was not specified, set an error. if (!isset($data[$id_key])) { - $form_state->setErrorByName('import', $this->t('Missing ID key "@id_key" for this @entity_type import.', array('@id_key' => $id_key, '@entity_type' => $definition->getLabel()))); + $form_state->setErrorByName('import', $this->t('Missing ID key "@id_key" for this @entity_type import.', ['@id_key' => $id_key, '@entity_type' => $definition->getLabel()])); return; } @@ -322,7 +322,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { } } // If there is no entity with a matching ID, check for a UUID match. - elseif (isset($data['uuid']) && $entity_storage->loadByProperties(array('uuid' => $data['uuid']))) { + elseif (isset($data['uuid']) && $entity_storage->loadByProperties(['uuid' => $data['uuid']])) { $form_state->setErrorByName('import', $this->t('An entity with this UUID already exists but the machine name does not match.')); } } diff --git a/core/modules/config/src/Form/ConfigSync.php b/core/modules/config/src/Form/ConfigSync.php index 8dd9ca0..cc3c04b 100644 --- a/core/modules/config/src/Form/ConfigSync.php +++ b/core/modules/config/src/Form/ConfigSync.php @@ -171,20 +171,20 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Import all'), - ); + ]; $source_list = $this->syncStorage->listAll(); $storage_comparer = new StorageComparer($this->syncStorage, $this->activeStorage, $this->configManager); if (empty($source_list) || !$storage_comparer->createChangelist()->hasChanges()) { - $form['no_changes'] = array( + $form['no_changes'] = [ '#type' => 'table', - '#header' => array($this->t('Name'), $this->t('Operations')), - '#rows' => array(), + '#header' => [$this->t('Name'), $this->t('Operations')], + '#rows' => [], '#empty' => $this->t('There are no configuration changes to import.'), - ); + ]; $form['actions']['#access'] = FALSE; return $form; } @@ -198,7 +198,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { if ($this->snapshotStorage->exists('core.extension')) { $snapshot_comparer = new StorageComparer($this->activeStorage, $this->snapshotStorage, $this->configManager); if (!$form_state->getUserInput() && $snapshot_comparer->createChangelist()->hasChanges()) { - $change_list = array(); + $change_list = []; foreach ($snapshot_comparer->getAllCollectionNames() as $collection) { foreach ($snapshot_comparer->getChangelist(NULL, $collection) as $config_names) { if (empty($config_names)) { @@ -231,11 +231,11 @@ public function buildForm(array $form, FormStateInterface $form_state) { foreach ($storage_comparer->getAllCollectionNames() as $collection) { if ($collection != StorageInterface::DEFAULT_COLLECTION) { - $form[$collection]['collection_heading'] = array( + $form[$collection]['collection_heading'] = [ '#type' => 'html_tag', '#tag' => 'h2', - '#value' => $this->t('@collection configuration collection', array('@collection' => $collection)), - ); + '#value' => $this->t('@collection configuration collection', ['@collection' => $collection]), + ]; } foreach ($storage_comparer->getChangelist(NULL, $collection) as $config_change_type => $config_names) { if (empty($config_names)) { @@ -244,10 +244,10 @@ public function buildForm(array $form, FormStateInterface $form_state) { // @todo A table caption would be more appropriate, but does not have the // visual importance of a heading. - $form[$collection][$config_change_type]['heading'] = array( + $form[$collection][$config_change_type]['heading'] = [ '#type' => 'html_tag', '#tag' => 'h3', - ); + ]; switch ($config_change_type) { case 'create': $form[$collection][$config_change_type]['heading']['#value'] = $this->formatPlural(count($config_names), '@count new', '@count new'); @@ -265,19 +265,19 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form[$collection][$config_change_type]['heading']['#value'] = $this->formatPlural(count($config_names), '@count renamed', '@count renamed'); break; } - $form[$collection][$config_change_type]['list'] = array( + $form[$collection][$config_change_type]['list'] = [ '#type' => 'table', - '#header' => array($this->t('Name'), $this->t('Operations')), - ); + '#header' => [$this->t('Name'), $this->t('Operations')], + ]; foreach ($config_names as $config_name) { if ($config_change_type == 'rename') { $names = $storage_comparer->extractRenameNames($config_name); - $route_options = array('source_name' => $names['old_name'], 'target_name' => $names['new_name']); - $config_name = $this->t('@source_name to @target_name', array('@source_name' => $names['old_name'], '@target_name' => $names['new_name'])); + $route_options = ['source_name' => $names['old_name'], 'target_name' => $names['new_name']]; + $config_name = $this->t('@source_name to @target_name', ['@source_name' => $names['old_name'], '@target_name' => $names['new_name']]); } else { - $route_options = array('source_name' => $config_name); + $route_options = ['source_name' => $config_name]; } if ($collection != StorageInterface::DEFAULT_COLLECTION) { $route_name = 'config.diff_collection'; @@ -286,26 +286,26 @@ public function buildForm(array $form, FormStateInterface $form_state) { else { $route_name = 'config.diff'; } - $links['view_diff'] = array( + $links['view_diff'] = [ 'title' => $this->t('View differences'), 'url' => Url::fromRoute($route_name, $route_options), - 'attributes' => array( - 'class' => array('use-ajax'), + 'attributes' => [ + 'class' => ['use-ajax'], 'data-dialog-type' => 'modal', - 'data-dialog-options' => json_encode(array( + 'data-dialog-options' => json_encode([ 'width' => 700 - )), - ), - ); - $form[$collection][$config_change_type]['list']['#rows'][] = array( + ]), + ], + ]; + $form[$collection][$config_change_type]['list']['#rows'][] = [ 'name' => $config_name, - 'operations' => array( - 'data' => array( + 'operations' => [ + 'data' => [ '#type' => 'operations', '#links' => $links, - ), - ), - ); + ], + ], + ]; } } } @@ -333,17 +333,17 @@ public function submitForm(array &$form, FormStateInterface $form_state) { else { try { $sync_steps = $config_importer->initialize(); - $batch = array( - 'operations' => array(), - 'finished' => array(get_class($this), 'finishBatch'), + $batch = [ + 'operations' => [], + 'finished' => [get_class($this), 'finishBatch'], 'title' => t('Synchronizing configuration'), 'init_message' => t('Starting configuration synchronization.'), 'progress_message' => t('Completed step @current of @total.'), 'error_message' => t('Configuration synchronization has encountered an error.'), 'file' => __DIR__ . '/../../config.admin.inc', - ); + ]; foreach ($sync_steps as $sync_step) { - $batch['operations'][] = array(array(get_class($this), 'processBatch'), array($config_importer, $sync_step)); + $batch['operations'][] = [[get_class($this), 'processBatch'], [$config_importer, $sync_step]]; } batch_set($batch); @@ -377,7 +377,7 @@ public static function processBatch(ConfigImporter $config_importer, $sync_step, $config_importer->doSyncStep($sync_step, $context); if ($errors = $config_importer->getErrors()) { if (!isset($context['results']['errors'])) { - $context['results']['errors'] = array(); + $context['results']['errors'] = []; } $context['results']['errors'] += $errors; } @@ -406,7 +406,7 @@ public static function finishBatch($success, $results, $operations) { // An error occurred. // $operations contains the operations that remained unprocessed. $error_operation = reset($operations); - $message = \Drupal::translation()->translate('An error occurred while processing %error_operation with arguments: @arguments', array('%error_operation' => $error_operation[0], '@arguments' => print_r($error_operation[1], TRUE))); + $message = \Drupal::translation()->translate('An error occurred while processing %error_operation with arguments: @arguments', ['%error_operation' => $error_operation[0], '@arguments' => print_r($error_operation[1], TRUE)]); drupal_set_message($message, 'error'); } } diff --git a/core/modules/config/src/Tests/ConfigDependencyWebTest.php b/core/modules/config/src/Tests/ConfigDependencyWebTest.php index 5eb5206..037e9c5 100644 --- a/core/modules/config/src/Tests/ConfigDependencyWebTest.php +++ b/core/modules/config/src/Tests/ConfigDependencyWebTest.php @@ -22,7 +22,7 @@ class ConfigDependencyWebTest extends WebTestBase { * * @var array */ - public static $modules = array('config_test'); + public static $modules = ['config_test']; /** * Tests ConfigDependencyDeleteFormTrait. @@ -36,10 +36,10 @@ function testConfigDependencyDeleteFormTrait() { $storage = $this->container->get('entity.manager')->getStorage('config_test'); // Entity1 will be deleted by the test. $entity1 = $storage->create( - array( + [ 'id' => 'entity1', 'label' => 'Entity One', - ) + ] ); $entity1->save(); @@ -47,14 +47,14 @@ function testConfigDependencyDeleteFormTrait() { // \Drupal\config_test\Entity::onDependencyRemoval() will remove the // dependency before config entities are deleted. $entity2 = $storage->create( - array( + [ 'id' => 'entity2', - 'dependencies' => array( - 'enforced' => array( - 'config' => array($entity1->getConfigDependencyName()), - ), - ), - ) + 'dependencies' => [ + 'enforced' => [ + 'config' => [$entity1->getConfigDependencyName()], + ], + ], + ] ); $entity2->save(); @@ -65,47 +65,47 @@ function testConfigDependencyDeleteFormTrait() { $this->assertNoText(t('Configuration updates'), 'No configuration updates found.'); $this->assertText(t('Configuration deletions'), 'Configuration deletions found.'); $this->assertText($entity2->id(), 'Entity2 id found'); - $this->drupalPostForm($entity1->urlInfo('delete-form'), array(), 'Delete'); + $this->drupalPostForm($entity1->urlInfo('delete-form'), [], 'Delete'); $storage->resetCache(); $this->assertFalse($storage->loadMultiple([$entity1->id(), $entity2->id()]), 'Test entities deleted'); // Set a more complicated test where dependencies will be fixed. // Entity1 will be deleted by the test. $entity1 = $storage->create( - array( + [ 'id' => 'entity1', - ) + ] ); $entity1->save(); - \Drupal::state()->set('config_test.fix_dependencies', array($entity1->getConfigDependencyName())); + \Drupal::state()->set('config_test.fix_dependencies', [$entity1->getConfigDependencyName()]); // Entity2 has a dependency on Entity1 but it can be fixed because // \Drupal\config_test\Entity::onDependencyRemoval() will remove the // dependency before config entities are deleted. $entity2 = $storage->create( - array( + [ 'id' => 'entity2', 'label' => 'Entity Two', - 'dependencies' => array( - 'enforced' => array( - 'config' => array($entity1->getConfigDependencyName()), - ), - ), - ) + 'dependencies' => [ + 'enforced' => [ + 'config' => [$entity1->getConfigDependencyName()], + ], + ], + ] ); $entity2->save(); // Entity3 will be unchanged because it is dependent on Entity2 which can // be fixed. $entity3 = $storage->create( - array( + [ 'id' => 'entity3', - 'dependencies' => array( - 'enforced' => array( - 'config' => array($entity2->getConfigDependencyName()), - ), - ), - ) + 'dependencies' => [ + 'enforced' => [ + 'config' => [$entity2->getConfigDependencyName()], + ], + ], + ] ); $entity3->save(); @@ -115,12 +115,12 @@ function testConfigDependencyDeleteFormTrait() { $this->assertNoText($entity2->id(), 'Entity2 id not found'); $this->assertText($entity2->label(), 'Entity2 label not found'); $this->assertNoText($entity3->id(), 'Entity3 id not found'); - $this->drupalPostForm($entity1->urlInfo('delete-form'), array(), 'Delete'); + $this->drupalPostForm($entity1->urlInfo('delete-form'), [], 'Delete'); $storage->resetCache(); $this->assertFalse($storage->load('entity1'), 'Test entity 1 deleted'); $entity2 = $storage->load('entity2'); $this->assertTrue($entity2, 'Entity 2 not deleted'); - $this->assertEqual($entity2->calculateDependencies()->getDependencies()['config'], array(), 'Entity 2 dependencies updated to remove dependency on Entity1.'); + $this->assertEqual($entity2->calculateDependencies()->getDependencies()['config'], [], 'Entity 2 dependencies updated to remove dependency on Entity1.'); $entity3 = $storage->load('entity3'); $this->assertTrue($entity3, 'Entity 3 not deleted'); $this->assertEqual($entity3->calculateDependencies()->getDependencies()['config'], [$entity2->getConfigDependencyName()], 'Entity 3 still depends on Entity 2.'); diff --git a/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php b/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php index 92693c4..41419b0 100644 --- a/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php +++ b/core/modules/config/src/Tests/ConfigEntityFormOverrideTest.php @@ -14,7 +14,7 @@ class ConfigEntityFormOverrideTest extends WebTestBase { /** * {@inheritdoc} */ - public static $modules = array('config_test'); + public static $modules = ['config_test']; /** * Tests that overrides do not affect forms or listing screens. @@ -29,10 +29,10 @@ public function testFormsWithOverrides() { $config_test_storage = $this->container->get('entity.manager')->getStorage('config_test'); // Set up an override. - $settings['config']['config_test.dynamic.dotted.default']['label'] = (object) array( + $settings['config']['config_test.dynamic.dotted.default']['label'] = (object) [ 'value' => $overridden_label, 'required' => TRUE, - ); + ]; $this->writeSettings($settings); // Test that the overridden label is loaded with the entity. @@ -50,9 +50,9 @@ public function testFormsWithOverrides() { $this->assertNoText($overridden_label); // Change to a new label and test that the listing now has the edited label. - $edit = array( + $edit = [ 'label' => $edited_label, - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); $this->drupalGet('admin/structure/config_test'); $this->assertNoText($overridden_label); diff --git a/core/modules/config/src/Tests/ConfigEntityListMultilingualTest.php b/core/modules/config/src/Tests/ConfigEntityListMultilingualTest.php index f5c12d8..a019ca8 100644 --- a/core/modules/config/src/Tests/ConfigEntityListMultilingualTest.php +++ b/core/modules/config/src/Tests/ConfigEntityListMultilingualTest.php @@ -17,7 +17,7 @@ class ConfigEntityListMultilingualTest extends WebTestBase { * * @var array */ - public static $modules = array('config_test', 'language', 'block'); + public static $modules = ['config_test', 'language', 'block']; /** * {@inheritdoc} @@ -36,7 +36,7 @@ protected function setUp() { */ function testListUI() { // Log in as an administrative user to access the full menu trail. - $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer site configuration'))); + $this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration'])); // Get the list page. $this->drupalGet('admin/structure/config_test'); @@ -44,11 +44,11 @@ function testListUI() { // Add a new entity using the action link. $this->clickLink('Add test configuration'); - $edit = array( + $edit = [ 'label' => 'Antilop', 'id' => 'antilop', 'langcode' => 'hu', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); // Ensure that operations for editing the Hungarian entity appear in English. $this->assertLinkByHref('admin/structure/config_test/manage/antilop'); diff --git a/core/modules/config/src/Tests/ConfigEntityListTest.php b/core/modules/config/src/Tests/ConfigEntityListTest.php index 9d31de0..161944b 100644 --- a/core/modules/config/src/Tests/ConfigEntityListTest.php +++ b/core/modules/config/src/Tests/ConfigEntityListTest.php @@ -50,71 +50,71 @@ function testList() { $this->assertTrue($entity instanceof ConfigTest, '"Default" ConfigTest entity is an instance of ConfigTest.'); // Test getOperations() method. - $expected_operations = array( - 'edit' => array ( + $expected_operations = [ + 'edit' => [ 'title' => t('Edit'), 'weight' => 10, 'url' => $entity->urlInfo(), - ), - 'disable' => array( + ], + 'disable' => [ 'title' => t('Disable'), 'weight' => 40, 'url' => $entity->urlInfo('disable'), - ), - 'delete' => array ( + ], + 'delete' => [ 'title' => t('Delete'), 'weight' => 100, 'url' => $entity->urlInfo('delete-form'), - ), - ); + ], + ]; $actual_operations = $controller->getOperations($entity); // Sort the operations to normalize link order. - uasort($actual_operations, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); + uasort($actual_operations, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']); $this->assertEqual($expected_operations, $actual_operations, 'The operations are identical.'); // Test buildHeader() method. - $expected_items = array( + $expected_items = [ 'label' => 'Label', 'id' => 'Machine name', 'operations' => 'Operations', - ); + ]; $actual_items = $controller->buildHeader(); $this->assertEqual($expected_items, $actual_items, 'Return value from buildHeader matches expected.'); // Test buildRow() method. $build_operations = $controller->buildOperations($entity); - $expected_items = array( + $expected_items = [ 'label' => 'Default', 'id' => 'dotted.default', - 'operations' => array( + 'operations' => [ 'data' => $build_operations, - ), - ); + ], + ]; $actual_items = $controller->buildRow($entity); $this->assertEqual($expected_items, $actual_items, 'Return value from buildRow matches expected.'); // Test sorting. $storage = $controller->getStorage(); - $entity = $storage->create(array( + $entity = $storage->create([ 'id' => 'alpha', 'label' => 'Alpha', 'weight' => 1, - )); + ]); $entity->save(); - $entity = $storage->create(array( + $entity = $storage->create([ 'id' => 'omega', 'label' => 'Omega', 'weight' => 1, - )); + ]); $entity->save(); - $entity = $storage->create(array( + $entity = $storage->create([ 'id' => 'beta', 'label' => 'Beta', 'weight' => 0, - )); + ]); $entity->save(); $list = $controller->load(); - $this->assertIdentical(array_keys($list), array('beta', 'dotted.default', 'alpha', 'omega')); + $this->assertIdentical(array_keys($list), ['beta', 'dotted.default', 'alpha', 'omega']); // Test that config entities that do not support status, do not have // enable/disable operations. @@ -125,22 +125,22 @@ function testList() { $entity = $list['default']; // Test getOperations() method. - $expected_operations = array( - 'edit' => array( + $expected_operations = [ + 'edit' => [ 'title' => t('Edit'), 'weight' => 10, 'url' => $entity->urlInfo(), - ), - 'delete' => array( + ], + 'delete' => [ 'title' => t('Delete'), 'weight' => 100, 'url' => $entity->urlInfo('delete-form'), - ), - ); + ], + ]; $actual_operations = $controller->getOperations($entity); // Sort the operations to normalize link order. - uasort($actual_operations, array('Drupal\Component\Utility\SortArray', 'sortByWeightElement')); + uasort($actual_operations, ['Drupal\Component\Utility\SortArray', 'sortByWeightElement']); $this->assertEqual($expected_operations, $actual_operations, 'The operations are identical.'); } @@ -149,7 +149,7 @@ function testList() { */ function testListUI() { // Log in as an administrative user to access the full menu trail. - $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer site configuration'))); + $this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration'])); // Get the list callback page. $this->drupalGet('admin/structure/config_test'); @@ -166,7 +166,7 @@ function testListUI() { $this->assertEqual(count($elements), 3, 'Correct number of table header cells found.'); // Test the contents of each th cell. - $expected_items = array('Label', 'Machine name', 'Operations'); + $expected_items = ['Label', 'Machine name', 'Operations']; foreach ($elements as $key => $element) { $this->assertIdentical((string) $element[0], $expected_items[$key]); } @@ -186,11 +186,11 @@ function testListUI() { $this->assertLink('Add test configuration'); $this->clickLink('Add test configuration'); $this->assertResponse(200); - $edit = array( + $edit = [ 'label' => 'Antelope', 'id' => 'antelope', 'weight' => 1, - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); // Ensure that the entity's sort method was called. @@ -207,7 +207,7 @@ function testListUI() { $this->clickLink('Edit', 1); $this->assertResponse(200); $this->assertTitle('Edit Antelope | Drupal'); - $edit = array('label' => 'Albatross', 'id' => 'albatross'); + $edit = ['label' => 'Albatross', 'id' => 'albatross']; $this->drupalPostForm(NULL, $edit, t('Save')); // Confirm that the user is returned to the listing, and verify that the @@ -221,7 +221,7 @@ function testListUI() { $this->clickLink('Delete', 1); $this->assertResponse(200); $this->assertTitle('Are you sure you want to delete the test configuration Albatross? | Drupal'); - $this->drupalPostForm(NULL, array(), t('Delete')); + $this->drupalPostForm(NULL, [], t('Delete')); // Verify that the text of the label and machine name does not appear in // the list (though it may appear elsewhere on the page). @@ -232,7 +232,7 @@ function testListUI() { $this->clickLink('Delete'); $this->assertResponse(200); $this->assertTitle('Are you sure you want to delete the test configuration Default? | Drupal'); - $this->drupalPostForm(NULL, array(), t('Delete')); + $this->drupalPostForm(NULL, [], t('Delete')); // Verify that the text of the label and machine name does not appear in // the list (though it may appear elsewhere on the page). @@ -253,12 +253,12 @@ public function testPager() { // Create 51 test entities. for ($i = 1; $i < 52; $i++) { - $storage->create(array( + $storage->create([ 'id' => str_pad($i, 2, '0', STR_PAD_LEFT), 'label' => 'Test config entity ' . $i, 'weight' => $i, 'protected_property' => $i, - ))->save(); + ])->save(); } // Load the listing page. diff --git a/core/modules/config/src/Tests/ConfigEntityStatusUITest.php b/core/modules/config/src/Tests/ConfigEntityStatusUITest.php index 95dd9da..eed0efa 100644 --- a/core/modules/config/src/Tests/ConfigEntityStatusUITest.php +++ b/core/modules/config/src/Tests/ConfigEntityStatusUITest.php @@ -16,7 +16,7 @@ class ConfigEntityStatusUITest extends WebTestBase { * * @var array */ - public static $modules = array('config_test'); + public static $modules = ['config_test']; /** * Tests status operations. @@ -25,10 +25,10 @@ function testCRUD() { $this->drupalLogin($this->drupalCreateUser(['administer site configuration'])); $id = strtolower($this->randomMachineName()); - $edit = array( + $edit = [ 'id' => $id, 'label' => $this->randomMachineName(), - ); + ]; $this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save'); $entity = entity_load('config_test', $id); diff --git a/core/modules/config/src/Tests/ConfigEntityTest.php b/core/modules/config/src/Tests/ConfigEntityTest.php index a8a8f0f..77b35cc 100644 --- a/core/modules/config/src/Tests/ConfigEntityTest.php +++ b/core/modules/config/src/Tests/ConfigEntityTest.php @@ -27,7 +27,7 @@ class ConfigEntityTest extends WebTestBase { * * @var array */ - public static $modules = array('config_test'); + public static $modules = ['config_test']; /** * Tests CRUD operations. @@ -76,9 +76,9 @@ function testCRUD() { } // Verify that an entity with an empty ID string is considered empty, too. - $empty_id = entity_create('config_test', array( + $empty_id = entity_create('config_test', [ 'id' => '', - )); + ]); $this->assertIdentical($empty_id->isNew(), TRUE); try { $empty_id->save(); @@ -89,11 +89,11 @@ function testCRUD() { } // Verify properties on a newly created entity. - $config_test = entity_create('config_test', $expected = array( + $config_test = entity_create('config_test', $expected = [ 'id' => $this->randomMachineName(), 'label' => $this->randomString(), 'style' => $this->randomMachineName(), - )); + ]); $this->assertTrue($config_test->uuid()); $this->assertNotEqual($config_test->uuid(), $empty->uuid()); $this->assertIdentical($config_test->label, $expected['label']); @@ -141,13 +141,13 @@ function testCRUD() { // maximum allowed length, but not longer. // Test with a short ID. - $id_length_config_test = entity_create('config_test', array( + $id_length_config_test = entity_create('config_test', [ 'id' => $this->randomMachineName(8), - )); + ]); try { $id_length_config_test->save(); - $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", array( - '@length' => strlen($id_length_config_test->id())) + $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", [ + '@length' => strlen($id_length_config_test->id())] )); } catch (ConfigEntityIdLengthException $e) { @@ -155,42 +155,42 @@ function testCRUD() { } // Test with an ID of the maximum allowed length. - $id_length_config_test = entity_create('config_test', array( + $id_length_config_test = entity_create('config_test', [ 'id' => $this->randomMachineName(static::MAX_ID_LENGTH), - )); + ]); try { $id_length_config_test->save(); - $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", array( + $this->pass(SafeMarkup::format("config_test entity with ID length @length was saved.", [ '@length' => strlen($id_length_config_test->id()), - ))); + ])); } catch (ConfigEntityIdLengthException $e) { $this->fail($e->getMessage()); } // Test with an ID exceeding the maximum allowed length. - $id_length_config_test = entity_create('config_test', array( + $id_length_config_test = entity_create('config_test', [ 'id' => $this->randomMachineName(static::MAX_ID_LENGTH + 1), - )); + ]); try { $status = $id_length_config_test->save(); - $this->fail(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max saved successfully", array( + $this->fail(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max saved successfully", [ '@length' => strlen($id_length_config_test->id()), '@max' => static::MAX_ID_LENGTH, - ))); + ])); } catch (ConfigEntityIdLengthException $e) { - $this->pass(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max failed to save", array( + $this->pass(SafeMarkup::format("config_test entity with ID length @length exceeding the maximum allowed length of @max failed to save", [ '@length' => strlen($id_length_config_test->id()), '@max' => static::MAX_ID_LENGTH, - ))); + ])); } // Ensure that creating an entity with the same id as an existing one is not // possible. - $same_id = entity_create('config_test', array( + $same_id = entity_create('config_test', [ 'id' => $config_test->id(), - )); + ]); $this->assertIdentical($same_id->isNew(), TRUE); try { $same_id->save(); @@ -201,7 +201,7 @@ function testCRUD() { } // Verify that renaming the ID returns correct status and properties. - $ids = array($expected['id'], 'second_' . $this->randomMachineName(4), 'third_' . $this->randomMachineName(4)); + $ids = [$expected['id'], 'second_' . $this->randomMachineName(4), 'third_' . $this->randomMachineName(4)]; for ($i = 1; $i < 3; $i++) { $old_id = $ids[$i - 1]; $new_id = $ids[$i]; @@ -223,7 +223,7 @@ function testCRUD() { // Test config entity prepopulation. \Drupal::state()->set('config_test.prepopulate', TRUE); - $config_test = entity_create('config_test', array('foo' => 'bar')); + $config_test = entity_create('config_test', ['foo' => 'bar']); $this->assertEqual($config_test->get('foo'), 'baz', 'Initial value correctly populated'); } @@ -237,15 +237,15 @@ function testCRUDUI() { $label1 = $this->randomMachineName(); $label2 = $this->randomMachineName(); $label3 = $this->randomMachineName(); - $message_insert = format_string('%label configuration has been created.', array('%label' => $label1)); - $message_update = format_string('%label configuration has been updated.', array('%label' => $label2)); - $message_delete = format_string('The test configuration %label has been deleted.', array('%label' => $label2)); + $message_insert = format_string('%label configuration has been created.', ['%label' => $label1]); + $message_update = format_string('%label configuration has been updated.', ['%label' => $label2]); + $message_delete = format_string('The test configuration %label has been deleted.', ['%label' => $label2]); // Create a configuration entity. - $edit = array( + $edit = [ 'id' => $id, 'label' => $label1, - ); + ]; $this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save'); $this->assertUrl('admin/structure/config_test'); $this->assertResponse(200); @@ -254,9 +254,9 @@ function testCRUDUI() { $this->assertLinkByHref("admin/structure/config_test/manage/$id"); // Update the configuration entity. - $edit = array( + $edit = [ 'label' => $label2, - ); + ]; $this->drupalPostForm("admin/structure/config_test/manage/$id", $edit, 'Save'); $this->assertUrl('admin/structure/config_test'); $this->assertResponse(200); @@ -269,7 +269,7 @@ function testCRUDUI() { $this->drupalGet("admin/structure/config_test/manage/$id"); $this->clickLink(t('Delete')); $this->assertUrl("admin/structure/config_test/manage/$id/delete"); - $this->drupalPostForm(NULL, array(), 'Delete'); + $this->drupalPostForm(NULL, [], 'Delete'); $this->assertUrl('admin/structure/config_test'); $this->assertResponse(200); $this->assertNoRaw($message_update); @@ -278,10 +278,10 @@ function testCRUDUI() { $this->assertNoLinkByHref("admin/structure/config_test/manage/$id"); // Re-create a configuration entity. - $edit = array( + $edit = [ 'id' => $id, 'label' => $label1, - ); + ]; $this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save'); $this->assertUrl('admin/structure/config_test'); $this->assertResponse(200); @@ -289,10 +289,10 @@ function testCRUDUI() { $this->assertLinkByHref("admin/structure/config_test/manage/$id"); // Rename the configuration entity's ID/machine name. - $edit = array( + $edit = [ 'id' => strtolower($this->randomMachineName()), 'label' => $label3, - ); + ]; $this->drupalPostForm("admin/structure/config_test/manage/$id", $edit, 'Save'); $this->assertUrl('admin/structure/config_test'); $this->assertResponse(200); @@ -304,17 +304,17 @@ function testCRUDUI() { $this->assertLinkByHref("admin/structure/config_test/manage/$id"); // Create a configuration entity with '0' machine name. - $edit = array( + $edit = [ 'id' => '0', 'label' => '0', - ); + ]; $this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save'); $this->assertResponse(200); - $message_insert = format_string('%label configuration has been created.', array('%label' => $edit['label'])); + $message_insert = format_string('%label configuration has been created.', ['%label' => $edit['label']]); $this->assertRaw($message_insert); $this->assertLinkByHref('admin/structure/config_test/manage/0'); $this->assertLinkByHref('admin/structure/config_test/manage/0/delete'); - $this->drupalPostForm('admin/structure/config_test/manage/0/delete', array(), 'Delete'); + $this->drupalPostForm('admin/structure/config_test/manage/0/delete', [], 'Delete'); $this->assertFalse(entity_load('config_test', '0'), 'Test entity deleted'); // Create a configuration entity with a property that uses AJAX to show diff --git a/core/modules/config/src/Tests/ConfigExportImportUITest.php b/core/modules/config/src/Tests/ConfigExportImportUITest.php index 828d4aa..9ba59a8 100644 --- a/core/modules/config/src/Tests/ConfigExportImportUITest.php +++ b/core/modules/config/src/Tests/ConfigExportImportUITest.php @@ -67,7 +67,7 @@ class ConfigExportImportUITest extends WebTestBase { * * @var array */ - public static $modules = array('config', 'node', 'field'); + public static $modules = ['config', 'node', 'field']; /** * {@inheritdoc} @@ -103,11 +103,11 @@ public function testExportImport() { // Create a field. $this->fieldName = Unicode::strtolower($this->randomMachineName()); - $this->fieldStorage = FieldStorageConfig::create(array( + $this->fieldStorage = FieldStorageConfig::create([ 'field_name' => $this->fieldName, 'entity_type' => 'node', 'type' => 'text', - )); + ]); $this->fieldStorage->save(); FieldConfig::create([ 'field_storage' => $this->fieldStorage, @@ -116,9 +116,9 @@ public function testExportImport() { // Update the displays so that configuration does not change unexpectedly on // import. entity_get_form_display('node', $this->contentType->id(), 'default') - ->setComponent($this->fieldName, array( + ->setComponent($this->fieldName, [ 'type' => 'text_textfield', - )) + ]) ->save(); entity_get_display('node', $this->contentType->id(), 'full') ->setComponent($this->fieldName) @@ -134,7 +134,7 @@ public function testExportImport() { $this->assertFieldByName("{$this->fieldName}[0][value]", '', 'Widget is displayed'); // Export the configuration. - $this->drupalPostForm('admin/config/development/configuration/full/export', array(), 'Export'); + $this->drupalPostForm('admin/config/development/configuration/full/export', [], 'Export'); $this->tarball = $this->getRawContent(); $this->config('system.site') @@ -161,13 +161,13 @@ public function testExportImport() { // Import the configuration. $filename = 'temporary://' . $this->randomMachineName(); file_put_contents($filename, $this->tarball); - $this->drupalPostForm('admin/config/development/configuration/full/import', array('files[import_tarball]' => $filename), 'Upload'); + $this->drupalPostForm('admin/config/development/configuration/full/import', ['files[import_tarball]' => $filename], 'Upload'); // There is no snapshot yet because an import has never run. $this->assertNoText(t('Warning message')); $this->assertNoText(t('There are no configuration changes to import.')); $this->assertText($this->contentType->label()); - $this->drupalPostForm(NULL, array(), 'Import all'); + $this->drupalPostForm(NULL, [], 'Import all'); // After importing the snapshot has been updated an there are no warnings. $this->assertNoText(t('Warning message')); $this->assertText(t('There are no configuration changes to import.')); @@ -217,25 +217,25 @@ public function testExportImportCollections() { /** @var \Drupal\Core\Config\StorageInterface $active_storage */ $active_storage = \Drupal::service('config.storage'); $test1_storage = $active_storage->createCollection('collection.test1'); - $test1_storage->write('config_test.create', array('foo' => 'bar')); - $test1_storage->write('config_test.update', array('foo' => 'bar')); + $test1_storage->write('config_test.create', ['foo' => 'bar']); + $test1_storage->write('config_test.update', ['foo' => 'bar']); $test2_storage = $active_storage->createCollection('collection.test2'); - $test2_storage->write('config_test.another_create', array('foo' => 'bar')); - $test2_storage->write('config_test.another_update', array('foo' => 'bar')); + $test2_storage->write('config_test.another_create', ['foo' => 'bar']); + $test2_storage->write('config_test.another_update', ['foo' => 'bar']); // Export the configuration. - $this->drupalPostForm('admin/config/development/configuration/full/export', array(), 'Export'); + $this->drupalPostForm('admin/config/development/configuration/full/export', [], 'Export'); $this->tarball = $this->getRawContent(); $filename = file_directory_temp() . '/' . $this->randomMachineName(); file_put_contents($filename, $this->tarball); // Set up the active storage collections to test import. $test1_storage->delete('config_test.create'); - $test1_storage->write('config_test.update', array('foo' => 'baz')); - $test1_storage->write('config_test.delete', array('foo' => 'bar')); + $test1_storage->write('config_test.update', ['foo' => 'baz']); + $test1_storage->write('config_test.delete', ['foo' => 'bar']); $test2_storage->delete('config_test.another_create'); - $test2_storage->write('config_test.another_update', array('foo' => 'baz')); - $test2_storage->write('config_test.another_delete', array('foo' => 'bar')); + $test2_storage->write('config_test.another_update', ['foo' => 'baz']); + $test2_storage->write('config_test.another_delete', ['foo' => 'bar']); // Create a snapshot. $snapshot_storage = \Drupal::service('config.storage.snapshot'); @@ -244,22 +244,22 @@ public function testExportImportCollections() { // Ensure that the snapshot has the expected collection data before import. $test1_snapshot = $snapshot_storage->createCollection('collection.test1'); $data = $test1_snapshot->read('config_test.delete'); - $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.delete in collection.test1 exists in the snapshot storage.'); + $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.delete in collection.test1 exists in the snapshot storage.'); $data = $test1_snapshot->read('config_test.update'); - $this->assertEqual($data, array('foo' => 'baz'), 'The config_test.update in collection.test1 exists in the snapshot storage.'); + $this->assertEqual($data, ['foo' => 'baz'], 'The config_test.update in collection.test1 exists in the snapshot storage.'); $this->assertFalse($test1_snapshot->read('config_test.create'), 'The config_test.create in collection.test1 does not exist in the snapshot storage.'); $test2_snapshot = $snapshot_storage->createCollection('collection.test2'); $data = $test2_snapshot->read('config_test.another_delete'); - $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_delete in collection.test2 exists in the snapshot storage.'); + $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_delete in collection.test2 exists in the snapshot storage.'); $data = $test2_snapshot->read('config_test.another_update'); - $this->assertEqual($data, array('foo' => 'baz'), 'The config_test.another_update in collection.test2 exists in the snapshot storage.'); + $this->assertEqual($data, ['foo' => 'baz'], 'The config_test.another_update in collection.test2 exists in the snapshot storage.'); $this->assertFalse($test2_snapshot->read('config_test.another_create'), 'The config_test.another_create in collection.test2 does not exist in the snapshot storage.'); // Create the tar that contains the expected content for the collections. $tar = new ArchiveTar($filename, 'gz'); $content_list = $tar->listContent(); // Convert the list of files into something easy to search. - $files = array(); + $files = []; foreach ($content_list as $file) { $files[] = $file['filename']; } @@ -270,12 +270,12 @@ public function testExportImportCollections() { $this->assertFalse(in_array('collection/test1/config_test.delete.yml', $files), 'Config export does not contain collection/test1/config_test.delete.yml.'); $this->assertFalse(in_array('collection/test2/config_test.another_delete.yml', $files), 'Config export does not contain collection/test2/config_test.another_delete.yml.'); - $this->drupalPostForm('admin/config/development/configuration/full/import', array('files[import_tarball]' => $filename), 'Upload'); + $this->drupalPostForm('admin/config/development/configuration/full/import', ['files[import_tarball]' => $filename], 'Upload'); // Verify that there are configuration differences to import. $this->drupalGet('admin/config/development/configuration'); $this->assertNoText(t('There are no configuration changes to import.')); - $this->assertText(t('@collection configuration collection', array('@collection' => 'collection.test1'))); - $this->assertText(t('@collection configuration collection', array('@collection' => 'collection.test2'))); + $this->assertText(t('@collection configuration collection', ['@collection' => 'collection.test1'])); + $this->assertText(t('@collection configuration collection', ['@collection' => 'collection.test2'])); $this->assertText('config_test.create'); $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test1/config_test.create'); $this->assertText('config_test.update'); @@ -289,35 +289,35 @@ public function testExportImportCollections() { $this->assertText('config_test.another_delete'); $this->assertLinkByHref('admin/config/development/configuration/sync/diff_collection/collection.test2/config_test.another_delete'); - $this->drupalPostForm(NULL, array(), 'Import all'); + $this->drupalPostForm(NULL, [], 'Import all'); $this->assertText(t('There are no configuration changes to import.')); // Test data in collections. $data = $test1_storage->read('config_test.create'); - $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.create in collection.test1 has been created.'); + $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.create in collection.test1 has been created.'); $data = $test1_storage->read('config_test.update'); - $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.update in collection.test1 has been updated.'); + $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.update in collection.test1 has been updated.'); $this->assertFalse($test1_storage->read('config_test.delete'), 'The config_test.delete in collection.test1 has been deleted.'); $data = $test2_storage->read('config_test.another_create'); - $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_create in collection.test2 has been created.'); + $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_create in collection.test2 has been created.'); $data = $test2_storage->read('config_test.another_update'); - $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_update in collection.test2 has been updated.'); + $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_update in collection.test2 has been updated.'); $this->assertFalse($test2_storage->read('config_test.another_delete'), 'The config_test.another_delete in collection.test2 has been deleted.'); // Ensure that the snapshot has been updated with the collection data. $snapshot_storage = \Drupal::service('config.storage.snapshot'); $test1_snapshot = $snapshot_storage->createCollection('collection.test1'); $data = $test1_snapshot->read('config_test.create'); - $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.create in collection.test1 has been created in the snapshot storage.'); + $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.create in collection.test1 has been created in the snapshot storage.'); $data = $test1_snapshot->read('config_test.update'); - $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.update in collection.test1 has been updated in the snapshot storage.'); + $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.update in collection.test1 has been updated in the snapshot storage.'); $this->assertFalse($test1_snapshot->read('config_test.delete'), 'The config_test.delete in collection.test1 does not exist in the snapshot storage.'); $test2_snapshot = $snapshot_storage->createCollection('collection.test2'); $data = $test2_snapshot->read('config_test.another_create'); - $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_create in collection.test2 has been created in the snapshot storage.'); + $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_create in collection.test2 has been created in the snapshot storage.'); $data = $test2_snapshot->read('config_test.another_update'); - $this->assertEqual($data, array('foo' => 'bar'), 'The config_test.another_update in collection.test2 has been updated in the snapshot storage.'); + $this->assertEqual($data, ['foo' => 'bar'], 'The config_test.another_update in collection.test2 has been updated in the snapshot storage.'); $this->assertFalse($test2_snapshot->read('config_test.another_delete'), 'The config_test.another_delete in collection.test2 does not exist in the snapshot storage.'); } diff --git a/core/modules/config/src/Tests/ConfigExportUITest.php b/core/modules/config/src/Tests/ConfigExportUITest.php index 413ce29..2e02146 100644 --- a/core/modules/config/src/Tests/ConfigExportUITest.php +++ b/core/modules/config/src/Tests/ConfigExportUITest.php @@ -18,7 +18,7 @@ class ConfigExportUITest extends WebTestBase { * * @var array */ - public static $modules = array('config', 'config_test'); + public static $modules = ['config', 'config_test']; /** * {@inheritdoc} @@ -27,13 +27,13 @@ protected function setUp() { parent::setUp(); // Set up an override. - $settings['config']['system.maintenance']['message'] = (object) array( + $settings['config']['system.maintenance']['message'] = (object) [ 'value' => 'Foo', 'required' => TRUE, - ); + ]; $this->writeSettings($settings); - $this->drupalLogin($this->drupalCreateUser(array('export configuration'))); + $this->drupalLogin($this->drupalCreateUser(['export configuration'])); } /** @@ -45,7 +45,7 @@ function testExport() { $this->assertFieldById('edit-submit', t('Export')); // Submit the export form and verify response. - $this->drupalPostForm('admin/config/development/configuration/full/export', array(), t('Export')); + $this->drupalPostForm('admin/config/development/configuration/full/export', [], t('Export')); $this->assertResponse(200, 'User can access the download callback.'); // Test if header contains file name with hostname and timestamp. @@ -70,7 +70,7 @@ function testExport() { // Prepare the list of config files from active storage, see // \Drupal\config\Controller\ConfigController::downloadExport(). $storage_active = $this->container->get('config.storage'); - $config_files = array(); + $config_files = []; foreach ($storage_active->listAll() as $config_name) { $config_files[] = $config_name . '.yml'; } @@ -80,7 +80,7 @@ function testExport() { // Ensure the test configuration override is in effect but was not exported. $this->assertIdentical(\Drupal::config('system.maintenance')->get('message'), 'Foo'); - $archiver->extract(file_directory_temp(), array('system.maintenance.yml')); + $archiver->extract(file_directory_temp(), ['system.maintenance.yml']); $file_contents = file_get_contents(file_directory_temp() . '/' . 'system.maintenance.yml'); $exported = Yaml::decode($file_contents); $this->assertNotIdentical($exported['message'], 'Foo'); diff --git a/core/modules/config/src/Tests/ConfigFormOverrideTest.php b/core/modules/config/src/Tests/ConfigFormOverrideTest.php index ffd4428..f721eeb 100644 --- a/core/modules/config/src/Tests/ConfigFormOverrideTest.php +++ b/core/modules/config/src/Tests/ConfigFormOverrideTest.php @@ -16,15 +16,15 @@ class ConfigFormOverrideTest extends WebTestBase { * Tests that overrides do not affect forms. */ public function testFormsWithOverrides() { - $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer site configuration'))); + $this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration'])); $overridden_name = 'Site name global conf override'; // Set up an override. - $settings['config']['system.site']['name'] = (object) array( + $settings['config']['system.site']['name'] = (object) [ 'value' => $overridden_name, 'required' => TRUE, - ); + ]; $this->writeSettings($settings); // Test that everything on the form is the same, but that the override @@ -35,9 +35,9 @@ public function testFormsWithOverrides() { $this->assertIdentical((string) $elements[0]['value'], 'Drupal'); // Submit the form and ensure the site name is not changed. - $edit = array( + $edit = [ 'site_name' => 'Custom site name', - ); + ]; $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration')); $this->assertTitle('Basic site settings | ' . $overridden_name); $elements = $this->xpath('//input[@name="site_name"]'); diff --git a/core/modules/config/src/Tests/ConfigImportAllTest.php b/core/modules/config/src/Tests/ConfigImportAllTest.php index baeacb9..459be7a 100644 --- a/core/modules/config/src/Tests/ConfigImportAllTest.php +++ b/core/modules/config/src/Tests/ConfigImportAllTest.php @@ -36,7 +36,7 @@ class ConfigImportAllTest extends ModuleTestBase { protected function setUp() { parent::setUp(); - $this->webUser = $this->drupalCreateUser(array('synchronize configuration')); + $this->webUser = $this->drupalCreateUser(['synchronize configuration']); $this->drupalLogin($this->webUser); } @@ -124,12 +124,12 @@ public function testInstallUninstall() { } // Import the configuration thereby re-installing all the modules. - $this->drupalPostForm('admin/config/development/configuration', array(), t('Import all')); + $this->drupalPostForm('admin/config/development/configuration', [], t('Import all')); // Modules have been installed that have services. $this->rebuildContainer(); // Check that there are no errors. - $this->assertIdentical($this->configImporter()->getErrors(), array()); + $this->assertIdentical($this->configImporter()->getErrors(), []); // Check that all modules that were uninstalled are now reinstalled. $this->assertModules(array_keys($modules_to_uninstall), TRUE); diff --git a/core/modules/config/src/Tests/ConfigImportInstallProfileTest.php b/core/modules/config/src/Tests/ConfigImportInstallProfileTest.php index 0c74c7f..eaece36 100644 --- a/core/modules/config/src/Tests/ConfigImportInstallProfileTest.php +++ b/core/modules/config/src/Tests/ConfigImportInstallProfileTest.php @@ -23,7 +23,7 @@ class ConfigImportInstallProfileTest extends WebTestBase { * * @var array */ - public static $modules = array('config'); + public static $modules = ['config']; /** * A user with the 'synchronize configuration' permission. @@ -35,7 +35,7 @@ class ConfigImportInstallProfileTest extends WebTestBase { protected function setUp() { parent::setUp(); - $this->webUser = $this->drupalCreateUser(array('synchronize configuration')); + $this->webUser = $this->drupalCreateUser(['synchronize configuration']); $this->drupalLogin($this->webUser); $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync')); } @@ -54,7 +54,7 @@ public function testInstallProfileValidation() { unset($core['module']['testing_config_import']); $sync->write('core.extension', $core); - $this->drupalPostForm('admin/config/development/configuration', array(), t('Import all')); + $this->drupalPostForm('admin/config/development/configuration', [], t('Import all')); $this->assertText('The configuration cannot be imported because it failed validation for the following reasons:'); $this->assertText('Unable to uninstall the Testing config import profile since it is the install profile.'); @@ -69,7 +69,7 @@ public function testInstallProfileValidation() { $theme = $sync->read('system.theme'); $theme['default'] = 'classy'; $sync->write('system.theme', $theme); - $this->drupalPostForm('admin/config/development/configuration', array(), t('Import all')); + $this->drupalPostForm('admin/config/development/configuration', [], t('Import all')); $this->assertText('The configuration was imported successfully.'); $this->rebuildContainer(); $this->assertFalse(\Drupal::moduleHandler()->moduleExists('syslog'), 'The syslog module has been uninstalled.'); diff --git a/core/modules/config/src/Tests/ConfigImportUITest.php b/core/modules/config/src/Tests/ConfigImportUITest.php index afa9b99..1b63c2a 100644 --- a/core/modules/config/src/Tests/ConfigImportUITest.php +++ b/core/modules/config/src/Tests/ConfigImportUITest.php @@ -19,7 +19,7 @@ class ConfigImportUITest extends WebTestBase { * * @var array */ - public static $modules = array('config', 'config_test', 'config_import_test', 'text', 'options'); + public static $modules = ['config', 'config_test', 'config_import_test', 'text', 'options']; /** * A user with the 'synchronize configuration' permission. @@ -31,7 +31,7 @@ class ConfigImportUITest extends WebTestBase { protected function setUp() { parent::setUp(); - $this->webUser = $this->drupalCreateUser(array('synchronize configuration')); + $this->webUser = $this->drupalCreateUser(['synchronize configuration']); $this->drupalLogin($this->webUser); $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync')); } @@ -55,11 +55,11 @@ function testImport() { $this->assertIdentical($sync->exists($name), TRUE, $name . ' found.'); // Create new config entity. - $original_dynamic_data = array( + $original_dynamic_data = [ 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', 'langcode' => \Drupal::languageManager()->getDefaultLanguage()->getId(), 'status' => TRUE, - 'dependencies' => array(), + 'dependencies' => [], 'id' => 'new', 'label' => 'New', 'weight' => 0, @@ -67,7 +67,7 @@ function testImport() { 'size' => '', 'size_value' => '', 'protected_property' => '', - ); + ]; $sync->write($dynamic_name, $original_dynamic_data); $this->assertIdentical($sync->exists($dynamic_name), TRUE, $dynamic_name . ' found.'); @@ -102,11 +102,11 @@ function testImport() { // handled correctly. Options depends on Text so Text should be installed // first. Since they were enabled during the test setup the core.extension // file in sync will already contain them. - \Drupal::service('module_installer')->uninstall(array('text', 'options')); + \Drupal::service('module_installer')->uninstall(['text', 'options']); // Set the state system to record installations and uninstallations. - \Drupal::state()->set('ConfigImportUITest.core.extension.modules_installed', array()); - \Drupal::state()->set('ConfigImportUITest.core.extension.modules_uninstalled', array()); + \Drupal::state()->set('ConfigImportUITest.core.extension.modules_installed', []); + \Drupal::state()->set('ConfigImportUITest.core.extension.modules_uninstalled', []); // Verify that both appear as ready to import. $this->drupalGet('admin/config/development/configuration'); @@ -118,7 +118,7 @@ function testImport() { $this->assertFieldById('edit-submit', t('Import all')); // Import and verify that both do not appear anymore. - $this->drupalPostForm(NULL, array(), t('Import all')); + $this->drupalPostForm(NULL, [], t('Import all')); $this->assertNoRaw('' . $name); $this->assertNoRaw('' . $dynamic_name); $this->assertNoRaw('core.extension'); @@ -150,9 +150,9 @@ function testImport() { $this->assertTrue($theme_info['bartik']->status, 'Bartik theme installed during import.'); // Ensure installations and uninstallation occur as expected. - $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', array()); - $uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', array()); - $expected = array('action', 'ban', 'text', 'options'); + $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', []); + $uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', []); + $expected = ['action', 'ban', 'text', 'options']; $this->assertIdentical($expected, $installed, 'Action, Ban, Text and Options modules installed in the correct order.'); $this->assertTrue(empty($uninstalled), 'No modules uninstalled during import'); @@ -161,8 +161,8 @@ function testImport() { // configuration. This verifies that the module's default configuration is // used during configuration import and, additionally, that after installing // a module, that configuration is not synced twice. - $recursion_limit_values = \Drupal::state()->get('ConfigImportUITest.action.settings.recursion_limit', array()); - $this->assertIdentical($recursion_limit_values, array(50)); + $recursion_limit_values = \Drupal::state()->get('ConfigImportUITest.action.settings.recursion_limit', []); + $this->assertIdentical($recursion_limit_values, [50]); $core_extension = $this->config('core.extension')->get(); unset($core_extension['module']['action']); @@ -180,8 +180,8 @@ function testImport() { $sync->write('system.theme', $system_theme); // Set the state system to record installations and uninstallations. - \Drupal::state()->set('ConfigImportUITest.core.extension.modules_installed', array()); - \Drupal::state()->set('ConfigImportUITest.core.extension.modules_uninstalled', array()); + \Drupal::state()->set('ConfigImportUITest.core.extension.modules_installed', []); + \Drupal::state()->set('ConfigImportUITest.core.extension.modules_uninstalled', []); // Verify that both appear as ready to import. $this->drupalGet('admin/config/development/configuration'); @@ -190,7 +190,7 @@ function testImport() { $this->assertRaw('action.settings'); // Import and verify that both do not appear anymore. - $this->drupalPostForm(NULL, array(), t('Import all')); + $this->drupalPostForm(NULL, [], t('Import all')); $this->assertNoRaw('core.extension'); $this->assertNoRaw('system.theme'); $this->assertNoRaw('action.settings'); @@ -203,9 +203,9 @@ function testImport() { $this->assertFalse(\Drupal::moduleHandler()->moduleExists('text'), 'Text module uninstalled during import.'); // Ensure installations and uninstallation occur as expected. - $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', array()); - $uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', array()); - $expected = array('options', 'text', 'ban', 'action'); + $installed = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_installed', []); + $uninstalled = \Drupal::state()->get('ConfigImportUITest.core.extension.modules_uninstalled', []); + $expected = ['options', 'text', 'ban', 'action']; $this->assertIdentical($expected, $uninstalled, 'Options, Text, Ban and Action modules uninstalled in the correct order.'); $this->assertTrue(empty($installed), 'No modules installed during import'); @@ -235,7 +235,7 @@ function testImportLock() { $this->container->get('lock.persistent')->acquire($config_importer::LOCK_NAME); // Attempt to import configuration and verify that an error message appears. - $this->drupalPostForm(NULL, array(), t('Import all')); + $this->drupalPostForm(NULL, [], t('Import all')); $this->assertText(t('Another request may be synchronizing configuration already.')); // Release the lock, just to keep testing sane. @@ -273,11 +273,11 @@ function testImportDiff() { $add_key = 'biff'; $add_data = 'bangpow'; $change_data = '

        foobar

        '; - $original_data = array( + $original_data = [ 'foo' => '

        foobar

        ', 'baz' => 'no change', '404' => 'herp', - ); + ]; // Update active storage to have html in config data. $this->config($config_name)->setData($original_data)->save(); @@ -290,7 +290,7 @@ function testImportDiff() { // Load the diff UI and verify that the diff reflects the change. $this->drupalGet('admin/config/development/configuration/sync/diff/' . $config_name); - $this->assertTitle(format_string('View changes of @config_name | Drupal', array('@config_name' => $config_name))); + $this->assertTitle(format_string('View changes of @config_name | Drupal', ['@config_name' => $config_name])); // The following assertions do not use $this::assertEscaped() because // \Drupal\Component\Diff\DiffFormatter adds markup that signifies what has @@ -307,7 +307,7 @@ function testImportDiff() { $this->assertText(Html::escape("404: 'herp'")); // Verify diff colors are displayed. - $result = $this->xpath('//table[contains(@class, :class)]', array(':class' => 'diff')); + $result = $this->xpath('//table[contains(@class, :class)]', [':class' => 'diff']); $this->assertEqual(count($result), 1, "Diff UI is displaying colors."); // Reset data back to original, and remove a key @@ -351,7 +351,7 @@ public function testImportValidation() { $this->drupalGet('admin/config/development/configuration'); $this->assertNoText(t('There are no configuration changes to import.')); - $this->drupalPostForm(NULL, array(), t('Import all')); + $this->drupalPostForm(NULL, [], t('Import all')); // Verify that the validation messages appear. $this->assertText('The configuration cannot be imported because it failed validation for the following reasons:'); @@ -373,7 +373,7 @@ public function testConfigUninstallConfigException() { $this->assertText('core.extension'); // Import and verify that both do not appear anymore. - $this->drupalPostForm(NULL, array(), t('Import all')); + $this->drupalPostForm(NULL, [], t('Import all')); $this->assertText('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'); } @@ -394,11 +394,11 @@ function testImportErrorLog() { $sync = $this->container->get('config.storage.sync'); $uuid = $this->container->get('uuid'); - $values_primary = array( + $values_primary = [ 'uuid' => $uuid->generate(), 'langcode' => 'en', 'status' => TRUE, - 'dependencies' => array(), + 'dependencies' => [], 'id' => 'primary', 'label' => 'Primary', 'weight' => 0, @@ -406,16 +406,16 @@ function testImportErrorLog() { 'size' => NULL, 'size_value' => NULL, 'protected_property' => NULL, - ); + ]; $sync->write($name_primary, $values_primary); - $values_secondary = array( + $values_secondary = [ 'uuid' => $uuid->generate(), 'langcode' => 'en', 'status' => TRUE, // Add a dependency on primary, to ensure that is synced first. - 'dependencies' => array( - 'config' => array($name_primary), - ), + 'dependencies' => [ + 'config' => [$name_primary], + ], 'id' => 'secondary', 'label' => 'Secondary Sync', 'weight' => 0, @@ -423,15 +423,15 @@ function testImportErrorLog() { 'size' => NULL, 'size_value' => NULL, 'protected_property' => NULL, - ); + ]; $sync->write($name_secondary, $values_secondary); // Verify that there are configuration differences to import. $this->drupalGet('admin/config/development/configuration'); $this->assertNoText(t('There are no configuration changes to import.')); // Attempt to import configuration and verify that an error message appears. - $this->drupalPostForm(NULL, array(), t('Import all')); - $this->assertText(SafeMarkup::format('Deleted and replaced configuration entity "@name"', array('@name' => $name_secondary))); + $this->drupalPostForm(NULL, [], t('Import all')); + $this->assertText(SafeMarkup::format('Deleted and replaced configuration entity "@name"', ['@name' => $name_secondary])); $this->assertText(t('The configuration was imported with errors.')); $this->assertNoText(t('The configuration was imported successfully.')); $this->assertText(t('There are no configuration changes to import.')); @@ -443,42 +443,42 @@ function testImportErrorLog() { * @see \Drupal\Core\Entity\Event\BundleConfigImportValidate */ public function testEntityBundleDelete() { - \Drupal::service('module_installer')->install(array('node')); + \Drupal::service('module_installer')->install(['node']); $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync')); $node_type = $this->drupalCreateContentType(); - $node = $this->drupalCreateNode(array('type' => $node_type->id())); + $node = $this->drupalCreateNode(['type' => $node_type->id()]); $this->drupalGet('admin/config/development/configuration'); // The node type, body field and entity displays will be scheduled for // removal. - $this->assertText(format_string('node.type.@type', array('@type' => $node_type->id()))); - $this->assertText(format_string('field.field.node.@type.body', array('@type' => $node_type->id()))); - $this->assertText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id()))); - $this->assertText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id()))); - $this->assertText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id()))); + $this->assertText(format_string('node.type.@type', ['@type' => $node_type->id()])); + $this->assertText(format_string('field.field.node.@type.body', ['@type' => $node_type->id()])); + $this->assertText(format_string('core.entity_view_display.node.@type.teaser', ['@type' => $node_type->id()])); + $this->assertText(format_string('core.entity_view_display.node.@type.default', ['@type' => $node_type->id()])); + $this->assertText(format_string('core.entity_form_display.node.@type.default', ['@type' => $node_type->id()])); // Attempt to import configuration and verify that an error message appears // and the node type, body field and entity displays are still scheduled for // removal. - $this->drupalPostForm(NULL, array(), t('Import all')); - $validation_message = t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', array('%entity_type' => $node->getEntityType()->getLabel(), '%bundle_label' => $node->getEntityType()->getBundleLabel(), '%bundle' => $node_type->label())); + $this->drupalPostForm(NULL, [], t('Import all')); + $validation_message = t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', ['%entity_type' => $node->getEntityType()->getLabel(), '%bundle_label' => $node->getEntityType()->getBundleLabel(), '%bundle' => $node_type->label()]); $this->assertRaw($validation_message); - $this->assertText(format_string('node.type.@type', array('@type' => $node_type->id()))); - $this->assertText(format_string('field.field.node.@type.body', array('@type' => $node_type->id()))); - $this->assertText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id()))); - $this->assertText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id()))); - $this->assertText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id()))); + $this->assertText(format_string('node.type.@type', ['@type' => $node_type->id()])); + $this->assertText(format_string('field.field.node.@type.body', ['@type' => $node_type->id()])); + $this->assertText(format_string('core.entity_view_display.node.@type.teaser', ['@type' => $node_type->id()])); + $this->assertText(format_string('core.entity_view_display.node.@type.default', ['@type' => $node_type->id()])); + $this->assertText(format_string('core.entity_form_display.node.@type.default', ['@type' => $node_type->id()])); // Delete the node and try to import again. $node->delete(); - $this->drupalPostForm(NULL, array(), t('Import all')); + $this->drupalPostForm(NULL, [], t('Import all')); $this->assertNoRaw($validation_message); $this->assertText(t('There are no configuration changes to import.')); - $this->assertNoText(format_string('node.type.@type', array('@type' => $node_type->id()))); - $this->assertNoText(format_string('field.field.node.@type.body', array('@type' => $node_type->id()))); - $this->assertNoText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id()))); - $this->assertNoText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id()))); - $this->assertNoText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id()))); + $this->assertNoText(format_string('node.type.@type', ['@type' => $node_type->id()])); + $this->assertNoText(format_string('field.field.node.@type.body', ['@type' => $node_type->id()])); + $this->assertNoText(format_string('core.entity_view_display.node.@type.teaser', ['@type' => $node_type->id()])); + $this->assertNoText(format_string('core.entity_view_display.node.@type.default', ['@type' => $node_type->id()])); + $this->assertNoText(format_string('core.entity_form_display.node.@type.default', ['@type' => $node_type->id()])); } /** @@ -508,7 +508,7 @@ public function testExtensionValidation() { $core['theme']['does_not_exist'] = 0; $sync->write('core.extension', $core); - $this->drupalPostForm('admin/config/development/configuration', array(), t('Import all')); + $this->drupalPostForm('admin/config/development/configuration', [], t('Import all')); $this->assertText('The configuration cannot be imported because it failed validation for the following reasons:'); $this->assertText('Unable to uninstall the Text module since the Node module is installed.'); $this->assertText('Unable to uninstall the Classy theme since the Bartik theme is installed.'); diff --git a/core/modules/config/src/Tests/ConfigImportUploadTest.php b/core/modules/config/src/Tests/ConfigImportUploadTest.php index 9836d77..9792213 100644 --- a/core/modules/config/src/Tests/ConfigImportUploadTest.php +++ b/core/modules/config/src/Tests/ConfigImportUploadTest.php @@ -23,12 +23,12 @@ class ConfigImportUploadTest extends WebTestBase { * * @var array */ - public static $modules = array('config'); + public static $modules = ['config']; protected function setUp() { parent::setUp(); - $this->webUser = $this->drupalCreateUser(array('import configuration')); + $this->webUser = $this->drupalCreateUser(['import configuration']); $this->drupalLogin($this->webUser); } @@ -42,7 +42,7 @@ function testImport() { // Attempt to upload a non-tar file. $text_file = current($this->drupalGetTestFiles('text')); - $edit = array('files[import_tarball]' => drupal_realpath($text_file->uri)); + $edit = ['files[import_tarball]' => drupal_realpath($text_file->uri)]; $this->drupalPostForm('admin/config/development/configuration/full/import', $edit, t('Upload')); $this->assertText(t('Could not extract the contents of the tar file')); diff --git a/core/modules/config/src/Tests/ConfigInstallProfileOverrideTest.php b/core/modules/config/src/Tests/ConfigInstallProfileOverrideTest.php index c2cea6d..60322c2 100644 --- a/core/modules/config/src/Tests/ConfigInstallProfileOverrideTest.php +++ b/core/modules/config/src/Tests/ConfigInstallProfileOverrideTest.php @@ -31,19 +31,19 @@ class ConfigInstallProfileOverrideTest extends WebTestBase { function testInstallProfileConfigOverwrite() { $config_name = 'system.cron'; // The expected configuration from the system module. - $expected_original_data = array( - 'threshold' => array( + $expected_original_data = [ + 'threshold' => [ 'requirements_warning' => 172800, 'requirements_error' => 1209600, - ), - ); + ], + ]; // The expected active configuration altered by the install profile. - $expected_profile_data = array( - 'threshold' => array( + $expected_profile_data = [ + 'threshold' => [ 'requirements_warning' => 259200, 'requirements_error' => 1209600, - ), - ); + ], + ]; $expected_profile_data['_core']['default_config_hash'] = Crypt::hashBase64(serialize($expected_profile_data)); // Verify that the original data matches. We have to read the module config diff --git a/core/modules/config/src/Tests/ConfigInstallWebTest.php b/core/modules/config/src/Tests/ConfigInstallWebTest.php index 083b123..d0d231c 100644 --- a/core/modules/config/src/Tests/ConfigInstallWebTest.php +++ b/core/modules/config/src/Tests/ConfigInstallWebTest.php @@ -26,7 +26,7 @@ class ConfigInstallWebTest extends WebTestBase { protected function setUp() { parent::setUp(); - $this->adminUser = $this->drupalCreateUser(array('administer modules', 'administer themes', 'administer site configuration')); + $this->adminUser = $this->drupalCreateUser(['administer modules', 'administer themes', 'administer site configuration']); // Ensure the global variable being asserted by this test does not exist; // a previous test executed in this request/process might have set it. @@ -41,7 +41,7 @@ function testIntegrationModuleReinstallation() { $default_configuration_entity = 'config_test.dynamic.config_integration_test'; // Install the config_test module we're integrating with. - \Drupal::service('module_installer')->install(array('config_test')); + \Drupal::service('module_installer')->install(['config_test']); // Verify the configuration does not exist prior to installation. $config_static = $this->config($default_config); @@ -50,7 +50,7 @@ function testIntegrationModuleReinstallation() { $this->assertIdentical($config_entity->isNew(), TRUE); // Install the integration module. - \Drupal::service('module_installer')->install(array('config_integration_test')); + \Drupal::service('module_installer')->install(['config_integration_test']); // Verify that default module config exists. \Drupal::configFactory()->reset($default_config); @@ -73,7 +73,7 @@ function testIntegrationModuleReinstallation() { $this->container->get('config.factory')->reset(); // Disable and uninstall the integration module. - $this->container->get('module_installer')->uninstall(array('config_integration_test')); + $this->container->get('module_installer')->uninstall(['config_integration_test']); // Verify the integration module's config was uninstalled. $config_static = $this->config($default_config); @@ -86,7 +86,7 @@ function testIntegrationModuleReinstallation() { // Reinstall the integration module. try { - \Drupal::service('module_installer')->install(array('config_integration_test')); + \Drupal::service('module_installer')->install(['config_integration_test']); $this->fail('Expected PreExistingConfigException not thrown.'); } catch (PreExistingConfigException $e) { @@ -97,7 +97,7 @@ function testIntegrationModuleReinstallation() { // Delete the configuration entity so that the install will work. $config_entity->delete(); - \Drupal::service('module_installer')->install(array('config_integration_test')); + \Drupal::service('module_installer')->install(['config_integration_test']); // Verify the integration module's config was re-installed. \Drupal::configFactory()->reset($default_config); @@ -122,19 +122,19 @@ public function testPreExistingConfigInstall() { // will install the config_test module first because it is a dependency of // config_install_fail_test. // @see \Drupal\system\Form\ModulesListForm::submitForm() - $this->drupalPostForm('admin/modules', array('modules[Testing][config_test][enable]' => TRUE, 'modules[Testing][config_install_fail_test][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', ['modules[Testing][config_test][enable]' => TRUE, 'modules[Testing][config_install_fail_test][enable]' => TRUE], t('Install')); $this->assertRaw('Unable to install Configuration install fail test, config_test.dynamic.dotted.default already exists in active configuration.'); // Uninstall the config_test module to test the confirm form. - $this->drupalPostForm('admin/modules/uninstall', array('uninstall[config_test]' => TRUE), t('Uninstall')); - $this->drupalPostForm(NULL, array(), t('Uninstall')); + $this->drupalPostForm('admin/modules/uninstall', ['uninstall[config_test]' => TRUE], t('Uninstall')); + $this->drupalPostForm(NULL, [], t('Uninstall')); // Try to install config_install_fail_test without selecting config_test. // The user is shown a confirm form because the config_test module is a // dependency. // @see \Drupal\system\Form\ModulesListConfirmForm::submitForm() - $this->drupalPostForm('admin/modules', array('modules[Testing][config_install_fail_test][enable]' => TRUE), t('Install')); - $this->drupalPostForm(NULL, array(), t('Continue')); + $this->drupalPostForm('admin/modules', ['modules[Testing][config_install_fail_test][enable]' => TRUE], t('Install')); + $this->drupalPostForm(NULL, [], t('Continue')); $this->assertRaw('Unable to install Configuration install fail test, config_test.dynamic.dotted.default already exists in active configuration.'); // Test that collection configuration clashes during a module install are @@ -147,7 +147,7 @@ public function testPreExistingConfigInstall() { ->set('label', 'Je suis Charlie') ->save(); - $this->drupalPostForm('admin/modules', array('modules[Testing][config_install_fail_test][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', ['modules[Testing][config_install_fail_test][enable]' => TRUE], t('Install')); $this->assertRaw('Unable to install Configuration install fail test, config_test.dynamic.dotted.default, language/fr/config_test.dynamic.dotted.default already exist in active configuration.'); // Test installing a theme through the UI that has existing configuration. @@ -178,12 +178,12 @@ public function testUnmetDependenciesInstall() { $this->drupalLogin($this->adminUser); // We need to install separately since config_install_dependency_test does // not depend on config_test and order is important. - $this->drupalPostForm('admin/modules', array('modules[Testing][config_test][enable]' => TRUE), t('Install')); - $this->drupalPostForm('admin/modules', array('modules[Testing][config_install_dependency_test][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', ['modules[Testing][config_test][enable]' => TRUE], t('Install')); + $this->drupalPostForm('admin/modules', ['modules[Testing][config_install_dependency_test][enable]' => TRUE], t('Install')); $this->assertRaw('Unable to install Config install dependency test, config_other_module_config_test.weird_simple_config, config_test.dynamic.other_module_test_with_dependency have unmet dependencies.'); - $this->drupalPostForm('admin/modules', array('modules[Testing][config_other_module_config_test][enable]' => TRUE), t('Install')); - $this->drupalPostForm('admin/modules', array('modules[Testing][config_install_dependency_test][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', ['modules[Testing][config_other_module_config_test][enable]' => TRUE], t('Install')); + $this->drupalPostForm('admin/modules', ['modules[Testing][config_install_dependency_test][enable]' => TRUE], t('Install')); $this->rebuildContainer(); $this->assertTrue(entity_load('config_test', 'other_module_test_with_dependency'), 'The config_test.dynamic.other_module_test_with_dependency configuration has been created during install.'); } @@ -193,12 +193,12 @@ public function testUnmetDependenciesInstall() { */ public function testConfigModuleRequirements() { $this->drupalLogin($this->adminUser); - $this->drupalPostForm('admin/modules', array('modules[Core][config][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', ['modules[Core][config][enable]' => TRUE], t('Install')); $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY); file_unmanaged_delete_recursive($directory); $this->drupalGet('/admin/reports/status'); - $this->assertRaw(t('The directory %directory does not exist.', array('%directory' => $directory))); + $this->assertRaw(t('The directory %directory does not exist.', ['%directory' => $directory])); file_prepare_directory($directory, FILE_CREATE_DIRECTORY); \Drupal::service('file_system')->chmod($directory, 0555); diff --git a/core/modules/config/src/Tests/ConfigLanguageOverrideWebTest.php b/core/modules/config/src/Tests/ConfigLanguageOverrideWebTest.php index f966e5f..709d471 100644 --- a/core/modules/config/src/Tests/ConfigLanguageOverrideWebTest.php +++ b/core/modules/config/src/Tests/ConfigLanguageOverrideWebTest.php @@ -35,18 +35,18 @@ protected function setUp() { * Tests translating the site name. */ function testSiteNameTranslation() { - $adminUser = $this->drupalCreateUser(array('administer site configuration', 'administer languages')); + $adminUser = $this->drupalCreateUser(['administer site configuration', 'administer languages']); $this->drupalLogin($adminUser); // Add a custom language. $langcode = 'xx'; $name = $this->randomMachineName(16); - $edit = array( + $edit = [ 'predefined_langcode' => 'custom', 'langcode' => $langcode, 'label' => $name, 'direction' => LanguageInterface::DIRECTION_LTR, - ); + ]; $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); \Drupal::languageManager() ->getLanguageConfigOverride($langcode, 'system.site') diff --git a/core/modules/config/src/Tests/ConfigOtherModuleTest.php b/core/modules/config/src/Tests/ConfigOtherModuleTest.php index 56c4b31..6fb12d3 100644 --- a/core/modules/config/src/Tests/ConfigOtherModuleTest.php +++ b/core/modules/config/src/Tests/ConfigOtherModuleTest.php @@ -86,14 +86,14 @@ public function testInstallConfigEntityModuleFirst() { public function testUninstall() { $this->installModule('views'); $storage = $this->container->get('entity_type.manager')->getStorage('view'); - $storage->resetCache(array('frontpage')); + $storage->resetCache(['frontpage']); $this->assertTrue($storage->load('frontpage') === NULL, 'After installing Views, frontpage view which is dependant on the Node and Views modules does not exist.'); $this->installModule('node'); - $storage->resetCache(array('frontpage')); + $storage->resetCache(['frontpage']); $this->assertTrue($storage->load('frontpage') !== NULL, 'After installing Node, frontpage view which is dependant on the Node and Views modules exists.'); $this->uninstallModule('node'); $storage = $this->container->get('entity_type.manager')->getStorage('view'); - $storage->resetCache(array('frontpage')); + $storage->resetCache(['frontpage']); $this->assertTrue($storage->load('frontpage') === NULL, 'After uninstalling Node, frontpage view which is dependant on the Node and Views modules does not exist.'); } @@ -104,7 +104,7 @@ public function testUninstall() { * The module name. */ protected function installModule($module) { - $this->container->get('module_installer')->install(array($module)); + $this->container->get('module_installer')->install([$module]); $this->container = \Drupal::getContainer(); } @@ -115,7 +115,7 @@ protected function installModule($module) { * The module name. */ protected function uninstallModule($module) { - $this->container->get('module_installer')->uninstall(array($module)); + $this->container->get('module_installer')->uninstall([$module]); $this->container = \Drupal::getContainer(); } diff --git a/core/modules/config/src/Tests/ConfigSingleImportExportTest.php b/core/modules/config/src/Tests/ConfigSingleImportExportTest.php index 53f6164..16cff0a 100644 --- a/core/modules/config/src/Tests/ConfigSingleImportExportTest.php +++ b/core/modules/config/src/Tests/ConfigSingleImportExportTest.php @@ -39,7 +39,7 @@ public function testImport() { $storage = \Drupal::entityManager()->getStorage('config_test'); $uuid = \Drupal::service('uuid'); - $this->drupalLogin($this->drupalCreateUser(array('import configuration'))); + $this->drupalLogin($this->drupalCreateUser(['import configuration'])); // Attempt an import with invalid YAML. $edit = [ @@ -57,20 +57,20 @@ public function testImport() { style: '' status: '1' EOD; - $edit = array( + $edit = [ 'config_type' => 'config_test', 'import' => $import, - ); + ]; // Attempt an import with a missing ID. $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertText(t('Missing ID key "@id_key" for this @entity_type import.', array('@id_key' => 'id', '@entity_type' => 'Test configuration'))); + $this->assertText(t('Missing ID key "@id_key" for this @entity_type import.', ['@id_key' => 'id', '@entity_type' => 'Test configuration'])); // Perform an import with no specified UUID and a unique ID. $this->assertNull($storage->load('first')); $edit['import'] = "id: first\n" . $edit['import']; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertRaw(t('Are you sure you want to create a new %name @type?', array('%name' => 'first', '@type' => 'test configuration'))); - $this->drupalPostForm(NULL, array(), t('Confirm')); + $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'first', '@type' => 'test configuration'])); + $this->drupalPostForm(NULL, [], t('Confirm')); $entity = $storage->load('first'); $this->assertIdentical($entity->label(), 'First'); $this->assertIdentical($entity->id(), 'first'); @@ -89,8 +89,8 @@ public function testImport() { // Attempt an import with a custom ID. $edit['custom_entity_id'] = 'custom_id'; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertRaw(t('Are you sure you want to create a new %name @type?', array('%name' => 'custom_id', '@type' => 'test configuration'))); - $this->drupalPostForm(NULL, array(), t('Confirm')); + $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'custom_id', '@type' => 'test configuration'])); + $this->drupalPostForm(NULL, [], t('Confirm')); $this->assertRaw(t('The configuration was imported successfully.')); // Perform an import with a unique ID and UUID. @@ -101,15 +101,15 @@ public function testImport() { style: '' status: '0' EOD; - $edit = array( + $edit = [ 'config_type' => 'config_test', 'import' => $import, - ); + ]; $second_uuid = $uuid->generate(); $edit['import'] .= "\nuuid: " . $second_uuid; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertRaw(t('Are you sure you want to create a new %name @type?', array('%name' => 'second', '@type' => 'test configuration'))); - $this->drupalPostForm(NULL, array(), t('Confirm')); + $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'second', '@type' => 'test configuration'])); + $this->drupalPostForm(NULL, [], t('Confirm')); $entity = $storage->load('second'); $this->assertRaw(t('The configuration was imported successfully.')); $this->assertIdentical($entity->label(), 'Second'); @@ -126,13 +126,13 @@ public function testImport() { style: '' status: '0' EOD; - $edit = array( + $edit = [ 'config_type' => 'config_test', 'import' => $import, - ); + ]; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertRaw(t('Are you sure you want to update the %name @type?', array('%name' => 'second', '@type' => 'test configuration'))); - $this->drupalPostForm(NULL, array(), t('Confirm')); + $this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => 'second', '@type' => 'test configuration'])); + $this->drupalPostForm(NULL, [], t('Confirm')); $entity = $storage->load('second'); $this->assertRaw(t('The configuration was imported successfully.')); $this->assertIdentical($entity->label(), 'Second updated'); @@ -149,10 +149,10 @@ public function testImport() { module: - does_not_exist EOD; - $edit = array( + $edit = [ 'config_type' => 'config_test', 'import' => $import, - ); + ]; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); $this->assertRaw(t('Configuration %name depends on the %owner module that will not be installed after import.', ['%name' => 'config_test.dynamic.second', '%owner' => 'does_not_exist'])); } @@ -161,20 +161,20 @@ public function testImport() { * Tests importing a simple configuration file. */ public function testImportSimpleConfiguration() { - $this->drupalLogin($this->drupalCreateUser(array('import configuration'))); + $this->drupalLogin($this->drupalCreateUser(['import configuration'])); $config = $this->config('system.site')->set('name', 'Test simple import'); // Place branding block with site name into header region. $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']); - $edit = array( + $edit = [ 'config_type' => 'system.simple', 'config_name' => $config->getName(), 'import' => Yaml::encode($config->get()), - ); + ]; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertRaw(t('Are you sure you want to update the %name @type?', array('%name' => $config->getName(), '@type' => 'simple configuration'))); - $this->drupalPostForm(NULL, array(), t('Confirm')); + $this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => $config->getName(), '@type' => 'simple configuration'])); + $this->drupalPostForm(NULL, [], t('Confirm')); $this->drupalGet(''); $this->assertText('Test simple import'); @@ -183,11 +183,11 @@ public function testImportSimpleConfiguration() { $config_data = $this->config('core.extension')->get(); // Simulate uninstalling the Config module. unset($config_data['module']['config']); - $edit = array( + $edit = [ 'config_type' => 'system.simple', 'config_name' => 'core.extension', 'import' => Yaml::encode($config_data), - ); + ]; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); $this->assertText(t('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.')); @@ -197,14 +197,14 @@ public function testImportSimpleConfiguration() { * Tests exporting a single configuration file. */ public function testExport() { - $this->drupalLogin($this->drupalCreateUser(array('export configuration'))); + $this->drupalLogin($this->drupalCreateUser(['export configuration'])); $this->drupalGet('admin/config/development/configuration/single/export/system.simple'); $this->assertFieldByXPath('//select[@name="config_type"]//option[@selected="selected"]', t('Simple configuration'), 'The simple configuration option is selected when specified in the URL.'); // Spot check several known simple configuration files. $element = $this->xpath('//select[@name="config_name"]'); $options = $this->getAllOptions($element[0]); - $expected_options = array('system.site', 'user.settings'); + $expected_options = ['system.site', 'user.settings']; foreach ($options as &$option) { $option = (string) $option; } diff --git a/core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php b/core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php index 1aa4c9a..ba67960 100644 --- a/core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php +++ b/core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php @@ -12,7 +12,7 @@ */ class LanguageNegotiationFormOverrideTest extends WebTestBase { - public static $modules = array('language', 'locale', 'locale_test'); + public static $modules = ['language', 'locale', 'locale_test']; /** * Tests that overrides do not affect language-negotiation form values. @@ -23,16 +23,16 @@ public function testFormWithOverride() { $overridden_value_es = 'loquesea'; // Set up an override. - $settings['config']['language.negotiation']['url']['prefixes'] = (object) array( - 'value' => array('en' => $overridden_value_en, 'es' => $overridden_value_es), + $settings['config']['language.negotiation']['url']['prefixes'] = (object) [ + 'value' => ['en' => $overridden_value_en, 'es' => $overridden_value_es], 'required' => TRUE, - ); + ]; $this->writeSettings($settings); // Add predefined language. - $edit = array( + $edit = [ 'predefined_langcode' => 'es', - ); + ]; $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); // Overridden string for language-negotiation should not exist in the form. diff --git a/core/modules/config/src/Tests/SchemaCheckTestTrait.php b/core/modules/config/src/Tests/SchemaCheckTestTrait.php index ede1e56..6867a02 100644 --- a/core/modules/config/src/Tests/SchemaCheckTestTrait.php +++ b/core/modules/config/src/Tests/SchemaCheckTestTrait.php @@ -28,19 +28,19 @@ public function assertConfigSchema(TypedConfigManagerInterface $typed_config, $c if ($errors === FALSE) { // @todo Since the use of this trait is under TestBase, it works. // Can be fixed as part of https://www.drupal.org/node/2260053. - $this->fail(SafeMarkup::format('No schema for @config_name', array('@config_name' => $config_name))); + $this->fail(SafeMarkup::format('No schema for @config_name', ['@config_name' => $config_name])); return; } elseif ($errors === TRUE) { // @todo Since the use of this trait is under TestBase, it works. // Can be fixed as part of https://www.drupal.org/node/2260053. - $this->pass(SafeMarkup::format('Schema found for @config_name and values comply with schema.', array('@config_name' => $config_name))); + $this->pass(SafeMarkup::format('Schema found for @config_name and values comply with schema.', ['@config_name' => $config_name])); } else { foreach ($errors as $key => $error) { // @todo Since the use of this trait is under TestBase, it works. // Can be fixed as part of https://www.drupal.org/node/2260053. - $this->fail(SafeMarkup::format('Schema key @key failed with: @error', array('@key' => $key, '@error' => $error))); + $this->fail(SafeMarkup::format('Schema key @key failed with: @error', ['@key' => $key, '@error' => $error])); } } } diff --git a/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php b/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php index 45aabc8..ca9f842 100644 --- a/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php +++ b/core/modules/config/src/Tests/SchemaConfigListenerWebTest.php @@ -15,7 +15,7 @@ class SchemaConfigListenerWebTest extends WebTestBase { /** * {@inheritdoc} */ - public static $modules = array('config_test'); + public static $modules = ['config_test']; /** * Tests \Drupal\Core\Config\Testing\ConfigSchemaChecker. diff --git a/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php b/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php index da3a9f1..76714a5 100644 --- a/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php +++ b/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php @@ -33,7 +33,7 @@ public function __construct(StateInterface $state) { * The configuration collection info event. */ public function addCollections(ConfigCollectionInfo $collection_info) { - $collections = $this->state->get('config_collection_install_test.collection_names', array()); + $collections = $this->state->get('config_collection_install_test.collection_names', []); foreach ($collections as $collection) { $collection_info->addCollection($collection); } @@ -43,7 +43,7 @@ public function addCollections(ConfigCollectionInfo $collection_info) { * {@inheritdoc} */ static function getSubscribedEvents() { - $events[ConfigEvents::COLLECTION_INFO][] = array('addCollections'); + $events[ConfigEvents::COLLECTION_INFO][] = ['addCollections']; return $events; } diff --git a/core/modules/config/tests/config_entity_static_cache_test/src/ConfigOverrider.php b/core/modules/config/tests/config_entity_static_cache_test/src/ConfigOverrider.php index 2345d55..8d21ee4 100644 --- a/core/modules/config/tests/config_entity_static_cache_test/src/ConfigOverrider.php +++ b/core/modules/config/tests/config_entity_static_cache_test/src/ConfigOverrider.php @@ -15,11 +15,11 @@ class ConfigOverrider implements ConfigFactoryOverrideInterface { * {@inheritdoc} */ public function loadOverrides($names) { - return array( - 'config_test.dynamic.test_1' => array( + return [ + 'config_test.dynamic.test_1' => [ 'label' => 'Overridden label', - ) - ); + ] + ]; } /** diff --git a/core/modules/config/tests/config_events_test/src/EventSubscriber.php b/core/modules/config/tests/config_events_test/src/EventSubscriber.php index bfa70db..39e8eb8 100644 --- a/core/modules/config/tests/config_events_test/src/EventSubscriber.php +++ b/core/modules/config/tests/config_events_test/src/EventSubscriber.php @@ -37,21 +37,21 @@ public function __construct(StateInterface $state) { */ public function configEventRecorder(ConfigCrudEvent $event, $name) { $config = $event->getConfig(); - $this->state->set('config_events_test.event', array( + $this->state->set('config_events_test.event', [ 'event_name' => $name, 'current_config_data' => $config->get(), 'original_config_data' => $config->getOriginal(), 'raw_config_data' => $config->getRawData() - )); + ]); } /** * {@inheritdoc} */ static function getSubscribedEvents() { - $events[ConfigEvents::SAVE][] = array('configEventRecorder'); - $events[ConfigEvents::DELETE][] = array('configEventRecorder'); - $events[ConfigEvents::RENAME][] = array('configEventRecorder'); + $events[ConfigEvents::SAVE][] = ['configEventRecorder']; + $events[ConfigEvents::DELETE][] = ['configEventRecorder']; + $events[ConfigEvents::RENAME][] = ['configEventRecorder']; return $events; } diff --git a/core/modules/config/tests/config_import_test/src/EventSubscriber.php b/core/modules/config/tests/config_import_test/src/EventSubscriber.php index f4ae97f..e0ef923 100644 --- a/core/modules/config/tests/config_import_test/src/EventSubscriber.php +++ b/core/modules/config/tests/config_import_test/src/EventSubscriber.php @@ -88,14 +88,14 @@ public function onConfigImporterMissingContentTwo(MissingContentEvent $event) { public function onConfigSave(ConfigCrudEvent $event) { $config = $event->getConfig(); if ($config->getName() == 'action.settings') { - $values = $this->state->get('ConfigImportUITest.action.settings.recursion_limit', array()); + $values = $this->state->get('ConfigImportUITest.action.settings.recursion_limit', []); $values[] = $config->get('recursion_limit'); $this->state->set('ConfigImportUITest.action.settings.recursion_limit', $values); } if ($config->getName() == 'core.extension') { - $installed = $this->state->get('ConfigImportUITest.core.extension.modules_installed', array()); - $uninstalled = $this->state->get('ConfigImportUITest.core.extension.modules_uninstalled', array()); + $installed = $this->state->get('ConfigImportUITest.core.extension.modules_installed', []); + $uninstalled = $this->state->get('ConfigImportUITest.core.extension.modules_uninstalled', []); $original = $config->getOriginal('module'); $data = $config->get('module'); $install = array_diff_key($data, $original); @@ -132,10 +132,10 @@ public function onConfigDelete(ConfigCrudEvent $event) { * An array of event listener definitions. */ static function getSubscribedEvents() { - $events[ConfigEvents::SAVE][] = array('onConfigSave', 40); - $events[ConfigEvents::DELETE][] = array('onConfigDelete', 40); - $events[ConfigEvents::IMPORT_VALIDATE] = array('onConfigImporterValidate'); - $events[ConfigEvents::IMPORT_MISSING_CONTENT] = array(array('onConfigImporterMissingContentOne'), array('onConfigImporterMissingContentTwo', -100)); + $events[ConfigEvents::SAVE][] = ['onConfigSave', 40]; + $events[ConfigEvents::DELETE][] = ['onConfigDelete', 40]; + $events[ConfigEvents::IMPORT_VALIDATE] = ['onConfigImporterValidate']; + $events[ConfigEvents::IMPORT_MISSING_CONTENT] = [['onConfigImporterMissingContentOne'], ['onConfigImporterMissingContentTwo', -100]]; return $events; } diff --git a/core/modules/config/tests/config_override_test/src/ConfigOverrider.php b/core/modules/config/tests/config_override_test/src/ConfigOverrider.php index 895f041..c8ffc69 100644 --- a/core/modules/config/tests/config_override_test/src/ConfigOverrider.php +++ b/core/modules/config/tests/config_override_test/src/ConfigOverrider.php @@ -14,13 +14,13 @@ class ConfigOverrider implements ConfigFactoryOverrideInterface { * {@inheritdoc} */ public function loadOverrides($names) { - $overrides = array(); + $overrides = []; if (!empty($GLOBALS['config_test_run_module_overrides'])) { if (in_array('system.site', $names)) { - $overrides = $overrides + array('system.site' => array('name' => 'ZOMG overridden site name')); + $overrides = $overrides + ['system.site' => ['name' => 'ZOMG overridden site name']]; } if (in_array('config_override_test.new', $names)) { - $overrides = $overrides + array('config_override_test.new' => array('module' => 'override')); + $overrides = $overrides + ['config_override_test.new' => ['module' => 'override']]; } } return $overrides; diff --git a/core/modules/config/tests/config_override_test/src/ConfigOverriderLowPriority.php b/core/modules/config/tests/config_override_test/src/ConfigOverriderLowPriority.php index 6f0b12d..b8109db 100644 --- a/core/modules/config/tests/config_override_test/src/ConfigOverriderLowPriority.php +++ b/core/modules/config/tests/config_override_test/src/ConfigOverriderLowPriority.php @@ -15,17 +15,17 @@ class ConfigOverriderLowPriority implements ConfigFactoryOverrideInterface { * {@inheritdoc} */ public function loadOverrides($names) { - $overrides = array(); + $overrides = []; if (!empty($GLOBALS['config_test_run_module_overrides'])) { if (in_array('system.site', $names)) { - $overrides = array('system.site' => - array( + $overrides = ['system.site' => + [ 'name' => 'Should not apply because of higher priority listener', // This override should apply because it is not overridden by the // higher priority listener. 'slogan' => 'Yay for overrides!', - ) - ); + ] + ]; } } return $overrides; diff --git a/core/modules/config/tests/config_test/src/ConfigTestController.php b/core/modules/config/tests/config_test/src/ConfigTestController.php index d60c62e..6799dc1 100644 --- a/core/modules/config/tests/config_test/src/ConfigTestController.php +++ b/core/modules/config/tests/config_test/src/ConfigTestController.php @@ -21,7 +21,7 @@ class ConfigTestController extends ControllerBase { * The title for the ConfigTest edit form. */ public function editTitle(ConfigTest $config_test) { - return $this->t('Edit %label', array('%label' => $config_test->label())); + return $this->t('Edit %label', ['%label' => $config_test->label()]); } /** @@ -35,7 +35,7 @@ public function editTitle(ConfigTest $config_test) { */ function enable(ConfigTest $config_test) { $config_test->enable()->save(); - return new RedirectResponse($config_test->url('collection', array('absolute' => TRUE))); + return new RedirectResponse($config_test->url('collection', ['absolute' => TRUE])); } /** @@ -49,7 +49,7 @@ function enable(ConfigTest $config_test) { */ function disable(ConfigTest $config_test) { $config_test->disable()->save(); - return new RedirectResponse($config_test->url('collection', array('absolute' => TRUE))); + return new RedirectResponse($config_test->url('collection', ['absolute' => TRUE])); } } diff --git a/core/modules/config/tests/config_test/src/ConfigTestForm.php b/core/modules/config/tests/config_test/src/ConfigTestForm.php index 8a375b8..bdd364b 100644 --- a/core/modules/config/tests/config_test/src/ConfigTestForm.php +++ b/core/modules/config/tests/config_test/src/ConfigTestForm.php @@ -46,33 +46,33 @@ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $entity = $this->entity; - $form['label'] = array( + $form['label'] = [ '#type' => 'textfield', '#title' => 'Label', '#default_value' => $entity->label(), '#required' => TRUE, - ); - $form['id'] = array( + ]; + $form['id'] = [ '#type' => 'machine_name', '#default_value' => $entity->id(), '#required' => TRUE, - '#machine_name' => array( + '#machine_name' => [ 'exists' => [$this, 'exists'], 'replace_pattern' => '[^a-z0-9_.]+', - ), - ); - $form['weight'] = array( + ], + ]; + $form['weight'] = [ '#type' => 'weight', '#title' => 'Weight', '#default_value' => $entity->get('weight'), - ); - $form['style'] = array( + ]; + $form['style'] = [ '#type' => 'select', '#title' => 'Image style', - '#options' => array(), + '#options' => [], '#default_value' => $entity->get('style'), '#access' => FALSE, - ); + ]; if ($this->moduleHandler->moduleExists('image')) { $form['style']['#access'] = TRUE; $form['style']['#options'] = image_style_options(); @@ -83,61 +83,61 @@ public function form(array $form, FormStateInterface $form_state) { // state. $size = $entity->get('size'); - $form['size_wrapper'] = array( + $form['size_wrapper'] = [ '#type' => 'container', - '#attributes' => array( + '#attributes' => [ 'id' => 'size-wrapper', - ), - ); - $form['size_wrapper']['size'] = array( + ], + ]; + $form['size_wrapper']['size'] = [ '#type' => 'select', '#title' => 'Size', - '#options' => array( + '#options' => [ 'custom' => 'Custom', - ), + ], '#empty_option' => '- None -', '#default_value' => $size, - '#ajax' => array( + '#ajax' => [ 'callback' => '::updateSize', 'wrapper' => 'size-wrapper', - ), - ); - $form['size_wrapper']['size_submit'] = array( + ], + ]; + $form['size_wrapper']['size_submit'] = [ '#type' => 'submit', '#value' => t('Change size'), - '#attributes' => array( - 'class' => array('js-hide'), - ), - '#submit' => array(array(get_class($this), 'changeSize')), - ); - $form['size_wrapper']['size_value'] = array( + '#attributes' => [ + 'class' => ['js-hide'], + ], + '#submit' => [[get_class($this), 'changeSize']], + ]; + $form['size_wrapper']['size_value'] = [ '#type' => 'select', '#title' => 'Custom size value', - '#options' => array( + '#options' => [ 'small' => 'Small', 'medium' => 'Medium', 'large' => 'Large', - ), + ], '#default_value' => $entity->get('size_value'), '#access' => !empty($size), - ); + ]; - $form['langcode'] = array( + $form['langcode'] = [ '#type' => 'language_select', '#title' => t('Language'), '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $entity->language()->getId(), - ); + ]; - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => 'Save', - ); - $form['actions']['delete'] = array( + ]; + $form['actions']['delete'] = [ '#type' => 'submit', '#value' => 'Delete', - ); + ]; return $form; } @@ -164,10 +164,10 @@ public function save(array $form, FormStateInterface $form_state) { $status = $entity->save(); if ($status === SAVED_UPDATED) { - drupal_set_message(format_string('%label configuration has been updated.', array('%label' => $entity->label()))); + drupal_set_message(format_string('%label configuration has been updated.', ['%label' => $entity->label()])); } else { - drupal_set_message(format_string('%label configuration has been created.', array('%label' => $entity->label()))); + drupal_set_message(format_string('%label configuration has been created.', ['%label' => $entity->label()])); } $form_state->setRedirectUrl($this->entity->urlInfo('collection')); diff --git a/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php b/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php index 10914f0..ca3b354 100644 --- a/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php +++ b/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php @@ -38,6 +38,6 @@ class ConfigQueryTest extends ConfigTest { * * @var array */ - public $array = array(); + public $array = []; } diff --git a/core/modules/config/tests/config_test/src/Entity/ConfigTest.php b/core/modules/config/tests/config_test/src/Entity/ConfigTest.php index 56ddfe6..465b339 100644 --- a/core/modules/config/tests/config_test/src/Entity/ConfigTest.php +++ b/core/modules/config/tests/config_test/src/Entity/ConfigTest.php @@ -88,10 +88,10 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) public function postSave(EntityStorageInterface $storage, $update = TRUE) { // Used to test secondary writes during config sync. if ($this->id() == 'primary') { - $secondary = $storage->create(array( + $secondary = $storage->create([ 'id' => 'secondary', 'label' => 'Secondary Default', - )); + ]); $secondary->save(); } if ($this->id() == 'deleter') { @@ -126,7 +126,7 @@ public function onDependencyRemoval(array $dependencies) { if (!isset($this->dependencies['enforced']['config'])) { return $changed; } - $fix_deps = \Drupal::state()->get('config_test.fix_dependencies', array()); + $fix_deps = \Drupal::state()->get('config_test.fix_dependencies', []); foreach ($dependencies['config'] as $entity) { if (in_array($entity->getConfigDependencyName(), $fix_deps)) { $key = array_search($entity->getConfigDependencyName(), $this->dependencies['enforced']['config']); diff --git a/core/modules/config/tests/config_test/src/TestInstallStorage.php b/core/modules/config/tests/config_test/src/TestInstallStorage.php index 074e99c..e3c4918 100644 --- a/core/modules/config/tests/config_test/src/TestInstallStorage.php +++ b/core/modules/config/tests/config_test/src/TestInstallStorage.php @@ -20,7 +20,7 @@ protected function getAllFolders() { if (!isset($this->folders)) { $this->folders = $this->getCoreNames(); $listing = new ExtensionDiscovery(\Drupal::root()); - $listing->setProfileDirectories(array()); + $listing->setProfileDirectories([]); $this->folders += $this->getComponentNames($listing->scan('profile')); $this->folders += $this->getComponentNames($listing->scan('module')); $this->folders += $this->getComponentNames($listing->scan('theme')); diff --git a/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php b/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php index 7dd8d7d..0bfb32e 100644 --- a/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php +++ b/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php @@ -12,7 +12,7 @@ class ConfigLocalTasksTest extends LocalTaskIntegrationTestBase { protected function setUp() { - $this->directoryList = array('config' => 'core/modules/config'); + $this->directoryList = ['config' => 'core/modules/config']; parent::setUp(); } @@ -29,13 +29,13 @@ public function testConfigAdminLocalTasks($route, $expected) { * Provides a list of routes to test. */ public function getConfigAdminRoutes() { - return array( - array('config.sync', array(array('config.sync', 'config.import', 'config.export'))), - array('config.import_full', array(array('config.sync', 'config.import', 'config.export'), array('config.import_full', 'config.import_single'))), - array('config.import_single', array(array('config.sync', 'config.import', 'config.export'), array('config.import_full', 'config.import_single'))), - array('config.export_full', array(array('config.sync', 'config.import', 'config.export'), array('config.export_full', 'config.export_single'))), - array('config.export_single', array(array('config.sync', 'config.import', 'config.export'), array('config.export_full', 'config.export_single'))), - ); + return [ + ['config.sync', [['config.sync', 'config.import', 'config.export']]], + ['config.import_full', [['config.sync', 'config.import', 'config.export'], ['config.import_full', 'config.import_single']]], + ['config.import_single', [['config.sync', 'config.import', 'config.export'], ['config.import_full', 'config.import_single']]], + ['config.export_full', [['config.sync', 'config.import', 'config.export'], ['config.export_full', 'config.export_single']]], + ['config.export_single', [['config.sync', 'config.import', 'config.export'], ['config.export_full', 'config.export_single']]], + ]; } } diff --git a/core/modules/config_translation/config_translation.api.php b/core/modules/config_translation/config_translation.api.php index f2ee4a2..f97e259 100644 --- a/core/modules/config_translation/config_translation.api.php +++ b/core/modules/config_translation/config_translation.api.php @@ -50,14 +50,14 @@ function hook_config_translation_info(&$info) { // Make sure entity type has field UI enabled and has a base route. if ($entity_type->get('field_ui_base_route') && !empty($base_route)) { - $info[$entity_type_id . '_fields'] = array( + $info[$entity_type_id . '_fields'] = [ 'base_route_name' => 'entity.field_config.' . $entity_type_id . '_field_edit_form', 'entity_type' => 'field_config', 'title' => t('Title'), 'class' => '\Drupal\config_translation\ConfigFieldMapper', 'base_entity_type' => $entity_type_id, 'weight' => 10, - ); + ]; } } } diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index 9f0803d..63af5de 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -17,15 +17,15 @@ function config_translation_help($route_name, RouteMatchInterface $route_match) case 'help.page.config_translation': $output = ''; $output .= '

        ' . t('About') . '

        '; - $output .= '

        ' . t('The Configuration Translation module allows you to translate configuration text; for example, the site name, vocabularies, menus, or date formats. Together with the modules Language, Content Translation, and Interface Translation, it allows you to build multilingual websites. For more information, see the online documentation for the Configuration Translation module.', array(':doc_url' => 'https://www.drupal.org/documentation/modules/config_translation', ':config' => \Drupal::url('help.page', array('name' => 'config')), ':language' => \Drupal::url('help.page', array('name' => 'language')), ':locale' => \Drupal::url('help.page', array('name' => 'locale')), ':content-translation' => (\Drupal::moduleHandler()->moduleExists('content_translation')) ? \Drupal::url('help.page', array('name' => 'content_translation')) : '#')) . '

        '; + $output .= '

        ' . t('The Configuration Translation module allows you to translate configuration text; for example, the site name, vocabularies, menus, or date formats. Together with the modules Language, Content Translation, and Interface Translation, it allows you to build multilingual websites. For more information, see the online documentation for the Configuration Translation module.', [':doc_url' => 'https://www.drupal.org/documentation/modules/config_translation', ':config' => \Drupal::url('help.page', ['name' => 'config']), ':language' => \Drupal::url('help.page', ['name' => 'language']), ':locale' => \Drupal::url('help.page', ['name' => 'locale']), ':content-translation' => (\Drupal::moduleHandler()->moduleExists('content_translation')) ? \Drupal::url('help.page', ['name' => 'content_translation']) : '#']) . '

        '; $output .= '

        ' . t('Uses') . '

        '; $output .= '
        '; $output .= '
        ' . t('Enabling translation') . '
        '; - $output .= '
        ' . t('In order to translate configuration, the website must have at least two languages.', array(':url' => \Drupal::url('entity.configurable_language.collection'))) . '
        '; + $output .= '
        ' . t('In order to translate configuration, the website must have at least two languages.', [':url' => \Drupal::url('entity.configurable_language.collection')]) . '
        '; $output .= '
        ' . t('Translating configuration text') . '
        '; - $output .= '
        ' . t('Users with the Translate user edited configuration permission can access the configuration translation overview, and manage translations for specific languages. The Configuration translation page shows a list of all configuration text that can be translated, either as individual items or as lists. After you click on Translate, you are provided with a list of all languages. You can add or edit a translation for a specific language. Users with specific configuration permissions can also edit the text for the site\'s default language. For some configuration text items (for example for the site information), the specific translation pages can also be accessed directly from their configuration pages.', array(':translation-page' => \Drupal::url('config_translation.mapper_list'))) . '
        '; + $output .= '
        ' . t('Users with the Translate user edited configuration permission can access the configuration translation overview, and manage translations for specific languages. The Configuration translation page shows a list of all configuration text that can be translated, either as individual items or as lists. After you click on Translate, you are provided with a list of all languages. You can add or edit a translation for a specific language. Users with specific configuration permissions can also edit the text for the site\'s default language. For some configuration text items (for example for the site information), the specific translation pages can also be accessed directly from their configuration pages.', [':translation-page' => \Drupal::url('config_translation.mapper_list')]) . '
        '; $output .= '
        ' . t('Translating date formats') . '
        '; - $output .= '
        ' . t('You can choose to translate date formats on the Configuration translation page. This allows you not only to translate the label text, but also to set a language-specific PHP date format.', array(':translation-page' => \Drupal::url('config_translation.mapper_list'))) . '
        '; + $output .= '
        ' . t('You can choose to translate date formats on the Configuration translation page. This allows you not only to translate the label text, but also to set a language-specific PHP date format.', [':translation-page' => \Drupal::url('config_translation.mapper_list')]) . '
        '; $output .= '
        '; return $output; @@ -39,12 +39,12 @@ function config_translation_help($route_name, RouteMatchInterface $route_match) * Implements hook_theme(). */ function config_translation_theme() { - return array( - 'config_translation_manage_form_element' => array( + return [ + 'config_translation_manage_form_element' => [ 'render element' => 'element', 'template' => 'config_translation_manage_form_element', - ), - ); + ], + ]; } /** @@ -109,13 +109,13 @@ function config_translation_config_translation_info(&$info) { foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) { // Make sure entity type has field UI enabled and has a base route. if ($entity_type->get('field_ui_base_route')) { - $info[$entity_type_id . '_fields'] = array( + $info[$entity_type_id . '_fields'] = [ 'base_route_name' => "entity.field_config.{$entity_type_id}_field_edit_form", 'entity_type' => 'field_config', 'class' => '\Drupal\config_translation\ConfigFieldMapper', 'base_entity_type' => $entity_type_id, 'weight' => 10, - ); + ]; } } } @@ -137,14 +137,14 @@ function config_translation_config_translation_info(&$info) { // Use the entity type as the plugin ID. $base_route_name = "entity.$entity_type_id.edit_form"; - $info[$entity_type_id] = array( + $info[$entity_type_id] = [ 'class' => '\Drupal\config_translation\ConfigEntityMapper', 'base_route_name' => $base_route_name, 'title' => $entity_type->getLowercaseLabel(), - 'names' => array(), + 'names' => [], 'entity_type' => $entity_type_id, 'weight' => 10, - ); + ]; } } @@ -152,7 +152,7 @@ function config_translation_config_translation_info(&$info) { * Implements hook_entity_operation(). */ function config_translation_entity_operation(EntityInterface $entity) { - $operations = array(); + $operations = []; $entity_type = $entity->getEntityType(); if ($entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface') && $entity->hasLinkTemplate('config-translation-overview') && @@ -163,11 +163,11 @@ function config_translation_entity_operation(EntityInterface $entity) { $link_template = "config-translation-overview.{$entity->getTargetEntityTypeId()}"; } - $operations['translate'] = array( + $operations['translate'] = [ 'title' => t('Translate'), 'weight' => 50, 'url' => $entity->urlInfo($link_template), - ); + ]; } return $operations; @@ -177,7 +177,7 @@ function config_translation_entity_operation(EntityInterface $entity) { * Implements hook_config_schema_info_alter(). */ function config_translation_config_schema_info_alter(&$definitions) { - $map = array( + $map = [ 'label' => '\Drupal\config_translation\FormElement\Textfield', 'text' => '\Drupal\config_translation\FormElement\Textarea', 'date_format' => '\Drupal\config_translation\FormElement\DateFormat', @@ -185,7 +185,7 @@ function config_translation_config_schema_info_alter(&$definitions) { 'mapping' => '\Drupal\config_translation\FormElement\ListElement', 'sequence' => '\Drupal\config_translation\FormElement\ListElement', 'plural_label' => '\Drupal\config_translation\FormElement\PluralVariants', - ); + ]; // Enhance the text and date type definitions with classes to generate proper // form elements in ConfigTranslationFormBase. Other translatable types will diff --git a/core/modules/config_translation/src/ConfigEntityMapper.php b/core/modules/config_translation/src/ConfigEntityMapper.php index 5ba4456..5c5ae36 100644 --- a/core/modules/config_translation/src/ConfigEntityMapper.php +++ b/core/modules/config_translation/src/ConfigEntityMapper.php @@ -165,7 +165,7 @@ public function getTitle() { * {@inheritdoc} */ public function getBaseRouteParameters() { - return array($this->entityType => $this->entity->id()); + return [$this->entityType => $this->entity->id()]; } /** @@ -220,14 +220,14 @@ public function getTypeLabel() { * {@inheritdoc} */ public function getOperations() { - return array( - 'list' => array( + return [ + 'list' => [ 'title' => $this->t('List'), 'url' => Url::fromRoute('config_translation.entity_list', [ 'mapper_id' => $this->getPluginId(), ]), - ), - ); + ], + ]; } /** @@ -259,12 +259,12 @@ public function getOverviewRouteName() { */ protected function processRoute(Route $route) { // Add entity upcasting information. - $parameters = $route->getOption('parameters') ?: array(); - $parameters += array( - $this->entityType => array( + $parameters = $route->getOption('parameters') ?: []; + $parameters += [ + $this->entityType => [ 'type' => 'entity:' . $this->entityType, - ) - ); + ] + ]; $route->setOption('parameters', $parameters); } diff --git a/core/modules/config_translation/src/ConfigFieldMapper.php b/core/modules/config_translation/src/ConfigFieldMapper.php index a9f6d76..c0e085f 100644 --- a/core/modules/config_translation/src/ConfigFieldMapper.php +++ b/core/modules/config_translation/src/ConfigFieldMapper.php @@ -44,7 +44,7 @@ public function getOverviewRouteName() { */ public function getTypeLabel() { $base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']); - return $this->t('@label fields', array('@label' => $base_entity_info->getLabel())); + return $this->t('@label fields', ['@label' => $base_entity_info->getLabel()]); } /** diff --git a/core/modules/config_translation/src/ConfigMapperManager.php b/core/modules/config_translation/src/ConfigMapperManager.php index cd0b72f..a43f080 100644 --- a/core/modules/config_translation/src/ConfigMapperManager.php +++ b/core/modules/config_translation/src/ConfigMapperManager.php @@ -39,12 +39,12 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa /** * {@inheritdoc} */ - protected $defaults = array( + protected $defaults = [ 'title' => '', - 'names' => array(), + 'names' => [], 'weight' => 20, 'class' => '\Drupal\config_translation\ConfigNamesMapper', - ); + ]; /** * Constructs a ConfigMapperManager. @@ -72,7 +72,7 @@ public function __construct(CacheBackendInterface $cache_backend, LanguageManage $this->alterInfo('config_translation_info'); // Config translation only uses an info hook discovery, cache by language. $cache_key = 'config_translation_info_plugins' . ':' . $language_manager->getCurrentLanguage()->getId(); - $this->setCacheBackend($cache_backend, $cache_key, array('config_translation_info_plugins')); + $this->setCacheBackend($cache_backend, $cache_key, ['config_translation_info_plugins']); } /** @@ -90,7 +90,7 @@ protected function getDiscovery() { // request; when routes are being rebuilt at the end of the request, // this service only happens to get instantiated with the updated list // of installed themes. - $directories = array(); + $directories = []; foreach ($this->moduleHandler->getModuleList() as $name => $module) { $directories[$name] = $module->getPath(); } @@ -111,7 +111,7 @@ protected function getDiscovery() { * {@inheritdoc} */ public function getMappers(RouteCollection $collection = NULL) { - $mappers = array(); + $mappers = []; foreach ($this->getDefinitions() as $id => $definition) { $mappers[$id] = $this->createInstance($id); if ($collection) { @@ -155,7 +155,7 @@ protected function findDefinitions() { // If this plugin was provided by a module that does not exist, remove the // plugin definition. foreach ($definitions as $plugin_id => $plugin_definition) { - if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array('core', 'component')) && (!$this->moduleHandler->moduleExists($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array_keys($this->themeHandler->listInfo())))) { + if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider'], ['core', 'component']) && (!$this->moduleHandler->moduleExists($plugin_definition['provider']) && !in_array($plugin_definition['provider'], array_keys($this->themeHandler->listInfo())))) { unset($definitions[$plugin_id]); } } diff --git a/core/modules/config_translation/src/ConfigNamesMapper.php b/core/modules/config_translation/src/ConfigNamesMapper.php index bb82fe5..3b09d71 100644 --- a/core/modules/config_translation/src/ConfigNamesMapper.php +++ b/core/modules/config_translation/src/ConfigNamesMapper.php @@ -180,7 +180,7 @@ public function getBaseRouteName() { * {@inheritdoc} */ public function getBaseRouteParameters() { - return array(); + return []; } /** @@ -231,11 +231,11 @@ public function getOverviewRouteParameters() { public function getOverviewRoute() { $route = new Route( $this->getBaseRoute()->getPath() . '/translate', - array( + [ '_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemPage', 'plugin_id' => $this->getPluginId(), - ), - array('_config_translation_overview_access' => 'TRUE') + ], + ['_config_translation_overview_access' => 'TRUE'] ); $this->processRoute($route); return $route; @@ -272,11 +272,11 @@ public function getAddRouteParameters() { public function getAddRoute() { $route = new Route( $this->getBaseRoute()->getPath() . '/translate/{langcode}/add', - array( + [ '_form' => '\Drupal\config_translation\Form\ConfigTranslationAddForm', 'plugin_id' => $this->getPluginId(), - ), - array('_config_translation_form_access' => 'TRUE') + ], + ['_config_translation_form_access' => 'TRUE'] ); $this->processRoute($route); return $route; @@ -302,11 +302,11 @@ public function getEditRouteParameters() { public function getEditRoute() { $route = new Route( $this->getBaseRoute()->getPath() . '/translate/{langcode}/edit', - array( + [ '_form' => '\Drupal\config_translation\Form\ConfigTranslationEditForm', 'plugin_id' => $this->getPluginId(), - ), - array('_config_translation_form_access' => 'TRUE') + ], + ['_config_translation_form_access' => 'TRUE'] ); $this->processRoute($route); return $route; @@ -332,11 +332,11 @@ public function getDeleteRouteParameters() { public function getDeleteRoute() { $route = new Route( $this->getBaseRoute()->getPath() . '/translate/{langcode}/delete', - array( + [ '_form' => '\Drupal\config_translation\Form\ConfigTranslationDeleteForm', 'plugin_id' => $this->getPluginId(), - ), - array('_config_translation_form_access' => 'TRUE') + ], + ['_config_translation_form_access' => 'TRUE'] ); $this->processRoute($route); return $route; @@ -413,7 +413,7 @@ public function setLangcode($langcode) { * {@inheritdoc} */ public function getConfigData() { - $config_data = array(); + $config_data = []; foreach ($this->getConfigNames() as $name) { $config_data[$name] = $this->configFactory->getEditable($name)->get(); } @@ -467,12 +467,12 @@ public function getTypeName() { * {@inheritdoc} */ public function getOperations() { - return array( - 'translate' => array( + return [ + 'translate' => [ 'title' => $this->t('Translate'), 'url' => Url::fromRoute($this->getOverviewRouteName(), $this->getOverviewRouteParameters()), - ), - ); + ], + ]; } /** diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php b/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php index d0de341..c226dfb 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationBlockListBuilder.php @@ -18,7 +18,7 @@ class ConfigTranslationBlockListBuilder extends ConfigTranslationEntityListBuild * * @var array */ - protected $themes = array(); + protected $themes = []; /** * {@inheritdoc} @@ -58,20 +58,20 @@ public function buildRow(EntityInterface $entity) { $theme = $entity->getTheme(); $plugin_definition = $entity->getPlugin()->getPluginDefinition(); - $row['label'] = array( + $row['label'] = [ 'data' => $entity->label(), 'class' => 'table-filter-text-source', - ); + ]; - $row['theme'] = array( + $row['theme'] = [ 'data' => $this->themes[$theme]->info['name'], 'class' => 'table-filter-text-source', - ); + ]; - $row['category'] = array( + $row['category'] = [ 'data' => $plugin_definition['category'], 'class' => 'table-filter-text-source', - ); + ]; $row['operations']['data'] = $this->buildOperations($entity); @@ -93,7 +93,7 @@ public function buildHeader() { * {@inheritdoc} */ public function sortRows($a, $b) { - return $this->sortRowsMultiple($a, $b, array('theme', 'category', 'label')); + return $this->sortRowsMultiple($a, $b, ['theme', 'category', 'label']); } } diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationController.php b/core/modules/config_translation/src/Controller/ConfigTranslationController.php index 927a1e2..8d9bfe7 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationController.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationController.php @@ -134,12 +134,12 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl $mapper = $this->configMapperManager->createInstance($plugin_id); $mapper->populateFromRouteMatch($route_match); - $page = array(); - $page['#title'] = $this->t('Translations for %label', array('%label' => $mapper->getTitle())); + $page = []; + $page['#title'] = $this->t('Translations for %label', ['%label' => $mapper->getTitle()]); $languages = $this->languageManager->getLanguages(); if (count($languages) == 1) { - drupal_set_message($this->t('In order to translate configuration, the website must have at least two languages.', array(':url' => $this->url('entity.configurable_language.collection'))), 'warning'); + drupal_set_message($this->t('In order to translate configuration, the website must have at least two languages.', [':url' => $this->url('entity.configurable_language.collection')]), 'warning'); } try { @@ -172,7 +172,7 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl // If the language is not configured on the site, create a dummy language // object for this listing only to ensure the user gets useful info. $language_name = $this->languageManager->getLanguageName($original_langcode); - $languages[$original_langcode] = new Language(array('id' => $original_langcode, 'name' => $language_name)); + $languages[$original_langcode] = new Language(['id' => $original_langcode, 'name' => $language_name]); } // We create a fake request object to pass into @@ -181,10 +181,10 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl // possible nor performant. $fake_request = $request->duplicate(); - $page['languages'] = array( + $page['languages'] = [ '#type' => 'table', - '#header' => array($this->t('Language'), $this->t('Operations')), - ); + '#header' => [$this->t('Language'), $this->t('Operations')], + ]; foreach ($languages as $language) { $langcode = $language->getId(); @@ -198,57 +198,57 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl // Prepare the language name and the operations depending on whether this // is the original language or not. if ($langcode == $original_langcode) { - $language_name = '' . $this->t('@language (original)', array('@language' => $language->getName())) . ''; + $language_name = '' . $this->t('@language (original)', ['@language' => $language->getName()]) . ''; // Check access for the path/route for editing, so we can decide to // include a link to edit or not. $edit_access = $this->accessManager->checkNamedRoute($mapper->getBaseRouteName(), $route_match->getRawParameters()->all(), $this->account); // Build list of operations. - $operations = array(); + $operations = []; if ($edit_access) { - $operations['edit'] = array( + $operations['edit'] = [ 'title' => $this->t('Edit'), 'url' => Url::fromRoute($mapper->getBaseRouteName(), $mapper->getBaseRouteParameters(), ['query' => ['destination' => $mapper->getOverviewPath()]]), - ); + ]; } } else { $language_name = $language->getName(); - $operations = array(); + $operations = []; // If no translation exists for this language, link to add one. if (!$mapper->hasTranslation($language)) { - $operations['add'] = array( + $operations['add'] = [ 'title' => $this->t('Add'), 'url' => Url::fromRoute($mapper->getAddRouteName(), $mapper->getAddRouteParameters()), - ); + ]; } else { // Otherwise, link to edit the existing translation. - $operations['edit'] = array( + $operations['edit'] = [ 'title' => $this->t('Edit'), 'url' => Url::fromRoute($mapper->getEditRouteName(), $mapper->getEditRouteParameters()), - ); + ]; - $operations['delete'] = array( + $operations['delete'] = [ 'title' => $this->t('Delete'), 'url' => Url::fromRoute($mapper->getDeleteRouteName(), $mapper->getDeleteRouteParameters()), - ); + ]; } } - $page['languages'][$langcode]['language'] = array( + $page['languages'][$langcode]['language'] = [ '#markup' => $language_name, - ); + ]; - $page['languages'][$langcode]['operations'] = array( + $page['languages'][$langcode]['operations'] = [ '#type' => 'operations', '#links' => $operations, // Even if the mapper contains multiple language codes, the source // configuration can still be edited. '#access' => ($langcode == $original_langcode) || $operations_access, - ); + ]; } return $page; } diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php b/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php index e86237e..87cb260 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationEntityListBuilder.php @@ -16,10 +16,10 @@ class ConfigTranslationEntityListBuilder extends ConfigEntityListBuilder impleme * @return array */ protected function getFilterLabels() { - return array( + return [ 'placeholder' => $this->t('Enter label'), 'description' => $this->t('Enter a part of the label or description to filter by.'), - ); + ]; } /** @@ -29,28 +29,28 @@ public function render() { $build = parent::render(); $filter = $this->getFilterLabels(); - usort($build['table']['#rows'], array($this, 'sortRows')); + usort($build['table']['#rows'], [$this, 'sortRows']); - $build['filters'] = array( + $build['filters'] = [ '#type' => 'container', - '#attributes' => array( - 'class' => array('table-filter', 'js-show'), - ), + '#attributes' => [ + 'class' => ['table-filter', 'js-show'], + ], '#weight' => -10, - ); + ]; - $build['filters']['text'] = array( + $build['filters']['text'] = [ '#type' => 'search', '#title' => $this->t('Search'), '#size' => 30, '#placeholder' => $filter['placeholder'], - '#attributes' => array( - 'class' => array('table-filter-text'), + '#attributes' => [ + 'class' => ['table-filter-text'], 'data-table' => '.config-translation-entity-list', 'autocomplete' => 'off', 'title' => $filter['description'], - ), - ); + ], + ]; $build['table']['#attributes']['class'][] = 'config-translation-entity-list'; $build['table']['#weight'] = 0; @@ -95,7 +95,7 @@ public function getOperations(EntityInterface $entity) { * {@inheritdoc} */ public function sortRows($a, $b) { - return $this->sortRowsMultiple($a, $b, array('label')); + return $this->sortRowsMultiple($a, $b, ['label']); } /** diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php b/core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php index 6388c81..566afdb 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationFieldListBuilder.php @@ -26,14 +26,14 @@ class ConfigTranslationFieldListBuilder extends ConfigTranslationEntityListBuild * * @var array */ - protected $baseEntityInfo = array(); + protected $baseEntityInfo = []; /** * The bundle info for the base entity type. * * @var array */ - protected $baseEntityBundles = array(); + protected $baseEntityBundles = []; /** * The entity manager. @@ -99,8 +99,8 @@ public function getFilterLabels() { $bundle = $this->baseEntityInfo->getBundleLabel() ?: $this->t('Bundle'); $bundle = Unicode::strtolower($bundle); - $info['placeholder'] = $this->t('Enter field or @bundle', array('@bundle' => $bundle)); - $info['description'] = $this->t('Enter a part of the field or @bundle to filter by.', array('@bundle' => $bundle)); + $info['placeholder'] = $this->t('Enter field or @bundle', ['@bundle' => $bundle]); + $info['description'] = $this->t('Enter a part of the field or @bundle to filter by.', ['@bundle' => $bundle]); return $info; } @@ -109,17 +109,17 @@ public function getFilterLabels() { * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { - $row['label'] = array( + $row['label'] = [ 'data' => $entity->label(), 'class' => 'table-filter-text-source', - ); + ]; if ($this->displayBundle()) { $bundle = $entity->get('bundle'); - $row['bundle'] = array( + $row['bundle'] = [ 'data' => $this->baseEntityBundles[$bundle]['label'], 'class' => 'table-filter-text-source', - ); + ]; } return $row + parent::buildRow($entity); @@ -165,7 +165,7 @@ public function displayBundle() { * {@inheritdoc} */ public function sortRows($a, $b) { - return $this->sortRowsMultiple($a, $b, array('bundle', 'label')); + return $this->sortRowsMultiple($a, $b, ['bundle', 'label']); } } diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationMapperList.php b/core/modules/config_translation/src/Controller/ConfigTranslationMapperList.php index f47d313..4e510aa 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationMapperList.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationMapperList.php @@ -46,13 +46,13 @@ public static function create(ContainerInterface $container) { * Renderable array with config translation mappers. */ public function render() { - $build = array( + $build = [ '#type' => 'table', '#header' => $this->buildHeader(), - '#rows' => array(), - ); + '#rows' => [], + ]; - $mappers = array(); + $mappers = []; foreach ($this->mappers as $mapper) { if ($row = $this->buildRow($mapper)) { @@ -120,10 +120,10 @@ protected function buildOperations(ConfigMapperInterface $mapper) { // Retrieve and sort operations. $operations = $mapper->getOperations(); uasort($operations, 'Drupal\Component\Utility\SortArray::sortByWeightElement'); - $build = array( + $build = [ '#type' => 'operations', '#links' => $operations, - ); + ]; return $build; } diff --git a/core/modules/config_translation/src/Form/ConfigTranslationAddForm.php b/core/modules/config_translation/src/Form/ConfigTranslationAddForm.php index 3d06202..9edcb8c 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationAddForm.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationAddForm.php @@ -22,10 +22,10 @@ public function getFormId() { */ public function buildForm(array $form, FormStateInterface $form_state, RouteMatchInterface $route_match = NULL, $plugin_id = NULL, $langcode = NULL) { $form = parent::buildForm($form, $form_state, $route_match, $plugin_id, $langcode); - $form['#title'] = $this->t('Add @language translation for %label', array( + $form['#title'] = $this->t('Add @language translation for %label', [ '%label' => $this->mapper->getTitle(), '@language' => $this->language->getName(), - )); + ]); return $form; } @@ -34,7 +34,7 @@ public function buildForm(array $form, FormStateInterface $form_state, RouteMatc */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); - drupal_set_message($this->t('Successfully saved @language translation.', array('@language' => $this->language->getName()))); + drupal_set_message($this->t('Successfully saved @language translation.', ['@language' => $this->language->getName()])); } } diff --git a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php index 089ae27..ca3ad28 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationDeleteForm.php @@ -84,7 +84,7 @@ public static function create(ContainerInterface $container) { * {@inheritdoc} */ public function getQuestion() { - return $this->t('Are you sure you want to delete the @language translation of %label?', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->getName())); + return $this->t('Are you sure you want to delete the @language translation of %label?', ['%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()]); } /** @@ -140,7 +140,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $cache_backend->deleteAll(); } - drupal_set_message($this->t('@language translation of %label was deleted', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()))); + drupal_set_message($this->t('@language translation of %label was deleted', ['%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()])); $form_state->setRedirectUrl($this->getCancelUrl()); } diff --git a/core/modules/config_translation/src/Form/ConfigTranslationEditForm.php b/core/modules/config_translation/src/Form/ConfigTranslationEditForm.php index 5af4244..86a8f1c 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationEditForm.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationEditForm.php @@ -22,10 +22,10 @@ public function getFormId() { */ public function buildForm(array $form, FormStateInterface $form_state, RouteMatchInterface $route_match = NULL, $plugin_id = NULL, $langcode = NULL) { $form = parent::buildForm($form, $form_state, $route_match, $plugin_id, $langcode); - $form['#title'] = $this->t('Edit @language translation for %label', array( + $form['#title'] = $this->t('Edit @language translation for %label', [ '%label' => $this->mapper->getTitle(), '@language' => $this->language->getName(), - )); + ]); return $form; } @@ -34,7 +34,7 @@ public function buildForm(array $form, FormStateInterface $form_state, RouteMatc */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); - drupal_set_message($this->t('Successfully updated @language translation.', array('@language' => $this->language->getName()))); + drupal_set_message($this->t('Successfully updated @language translation.', ['@language' => $this->language->getName()])); } } diff --git a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php index 12e0216..82f01d7 100644 --- a/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php +++ b/core/modules/config_translation/src/Form/ConfigTranslationFormBase.php @@ -65,7 +65,7 @@ * * @var array */ - protected $baseConfigData = array(); + protected $baseConfigData = []; /** * Constructs a ConfigTranslationFormBase. @@ -164,26 +164,26 @@ public function buildForm(array $form, FormStateInterface $form_state, RouteMatc // Even though this is a nested form, we do not set #tree to TRUE because // the form value structure is generated by using #parents for each element. // @see \Drupal\config_translation\FormElement\FormElementBase::getElements() - $form['config_names'] = array('#type' => 'container'); + $form['config_names'] = ['#type' => 'container']; foreach ($this->mapper->getConfigNames() as $name) { - $form['config_names'][$name] = array('#type' => 'container'); + $form['config_names'][$name] = ['#type' => 'container']; $schema = $this->typedConfigManager->get($name); $source_config = $this->baseConfigData[$name]; $translation_config = $this->configFactory()->get($name)->get(); if ($form_element = $this->createFormElement($schema)) { - $parents = array('config_names', $name); + $parents = ['config_names', $name]; $form['config_names'][$name] += $form_element->getTranslationBuild($this->sourceLanguage, $this->language, $source_config, $translation_config, $parents); } } $form['actions']['#type'] = 'actions'; - $form['actions']['submit'] = array( + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Save translation'), '#button_type' => 'primary', - ); + ]; // Set the configuration language back. $this->languageManager->setConfigOverrideLanguage($original_language); @@ -195,7 +195,7 @@ public function buildForm(array $form, FormStateInterface $form_state, RouteMatc * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - $form_values = $form_state->getValue(array('translation', 'config_names')); + $form_values = $form_state->getValue(['translation', 'config_names']); foreach ($this->mapper->getConfigNames() as $name) { $schema = $this->typedConfigManager->get($name); diff --git a/core/modules/config_translation/src/FormElement/DateFormat.php b/core/modules/config_translation/src/FormElement/DateFormat.php index 4a4b995..d0ae033 100644 --- a/core/modules/config_translation/src/FormElement/DateFormat.php +++ b/core/modules/config_translation/src/FormElement/DateFormat.php @@ -16,7 +16,7 @@ public function getTranslationElement(LanguageInterface $translation_language, $ /** @var \Drupal\Core\Datetime\DateFormatterInterface $date_formatter */ $date_formatter = \Drupal::service('date.formatter'); $description = $this->t('A user-defined date format. See the PHP manual for available options.'); - $format = $this->t('Displayed as %date_format', array('%date_format' => $date_formatter->format(REQUEST_TIME, 'custom', $translation_config))); + $format = $this->t('Displayed as %date_format', ['%date_format' => $date_formatter->format(REQUEST_TIME, 'custom', $translation_config)]); return [ '#type' => 'textfield', diff --git a/core/modules/config_translation/src/FormElement/FormElementBase.php b/core/modules/config_translation/src/FormElement/FormElementBase.php index 2b5c8f4..3c97daf 100644 --- a/core/modules/config_translation/src/FormElement/FormElementBase.php +++ b/core/modules/config_translation/src/FormElement/FormElementBase.php @@ -64,8 +64,8 @@ public function getTranslationBuild(LanguageInterface $source_language, Language $build['source'] = $this->getSourceElement($source_language, $source_config); $build['translation'] = $this->getTranslationElement($translation_language, $source_config, $translation_config); - $build['source']['#parents'] = array_merge(array('source'), $parents); - $build['translation']['#parents'] = array_merge(array('translation'), $parents); + $build['source']['#parents'] = array_merge(['source'], $parents); + $build['translation']['#parents'] = array_merge(['translation'], $parents); return $build; } @@ -93,15 +93,15 @@ protected function getSourceElement(LanguageInterface $source_language, $source_ $value = $this->t('(Empty)'); } - return array( + return [ '#type' => 'item', - '#title' => $this->t('@label (@source_language)', array( + '#title' => $this->t('@label (@source_language)', [ // Labels originate from configuration schema and are translatable. '@label' => $this->t($this->definition->getLabel()), '@source_language' => $source_language->getName(), - )), + ]), '#markup' => $value, - ); + ]; } /** @@ -157,15 +157,15 @@ protected function getSourceElement(LanguageInterface $source_language, $source_ */ protected function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) { // Add basic properties that apply to all form elements. - return array( - '#title' => $this->t('@label (@source_language)', array( + return [ + '#title' => $this->t('@label (@source_language)', [ // Labels originate from configuration schema and are translatable. '@label' => $this->t($this->definition->getLabel()), '@source_language' => $translation_language->getName(), - )), + ]), '#default_value' => $translation_config, - '#attributes' => array('lang' => $translation_language->getId()), - ); + '#attributes' => ['lang' => $translation_language->getId()], + ]; } /** diff --git a/core/modules/config_translation/src/FormElement/ListElement.php b/core/modules/config_translation/src/FormElement/ListElement.php index e956536..1ea4523 100644 --- a/core/modules/config_translation/src/FormElement/ListElement.php +++ b/core/modules/config_translation/src/FormElement/ListElement.php @@ -46,14 +46,14 @@ public static function create(TypedDataInterface $schema) { * {@inheritdoc} */ public function getTranslationBuild(LanguageInterface $source_language, LanguageInterface $translation_language, $source_config, $translation_config, array $parents, $base_key = NULL) { - $build = array(); + $build = []; foreach ($this->element as $key => $element) { - $sub_build = array(); + $sub_build = []; $element_key = isset($base_key) ? "$base_key.$key" : $key; $definition = $element->getDataDefinition(); if ($form_element = ConfigTranslationFormBase::createFormElement($element)) { - $element_parents = array_merge($parents, array($key)); + $element_parents = array_merge($parents, [$key]); $sub_build += $form_element->getTranslationBuild($source_language, $translation_language, $source_config[$key], $translation_config[$key], $element_parents, $element_key); if (empty($sub_build)) { @@ -62,13 +62,13 @@ public function getTranslationBuild(LanguageInterface $source_language, Language // Build the sub-structure and include it with a wrapper in the form if // there are any translatable elements there. - $build[$key] = array(); + $build[$key] = []; if ($element instanceof TraversableTypedDataInterface) { - $build[$key] = array( + $build[$key] = [ '#type' => 'details', '#title' => $this->getGroupTitle($definition, $sub_build), '#open' => empty($base_key), - ); + ]; } $build[$key] += $sub_build; } diff --git a/core/modules/config_translation/src/FormElement/PluralVariants.php b/core/modules/config_translation/src/FormElement/PluralVariants.php index 624ff77..aabca8a 100644 --- a/core/modules/config_translation/src/FormElement/PluralVariants.php +++ b/core/modules/config_translation/src/FormElement/PluralVariants.php @@ -18,25 +18,25 @@ class PluralVariants extends FormElementBase { protected function getSourceElement(LanguageInterface $source_language, $source_config) { $plurals = $this->getNumberOfPlurals($source_language->getId()); $values = explode(LOCALE_PLURAL_DELIMITER, $source_config); - $element = array( + $element = [ '#type' => 'fieldset', - '#title' => SafeMarkup::format('@label (@source_language)', array( + '#title' => SafeMarkup::format('@label (@source_language)', [ // Labels originate from configuration schema and are translatable. '@label' => $this->t($this->definition->getLabel()), '@source_language' => $source_language->getName(), - )), + ]), '#tree' => TRUE, - ); + ]; for ($i = 0; $i < $plurals; $i++) { - $element[$i] = array( + $element[$i] = [ '#type' => 'item', // @todo Should use better labels https://www.drupal.org/node/2499639 '#title' => $i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form'), - '#markup' => SafeMarkup::format('@value', array( + '#markup' => SafeMarkup::format('@value', [ '@langcode' => $source_language->getId(), '@value' => isset($values[$i]) ? $values[$i] : $this->t('(Empty)'), - )), - ); + ]), + ]; } return $element; } @@ -47,23 +47,23 @@ protected function getSourceElement(LanguageInterface $source_language, $source_ protected function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) { $plurals = $this->getNumberOfPlurals($translation_language->getId()); $values = explode(LOCALE_PLURAL_DELIMITER, $translation_config); - $element = array( + $element = [ '#type' => 'fieldset', - '#title' => SafeMarkup::format('@label (@translation_language)', array( + '#title' => SafeMarkup::format('@label (@translation_language)', [ // Labels originate from configuration schema and are translatable. '@label' => $this->t($this->definition->getLabel()), '@translation_language' => $translation_language->getName(), - )), + ]), '#tree' => TRUE, - ); + ]; for ($i = 0; $i < $plurals; $i++) { - $element[$i] = array( + $element[$i] = [ '#type' => 'textfield', // @todo Should use better labels https://www.drupal.org/node/2499639 '#title' => $i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form'), '#default_value' => isset($values[$i]) ? $values[$i] : '', - '#attributes' => array('lang' => $translation_language->getId()), - ); + '#attributes' => ['lang' => $translation_language->getId()], + ]; } return $element; } diff --git a/core/modules/config_translation/src/FormElement/TextFormat.php b/core/modules/config_translation/src/FormElement/TextFormat.php index e9d56f2..f9f6bc6 100644 --- a/core/modules/config_translation/src/FormElement/TextFormat.php +++ b/core/modules/config_translation/src/FormElement/TextFormat.php @@ -16,25 +16,25 @@ public function getSourceElement(LanguageInterface $source_language, $source_con // Instead of the formatted output show a disabled textarea. This allows for // easier side-by-side comparison, especially with formats with text // editors. - return $this->getTranslationElement($source_language, $source_config, $source_config) + array( + return $this->getTranslationElement($source_language, $source_config, $source_config) + [ '#value' => $source_config['value'], '#disabled' => TRUE, '#allow_focus' => TRUE, - ); + ]; } /** * {@inheritdoc} */ public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) { - return array( + return [ '#type' => 'text_format', // Override the #default_value property from the parent class. '#default_value' => $translation_config['value'], '#format' => $translation_config['format'], // @see \Drupal\config_translation\Element\FormElementBase::getTranslationElement() - '#allowed_formats' => array($source_config['format']), - ) + parent::getTranslationElement($translation_language, $source_config, $translation_config); + '#allowed_formats' => [$source_config['format']], + ] + parent::getTranslationElement($translation_language, $source_config, $translation_config); } } diff --git a/core/modules/config_translation/src/FormElement/Textarea.php b/core/modules/config_translation/src/FormElement/Textarea.php index 174a70c..ff9e4cd 100644 --- a/core/modules/config_translation/src/FormElement/Textarea.php +++ b/core/modules/config_translation/src/FormElement/Textarea.php @@ -18,10 +18,10 @@ public function getTranslationElement(LanguageInterface $translation_language, $ $rows_newlines = substr_count($translation_config, "\n" ) + 1; $rows = max($rows_words, $rows_newlines); - return array( + return [ '#type' => 'textarea', '#rows' => $rows, - ) + parent::getTranslationElement($translation_language, $source_config, $translation_config); + ] + parent::getTranslationElement($translation_language, $source_config, $translation_config); } } diff --git a/core/modules/config_translation/src/FormElement/Textfield.php b/core/modules/config_translation/src/FormElement/Textfield.php index fa0c869..cff1037 100644 --- a/core/modules/config_translation/src/FormElement/Textfield.php +++ b/core/modules/config_translation/src/FormElement/Textfield.php @@ -13,9 +13,9 @@ class Textfield extends FormElementBase { * {@inheritdoc} */ public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) { - return array( + return [ '#type' => 'textfield', - ) + parent::getTranslationElement($translation_language, $source_config, $translation_config); + ] + parent::getTranslationElement($translation_language, $source_config, $translation_config); } } diff --git a/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php b/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php index fb2bf24..63145a5 100644 --- a/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php +++ b/core/modules/config_translation/src/Plugin/Menu/ContextualLink/ConfigTranslationContextualLink.php @@ -28,7 +28,7 @@ public function getTitle() { // storing the title on the plugin definition for the link) because it // contains translated parts that we need in the runtime language. $type_name = Unicode::strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel()); - return $this->t('Translate @type_name', array('@type_name' => $type_name)); + return $this->t('Translate @type_name', ['@type_name' => $type_name]); } /** diff --git a/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php b/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php index 63605c6..5a88d91 100644 --- a/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php +++ b/core/modules/config_translation/src/Plugin/Menu/LocalTask/ConfigTranslationLocalTask.php @@ -28,7 +28,7 @@ public function getTitle() { // storing the title on the plugin definition for the link) because // it contains translated parts that we need in the runtime language. $type_name = Unicode::strtolower($this->mapperManager()->createInstance($this->pluginDefinition['config_translation_plugin_id'])->getTypeLabel()); - return $this->t('Translate @type_name', array('@type_name' => $type_name)); + return $this->t('Translate @type_name', ['@type_name' => $type_name]); } /** diff --git a/core/modules/config_translation/src/Routing/RouteSubscriber.php b/core/modules/config_translation/src/Routing/RouteSubscriber.php index b20c13f..10044aa 100644 --- a/core/modules/config_translation/src/Routing/RouteSubscriber.php +++ b/core/modules/config_translation/src/Routing/RouteSubscriber.php @@ -48,7 +48,7 @@ protected function alterRoutes(RouteCollection $collection) { */ public static function getSubscribedEvents() { // Come after field_ui. - $events[RoutingEvents::ALTER] = array('onAlterRoutes', -110); + $events[RoutingEvents::ALTER] = ['onAlterRoutes', -110]; return $events; } diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationDateFormatUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationDateFormatUiTest.php index ceb69d0..b38d8d0 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationDateFormatUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationDateFormatUiTest.php @@ -12,11 +12,11 @@ */ class ConfigTranslationDateFormatUiTest extends WebTestBase { - public static $modules = array( + public static $modules = [ 'language', 'config_translation', 'system' - ); + ]; protected function setUp() { parent::setUp(); @@ -27,10 +27,10 @@ protected function setUp() { ConfigurableLanguage::createFromLangcode($langcode)->save(); } - $user = $this->drupalCreateUser(array( + $user = $this->drupalCreateUser([ 'administer site configuration', 'translate configuration', - )); + ]); $this->drupalLogin($user); } diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationFormTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationFormTest.php index 648f047..387d686 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationFormTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationFormTest.php @@ -17,7 +17,7 @@ class ConfigTranslationFormTest extends WebTestBase { * * @var array */ - public static $modules = array('config_translation', 'config_translation_test', 'editor'); + public static $modules = ['config_translation', 'config_translation_test', 'editor']; /** * The plugin ID of the mapper to test. @@ -40,7 +40,7 @@ protected function setUp() { $this->pluginId = key($definitions); $this->langcode = 'xx'; - ConfigurableLanguage::create(array('id' => $this->langcode, 'label' => 'XX'))->save(); + ConfigurableLanguage::create(['id' => $this->langcode, 'label' => 'XX'])->save(); \Drupal::state()->set('config_translation_test_alter_form_alter', TRUE); } diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php index 8bd3d71..9707189 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php @@ -26,7 +26,7 @@ class ConfigTranslationListUiTest extends WebTestBase { * * @var array */ - public static $modules = array( + public static $modules = [ 'block', 'config_translation', 'contact', @@ -40,7 +40,7 @@ class ConfigTranslationListUiTest extends WebTestBase { 'image', 'responsive_image', 'toolbar', - ); + ]; /** * Admin user with all needed permissions. @@ -52,7 +52,7 @@ class ConfigTranslationListUiTest extends WebTestBase { protected function setUp() { parent::setUp(); - $permissions = array( + $permissions = [ 'access site-wide contact form', 'administer blocks', 'administer contact forms', @@ -70,7 +70,7 @@ protected function setUp() { 'administer image styles', 'administer responsive images', 'translate configuration', - ); + ]; // Create and log in user. $this->adminUser = $this->drupalCreateUser($permissions); @@ -94,7 +94,7 @@ protected function doBlockListTest() { // Add a test block, any block will do. // Set the machine name so the translate link can be built later. $id = Unicode::strtolower($this->randomMachineName(16)); - $this->drupalPlaceBlock('system_powered_by_block', array('id' => $id)); + $this->drupalPlaceBlock('system_powered_by_block', ['id' => $id]); // Get the Block listing. $this->drupalGet('admin/structure/block'); @@ -118,11 +118,11 @@ protected function doMenuListTest() { // Lowercase the machine name. $menu_name = Unicode::strtolower($this->randomMachineName(16)); $label = $this->randomMachineName(16); - $edit = array( + $edit = [ 'id' => $menu_name, 'description' => '', 'label' => $label, - ); + ]; // Create the menu by posting the form. $this->drupalPostForm('admin/structure/menu/add', $edit, t('Save')); @@ -135,9 +135,9 @@ protected function doMenuListTest() { // Check if the Link is not added if you are missing 'translate // configuration' permission. - $permissions = array( + $permissions = [ 'administer menu', - ); + ]; $this->drupalLogin($this->drupalCreateUser($permissions)); // Get the Menu listing. @@ -186,11 +186,11 @@ protected function doVocabularyListTest() { public function doCustomContentTypeListTest() { // Create a test custom block type to decouple looking for translate // operations link so this does not test more than necessary. - $block_content_type = BlockContentType::create(array( + $block_content_type = BlockContentType::create([ 'id' => Unicode::strtolower($this->randomMachineName(16)), 'label' => $this->randomMachineName(), 'revision' => FALSE - )); + ]); $block_content_type->save(); // Get the custom block type listing. @@ -235,10 +235,10 @@ public function doContactFormsListTest() { public function doContentTypeListTest() { // Create a test content type to decouple looking for translate operations // link so this does not test more than necessary. - $content_type = $this->drupalCreateContentType(array( + $content_type = $this->drupalCreateContentType([ 'type' => Unicode::strtolower($this->randomMachineName(16)), 'name' => $this->randomMachineName(), - )); + ]); // Get the content type listing. $this->drupalGet('admin/structure/types'); @@ -258,10 +258,10 @@ public function doContentTypeListTest() { public function doFormatsListTest() { // Create a test format to decouple looking for translate operations // link so this does not test more than necessary. - $filter_format = FilterFormat::create(array( + $filter_format = FilterFormat::create([ 'format' => Unicode::strtolower($this->randomMachineName(16)), 'name' => $this->randomMachineName(), - )); + ]); $filter_format->save(); // Get the format listing. @@ -282,10 +282,10 @@ public function doFormatsListTest() { public function doShortcutListTest() { // Create a test shortcut to decouple looking for translate operations // link so this does not test more than necessary. - $shortcut = ShortcutSet::create(array( + $shortcut = ShortcutSet::create([ 'id' => Unicode::strtolower($this->randomMachineName(16)), 'label' => $this->randomString(), - )); + ]); $shortcut->save(); // Get the shortcut listing. @@ -307,7 +307,7 @@ public function doUserRoleListTest() { // Create a test role to decouple looking for translate operations // link so this does not test more than necessary. $role_id = Unicode::strtolower($this->randomMachineName(16)); - $this->drupalCreateRole(array(), $role_id); + $this->drupalCreateRole([], $role_id); // Get the role listing. $this->drupalGet('admin/people/roles'); @@ -361,13 +361,13 @@ public function doImageStyleListTest() { * Tests the responsive image mapping listing for the translate operation. */ public function doResponsiveImageListTest() { - $edit = array(); + $edit = []; $edit['label'] = $this->randomMachineName(); $edit['id'] = strtolower($edit['label']); $edit['fallback_image_style'] = 'thumbnail'; $this->drupalPostForm('admin/config/media/responsive-image-style/add', $edit, t('Save')); - $this->assertRaw(t('Responsive image style %label saved.', array('%label' => $edit['label']))); + $this->assertRaw(t('Responsive image style %label saved.', ['%label' => $edit['label']])); // Get the responsive image style listing. $this->drupalGet('admin/config/media/responsive-image-style'); @@ -386,17 +386,17 @@ public function doResponsiveImageListTest() { */ public function doFieldListTest() { // Create a base content type. - $content_type = $this->drupalCreateContentType(array( + $content_type = $this->drupalCreateContentType([ 'type' => Unicode::strtolower($this->randomMachineName(16)), 'name' => $this->randomMachineName(), - )); + ]); // Create a block content type. - $block_content_type = BlockContentType::create(array( + $block_content_type = BlockContentType::create([ 'id' => 'basic', 'label' => 'Basic', 'revision' => FALSE - )); + ]); $block_content_type->save(); $field = FieldConfig::create([ // The field storage is guaranteed to exist because it is supplied by the @@ -404,21 +404,21 @@ public function doFieldListTest() { 'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'), 'bundle' => $block_content_type->id(), 'label' => 'Body', - 'settings' => array('display_summary' => FALSE), + 'settings' => ['display_summary' => FALSE], ]); $field->save(); // Look at a few fields on a few entity types. - $pages = array( - array( + $pages = [ + [ 'list' => 'admin/structure/types/manage/' . $content_type->id() . '/fields', 'field' => 'node.' . $content_type->id() . '.body', - ), - array( + ], + [ 'list' => 'admin/structure/block/block-content/manage/basic/fields', 'field' => 'block_content.basic.body', - ), - ); + ], + ]; foreach ($pages as $values) { // Get fields listing. diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php index e7c58fd..d593a69 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationOverviewTest.php @@ -35,7 +35,7 @@ class ConfigTranslationOverviewTest extends WebTestBase { * * @var array */ - protected $langcodes = array('fr', 'ta'); + protected $langcodes = ['fr', 'ta']; /** * String translation storage object. @@ -46,7 +46,7 @@ class ConfigTranslationOverviewTest extends WebTestBase { protected function setUp() { parent::setUp(); - $permissions = array( + $permissions = [ 'translate configuration', 'administer languages', 'administer site configuration', @@ -54,7 +54,7 @@ protected function setUp() { 'access site-wide contact form', 'access contextual links', 'administer views', - ); + ]; // Create and log in user. $this->drupalLogin($this->drupalCreateUser($permissions)); @@ -83,17 +83,17 @@ public function testMapperListPage() { } } - $labels = array( + $labels = [ '&$nxd~i0', 'some "label" with quotes', $this->randomString(), - ); + ]; foreach ($labels as $label) { - $test_entity = entity_create('config_test', array( + $test_entity = entity_create('config_test', [ 'id' => $this->randomMachineName(), 'label' => $label, - )); + ]); $test_entity->save(); $base_url = 'admin/structure/config_test/manage/' . $test_entity->id(); @@ -119,7 +119,7 @@ public function testMapperListPage() { $this->assertRaw('' . t('Language') . ''); $this->drupalGet($base_url); - $this->assertLink(t('Translate @title', array('@title' => $entity_type->getLowercaseLabel()))); + $this->assertLink(t('Translate @title', ['@title' => $entity_type->getLowercaseLabel()])); } } @@ -154,10 +154,10 @@ public function testListingPageWithOverrides() { $config_test_storage = $this->container->get('entity.manager')->getStorage('config_test'); // Set up an override. - $settings['config']['config_test.dynamic.dotted.default']['label'] = (object) array( + $settings['config']['config_test.dynamic.dotted.default']['label'] = (object) [ 'value' => $overridden_label, 'required' => TRUE, - ); + ]; $this->writeSettings($settings); // Test that the overridden label is loaded with the entity. diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php index b69357e..d5f5e54 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php @@ -48,7 +48,7 @@ class ConfigTranslationUiTest extends WebTestBase { * * @var array */ - protected $langcodes = array('fr', 'ta'); + protected $langcodes = ['fr', 'ta']; /** * Administrator user for tests. @@ -157,13 +157,13 @@ public function testSiteInformationTranslationUi() { $this->assertRaw($site_slogan); // Update site name and slogan for French. - $edit = array( + $edit = [ 'translation[config_names][system.site][name]' => $fr_site_name, 'translation[config_names][system.site][slogan]' => $fr_site_slogan, - ); + ]; $this->drupalPostForm("$translation_base_url/fr/add", $edit, t('Save translation')); - $this->assertRaw(t('Successfully saved @language translation.', array('@language' => 'French'))); + $this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French'])); // Check for edit, delete links (and no 'add' link) for French language. $this->assertNoLinkByHref("$translation_base_url/fr/add"); @@ -189,18 +189,18 @@ public function testSiteInformationTranslationUi() { $this->assertText($site_slogan); // Translate 'Site name' label in French. - $search = array( + $search = [ 'string' => $site_name_label, 'langcode' => 'fr', 'translation' => 'untranslated', - ); + ]; $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter')); $textarea = current($this->xpath('//textarea')); $lid = (string) $textarea[0]['name']; - $edit = array( + $edit = [ $lid => $fr_site_name_label, - ); + ]; $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations')); // Ensure that the label is in French (and not in English). @@ -234,10 +234,10 @@ public function testSourceValueDuplicateSave() { $this->drupalGet($translation_base_url); // Case 1: Update new value for site slogan and site name. - $edit = array( + $edit = [ 'translation[config_names][system.site][name]' => 'FR ' . $site_name, 'translation[config_names][system.site][slogan]' => 'FR ' . $site_slogan, - ); + ]; // First time, no overrides, so just Add link. $this->drupalPostForm("$translation_base_url/fr/add", $edit, t('Save translation')); @@ -245,10 +245,10 @@ public function testSourceValueDuplicateSave() { $override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.site'); // Expect both name and slogan in language specific file. - $expected = array( + $expected = [ 'name' => 'FR ' . $site_name, 'slogan' => 'FR ' . $site_slogan, - ); + ]; $this->assertEqual($expected, $override->get()); // Case 2: Update new value for site slogan and default value for site name. @@ -257,12 +257,12 @@ public function testSourceValueDuplicateSave() { // translation form into the actual site name and slogan. $this->assertNoText('FR ' . $site_name); $this->assertNoText('FR ' . $site_slogan); - $edit = array( + $edit = [ 'translation[config_names][system.site][name]' => $site_name, 'translation[config_names][system.site][slogan]' => 'FR ' . $site_slogan, - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save translation')); - $this->assertRaw(t('Successfully updated @language translation.', array('@language' => 'French'))); + $this->assertRaw(t('Successfully updated @language translation.', ['@language' => 'French'])); $override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.site'); // Expect only slogan in language specific file. @@ -272,10 +272,10 @@ public function testSourceValueDuplicateSave() { // Case 3: Keep default value for site name and slogan. $this->drupalGet("$translation_base_url/fr/edit"); $this->assertNoText('FR ' . $site_slogan); - $edit = array( + $edit = [ 'translation[config_names][system.site][name]' => $site_name, 'translation[config_names][system.site][slogan]' => $site_slogan, - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save translation')); $override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'system.site'); @@ -310,11 +310,11 @@ public function testContactConfigEntityTranslation() { // Save default language configuration. $label = 'Send your feedback'; - $edit = array( + $edit = [ 'label' => $label, 'recipients' => 'sales@example.com,support@example.com', 'reply' => 'Thank you for your mail', - ); + ]; $this->drupalPostForm('admin/structure/contact/manage/feedback', $edit, t('Save')); // Ensure translation link is present. @@ -323,7 +323,7 @@ public function testContactConfigEntityTranslation() { // Make sure translate tab is present. $this->drupalGet('admin/structure/contact/manage/feedback'); - $this->assertLink(t('Translate @type', array('@type' => 'contact form'))); + $this->assertLink(t('Translate @type', ['@type' => 'contact form'])); // Visit the form to confirm the changes. $this->drupalGet('contact/feedback'); @@ -331,7 +331,7 @@ public function testContactConfigEntityTranslation() { foreach ($this->langcodes as $langcode) { $this->drupalGet($translation_base_url); - $this->assertLink(t('Translate @type', array('@type' => 'contact form'))); + $this->assertLink(t('Translate @type', ['@type' => 'contact form'])); // 'Add' link should be present for $langcode translation. $translation_page_url = "$translation_base_url/$langcode/add"; @@ -342,20 +342,20 @@ public function testContactConfigEntityTranslation() { $this->assertText($label); // Update translatable fields. - $edit = array( + $edit = [ 'translation[config_names][contact.form.feedback][label]' => 'Website feedback - ' . $langcode, 'translation[config_names][contact.form.feedback][reply]' => 'Thank you for your mail - ' . $langcode, - ); + ]; // Save language specific version of form. $this->drupalPostForm($translation_page_url, $edit, t('Save translation')); // Expect translated values in language specific file. $override = \Drupal::languageManager()->getLanguageConfigOverride($langcode, 'contact.form.feedback'); - $expected = array( + $expected = [ 'label' => 'Website feedback - ' . $langcode, 'reply' => 'Thank you for your mail - ' . $langcode, - ); + ]; $this->assertEqual($expected, $override->get()); // Check for edit, delete links (and no 'add' link) for $langcode. @@ -368,10 +368,10 @@ public function testContactConfigEntityTranslation() { $this->assertText('Website feedback - ' . $langcode); // Submit feedback. - $edit = array( + $edit = [ 'subject[0][value]' => 'Test subject', 'message[0][value]' => 'Test message', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Send message')); } @@ -379,7 +379,7 @@ public function testContactConfigEntityTranslation() { // original text all appear in any translated page on the translation // forms. foreach ($this->langcodes as $langcode) { - $langcode_prefixes = array_merge(array(''), $this->langcodes); + $langcode_prefixes = array_merge([''], $this->langcodes); foreach ($langcode_prefixes as $langcode_prefix) { $this->drupalGet(ltrim("$langcode_prefix/$translation_base_url/$langcode/edit", '/')); $this->assertFieldByName('translation[config_names][contact.form.feedback][label]', 'Website feedback - ' . $langcode); @@ -400,14 +400,14 @@ public function testContactConfigEntityTranslation() { // Test that delete links work and operations perform properly. foreach ($this->langcodes as $langcode) { - $replacements = array('%label' => t('@label @entity_type', array('@label' => $label, '@entity_type' => Unicode::strtolower(t('Contact form')))), '@language' => \Drupal::languageManager()->getLanguage($langcode)->getName()); + $replacements = ['%label' => t('@label @entity_type', ['@label' => $label, '@entity_type' => Unicode::strtolower(t('Contact form'))]), '@language' => \Drupal::languageManager()->getLanguage($langcode)->getName()]; $this->drupalGet("$translation_base_url/$langcode/delete"); $this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements)); // Assert link back to list page to cancel delete is present. $this->assertLinkByHref($translation_base_url); - $this->drupalPostForm(NULL, array(), t('Delete')); + $this->drupalPostForm(NULL, [], t('Delete')); $this->assertRaw(t('@language translation of %label was deleted', $replacements)); $this->assertLinkByHref("$translation_base_url/$langcode/add"); $this->assertNoLinkByHref("translation_base_url/$langcode/edit"); @@ -445,18 +445,18 @@ public function testDateFormatTranslation() { $this->assertLinkByHref('admin/config/regional/date-time/formats/manage/medium'); // Save default language configuration for a new format. - $edit = array( + $edit = [ 'label' => 'Custom medium date', 'id' => 'custom_medium', 'date_format_pattern' => 'Y. m. d. H:i', - ); + ]; $this->drupalPostForm('admin/config/regional/date-time/formats/add', $edit, t('Add format')); // Test translating a default shipped format and our custom format. - $formats = array( + $formats = [ 'medium' => 'Default medium date', 'custom_medium' => 'Custom medium date', - ); + ]; foreach ($formats as $id => $label) { $translation_base_url = 'admin/config/regional/date-time/formats/manage/' . $id . '/translate'; @@ -474,20 +474,20 @@ public function testDateFormatTranslation() { $this->assertRaw('core/modules/system/js/system.date.js'); // Update translatable fields. - $edit = array( + $edit = [ 'translation[config_names][core.date_format.' . $id . '][label]' => $id . ' - FR', 'translation[config_names][core.date_format.' . $id . '][pattern]' => 'D', - ); + ]; // Save language specific version of form. $this->drupalPostForm($translation_page_url, $edit, t('Save translation')); // Get translation and check we've got the right value. $override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'core.date_format.' . $id); - $expected = array( + $expected = [ 'label' => $id . ' - FR', 'pattern' => 'D', - ); + ]; $this->assertEqual($expected, $override->get()); // Formatting the date 8 / 27 / 1985 @ 13:37 EST with pattern D should @@ -508,18 +508,18 @@ public function testAccountSettingsConfigurationTranslation() { $this->drupalLogin($this->adminUser); $this->drupalGet('admin/config/people/accounts'); - $this->assertLink(t('Translate @type', array('@type' => 'account settings'))); + $this->assertLink(t('Translate @type', ['@type' => 'account settings'])); $this->drupalGet('admin/config/people/accounts/translate'); - $this->assertLink(t('Translate @type', array('@type' => 'account settings'))); + $this->assertLink(t('Translate @type', ['@type' => 'account settings'])); $this->assertLinkByHref('admin/config/people/accounts/translate/fr/add'); // Update account settings fields for French. - $edit = array( + $edit = [ 'translation[config_names][user.settings][anonymous]' => 'Anonyme', 'translation[config_names][user.mail][status_blocked][subject]' => 'Testing, your account is blocked.', 'translation[config_names][user.mail][status_blocked][body]' => 'Testing account blocked body.', - ); + ]; $this->drupalPostForm('admin/config/people/accounts/translate/fr/add', $edit, t('Save translation')); @@ -588,7 +588,7 @@ public function testViewsTranslationUI() { $this->drupalLogin($this->adminUser); // Assert contextual link related to views. - $ids = array('entity.view.edit_form:view=frontpage:location=page&name=frontpage&display_id=page_1'); + $ids = ['entity.view.edit_form:view=frontpage:location=page&name=frontpage&display_id=page_1']; $response = $this->renderContextualLinks($ids, 'node'); $this->assertResponse(200); $json = Json::decode($response); @@ -611,14 +611,14 @@ public function testViewsTranslationUI() { $this->assertRaw($human_readable_name); // Update Views Fields for French. - $edit = array( + $edit = [ 'translation[config_names][views.view.frontpage][description]' => $description . " FR", 'translation[config_names][views.view.frontpage][label]' => $human_readable_name . " FR", 'translation[config_names][views.view.frontpage][display][default][display_title]' => $display_settings_master . " FR", 'translation[config_names][views.view.frontpage][display][default][display_options][title]' => $display_options_master . " FR", - ); + ]; $this->drupalPostForm("$translation_base_url/fr/add", $edit, t('Save translation')); - $this->assertRaw(t('Successfully saved @language translation.', array('@language' => 'French'))); + $this->assertRaw(t('Successfully saved @language translation.', ['@language' => 'French'])); // Check for edit, delete links (and no 'add' link) for French language. $this->assertNoLinkByHref("$translation_base_url/fr/add"); @@ -640,20 +640,20 @@ public function testPluralConfigStringsSourceElements() { $this->drupalLogin($this->adminUser); // Languages to test, with various number of plural forms. - $languages = array( - 'vi' => array('plurals' => 1, 'expected' => array(TRUE, FALSE, FALSE, FALSE)), - 'fr' => array('plurals' => 2, 'expected' => array(TRUE, TRUE, FALSE, FALSE)), - 'sl' => array('plurals' => 4, 'expected' => array(TRUE, TRUE, TRUE, TRUE)), - ); + $languages = [ + 'vi' => ['plurals' => 1, 'expected' => [TRUE, FALSE, FALSE, FALSE]], + 'fr' => ['plurals' => 2, 'expected' => [TRUE, TRUE, FALSE, FALSE]], + 'sl' => ['plurals' => 4, 'expected' => [TRUE, TRUE, TRUE, TRUE]], + ]; foreach ($languages as $langcode => $data) { // Import a .po file to add a new language with a given number of plural forms $name = tempnam('temporary://', $langcode . '_') . '.po'; file_put_contents($name, $this->getPoFile($data['plurals'])); - $this->drupalPostForm('admin/config/regional/translate/import', array( + $this->drupalPostForm('admin/config/regional/translate/import', [ 'langcode' => $langcode, 'files[file]' => $name, - ), t('Import')); + ], t('Import')); // Change the config langcode of the 'files' view. $config = \Drupal::service('config.factory')->getEditable('views.view.files'); @@ -686,10 +686,10 @@ public function testPluralConfigStrings() { // This will also automatically add the 'sl' language. $name = tempnam('temporary://', "sl_") . '.po'; file_put_contents($name, $this->getPoFile(4)); - $this->drupalPostForm('admin/config/regional/translate/import', array( + $this->drupalPostForm('admin/config/regional/translate/import', [ 'langcode' => 'sl', 'files[file]' => $name, - ), t('Import')); + ], t('Import')); // Translate the files view, as this one uses numeric formatters. $description = 'Singular form'; @@ -817,12 +817,12 @@ public function testLocaleDBStorage() { $langcode = 'xx'; $name = $this->randomMachineName(16); - $edit = array( + $edit = [ 'predefined_langcode' => 'custom', 'langcode' => $langcode, 'label' => $name, 'direction' => Language::DIRECTION_LTR, - ); + ]; $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); // Make sure there is no translation stored in locale storage before edit. @@ -830,9 +830,9 @@ public function testLocaleDBStorage() { $this->assertTrue(empty($translation)); // Add custom translation. - $edit = array( + $edit = [ 'translation[config_names][user.settings][anonymous]' => 'Anonyme', - ); + ]; $this->drupalPostForm('admin/config/people/accounts/translate/fr/add', $edit, t('Save translation')); // Make sure translation stored in locale storage after saved language @@ -841,9 +841,9 @@ public function testLocaleDBStorage() { $this->assertEqual('Anonyme', $translation->getString()); // revert custom translations to base translation. - $edit = array( + $edit = [ 'translation[config_names][user.settings][anonymous]' => 'Anonymous', - ); + ]; $this->drupalPostForm('admin/config/people/accounts/translate/fr/edit', $edit, t('Save translation')); // Make sure there is no translation stored in locale storage after revert. @@ -858,19 +858,19 @@ public function testSingleLanguageUI() { $this->drupalLogin($this->adminUser); // Delete French language - $this->drupalPostForm('admin/config/regional/language/delete/fr', array(), t('Delete')); - $this->assertRaw(t('The %language (%langcode) language has been removed.', array('%language' => 'French', '%langcode' => 'fr'))); + $this->drupalPostForm('admin/config/regional/language/delete/fr', [], t('Delete')); + $this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'French', '%langcode' => 'fr'])); // Change default language to Tamil. - $edit = array( + $edit = [ 'site_default_language' => 'ta', - ); + ]; $this->drupalPostForm('admin/config/regional/language', $edit, t('Save configuration')); $this->assertRaw(t('Configuration saved.')); // Delete English language - $this->drupalPostForm('admin/config/regional/language/delete/en', array(), t('Delete')); - $this->assertRaw(t('The %language (%langcode) language has been removed.', array('%language' => 'English', '%langcode' => 'en'))); + $this->drupalPostForm('admin/config/regional/language/delete/en', [], t('Delete')); + $this->assertRaw(t('The %language (%langcode) language has been removed.', ['%language' => 'English', '%langcode' => 'en'])); // Visit account setting translation page, this should not // throw any notices. @@ -907,32 +907,32 @@ public function testSequenceTranslation() { /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */ $config_factory = $this->container->get('config.factory'); - $expected = array( + $expected = [ 'kitten', 'llama', 'elephant' - ); + ]; $actual = $config_factory ->getEditable('config_translation_test.content') ->get('animals'); $this->assertEqual($expected, $actual); - $edit = array( + $edit = [ 'translation[config_names][config_translation_test.content][content][value]' => '

        Hello World - FR

        ', 'translation[config_names][config_translation_test.content][animals][0]' => 'kitten - FR', 'translation[config_names][config_translation_test.content][animals][1]' => 'llama - FR', 'translation[config_names][config_translation_test.content][animals][2]' => 'elephant - FR', - ); + ]; $this->drupalPostForm('admin/config/media/file-system/translate/fr/add', $edit, t('Save translation')); $this->container->get('language.config_factory_override') - ->setLanguage(new Language(array('id' => 'fr'))); + ->setLanguage(new Language(['id' => 'fr'])); - $expected = array( + $expected = [ 'kitten - FR', 'llama - FR', 'elephant - FR', - ); + ]; $actual = $config_factory ->get('config_translation_test.content') ->get('animals'); @@ -947,10 +947,10 @@ public function testTextFormatTranslation() { /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */ $config_factory = $this->container->get('config.factory'); - $expected = array( + $expected = [ 'value' => '

        Hello World

        ', 'format' => 'plain_text', - ); + ]; $actual = $config_factory ->get('config_translation_test.content') ->getOriginal('content', FALSE); @@ -970,20 +970,20 @@ public function testTextFormatTranslation() { $this->assertNoFieldByName('translation[config_names][config_translation_test.content][content][format]'); // Update translatable fields. - $edit = array( + $edit = [ 'translation[config_names][config_translation_test.content][content][value]' => '

        Hello World - FR

        ', - ); + ]; // Save language specific version of form. $this->drupalPostForm($translation_page_url, $edit, t('Save translation')); // Get translation and check we've got the right value. - $expected = array( + $expected = [ 'value' => '

        Hello World - FR

        ', 'format' => 'plain_text', - ); + ]; $this->container->get('language.config_factory_override') - ->setLanguage(new Language(array('id' => 'fr'))); + ->setLanguage(new Language(['id' => 'fr'])); $actual = $config_factory ->get('config_translation_test.content') ->get('content'); @@ -1009,7 +1009,7 @@ public function testTextFormatTranslation() { $this->drupalLogin($this->translatorUser); $this->drupalGet($translation_page_url); $this->assertDisabledTextarea('edit-translation-config-names-config-translation-testcontent-content-value'); - $this->drupalPostForm(NULL, array(), t('Save translation')); + $this->drupalPostForm(NULL, [], t('Save translation')); // Check that submitting the form did not update the text format of the // translation. $actual = $config_factory @@ -1019,14 +1019,14 @@ public function testTextFormatTranslation() { // The administrator must explicitly change the text format. $this->drupalLogin($this->adminUser); - $edit = array( + $edit = [ 'translation[config_names][config_translation_test.content][content][format]' => 'full_html', - ); + ]; $this->drupalPostForm($translation_page_url, $edit, t('Save translation')); - $expected = array( + $expected = [ 'value' => '

        Hello World - FR

        ', 'format' => 'full_html', - ); + ]; $actual = $config_factory ->get('config_translation_test.content') ->get('content'); @@ -1047,20 +1047,20 @@ public function testTextFormatTranslation() { * Returns translation if exists, FALSE otherwise. */ protected function getTranslation($config_name, $key, $langcode) { - $settings_locations = $this->localeStorage->getLocations(array('type' => 'configuration', 'name' => $config_name)); - $this->assertTrue(!empty($settings_locations), format_string('Configuration locations found for %config_name.', array('%config_name' => $config_name))); + $settings_locations = $this->localeStorage->getLocations(['type' => 'configuration', 'name' => $config_name]); + $this->assertTrue(!empty($settings_locations), format_string('Configuration locations found for %config_name.', ['%config_name' => $config_name])); if (!empty($settings_locations)) { $source = $this->container->get('config.factory')->get($config_name)->get($key); - $source_string = $this->localeStorage->findString(array('source' => $source, 'type' => 'configuration')); - $this->assertTrue(!empty($source_string), format_string('Found string for %config_name.%key.', array('%config_name' => $config_name, '%key' => $key))); + $source_string = $this->localeStorage->findString(['source' => $source, 'type' => 'configuration']); + $this->assertTrue(!empty($source_string), format_string('Found string for %config_name.%key.', ['%config_name' => $config_name, '%key' => $key])); if (!empty($source_string)) { - $conditions = array( + $conditions = [ 'lid' => $source_string->lid, 'language' => $langcode, - ); - $translations = $this->localeStorage->getTranslations($conditions + array('translated' => TRUE)); + ]; + $translations = $this->localeStorage->getTranslations($conditions + ['translated' => TRUE]); return reset($translations); } } @@ -1074,10 +1074,10 @@ protected function getTranslation($config_name, $key, $langcode) { * @param string $site_slogan */ protected function setSiteInformation($site_name, $site_slogan) { - $edit = array( + $edit = [ 'site_name' => $site_name, 'site_slogan' => $site_slogan, - ); + ]; $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration')); $this->assertRaw(t('The configuration options have been saved.')); } @@ -1094,11 +1094,11 @@ protected function setSiteInformation($site_name, $site_slogan) { * The response body. */ protected function renderContextualLinks($ids, $current_path) { - $post = array(); + $post = []; for ($i = 0; $i < count($ids); $i++) { $post['ids[' . $i . ']'] = $ids[$i]; } - return $this->drupalPostWithFormat('contextual/render', 'json', $post, array('query' => array('destination' => $current_path))); + return $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => $current_path]]); } /** @@ -1111,30 +1111,30 @@ protected function renderContextualLinks($ids, $current_path) { * TRUE if the assertion passed; FALSE otherwise. */ protected function assertDisabledTextarea($id) { - $textarea = $this->xpath('//textarea[@id=:id and contains(@disabled, "disabled")]', array( + $textarea = $this->xpath('//textarea[@id=:id and contains(@disabled, "disabled")]', [ ':id' => $id, - )); + ]); $textarea = reset($textarea); - $passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Disabled field @id exists.', array( + $passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Disabled field @id exists.', [ '@id' => $id, - ))); + ])); $expected = 'This field has been disabled because you do not have sufficient permissions to edit it.'; - $passed = $passed && $this->assertEqual((string) $textarea, $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', array( + $passed = $passed && $this->assertEqual((string) $textarea, $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', [ '@id' => $id, - ))); + ])); // Make sure the text format select is not shown. $select_id = str_replace('value', 'format--2', $id); - $select = $this->xpath('//select[@id=:id]', array(':id' => $select_id)); - return $passed && $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', array( + $select = $this->xpath('//select[@id=:id]', [':id' => $select_id]); + return $passed && $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', [ '@id' => $id, - ))); + ])); } /** * Helper function that returns a .po file with a given number of plural forms. */ public function getPoFile($plurals) { - $po_file = array(); + $po_file = []; $po_file[1] = <<< EOF msgid "" diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php index ab51a43..53713a9 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php @@ -24,7 +24,7 @@ class ConfigTranslationUiThemeTest extends WebTestBase { * * @var array */ - protected $langcodes = array('fr', 'ta'); + protected $langcodes = ['fr', 'ta']; /** * Administrator user for tests. diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationViewListUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationViewListUiTest.php index bccbd88..b259a18 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationViewListUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationViewListUiTest.php @@ -16,22 +16,22 @@ class ConfigTranslationViewListUiTest extends UITestBase { * * @var array */ - public static $testViews = array('node', 'test_view'); + public static $testViews = ['node', 'test_view']; /** * Modules to enable. * * @var array */ - public static $modules = array('config_translation', 'views_ui'); + public static $modules = ['config_translation', 'views_ui']; protected function setUp() { parent::setUp(); - $permissions = array( + $permissions = [ 'administer views', 'translate configuration', - ); + ]; // Create and log in user. $this->drupalLogin($this->drupalCreateUser($permissions)); diff --git a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module index eb41793..8c00b90 100644 --- a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module +++ b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module @@ -33,7 +33,7 @@ function config_translation_test_entity_type_alter(array &$entity_types) { function config_translation_test_config_translation_info_alter(&$info) { if (\Drupal::state()->get('config_translation_test_config_translation_info_alter')) { // Limit account settings config files to only one of them. - $info['entity.user.admin_form']['names'] = array('user.settings'); + $info['entity.user.admin_form']['names'] = ['user.settings']; // Add one more config file to the site information page. $info['system.site_information_settings']['names'][] = 'system.rss'; diff --git a/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php index dc56e8d..11e72c2 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php @@ -62,14 +62,14 @@ protected function setUp() { ->with('entity.configurable_language.edit_form') ->will($this->returnValue(new Route('/admin/config/regional/language/edit/{configurable_language}'))); - $definition = array( + $definition = [ 'class' => '\Drupal\config_translation\ConfigEntityMapper', 'base_route_name' => 'entity.configurable_language.edit_form', 'title' => '@label language', - 'names' => array(), + 'names' => [], 'entity_type' => 'configurable_language', 'route_name' => 'config_translation.item.overview.entity.configurable_language.edit_form', - ); + ]; $typed_config_manager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface'); @@ -152,7 +152,7 @@ public function testGetOverviewRouteParameters() { $result = $this->configEntityMapper->getOverviewRouteParameters(); - $this->assertSame(array('configurable_language' => 'entity_id'), $result); + $this->assertSame(['configurable_language' => 'entity_id'], $result); } /** @@ -205,12 +205,12 @@ public function testGetTypeLabel() { public function testGetOperations() { $result = $this->configEntityMapper->getOperations(); - $expected = array( - 'list' => array( + $expected = [ + 'list' => [ 'title' => 'List', 'url' => Url::fromRoute('config_translation.entity_list', ['mapper_id' => 'configurable_language']), - ), - ); + ], + ]; $this->assertEquals($expected, $result); } diff --git a/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php index 204d84e..8e6d0b9 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php @@ -42,13 +42,13 @@ protected function setUp() { $this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $this->entity = $this->getMock('Drupal\field\FieldConfigInterface'); - $definition = array( + $definition = [ 'class' => '\Drupal\config_translation\ConfigFieldMapper', 'base_route_name' => 'entity.field_config.node_field_edit_form', 'title' => '@label field', - 'names' => array(), + 'names' => [], 'entity_type' => 'field_config', - ); + ]; $locale_config_manager = $this->getMockBuilder('Drupal\locale\LocaleConfigManager') ->disableOriginalConstructor() diff --git a/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php b/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php index 10bbf7d..9f064ac 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php @@ -31,7 +31,7 @@ class ConfigMapperManagerTest extends UnitTestCase { protected $typedConfigManager; protected function setUp() { - $language = new Language(array('id' => 'en')); + $language = new Language(['id' => 'en']); $language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); $language_manager->expects($this->once()) ->method('getCurrentLanguage') @@ -83,50 +83,50 @@ public function testHasTranslatable(TypedDataInterface $element, $expected) { * ConfigMapperManager::hasTranslatable() as the second key. */ public function providerTestHasTranslatable() { - return array( - array($this->getElement(array()), FALSE), - array($this->getElement(array('aaa' => 'bbb')), FALSE), - array($this->getElement(array('translatable' => FALSE)), FALSE), - array($this->getElement(array('translatable' => TRUE)), TRUE), - array($this->getNestedElement(array( - $this->getElement(array()), - )), FALSE), - array($this->getNestedElement(array( - $this->getElement(array('translatable' => TRUE)), - )), TRUE), - array($this->getNestedElement(array( - $this->getElement(array('aaa' => 'bbb')), - $this->getElement(array('ccc' => 'ddd')), - $this->getElement(array('eee' => 'fff')), - )), FALSE), - array($this->getNestedElement(array( - $this->getElement(array('aaa' => 'bbb')), - $this->getElement(array('ccc' => 'ddd')), - $this->getElement(array('translatable' => TRUE)), - )), TRUE), - array($this->getNestedElement(array( - $this->getElement(array('aaa' => 'bbb')), - $this->getNestedElement(array( - $this->getElement(array('ccc' => 'ddd')), - $this->getElement(array('eee' => 'fff')), - )), - $this->getNestedElement(array( - $this->getElement(array('ggg' => 'hhh')), - $this->getElement(array('iii' => 'jjj')), - )), - )), FALSE), - array($this->getNestedElement(array( - $this->getElement(array('aaa' => 'bbb')), - $this->getNestedElement(array( - $this->getElement(array('ccc' => 'ddd')), - $this->getElement(array('eee' => 'fff')), - )), - $this->getNestedElement(array( - $this->getElement(array('ggg' => 'hhh')), - $this->getElement(array('translatable' => TRUE)), - )), - )), TRUE), - ); + return [ + [$this->getElement([]), FALSE], + [$this->getElement(['aaa' => 'bbb']), FALSE], + [$this->getElement(['translatable' => FALSE]), FALSE], + [$this->getElement(['translatable' => TRUE]), TRUE], + [$this->getNestedElement([ + $this->getElement([]), + ]), FALSE], + [$this->getNestedElement([ + $this->getElement(['translatable' => TRUE]), + ]), TRUE], + [$this->getNestedElement([ + $this->getElement(['aaa' => 'bbb']), + $this->getElement(['ccc' => 'ddd']), + $this->getElement(['eee' => 'fff']), + ]), FALSE], + [$this->getNestedElement([ + $this->getElement(['aaa' => 'bbb']), + $this->getElement(['ccc' => 'ddd']), + $this->getElement(['translatable' => TRUE]), + ]), TRUE], + [$this->getNestedElement([ + $this->getElement(['aaa' => 'bbb']), + $this->getNestedElement([ + $this->getElement(['ccc' => 'ddd']), + $this->getElement(['eee' => 'fff']), + ]), + $this->getNestedElement([ + $this->getElement(['ggg' => 'hhh']), + $this->getElement(['iii' => 'jjj']), + ]), + ]), FALSE], + [$this->getNestedElement([ + $this->getElement(['aaa' => 'bbb']), + $this->getNestedElement([ + $this->getElement(['ccc' => 'ddd']), + $this->getElement(['eee' => 'fff']), + ]), + $this->getNestedElement([ + $this->getElement(['ggg' => 'hhh']), + $this->getElement(['translatable' => TRUE]), + ]), + ]), TRUE], + ]; } /** diff --git a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php index cbf42c8..e7a0679 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php @@ -91,13 +91,13 @@ class ConfigNamesMapperTest extends UnitTestCase { protected function setUp() { $this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface'); - $this->pluginDefinition = array( + $this->pluginDefinition = [ 'class' => '\Drupal\config_translation\ConfigNamesMapper', 'base_route_name' => 'system.site_information_settings', 'title' => 'System information', - 'names' => array('system.site'), + 'names' => ['system.site'], 'weight' => 42, - ); + ]; $this->typedConfigManager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface'); @@ -156,7 +156,7 @@ public function testGetBaseRouteName() { */ public function testGetBaseRouteParameters() { $result = $this->configNamesMapper->getBaseRouteParameters(); - $this->assertSame(array(), $result); + $this->assertSame([], $result); } /** @@ -193,7 +193,7 @@ public function testGetOverviewRouteName() { */ public function testGetOverviewRouteParameters() { $result = $this->configNamesMapper->getOverviewRouteParameters(); - $this->assertSame(array(), $result); + $this->assertSame([], $result); } /** @@ -201,13 +201,13 @@ public function testGetOverviewRouteParameters() { */ public function testGetOverviewRoute() { $expected = new Route('/admin/config/system/site-information/translate', - array( + [ '_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemPage', 'plugin_id' => 'system.site_information_settings', - ), - array( + ], + [ '_config_translation_overview_access' => 'TRUE', - ) + ] ); $result = $this->configNamesMapper->getOverviewRoute(); $this->assertSame(serialize($expected), serialize($result)); @@ -242,7 +242,7 @@ public function testGetAddRouteParameters() { $route_match = new RouteMatch('example', new Route('/test/{langcode}'), ['langcode' => 'xx']); $this->configNamesMapper->populateFromRouteMatch($route_match); - $expected = array('langcode' => 'xx'); + $expected = ['langcode' => 'xx']; $result = $this->configNamesMapper->getAddRouteParameters(); $this->assertSame($expected, $result); } @@ -252,13 +252,13 @@ public function testGetAddRouteParameters() { */ public function testGetAddRoute() { $expected = new Route('/admin/config/system/site-information/translate/{langcode}/add', - array( + [ '_form' => '\Drupal\config_translation\Form\ConfigTranslationAddForm', 'plugin_id' => 'system.site_information_settings', - ), - array( + ], + [ '_config_translation_form_access' => 'TRUE', - ) + ] ); $result = $this->configNamesMapper->getAddRoute(); $this->assertSame(serialize($expected), serialize($result)); @@ -280,7 +280,7 @@ public function testGetEditRouteParameters() { $route_match = new RouteMatch('example', new Route('/test/{langcode}'), ['langcode' => 'xx']); $this->configNamesMapper->populateFromRouteMatch($route_match); - $expected = array('langcode' => 'xx'); + $expected = ['langcode' => 'xx']; $result = $this->configNamesMapper->getEditRouteParameters(); $this->assertSame($expected, $result); } @@ -290,13 +290,13 @@ public function testGetEditRouteParameters() { */ public function testGetEditRoute() { $expected = new Route('/admin/config/system/site-information/translate/{langcode}/edit', - array( + [ '_form' => '\Drupal\config_translation\Form\ConfigTranslationEditForm', 'plugin_id' => 'system.site_information_settings', - ), - array( + ], + [ '_config_translation_form_access' => 'TRUE', - ) + ] ); $result = $this->configNamesMapper->getEditRoute(); $this->assertSame(serialize($expected), serialize($result)); @@ -318,7 +318,7 @@ public function testGetDeleteRouteParameters() { $route_match = new RouteMatch('example', new Route('/test/{langcode}'), ['langcode' => 'xx']); $this->configNamesMapper->populateFromRouteMatch($route_match); - $expected = array('langcode' => 'xx'); $result = $this->configNamesMapper->getDeleteRouteParameters(); + $expected = ['langcode' => 'xx']; $result = $this->configNamesMapper->getDeleteRouteParameters(); $this->assertSame($expected, $result); } @@ -327,13 +327,13 @@ public function testGetDeleteRouteParameters() { */ public function testGetDeleteRoute() { $expected = new Route('/admin/config/system/site-information/translate/{langcode}/delete', - array( + [ '_form' => '\Drupal\config_translation\Form\ConfigTranslationDeleteForm', 'plugin_id' => 'system.site_information_settings', - ), - array( + ], + [ '_config_translation_form_access' => 'TRUE', - ) + ] ); $result = $this->configNamesMapper->getDeleteRoute(); $this->assertSame(serialize($expected), serialize($result)); @@ -403,38 +403,38 @@ public function testGetTypeLabel() { public function testGetLangcode() { // Test that the getLangcode() falls back to 'en', if no explicit language // code is provided. - $config_factory = $this->getConfigFactoryStub(array( - 'system.site' => array('key' => 'value'), - )); + $config_factory = $this->getConfigFactoryStub([ + 'system.site' => ['key' => 'value'], + ]); $this->configNamesMapper->setConfigFactory($config_factory); $result = $this->configNamesMapper->getLangcode(); $this->assertSame('en', $result); // Test that getLangcode picks up the language code provided by the // configuration. - $config_factory = $this->getConfigFactoryStub(array( - 'system.site' => array('langcode' => 'xx'), - )); + $config_factory = $this->getConfigFactoryStub([ + 'system.site' => ['langcode' => 'xx'], + ]); $this->configNamesMapper->setConfigFactory($config_factory); $result = $this->configNamesMapper->getLangcode(); $this->assertSame('xx', $result); // Test that getLangcode() works for multiple configuration names. $this->configNamesMapper->addConfigName('system.maintenance'); - $config_factory = $this->getConfigFactoryStub(array( - 'system.site' => array('langcode' => 'xx'), - 'system.maintenance' => array('langcode' => 'xx'), - )); + $config_factory = $this->getConfigFactoryStub([ + 'system.site' => ['langcode' => 'xx'], + 'system.maintenance' => ['langcode' => 'xx'], + ]); $this->configNamesMapper->setConfigFactory($config_factory); $result = $this->configNamesMapper->getLangcode(); $this->assertSame('xx', $result); // Test that getLangcode() throws an exception when different language codes // are given. - $config_factory = $this->getConfigFactoryStub(array( - 'system.site' => array('langcode' => 'xx'), - 'system.maintenance' => array('langcode' => 'yy'), - )); + $config_factory = $this->getConfigFactoryStub([ + 'system.site' => ['langcode' => 'xx'], + 'system.maintenance' => ['langcode' => 'yy'], + ]); $this->configNamesMapper->setConfigFactory($config_factory); try { $this->configNamesMapper->getLangcode(); @@ -448,22 +448,22 @@ public function testGetLangcode() { * Tests ConfigNamesMapper::getConfigData(). */ public function testGetConfigData() { - $configs = array( - 'system.site' => array( + $configs = [ + 'system.site' => [ 'name' => 'Drupal', 'slogan' => 'Come for the software, stay for the community!', - ), - 'system.maintenance' => array( + ], + 'system.maintenance' => [ 'enabled' => FALSE, 'message' => '@site is currently under maintenance.', - ), - 'system.rss' => array( - 'items' => array( + ], + 'system.rss' => [ + 'items' => [ 'limit' => 10, 'view_mode' => 'rss', - ), - ), - ); + ], + ], + ]; $this->configNamesMapper->setConfigNames(array_keys($configs)); $config_factory = $this->getConfigFactoryStub($configs); @@ -489,9 +489,9 @@ public function testHasSchema(array $mock_return_values, $expected) { $config_names = range(1, count($mock_return_values)); $this->configNamesMapper->setConfigNames($config_names); - $map = array(); + $map = []; foreach ($config_names as $i => $config_name) { - $map[] = array($config_name, $mock_return_values[$i]); + $map[] = [$config_name, $mock_return_values[$i]]; } $this->typedConfigManager ->expects($this->any()) @@ -512,12 +512,12 @@ public function testHasSchema(array $mock_return_values, $expected) { * ConfigNamesMapper::hasSchema() as the second value. */ public function providerTestHasSchema() { - return array( - array(array(TRUE), TRUE), - array(array(FALSE), FALSE), - array(array(TRUE, TRUE, TRUE), TRUE), - array(array(TRUE, FALSE, TRUE), FALSE), - ); + return [ + [[TRUE], TRUE], + [[FALSE], FALSE], + [[TRUE, TRUE, TRUE], TRUE], + [[TRUE, FALSE, TRUE], FALSE], + ]; } /** @@ -536,9 +536,9 @@ public function testHasTranslatable(array $mock_return_values, $expected) { $config_names = range(1, count($mock_return_values)); $this->configNamesMapper->setConfigNames($config_names); - $map = array(); + $map = []; foreach ($config_names as $i => $config_name) { - $map[] = isset($mock_return_values[$i]) ? array($config_name, $mock_return_values[$i]) : array(); + $map[] = isset($mock_return_values[$i]) ? [$config_name, $mock_return_values[$i]] : []; } $this->configMapperManager ->expects($this->any()) @@ -559,14 +559,14 @@ public function testHasTranslatable(array $mock_return_values, $expected) { * ConfigNamesMapper::hasTranslatable() as the second value. */ public function providerTestHasTranslatable() { - return array( - array(array(), FALSE), - array(array(TRUE), TRUE), - array(array(FALSE), FALSE), - array(array(TRUE, TRUE, TRUE), TRUE), - array(array(FALSE, FALSE, FALSE), FALSE), - array(array(TRUE, FALSE, TRUE), TRUE), - ); + return [ + [[], FALSE], + [[TRUE], TRUE], + [[FALSE], FALSE], + [[TRUE, TRUE, TRUE], TRUE], + [[FALSE, FALSE, FALSE], FALSE], + [[TRUE, FALSE, TRUE], TRUE], + ]; } /** @@ -587,9 +587,9 @@ public function testHasTranslation(array $mock_return_values, $expected) { $config_names = range(1, count($mock_return_values)); $this->configNamesMapper->setConfigNames($config_names); - $map = array(); + $map = []; foreach ($config_names as $i => $config_name) { - $map[] = array($config_name, $language->getId(), $mock_return_values[$i]); + $map[] = [$config_name, $language->getId(), $mock_return_values[$i]]; } $this->localeConfigManager ->expects($this->any()) @@ -610,13 +610,13 @@ public function testHasTranslation(array $mock_return_values, $expected) { * ConfigNamesMapper::hasTranslation() as the second value. */ public function providerTestHasTranslation() { - return array( - array(array(TRUE), TRUE), - array(array(FALSE), FALSE), - array(array(TRUE, TRUE, TRUE), TRUE), - array(array(FALSE, FALSE, TRUE), TRUE), - array(array(FALSE, FALSE, FALSE), FALSE), - ); + return [ + [[TRUE], TRUE], + [[FALSE], FALSE], + [[TRUE, TRUE, TRUE], TRUE], + [[FALSE, FALSE, TRUE], TRUE], + [[FALSE, FALSE, FALSE], FALSE], + ]; } /** @@ -631,12 +631,12 @@ public function testGetTypeName() { * Tests ConfigNamesMapper::hasTranslation(). */ public function testGetOperations() { - $expected = array( - 'translate' => array( + $expected = [ + 'translate' => [ 'title' => 'Translate', 'url' => Url::fromRoute('config_translation.item.overview.system.site_information_settings'), - ), - ); + ], + ]; $result = $this->configNamesMapper->getOperations(); $this->assertEquals($expected, $result); } diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index a35cd25..95418a9 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -21,17 +21,17 @@ function contact_help($route_name, RouteMatchInterface $route_match) { $contact_page = \Drupal::url('entity.contact_form.collection'); $output = ''; $output .= '

        ' . t('About') . '

        '; - $output .= '

        ' . t('The Contact module allows visitors to contact registered users on your site, using the personal contact form, and also allows you to set up site-wide contact forms. For more information, see the online documentation for the Contact module.', array(':contact' => 'https://www.drupal.org/documentation/modules/contact')) . '

        '; + $output .= '

        ' . t('The Contact module allows visitors to contact registered users on your site, using the personal contact form, and also allows you to set up site-wide contact forms. For more information, see the online documentation for the Contact module.', [':contact' => 'https://www.drupal.org/documentation/modules/contact']) . '

        '; $output .= '

        ' . t('Uses') . '

        '; $output .= '
        '; $output .= '
        ' . t('Using the personal contact form') . '
        '; $output .= '
        ' . t("Site visitors can email registered users on your site by using the personal contact form, without knowing or learning the email address of the recipient. When a site visitor is viewing a user profile, the viewer will see a Contact tab or link, which leads to the personal contact form. The personal contact link is not shown when you are viewing your own profile, and users must have both View user information (to see user profiles) and Use users' personal contact forms permission to see the link. The user whose profile is being viewed must also have their personal contact form enabled (this is a user account setting); viewers with Administer users permission can bypass this setting.") . '
        '; $output .= '
        ' . t('Configuring contact forms') . '
        '; - $output .= '
        ' . t('On the Contact forms page, you can configure the fields and display of the personal contact form, and you can set up one or more site-wide contact forms. Each site-wide contact form has a machine name, a label, and one or more defined recipients; when a site visitor submits the form, the field values are sent to those recipients.', array(':contact_admin' => $contact_page)) . '
        '; + $output .= '
        ' . t('On the Contact forms page, you can configure the fields and display of the personal contact form, and you can set up one or more site-wide contact forms. Each site-wide contact form has a machine name, a label, and one or more defined recipients; when a site visitor submits the form, the field values are sent to those recipients.', [':contact_admin' => $contact_page]) . '
        '; $output .= '
        ' . t('Linking to contact forms') . '
        '; - $output .= '
        ' . t('One site-wide contact form can be designated as the default contact form. If you choose to designate a default form, the Contact menu link in the Footer menu will link to it. You can modify this link from the Menus page if you have the Menu UI module installed. You can also create links to other contact forms; the URL for each form you have set up has format contact/machine_name_of_form.', array(':menu-settings' => $menu_page)) . '

        '; + $output .= '
        ' . t('One site-wide contact form can be designated as the default contact form. If you choose to designate a default form, the Contact menu link in the Footer menu will link to it. You can modify this link from the Menus page if you have the Menu UI module installed. You can also create links to other contact forms; the URL for each form you have set up has format contact/machine_name_of_form.', [':menu-settings' => $menu_page]) . '

        '; $output .= '
        ' . t('Adding content to contact forms') . '
        '; - $output .= '
        ' . t('From the Contact forms page, you can configure the fields to be shown on contact forms, including their labels and help text. If you would like other content (such as text or images) to appear on a contact form, use a block. You can create and edit blocks on the Block layout page, if the Block module is installed.', array(':blocks' => $block_page, ':contact_admin' => $contact_page)) . '
        '; + $output .= '
        ' . t('From the Contact forms page, you can configure the fields to be shown on contact forms, including their labels and help text. If you would like other content (such as text or images) to appear on a contact form, use a block. You can create and edit blocks on the Block layout page, if the Block module is installed.', [':blocks' => $block_page, ':contact_admin' => $contact_page]) . '
        '; $output .= '
        '; return $output; @@ -50,37 +50,37 @@ function contact_entity_type_alter(array &$entity_types) { * Implements hook_entity_extra_field_info(). */ function contact_entity_extra_field_info() { - $fields = array(); + $fields = []; foreach (array_keys(\Drupal::service('entity_type.bundle.info')->getBundleInfo('contact_message')) as $bundle) { - $fields['contact_message'][$bundle]['form']['name'] = array( + $fields['contact_message'][$bundle]['form']['name'] = [ 'label' => t('Sender name'), 'description' => t('Text'), 'weight' => -50, - ); - $fields['contact_message'][$bundle]['form']['mail'] = array( + ]; + $fields['contact_message'][$bundle]['form']['mail'] = [ 'label' => t('Sender email'), 'description' => t('Email'), 'weight' => -40, - ); + ]; if ($bundle == 'personal') { - $fields['contact_message'][$bundle]['form']['recipient'] = array( + $fields['contact_message'][$bundle]['form']['recipient'] = [ 'label' => t('Recipient username'), 'description' => t('User'), 'weight' => -30, - ); + ]; } - $fields['contact_message'][$bundle]['form']['copy'] = array( + $fields['contact_message'][$bundle]['form']['copy'] = [ 'label' => t('Send copy to sender'), 'description' => t('Option'), 'weight' => 50, - ); + ]; } - $fields['user']['user']['form']['contact'] = array( + $fields['user']['user']['form']['contact'] = [ 'label' => t('Contact settings'), 'description' => t('Contact module form element.'), 'weight' => 5, - ); + ]; return $fields; } @@ -113,21 +113,21 @@ function contact_mail($key, &$message, $params) { $sender = $params['sender']; $language = \Drupal::languageManager()->getLanguage($message['langcode']); - $variables = array( + $variables = [ '@site-name' => \Drupal::config('system.site')->get('name'), '@subject' => $contact_message->getSubject(), '@form' => !empty($params['contact_form']) ? $params['contact_form']->label() : NULL, '@form-url' => \Drupal::url('', [], ['absolute' => TRUE, 'language' => $language]), '@sender-name' => $sender->getDisplayName(), - ); + ]; if ($sender->isAuthenticated()) { - $variables['@sender-url'] = $sender->url('canonical', array('absolute' => TRUE, 'language' => $language)); + $variables['@sender-url'] = $sender->url('canonical', ['absolute' => TRUE, 'language' => $language]); } else { $variables['@sender-url'] = $params['sender']->getEmail(); } - $options = array('langcode' => $language->getId()); + $options = ['langcode' => $language->getId()]; switch ($key) { case 'page_mail': @@ -145,10 +145,10 @@ function contact_mail($key, &$message, $params) { case 'user_mail': case 'user_copy': - $variables += array( + $variables += [ '@recipient-name' => $params['recipient']->getDisplayName(), - '@recipient-edit-url' => $params['recipient']->url('edit-form', array('absolute' => TRUE, 'language' => $language)), - ); + '@recipient-edit-url' => $params['recipient']->url('edit-form', ['absolute' => TRUE, 'language' => $language]), + ]; $message['subject'] .= t('[@site-name] @subject', $variables, $options); $message['body'][] = t('Hello @recipient-name,', $variables, $options); $message['body'][] = t("@sender-name (@sender-url) has sent you a message via your contact form at @site-name.", $variables, $options); @@ -167,22 +167,22 @@ function contact_mail($key, &$message, $params) { * @see \Drupal\user\ProfileForm::form() */ function contact_form_user_form_alter(&$form, FormStateInterface $form_state) { - $form['contact'] = array( + $form['contact'] = [ '#type' => 'details', '#title' => t('Contact settings'), '#open' => TRUE, '#weight' => 5, - ); + ]; $account = $form_state->getFormObject()->getEntity(); if (!\Drupal::currentUser()->isAnonymous() && $account->id()) { $account_data = \Drupal::service('user.data')->get('contact', $account->id(), 'enabled'); } - $form['contact']['contact'] = array( + $form['contact']['contact'] = [ '#type' => 'checkbox', '#title' => t('Personal contact form'), '#default_value' => isset($account_data) ? $account_data : \Drupal::config('contact.settings')->get('user_default_enabled'), '#description' => t('Allow other users to contact you via a personal contact form which keeps your email address hidden. Note that some privileged users such as site administrators are still able to contact you even if you choose to disable this feature.'), - ); + ]; $form['actions']['submit']['#submit'][] = 'contact_user_profile_form_submit'; } @@ -204,18 +204,18 @@ function contact_user_profile_form_submit($form, FormStateInterface $form_state) * @see \Drupal\user\AccountSettingsForm */ function contact_form_user_admin_settings_alter(&$form, FormStateInterface $form_state) { - $form['contact'] = array( + $form['contact'] = [ '#type' => 'details', '#title' => t('Contact settings'), '#open' => TRUE, '#weight' => 0, - ); - $form['contact']['contact_default_status'] = array( + ]; + $form['contact']['contact_default_status'] = [ '#type' => 'checkbox', '#title' => t('Enable the personal contact form by default for new users'), '#description' => t('Changing this setting will not affect existing users.'), '#default_value' => \Drupal::configFactory()->getEditable('contact.settings')->get('user_default_enabled'), - ); + ]; // Add submit handler to save contact configuration. $form['#submit'][] = 'contact_form_user_admin_settings_submit'; } diff --git a/core/modules/contact/contact.views.inc b/core/modules/contact/contact.views.inc index 1560362..a18c9e7 100644 --- a/core/modules/contact/contact.views.inc +++ b/core/modules/contact/contact.views.inc @@ -9,11 +9,11 @@ * Implements hook_views_data_alter(). */ function contact_views_data_alter(&$data) { - $data['users']['contact'] = array( - 'field' => array( + $data['users']['contact'] = [ + 'field' => [ 'title' => t('Contact link'), 'help' => t('Provide a simple link to the user contact page.'), 'id' => 'contact_link', - ), - ); + ], + ]; } diff --git a/core/modules/contact/src/ContactFormEditForm.php b/core/modules/contact/src/ContactFormEditForm.php index 473d317..5c96ba2 100644 --- a/core/modules/contact/src/ContactFormEditForm.php +++ b/core/modules/contact/src/ContactFormEditForm.php @@ -70,60 +70,60 @@ public function form(array $form, FormStateInterface $form_state) { $contact_form = $this->entity; $default_form = $this->config('contact.settings')->get('default_form'); - $form['label'] = array( + $form['label'] = [ '#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $contact_form->label(), '#description' => $this->t("Example: 'website feedback' or 'product information'."), '#required' => TRUE, - ); - $form['id'] = array( + ]; + $form['id'] = [ '#type' => 'machine_name', '#default_value' => $contact_form->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, - '#machine_name' => array( + '#machine_name' => [ 'exists' => '\Drupal\contact\Entity\ContactForm::load', - ), + ], '#disabled' => !$contact_form->isNew(), - ); - $form['recipients'] = array( + ]; + $form['recipients'] = [ '#type' => 'textarea', '#title' => $this->t('Recipients'), '#default_value' => implode(', ', $contact_form->getRecipients()), '#description' => $this->t("Example: 'webmaster@example.com' or 'sales@example.com,support@example.com' . To specify multiple recipients, separate each email address with a comma."), '#required' => TRUE, - ); - $form['message'] = array( + ]; + $form['message'] = [ '#type' => 'textarea', '#title' => $this->t('Message'), '#default_value' => $contact_form->getMessage(), '#description' => $this->t('The message to display to the user after submission of this form. Leave blank for no message.'), - ); - $form['redirect'] = array( + ]; + $form['redirect'] = [ '#type' => 'path', '#title' => $this->t('Redirect path'), '#convert_path' => PathElement::CONVERT_NONE, '#default_value' => $contact_form->getRedirectPath(), '#description' => $this->t('Path to redirect the user to after submission of this form. For example, type "/about" to redirect to that page. Use a relative path with a slash in front.'), - ); - $form['reply'] = array( + ]; + $form['reply'] = [ '#type' => 'textarea', '#title' => $this->t('Auto-reply'), '#default_value' => $contact_form->getReply(), '#description' => $this->t('Optional auto-reply. Leave empty if you do not want to send the user an auto-reply message.'), - ); - $form['weight'] = array( + ]; + $form['weight'] = [ '#type' => 'weight', '#title' => $this->t('Weight'), '#default_value' => $contact_form->getWeight(), '#description' => $this->t('When listing forms, those with lighter (smaller) weights get listed before forms with heavier (larger) weights. Forms with equal weights are sorted alphabetically.'), - ); - $form['selected'] = array( + ]; + $form['selected'] = [ '#type' => 'checkbox', '#title' => $this->t('Make this the default form'), '#default_value' => $default_form === $contact_form->id(), - ); + ]; return $form; } @@ -140,7 +140,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { foreach ($recipients as &$recipient) { $recipient = trim($recipient); if (!$this->emailValidator->isValid($recipient)) { - $form_state->setErrorByName('recipients', $this->t('%recipient is an invalid email address.', array('%recipient' => $recipient))); + $form_state->setErrorByName('recipients', $this->t('%recipient is an invalid email address.', ['%recipient' => $recipient])); } } $form_state->setValue('recipients', $recipients); @@ -163,12 +163,12 @@ public function save(array $form, FormStateInterface $form_state) { $edit_link = $this->entity->link($this->t('Edit')); $view_link = $contact_form->link($contact_form->label(), 'canonical'); if ($status == SAVED_UPDATED) { - drupal_set_message($this->t('Contact form %label has been updated.', array('%label' => $view_link))); - $this->logger('contact')->notice('Contact form %label has been updated.', array('%label' => $contact_form->label(), 'link' => $edit_link)); + drupal_set_message($this->t('Contact form %label has been updated.', ['%label' => $view_link])); + $this->logger('contact')->notice('Contact form %label has been updated.', ['%label' => $contact_form->label(), 'link' => $edit_link]); } else { - drupal_set_message($this->t('Contact form %label has been added.', array('%label' => $view_link))); - $this->logger('contact')->notice('Contact form %label has been added.', array('%label' => $contact_form->label(), 'link' => $edit_link)); + drupal_set_message($this->t('Contact form %label has been added.', ['%label' => $view_link])); + $this->logger('contact')->notice('Contact form %label has been added.', ['%label' => $contact_form->label(), 'link' => $edit_link]); } // Update the default form. diff --git a/core/modules/contact/src/Controller/ContactController.php b/core/modules/contact/src/Controller/ContactController.php index 4d46f83..b8b69d5 100644 --- a/core/modules/contact/src/Controller/ContactController.php +++ b/core/modules/contact/src/Controller/ContactController.php @@ -64,9 +64,9 @@ public function contactSitePage(ContactFormInterface $contact_form = NULL) { // If there are no forms, do not display the form. if (empty($contact_form)) { if ($this->currentUser()->hasPermission('administer contact forms')) { - drupal_set_message($this->t('The contact form has not been configured. Add one or more forms .', array( - ':add' => $this->url('contact.form_add'))), 'error'); - return array(); + drupal_set_message($this->t('The contact form has not been configured. Add one or more forms .', [ + ':add' => $this->url('contact.form_add')]), 'error'); + return []; } else { throw new NotFoundHttpException(); @@ -76,9 +76,9 @@ public function contactSitePage(ContactFormInterface $contact_form = NULL) { $message = $this->entityManager() ->getStorage('contact_message') - ->create(array( + ->create([ 'contact_form' => $contact_form->id(), - )); + ]); $form = $this->entityFormBuilder()->getForm($message); $form['#title'] = $contact_form->label(); @@ -106,13 +106,13 @@ public function contactPersonalPage(UserInterface $user) { throw new NotFoundHttpException(); } - $message = $this->entityManager()->getStorage('contact_message')->create(array( + $message = $this->entityManager()->getStorage('contact_message')->create([ 'contact_form' => 'personal', 'recipient' => $user->id(), - )); + ]); $form = $this->entityFormBuilder()->getForm($message); - $form['#title'] = $this->t('Contact @username', array('@username' => $user->getDisplayName())); + $form['#title'] = $this->t('Contact @username', ['@username' => $user->getDisplayName()]); $form['#cache']['contexts'][] = 'user.permissions'; return $form; } diff --git a/core/modules/contact/src/Entity/ContactForm.php b/core/modules/contact/src/Entity/ContactForm.php index 9c63747..00e5416 100644 --- a/core/modules/contact/src/Entity/ContactForm.php +++ b/core/modules/contact/src/Entity/ContactForm.php @@ -73,7 +73,7 @@ class ContactForm extends ConfigEntityBundleBase implements ContactFormInterface * * @var array */ - protected $recipients = array(); + protected $recipients = []; /** * The path to redirect to on form submission. diff --git a/core/modules/contact/src/Entity/Message.php b/core/modules/contact/src/Entity/Message.php index 20f360f..d75496b 100644 --- a/core/modules/contact/src/Entity/Message.php +++ b/core/modules/contact/src/Entity/Message.php @@ -153,29 +153,29 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Subject')) ->setRequired(TRUE) ->setSetting('max_length', 100) - ->setDisplayOptions('form', array( + ->setDisplayOptions('form', [ 'type' => 'string_textfield', 'weight' => -10, - )) + ]) ->setDisplayConfigurable('form', TRUE); // The text of the contact message. $fields['message'] = BaseFieldDefinition::create('string_long') ->setLabel(t('Message')) ->setRequired(TRUE) - ->setDisplayOptions('form', array( + ->setDisplayOptions('form', [ 'type' => 'string_textarea', 'weight' => 0, - 'settings' => array( + 'settings' => [ 'rows' => 12, - ), - )) + ], + ]) ->setDisplayConfigurable('form', TRUE) - ->setDisplayOptions('view', array( + ->setDisplayOptions('view', [ 'type' => 'string', 'weight' => 0, 'label' => 'above', - )) + ]) ->setDisplayConfigurable('view', TRUE); $fields['copy'] = BaseFieldDefinition::create('boolean') diff --git a/core/modules/contact/src/MailHandler.php b/core/modules/contact/src/MailHandler.php index bac7659..5d34d6d 100644 --- a/core/modules/contact/src/MailHandler.php +++ b/core/modules/contact/src/MailHandler.php @@ -73,7 +73,7 @@ public function __construct(MailManagerInterface $mail_manager, LanguageManagerI public function sendMailMessages(MessageInterface $message, AccountInterface $sender) { // Clone the sender, as we make changes to mail and name properties. $sender_cloned = clone $this->userStorage->load($sender->id()); - $params = array(); + $params = []; $current_langcode = $this->languageManager->getCurrentLanguage()->getId(); $recipient_langcode = $this->languageManager->getDefaultLanguage()->getId(); $contact_form = $message->getContactForm(); @@ -86,7 +86,7 @@ public function sendMailMessages(MessageInterface $message, AccountInterface $se // For the email message, clarify that the sender name is not verified; it // could potentially clash with a username on this site. - $sender_cloned->name = $this->t('@name (not verified)', array('@name' => $message->getSenderName())); + $sender_cloned->name = $this->t('@name (not verified)', ['@name' => $message->getSenderName()]); } // Build email parameters. @@ -126,18 +126,18 @@ public function sendMailMessages(MessageInterface $message, AccountInterface $se } if (!$message->isPersonal()) { - $this->logger->notice('%sender-name (@sender-from) sent an email regarding %contact_form.', array( + $this->logger->notice('%sender-name (@sender-from) sent an email regarding %contact_form.', [ '%sender-name' => $sender_cloned->getUsername(), '@sender-from' => $sender_cloned->getEmail(), '%contact_form' => $contact_form->label(), - )); + ]); } else { - $this->logger->notice('%sender-name (@sender-from) sent %recipient-name an email.', array( + $this->logger->notice('%sender-name (@sender-from) sent %recipient-name an email.', [ '%sender-name' => $sender_cloned->getUsername(), '@sender-from' => $sender_cloned->getEmail(), '%recipient-name' => $message->getPersonalRecipient()->getUsername(), - )); + ]); } } diff --git a/core/modules/contact/src/MessageForm.php b/core/modules/contact/src/MessageForm.php index 668dd06..3258336 100644 --- a/core/modules/contact/src/MessageForm.php +++ b/core/modules/contact/src/MessageForm.php @@ -95,24 +95,24 @@ public function form(array $form, FormStateInterface $form_state) { $form['#attributes']['class'][] = 'contact-form'; if (!empty($message->preview)) { - $form['preview'] = array( - '#theme_wrappers' => array('container__preview'), - '#attributes' => array('class' => array('preview')), - ); + $form['preview'] = [ + '#theme_wrappers' => ['container__preview'], + '#attributes' => ['class' => ['preview']], + ]; $form['preview']['message'] = $this->entityManager->getViewBuilder('contact_message')->view($message, 'full'); } - $form['name'] = array( + $form['name'] = [ '#type' => 'textfield', '#title' => $this->t('Your name'), '#maxlength' => 255, '#required' => TRUE, - ); - $form['mail'] = array( + ]; + $form['mail'] = [ '#type' => 'email', '#title' => $this->t('Your email address'), '#required' => TRUE, - ); + ]; if ($user->isAnonymous()) { $form['#attached']['library'][] = 'core/drupal.form'; $form['#attributes']['data-user-info-from-browser'] = TRUE; @@ -133,24 +133,24 @@ public function form(array $form, FormStateInterface $form_state) { // The user contact form has a preset recipient. if ($message->isPersonal()) { - $form['recipient'] = array( + $form['recipient'] = [ '#type' => 'item', '#title' => $this->t('To'), '#value' => $message->getPersonalRecipient()->id(), - 'name' => array( + 'name' => [ '#theme' => 'username', '#account' => $message->getPersonalRecipient(), - ), - ); + ], + ]; } - $form['copy'] = array( + $form['copy'] = [ '#type' => 'checkbox', '#title' => $this->t('Send yourself a copy'), // Do not allow anonymous users to send themselves a copy, because it can // be abused to spam people. '#access' => $user->isAuthenticated(), - ); + ]; return $form; } @@ -160,11 +160,11 @@ public function form(array $form, FormStateInterface $form_state) { public function actions(array $form, FormStateInterface $form_state) { $elements = parent::actions($form, $form_state); $elements['submit']['#value'] = $this->t('Send message'); - $elements['preview'] = array( + $elements['preview'] = [ '#type' => 'submit', '#value' => $this->t('Preview'), - '#submit' => array('::submitForm', '::preview'), - ); + '#submit' => ['::submitForm', '::preview'], + ]; return $elements; } @@ -189,10 +189,10 @@ public function validateForm(array &$form, FormStateInterface $form_state) { $interval = $this->config('contact.settings')->get('flood.interval'); if (!$this->flood->isAllowed('contact', $limit, $interval)) { - $form_state->setErrorByName('', $this->t('You cannot send more than %limit messages in @interval. Try again later.', array( + $form_state->setErrorByName('', $this->t('You cannot send more than %limit messages in @interval. Try again later.', [ '%limit' => $limit, '@interval' => $this->dateFormatter->formatInterval($interval), - ))); + ])); } } diff --git a/core/modules/contact/src/MessageViewBuilder.php b/core/modules/contact/src/MessageViewBuilder.php index 3024f62..6cbf0e7 100644 --- a/core/modules/contact/src/MessageViewBuilder.php +++ b/core/modules/contact/src/MessageViewBuilder.php @@ -33,11 +33,11 @@ public function buildComponents(array &$build, array $entities, array $displays, // Add the message extra field, if enabled. $display = $displays[$entity->bundle()]; if ($entity->getMessage() && $display->getComponent('message')) { - $build[$id]['message'] = array( + $build[$id]['message'] = [ '#type' => 'item', '#title' => t('Message'), '#plain_text' => $entity->getMessage(), - ); + ]; } } } @@ -54,7 +54,7 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N // convert DIVs correctly. foreach (Element::children($build) as $key) { if (isset($build[$key]['#label_display']) && $build[$key]['#label_display'] == 'above') { - $build[$key] += array('#prefix' => ''); + $build[$key] += ['#prefix' => '']; $build[$key]['#prefix'] = $build[$key]['#title'] . ":\n"; $build[$key]['#label_display'] = 'hidden'; } diff --git a/core/modules/contact/src/Plugin/migrate/source/ContactCategory.php b/core/modules/contact/src/Plugin/migrate/source/ContactCategory.php index 2975431..0b9f7b3 100644 --- a/core/modules/contact/src/Plugin/migrate/source/ContactCategory.php +++ b/core/modules/contact/src/Plugin/migrate/source/ContactCategory.php @@ -20,14 +20,14 @@ class ContactCategory extends DrupalSqlBase { */ public function query() { $query = $this->select('contact', 'c') - ->fields('c', array( + ->fields('c', [ 'cid', 'category', 'recipients', 'reply', 'weight', 'selected', - ) + ] ); $query->orderBy('c.cid'); return $query; @@ -45,14 +45,14 @@ public function prepareRow(Row $row) { * {@inheritdoc} */ public function fields() { - return array( + return [ 'cid' => $this->t('Primary Key: Unique category ID.'), 'category' => $this->t('Category name.'), 'recipients' => $this->t('Comma-separated list of recipient email addresses.'), 'reply' => $this->t('Text of the auto-reply message.'), 'weight' => $this->t("The category's weight."), 'selected' => $this->t('Flag to indicate whether or not category is selected by default. (1 = Yes, 0 = No)'), - ); + ]; } /** diff --git a/core/modules/contact/src/Plugin/views/field/ContactLink.php b/core/modules/contact/src/Plugin/views/field/ContactLink.php index ecc4cea..a98be13 100644 --- a/core/modules/contact/src/Plugin/views/field/ContactLink.php +++ b/core/modules/contact/src/Plugin/views/field/ContactLink.php @@ -42,8 +42,8 @@ protected function renderLink(ResultRow $row) { $this->options['alter']['make_link'] = TRUE; $this->options['alter']['url'] = $this->getUrlInfo($row); - $title = $this->t('Contact %user', array('%user' => $entity->label())); - $this->options['alter']['attributes'] = array('title' => $title); + $title = $this->t('Contact %user', ['%user' => $entity->label()]); + $this->options['alter']['attributes'] = ['title' => $title]; if (!empty($this->options['text'])) { return $this->options['text']; diff --git a/core/modules/contact/src/Tests/ContactAuthenticatedUserTest.php b/core/modules/contact/src/Tests/ContactAuthenticatedUserTest.php index eb7c527..643797a 100644 --- a/core/modules/contact/src/Tests/ContactAuthenticatedUserTest.php +++ b/core/modules/contact/src/Tests/ContactAuthenticatedUserTest.php @@ -16,20 +16,20 @@ class ContactAuthenticatedUserTest extends WebTestBase { * * @var array */ - public static $modules = array('contact'); + public static $modules = ['contact']; /** * Tests that name and email fields are not present for authenticated users. */ function testContactSiteWideTextfieldsLoggedInTestCase() { - $this->drupalLogin($this->drupalCreateUser(array('access site-wide contact form'))); + $this->drupalLogin($this->drupalCreateUser(['access site-wide contact form'])); $this->drupalGet('contact'); // Ensure that there is no textfield for name. - $this->assertFalse($this->xpath('//input[@name=:name]', array(':name' => 'name'))); + $this->assertFalse($this->xpath('//input[@name=:name]', [':name' => 'name'])); // Ensure that there is no textfield for email. - $this->assertFalse($this->xpath('//input[@name=:name]', array(':name' => 'mail'))); + $this->assertFalse($this->xpath('//input[@name=:name]', [':name' => 'mail'])); } } diff --git a/core/modules/contact/src/Tests/ContactLanguageTest.php b/core/modules/contact/src/Tests/ContactLanguageTest.php index 4623bda..5fc73a7 100644 --- a/core/modules/contact/src/Tests/ContactLanguageTest.php +++ b/core/modules/contact/src/Tests/ContactLanguageTest.php @@ -20,11 +20,11 @@ class ContactLanguageTest extends WebTestBase { * * @var array */ - public static $modules = array( + public static $modules = [ 'contact', 'language', 'contact_test', - ); + ]; /** * {@inheritdoc} @@ -33,10 +33,10 @@ protected function setUp() { parent::setUp(); // Create and log in administrative user. - $admin_user = $this->drupalCreateUser(array( + $admin_user = $this->drupalCreateUser([ 'access site-wide contact form', 'administer languages', - )); + ]); $this->drupalLogin($admin_user); } diff --git a/core/modules/contact/src/Tests/ContactPersonalTest.php b/core/modules/contact/src/Tests/ContactPersonalTest.php index 936aed5..d80484f 100644 --- a/core/modules/contact/src/Tests/ContactPersonalTest.php +++ b/core/modules/contact/src/Tests/ContactPersonalTest.php @@ -20,7 +20,7 @@ class ContactPersonalTest extends WebTestBase { * * @var array */ - public static $modules = array('contact', 'dblog'); + public static $modules = ['contact', 'dblog']; /** * A user with some administrative permissions. @@ -47,11 +47,11 @@ protected function setUp() { parent::setUp(); // Create an admin user. - $this->adminUser = $this->drupalCreateUser(array('administer contact forms', 'administer users', 'administer account settings', 'access site reports')); + $this->adminUser = $this->drupalCreateUser(['administer contact forms', 'administer users', 'administer account settings', 'access site reports']); // Create some normal users with their contact forms enabled by default. $this->config('contact.settings')->set('user_default_enabled', TRUE)->save(); - $this->webUser = $this->drupalCreateUser(array('access user profiles', 'access user contact forms')); + $this->webUser = $this->drupalCreateUser(['access user profiles', 'access user contact forms']); $this->contactUser = $this->drupalCreateUser(); } @@ -74,11 +74,11 @@ function testSendPersonalContactMessage() { $this->assertEqual($mail['from'], $this->config('system.site')->get('mail')); $this->assertEqual($mail['reply-to'], $this->webUser->getEmail()); $this->assertEqual($mail['key'], 'user_mail'); - $variables = array( + $variables = [ '@site-name' => $this->config('system.site')->get('name'), '@subject' => $message['subject[0][value]'], '@recipient-name' => $this->contactUser->getDisplayName(), - ); + ]; $subject = PlainTextOutput::renderFromHtml(t('[@site-name] @subject', $variables)); $this->assertEqual($mail['subject'], $subject, 'Subject is in sent message.'); $this->assertTrue(strpos($mail['body'], 'Hello ' . $variables['@recipient-name']) !== FALSE, 'Recipient name is in sent message.'); @@ -90,11 +90,11 @@ function testSendPersonalContactMessage() { $this->drupalLogin($this->adminUser); // Verify that the correct watchdog message has been logged. $this->drupalGet('/admin/reports/dblog'); - $placeholders = array( + $placeholders = [ '@sender_name' => $this->webUser->username, '@sender_email' => $this->webUser->getEmail(), '@recipient_name' => $this->contactUser->getUsername() - ); + ]; $this->assertRaw(SafeMarkup::format('@sender_name (@sender_email) sent @recipient_name an email.', $placeholders)); // Ensure an unescaped version of the email does not exist anywhere. $this->assertNoRaw($this->webUser->getEmail()); @@ -109,7 +109,7 @@ function testPersonalContactAccess() { $this->drupalGet('user/' . $this->adminUser->id() . '/contact'); $this->assertResponse(200); // Check the page title is properly displayed. - $this->assertRaw(t('Contact @username', array('@username' => $this->adminUser->getDisplayName()))); + $this->assertRaw(t('Contact @username', ['@username' => $this->adminUser->getDisplayName()])); // Test denied access to admin user's own contact form. $this->drupalLogout(); @@ -149,7 +149,7 @@ function testPersonalContactAccess() { // Test that anonymous users can access the contact form. $this->drupalLogout(); - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access user contact forms')); + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access user contact forms']); $this->drupalGet('user/' . $this->contactUser->id() . '/contact'); $this->assertResponse(200); @@ -159,7 +159,7 @@ function testPersonalContactAccess() { $this->assertCacheContext('user'); // Revoke the personal contact permission for the anonymous user. - user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, array('access user contact forms')); + user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, ['access user contact forms']); $this->drupalGet('user/' . $this->contactUser->id() . '/contact'); $this->assertResponse(403); $this->assertCacheContext('user'); @@ -168,7 +168,7 @@ function testPersonalContactAccess() { // Disable the personal contact form. $this->drupalLogin($this->adminUser); - $edit = array('contact_default_status' => FALSE); + $edit = ['contact_default_status' => FALSE]; $this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.'), 'Setting successfully saved.'); $this->drupalLogout(); @@ -206,7 +206,7 @@ function testPersonalContactAccess() { $this->drupalGet('user/' . $this->webUser->id() . '/edit'); $this->assertNoFieldChecked('edit-contact--2'); $this->assertFalse(\Drupal::service('user.data')->get('contact', $this->webUser->id(), 'enabled'), 'Personal contact form disabled'); - $this->drupalPostForm(NULL, array('contact' => TRUE), t('Save')); + $this->drupalPostForm(NULL, ['contact' => TRUE], t('Save')); $this->assertFieldChecked('edit-contact--2'); $this->assertTrue(\Drupal::service('user.data')->get('contact', $this->webUser->id(), 'enabled'), 'Personal contact form enabled'); @@ -237,7 +237,7 @@ function testPersonalContactFlood() { // Submit contact form one over limit. $this->submitPersonalContact($this->contactUser); - $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', array('%number' => $flood_limit, '@interval' => \Drupal::service('date.formatter')->formatInterval($this->config('contact.settings')->get('flood.interval')))), 'Normal user denied access to flooded contact form.'); + $this->assertRaw(t('You cannot send more than %number messages in @interval. Try again later.', ['%number' => $flood_limit, '@interval' => \Drupal::service('date.formatter')->formatInterval($this->config('contact.settings')->get('flood.interval'))]), 'Normal user denied access to flooded contact form.'); // Test that the admin user can still access the contact form even though // the flood limit was reached. @@ -249,7 +249,7 @@ function testPersonalContactFlood() { * Tests the personal contact form based access when an admin adds users. */ function testAdminContact() { - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access user contact forms')); + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access user contact forms']); $this->checkContactAccess(200); $this->checkContactAccess(403, FALSE); $config = $this->config('contact.settings'); @@ -276,13 +276,13 @@ protected function checkContactAccess($response, $contact_value = NULL) { $this->assertNoFieldChecked('edit-contact--2'); } $name = $this->randomMachineName(); - $edit = array( + $edit = [ 'name' => $name, 'mail' => $this->randomMachineName() . '@example.com', 'pass[pass1]' => $pass = $this->randomString(), 'pass[pass2]' => $pass, 'notify' => FALSE, - ); + ]; if (isset($contact_value)) { $edit['contact'] = $contact_value; } @@ -306,11 +306,11 @@ protected function checkContactAccess($response, $contact_value = NULL) { * @return array * An array with the form fields being used. */ - protected function submitPersonalContact(AccountInterface $account, array $message = array()) { - $message += array( + protected function submitPersonalContact(AccountInterface $account, array $message = []) { + $message += [ 'subject[0][value]' => $this->randomMachineName(16), 'message[0][value]' => $this->randomMachineName(64), - ); + ]; $this->drupalPostForm('user/' . $account->id() . '/contact', $message, t('Send message')); return $message; } diff --git a/core/modules/contact/src/Tests/ContactSitewideTest.php b/core/modules/contact/src/Tests/ContactSitewideTest.php index c148715..f5250ed 100644 --- a/core/modules/contact/src/Tests/ContactSitewideTest.php +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php @@ -27,7 +27,7 @@ class ContactSitewideTest extends WebTestBase { * * @var array */ - public static $modules = array('text', 'contact', 'field_ui', 'contact_test', 'block'); + public static $modules = ['text', 'contact', 'field_ui', 'contact_test', 'block']; /** * {@inheritdoc} @@ -44,13 +44,13 @@ protected function setUp() { */ function testSiteWideContact() { // Create and log in administrative user. - $admin_user = $this->drupalCreateUser(array( + $admin_user = $this->drupalCreateUser([ 'access site-wide contact form', 'administer contact forms', 'administer users', 'administer account settings', 'administer contact_message fields', - )); + ]); $this->drupalLogin($admin_user); // Check the presence of expected cache tags. @@ -64,7 +64,7 @@ function testSiteWideContact() { ->save(); // Set settings. - $edit = array(); + $edit = []; $edit['contact_default_status'] = TRUE; $this->drupalPostForm('admin/config/people/accounts', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.')); @@ -76,11 +76,11 @@ function testSiteWideContact() { // Cannot use ::assertNoLinkByHref as it does partial url matching and with // field_ui enabled admin/structure/contact/manage/personal/fields exists. // @todo: See https://www.drupal.org/node/2031223 for the above. - $edit_link = $this->xpath('//a[@href=:href]', array( - ':href' => \Drupal::url('entity.contact_form.edit_form', array('contact_form' => 'personal')) - )); + $edit_link = $this->xpath('//a[@href=:href]', [ + ':href' => \Drupal::url('entity.contact_form.edit_form', ['contact_form' => 'personal']) + ]); $this->assertTrue(empty($edit_link), format_string('No link containing href %href found.', - array('%href' => 'admin/structure/contact/manage/personal') + ['%href' => 'admin/structure/contact/manage/personal'] )); $this->assertNoLinkByHref('admin/structure/contact/manage/personal/delete'); @@ -94,7 +94,7 @@ function testSiteWideContact() { $this->assertNoLinkByHref('admin/structure/contact/manage/feedback'); // Ensure that the contact form won't be shown without forms. - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form')); + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']); $this->drupalLogout(); $this->drupalGet('contact'); $this->assertResponse(404); @@ -109,10 +109,10 @@ function testSiteWideContact() { // Add forms. // Test invalid recipients. - $invalid_recipients = array('invalid', 'invalid@', 'invalid@site.', '@site.', '@site.com'); + $invalid_recipients = ['invalid', 'invalid@', 'invalid@site.', '@site.', '@site.com']; foreach ($invalid_recipients as $invalid_recipient) { $this->addContactForm($this->randomMachineName(16), $this->randomMachineName(16), $invalid_recipient, '', FALSE); - $this->assertRaw(t('%recipient is an invalid email address.', array('%recipient' => $invalid_recipient))); + $this->assertRaw(t('%recipient is an invalid email address.', ['%recipient' => $invalid_recipient])); } // Test validation of empty form and recipients fields. @@ -122,24 +122,24 @@ function testSiteWideContact() { $this->assertText(t('Recipients field is required.')); // Test validation of max_length machine name. - $recipients = array('simpletest&@example.com', 'simpletest2@example.com', 'simpletest3@example.com'); + $recipients = ['simpletest&@example.com', 'simpletest2@example.com', 'simpletest3@example.com']; $max_length = EntityTypeInterface::BUNDLE_MAX_LENGTH; $max_length_exceeded = $max_length + 1; - $this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length_exceeded)), $label = $this->randomMachineName($max_length_exceeded), implode(',', array($recipients[0])), '', TRUE); - $this->assertText(format_string('Machine-readable name cannot be longer than @max characters but is currently @exceeded characters long.', array('@max' => $max_length, '@exceeded' => $max_length_exceeded))); - $this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length)), $label = $this->randomMachineName($max_length), implode(',', array($recipients[0])), '', TRUE); - $this->assertText(t('Contact form @label has been added.', array('@label' => $label))); + $this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length_exceeded)), $label = $this->randomMachineName($max_length_exceeded), implode(',', [$recipients[0]]), '', TRUE); + $this->assertText(format_string('Machine-readable name cannot be longer than @max characters but is currently @exceeded characters long.', ['@max' => $max_length, '@exceeded' => $max_length_exceeded])); + $this->addContactForm($id = Unicode::strtolower($this->randomMachineName($max_length)), $label = $this->randomMachineName($max_length), implode(',', [$recipients[0]]), '', TRUE); + $this->assertText(t('Contact form @label has been added.', ['@label' => $label])); // Verify that the creation message contains a link to a contact form. - $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'contact/')); + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'contact/']); $this->assert(isset($view_link), 'The message area contains a link to a contact form.'); // Create first valid form. - $this->addContactForm($id = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0])), '', TRUE); - $this->assertText(t('Contact form @label has been added.', array('@label' => $label))); + $this->addContactForm($id = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', [$recipients[0]]), '', TRUE); + $this->assertText(t('Contact form @label has been added.', ['@label' => $label])); // Verify that the creation message contains a link to a contact form. - $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', array(':href' => 'contact/')); + $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'contact/']); $this->assert(isset($view_link), 'The message area contains a link to a contact form.'); // Check that the form was created in site default language. @@ -155,13 +155,13 @@ function testSiteWideContact() { $this->assertEscaped($recipients[0]); // Test update contact form. - $this->updateContactForm($id, $label = $this->randomMachineName(16), $recipients_str = implode(',', array($recipients[0], $recipients[1])), $reply = $this->randomMachineName(30), FALSE, 'Your message has been sent.', '/user'); + $this->updateContactForm($id, $label = $this->randomMachineName(16), $recipients_str = implode(',', [$recipients[0], $recipients[1]]), $reply = $this->randomMachineName(30), FALSE, 'Your message has been sent.', '/user'); $config = $this->config('contact.form.' . $id)->get(); $this->assertEqual($config['label'], $label); - $this->assertEqual($config['recipients'], array($recipients[0], $recipients[1])); + $this->assertEqual($config['recipients'], [$recipients[0], $recipients[1]]); $this->assertEqual($config['reply'], $reply); $this->assertNotEqual($id, $this->config('contact.settings')->get('default_form')); - $this->assertText(t('Contact form @label has been updated.', array('@label' => $label))); + $this->assertText(t('Contact form @label has been updated.', ['@label' => $label])); // Ensure the label is displayed on the contact page for this form. $this->drupalGet('contact/' . $id); $this->assertText($label); @@ -170,7 +170,7 @@ function testSiteWideContact() { $this->config('contact.settings')->set('default_form', $id)->save(); // Ensure that the contact form is shown without a form selection input. - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form')); + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']); $this->drupalLogout(); $this->drupalGet('contact'); $this->assertText(t('Your email address')); @@ -178,26 +178,26 @@ function testSiteWideContact() { $this->drupalLogin($admin_user); // Add more forms. - $this->addContactForm(Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0], $recipients[1])), '', FALSE); - $this->assertText(t('Contact form @label has been added.', array('@label' => $label))); + $this->addContactForm(Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', [$recipients[0], $recipients[1]]), '', FALSE); + $this->assertText(t('Contact form @label has been added.', ['@label' => $label])); - $this->addContactForm($name = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0], $recipients[1], $recipients[2])), '', FALSE); - $this->assertText(t('Contact form @label has been added.', array('@label' => $label))); + $this->addContactForm($name = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', [$recipients[0], $recipients[1], $recipients[2]]), '', FALSE); + $this->assertText(t('Contact form @label has been added.', ['@label' => $label])); // Try adding a form that already exists. $this->addContactForm($name, $label, '', '', FALSE); - $this->assertNoText(t('Contact form @label has been added.', array('@label' => $label))); + $this->assertNoText(t('Contact form @label has been added.', ['@label' => $label])); $this->assertRaw(t('The machine-readable name is already in use. It must be unique.')); $this->drupalLogout(); // Check to see that anonymous user cannot see contact page without permission. - user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form')); + user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']); $this->drupalGet('contact'); $this->assertResponse(403); // Give anonymous user permission and see that page is viewable. - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form')); + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']); $this->drupalGet('contact'); $this->assertResponse(200); @@ -209,7 +209,7 @@ function testSiteWideContact() { $this->assertText(t('Your email address field is required.')); $this->submitContact($this->randomMachineName(16), $invalid_recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64)); - $this->assertRaw(t('The email address %mail is not valid.', array('%mail' => 'invalid'))); + $this->assertRaw(t('The email address %mail is not valid.', ['%mail' => 'invalid'])); $this->submitContact($this->randomMachineName(16), $recipients[0], '', $id, $this->randomMachineName(64)); $this->assertText(t('Subject field is required.')); @@ -237,7 +237,7 @@ function testSiteWideContact() { } // Submit contact form one over limit. $this->submitContact($this->randomMachineName(16), $recipients[0], $this->randomMachineName(16), $id, $this->randomMachineName(64)); - $this->assertRaw(t('You cannot send more than %number messages in 10 min. Try again later.', array('%number' => $this->config('contact.settings')->get('flood.limit')))); + $this->assertRaw(t('You cannot send more than %number messages in 10 min. Try again later.', ['%number' => $this->config('contact.settings')->get('flood.limit')])); // Test listing controller. $this->drupalLogin($admin_user); @@ -245,7 +245,7 @@ function testSiteWideContact() { $this->deleteContactForms(); $label = $this->randomMachineName(16); - $recipients = implode(',', array($recipients[0], $recipients[1], $recipients[2])); + $recipients = implode(',', [$recipients[0], $recipients[1], $recipients[2]]); $contact_form = Unicode::strtolower($this->randomMachineName(16)); $this->addContactForm($contact_form, $label, $recipients, '', FALSE); $this->drupalGet('admin/structure/contact'); @@ -288,15 +288,15 @@ function testSiteWideContact() { $this->assertText($field_label); // Submit the contact form and verify the content. - $edit = array( + $edit = [ 'subject[0][value]' => $this->randomMachineName(), 'message[0][value]' => $this->randomMachineName(), $field_name . '[0][value]' => $this->randomMachineName(), - ); + ]; $this->drupalPostForm(NULL, $edit, t('Send message')); $mails = $this->drupalGetMails(); $mail = array_pop($mails); - $this->assertEqual($mail['subject'], t('[@label] @subject', array('@label' => $label, '@subject' => $edit['subject[0][value]']))); + $this->assertEqual($mail['subject'], t('[@label] @subject', ['@label' => $label, '@subject' => $edit['subject[0][value]']])); $this->assertTrue(strpos($mail['body'], $field_label)); $this->assertTrue(strpos($mail['body'], $edit[$field_name . '[0][value]'])); @@ -310,11 +310,11 @@ function testSiteWideContact() { $this->drupalGet('contact/' . $contact_form); // Submit the contact form and verify the content. - $edit = array( + $edit = [ 'subject[0][value]' => $this->randomMachineName(), 'message[0][value]' => $this->randomMachineName(), $field_name . '[0][value]' => $this->randomMachineName(), - ); + ]; $this->drupalPostForm(NULL, $edit, t('Send message')); $this->assertText('Thanks for your submission.'); $this->assertUrl('user/' . $admin_user->id()); @@ -330,13 +330,13 @@ function testSiteWideContact() { $this->drupalGet('contact/' . $contact_form); // Submit the contact form and verify the content. - $edit = array( + $edit = [ 'subject[0][value]' => $this->randomMachineName(), 'message[0][value]' => $this->randomMachineName(), $field_name . '[0][value]' => $this->randomMachineName(), - ); + ]; $this->drupalPostForm(NULL, $edit, t('Send message')); - $result = $this->xpath('//div[@role=:role]', array(':role' => 'contentinfo')); + $result = $this->xpath('//div[@role=:role]', [':role' => 'contentinfo']); $this->assertEqual(count($result), 0, 'Messages not found.'); $this->assertUrl('user/' . $admin_user->id()); } @@ -346,7 +346,7 @@ function testSiteWideContact() { */ function testAutoReply() { // Create and log in administrative user. - $admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer contact forms', 'administer permissions', 'administer users')); + $admin_user = $this->drupalCreateUser(['access site-wide contact form', 'administer contact forms', 'administer permissions', 'administer users']); $this->drupalLogin($admin_user); // Set up three forms, 2 with an auto-reply and one without. @@ -358,7 +358,7 @@ function testAutoReply() { // Log the current user out in order to test the name and email fields. $this->drupalLogout(); - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form')); + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']); // Test the auto-reply for form 'foo'. $email = $this->randomMachineName(32) . '@example.com'; @@ -366,7 +366,7 @@ function testAutoReply() { $this->submitContact($this->randomMachineName(16), $email, $subject, 'foo', $this->randomString(128)); // We are testing the auto-reply, so there should be one email going to the sender. - $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email)); + $captured_emails = $this->drupalGetMails(['id' => 'contact_page_autoreply', 'to' => $email]); $this->assertEqual(count($captured_emails), 1); $this->assertEqual(trim($captured_emails[0]['body']), trim(MailFormatHelper::htmlToText($foo_autoreply))); @@ -375,14 +375,14 @@ function testAutoReply() { $this->submitContact($this->randomMachineName(16), $email, $this->randomString(64), 'bar', $this->randomString(128)); // Auto-reply for form 'bar' should result in one auto-reply email to the sender. - $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email)); + $captured_emails = $this->drupalGetMails(['id' => 'contact_page_autoreply', 'to' => $email]); $this->assertEqual(count($captured_emails), 1); $this->assertEqual(trim($captured_emails[0]['body']), trim(MailFormatHelper::htmlToText($bar_autoreply))); // Verify that no auto-reply is sent when the auto-reply field is left blank. $email = $this->randomMachineName(32) . '@example.com'; $this->submitContact($this->randomMachineName(16), $email, $this->randomString(64), 'no_autoreply', $this->randomString(128)); - $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email)); + $captured_emails = $this->drupalGetMails(['id' => 'contact_page_autoreply', 'to' => $email]); $this->assertEqual(count($captured_emails), 0); } @@ -407,7 +407,7 @@ function testAutoReply() { * Array of third party settings to be added to the posted form data. */ function addContactForm($id, $label, $recipients, $reply, $selected, $message = 'Your message has been sent.', $third_party_settings = []) { - $edit = array(); + $edit = []; $edit['label'] = $label; $edit['id'] = $id; $edit['message'] = $message; @@ -439,7 +439,7 @@ function addContactForm($id, $label, $recipients, $reply, $selected, $message = * The path where user will be redirect after this form has been submitted.. */ function updateContactForm($id, $label, $recipients, $reply, $selected, $message = 'Your message has been sent.', $redirect = '/') { - $edit = array(); + $edit = []; $edit['label'] = $label; $edit['recipients'] = $recipients; $edit['reply'] = $reply; @@ -464,7 +464,7 @@ function updateContactForm($id, $label, $recipients, $reply, $selected, $message * The message body. */ function submitContact($name, $mail, $subject, $id, $message) { - $edit = array(); + $edit = []; $edit['name'] = $name; $edit['mail'] = $mail; $edit['subject[0][value]'] = $subject; @@ -489,9 +489,9 @@ function deleteContactForms() { $this->assertResponse(403); } else { - $this->drupalPostForm("admin/structure/contact/manage/$id/delete", array(), t('Delete')); - $this->assertRaw(t('The contact form %label has been deleted.', array('%label' => $contact_form->label()))); - $this->assertFalse(ContactForm::load($id), format_string('Form %contact_form not found', array('%contact_form' => $contact_form->label()))); + $this->drupalPostForm("admin/structure/contact/manage/$id/delete", [], t('Delete')); + $this->assertRaw(t('The contact form %label has been deleted.', ['%label' => $contact_form->label()])); + $this->assertFalse(ContactForm::load($id), format_string('Form %contact_form not found', ['%contact_form' => $contact_form->label()])); } } } diff --git a/core/modules/contact/src/Tests/ContactStorageTest.php b/core/modules/contact/src/Tests/ContactStorageTest.php index ad0e8d4..f9165a8 100644 --- a/core/modules/contact/src/Tests/ContactStorageTest.php +++ b/core/modules/contact/src/Tests/ContactStorageTest.php @@ -37,23 +37,23 @@ class ContactStorageTest extends ContactSitewideTest { */ public function testContactStorage() { // Create and log in administrative user. - $admin_user = $this->drupalCreateUser(array( + $admin_user = $this->drupalCreateUser([ 'access site-wide contact form', 'administer contact forms', 'administer users', 'administer account settings', 'administer contact_message fields', - )); + ]); $this->drupalLogin($admin_user); // Create first valid contact form. $mail = 'simpletest@example.com'; - $this->addContactForm($id = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($mail)), '', TRUE, 'Your message has been sent.', [ + $this->addContactForm($id = Unicode::strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', [$mail]), '', TRUE, 'Your message has been sent.', [ 'send_a_pony' => 1, ]); - $this->assertText(t('Contact form @label has been added.', array('@label' => $label))); + $this->assertText(t('Contact form @label has been added.', ['@label' => $label])); // Ensure that anonymous can submit site-wide contact form. - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form')); + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']); $this->drupalLogout(); $this->drupalGet('contact'); $this->assertText(t('Your email address')); diff --git a/core/modules/contact/src/Tests/Views/ContactFieldsTest.php b/core/modules/contact/src/Tests/Views/ContactFieldsTest.php index cf70799..fafe451 100644 --- a/core/modules/contact/src/Tests/Views/ContactFieldsTest.php +++ b/core/modules/contact/src/Tests/Views/ContactFieldsTest.php @@ -19,7 +19,7 @@ class ContactFieldsTest extends ViewTestBase { * * @var array */ - public static $modules = array('field', 'text', 'contact'); + public static $modules = ['field', 'text', 'contact']; /** * Contains the field storage definition for contact used for this test. @@ -31,11 +31,11 @@ class ContactFieldsTest extends ViewTestBase { protected function setUp() { parent::setUp(); - $this->fieldStorage = FieldStorageConfig::create(array( + $this->fieldStorage = FieldStorageConfig::create([ 'field_name' => strtolower($this->randomMachineName()), 'entity_type' => 'contact_message', 'type' => 'text' - )); + ]); $this->fieldStorage->save(); ContactForm::create([ diff --git a/core/modules/contact/src/Tests/Views/ContactLinkTest.php b/core/modules/contact/src/Tests/Views/ContactLinkTest.php index 738f67c..f6b6013 100644 --- a/core/modules/contact/src/Tests/Views/ContactLinkTest.php +++ b/core/modules/contact/src/Tests/Views/ContactLinkTest.php @@ -27,14 +27,14 @@ class ContactLinkTest extends ViewTestBase { * * @var array */ - public static $modules = array('contact_test_views'); + public static $modules = ['contact_test_views']; /** * Views used by this test. * * @var array */ - public static $testViews = array('test_contact_link'); + public static $testViews = ['test_contact_link']; /** * {@inheritdoc} @@ -42,7 +42,7 @@ class ContactLinkTest extends ViewTestBase { protected function setUp() { parent::setUp(); - ViewTestData::createTestViews(get_class($this), array('contact_test_views')); + ViewTestData::createTestViews(get_class($this), ['contact_test_views']); $this->userData = $this->container->get('user.data'); } @@ -51,39 +51,39 @@ protected function setUp() { * Tests contact link. */ public function testContactLink() { - $accounts = array(); + $accounts = []; $accounts['root'] = User::load(1); // Create an account with access to all contact pages. - $admin_account = $this->drupalCreateUser(array('administer users')); + $admin_account = $this->drupalCreateUser(['administer users']); $accounts['admin'] = $admin_account; // Create an account with no access to contact pages. $no_contact_account = $this->drupalCreateUser(); $accounts['no_contact'] = $no_contact_account; // Create an account with access to contact pages. - $contact_account = $this->drupalCreateUser(array('access user contact forms')); + $contact_account = $this->drupalCreateUser(['access user contact forms']); $accounts['contact'] = $contact_account; $this->drupalLogin($admin_account); $this->drupalGet('test-contact-link'); // The admin user has access to all contact links beside his own. - $this->assertContactLinks($accounts, array('root', 'no_contact', 'contact')); + $this->assertContactLinks($accounts, ['root', 'no_contact', 'contact']); $this->drupalLogin($no_contact_account); $this->drupalGet('test-contact-link'); // Ensure that the user without the permission doesn't see any link. - $this->assertContactLinks($accounts, array()); + $this->assertContactLinks($accounts, []); $this->drupalLogin($contact_account); $this->drupalGet('test-contact-link'); - $this->assertContactLinks($accounts, array('root', 'admin', 'no_contact')); + $this->assertContactLinks($accounts, ['root', 'admin', 'no_contact']); // Disable contact link for no_contact. $this->userData->set('contact', $no_contact_account->id(), 'enabled', FALSE); // @todo Remove cache invalidation in https://www.drupal.org/node/2477903. Cache::invalidateTags($no_contact_account->getCacheTagsToInvalidate()); $this->drupalGet('test-contact-link'); - $this->assertContactLinks($accounts, array('root', 'admin')); + $this->assertContactLinks($accounts, ['root', 'admin']); } /** @@ -100,7 +100,7 @@ public function assertContactLinks(array $accounts, array $names) { foreach ($names as $name) { $account = $accounts[$name]; - $result = $this->xpath('//div[contains(@class, "views-field-contact")]//a[contains(@href, :url)]', array(':url' => $account->url('contact-form'))); + $result = $this->xpath('//div[contains(@class, "views-field-contact")]//a[contains(@href, :url)]', [':url' => $account->url('contact-form')]); $this->assertTrue(count($result)); } } diff --git a/core/modules/contact/tests/drupal-7.contact.database.php b/core/modules/contact/tests/drupal-7.contact.database.php index 494e430..f0ccd93 100644 --- a/core/modules/contact/tests/drupal-7.contact.database.php +++ b/core/modules/contact/tests/drupal-7.contact.database.php @@ -11,23 +11,23 @@ // Update the default category to that it is not selected. db_update('contact') - ->fields(array('selected' => '0')) + ->fields(['selected' => '0']) ->condition('cid', '1') ->execute(); // Add a custom contact category. -db_insert('contact')->fields(array( +db_insert('contact')->fields([ 'category', 'recipients', 'reply', 'weight', 'selected' -)) -->values(array( +]) +->values([ 'category' => 'Upgrade test', 'recipients' => 'test1@example.com,test2@example.com', 'reply' => 'Test reply', 'weight' => 1, 'selected' => 1, -)) +]) ->execute(); diff --git a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module index e20dc43..cef976c 100644 --- a/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module +++ b/core/modules/contact/tests/modules/contact_storage_test/contact_storage_test.module @@ -15,7 +15,7 @@ */ function contact_storage_test_entity_base_field_info(EntityTypeInterface $entity_type) { if ($entity_type->id() == 'contact_message') { - $fields = array(); + $fields = []; $fields['id'] = BaseFieldDefinition::create('integer') ->setLabel(t('Message ID')) @@ -48,12 +48,12 @@ function contact_storage_test_entity_type_alter(array &$entity_types) { function contact_storage_test_form_contact_form_form_alter(&$form, FormStateInterface $form_state) { /** @var \Drupal\contact\ContactFormInterface $contact_form */ $contact_form = $form_state->getFormObject()->getEntity(); - $form['send_a_pony'] = array( + $form['send_a_pony'] = [ '#type' => 'checkbox', '#title' => t('Send submitters a voucher for a free pony.'), '#description' => t('Enable to send an additional email with a free pony voucher to anyone who submits the form.'), '#default_value' => $contact_form->getThirdPartySetting('contact_storage_test', 'send_a_pony', FALSE), - ); + ]; $form['#entity_builders'][] = 'contact_storage_test_contact_form_form_builder'; } /** diff --git a/core/modules/contact/tests/src/Kernel/MessageEntityTest.php b/core/modules/contact/tests/src/Kernel/MessageEntityTest.php index 70ddea1..e7343b9 100644 --- a/core/modules/contact/tests/src/Kernel/MessageEntityTest.php +++ b/core/modules/contact/tests/src/Kernel/MessageEntityTest.php @@ -17,17 +17,17 @@ class MessageEntityTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array( + public static $modules = [ 'system', 'contact', 'field', 'user', 'contact_test', - ); + ]; protected function setUp() { parent::setUp(); - $this->installConfig(array('contact', 'contact_test')); + $this->installConfig(['contact', 'contact_test']); } /** @@ -35,7 +35,7 @@ protected function setUp() { */ public function testMessageMethods() { $message_storage = $this->container->get('entity.manager')->getStorage('contact_message'); - $message = $message_storage->create(array('contact_form' => 'feedback')); + $message = $message_storage->create(['contact_form' => 'feedback']); // Check for empty values first. $this->assertEqual($message->getMessage(), ''); diff --git a/core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php b/core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php index 291826c..935390c 100644 --- a/core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php +++ b/core/modules/contact/tests/src/Kernel/Migrate/MigrateContactCategoryTest.php @@ -18,7 +18,7 @@ class MigrateContactCategoryTest extends MigrateDrupal6TestBase { * * @var array */ - public static $modules = array('contact'); + public static $modules = ['contact']; /** * {@inheritdoc} diff --git a/core/modules/contact/tests/src/Kernel/Migrate/d6/MigrateContactCategoryTest.php b/core/modules/contact/tests/src/Kernel/Migrate/d6/MigrateContactCategoryTest.php index d613cac..d7af64d 100644 --- a/core/modules/contact/tests/src/Kernel/Migrate/d6/MigrateContactCategoryTest.php +++ b/core/modules/contact/tests/src/Kernel/Migrate/d6/MigrateContactCategoryTest.php @@ -32,19 +32,19 @@ public function testContactCategory() { /** @var \Drupal\contact\Entity\ContactForm $contact_form */ $contact_form = ContactForm::load('website_feedback'); $this->assertIdentical('Website feedback', $contact_form->label()); - $this->assertIdentical(array('admin@example.com'), $contact_form->getRecipients()); + $this->assertIdentical(['admin@example.com'], $contact_form->getRecipients()); $this->assertIdentical('', $contact_form->getReply()); $this->assertIdentical(0, $contact_form->getWeight()); $contact_form = ContactForm::load('some_other_category'); $this->assertIdentical('Some other category', $contact_form->label()); - $this->assertIdentical(array('test@example.com'), $contact_form->getRecipients()); + $this->assertIdentical(['test@example.com'], $contact_form->getRecipients()); $this->assertIdentical('Thanks for contacting us, we will reply ASAP!', $contact_form->getReply()); $this->assertIdentical(1, $contact_form->getWeight()); $contact_form = ContactForm::load('a_category_much_longer_than_thir'); $this->assertIdentical('A category much longer than thirty two characters', $contact_form->label()); - $this->assertIdentical(array('fortyninechars@example.com'), $contact_form->getRecipients()); + $this->assertIdentical(['fortyninechars@example.com'], $contact_form->getRecipients()); $this->assertIdentical('', $contact_form->getReply()); $this->assertIdentical(2, $contact_form->getWeight()); } diff --git a/core/modules/contact/tests/src/Unit/MailHandlerTest.php b/core/modules/contact/tests/src/Unit/MailHandlerTest.php index 9e5c82c..ce24cf4 100644 --- a/core/modules/contact/tests/src/Unit/MailHandlerTest.php +++ b/core/modules/contact/tests/src/Unit/MailHandlerTest.php @@ -80,7 +80,7 @@ protected function setUp() { $string_translation = $this->getStringTranslationStub(); $this->contactMailHandler = new MailHandler($this->mailManager, $this->languageManager, $this->logger, $string_translation, $this->entityManager); - $language = new Language(array('id' => 'en')); + $language = new Language(['id' => 'en']); $this->languageManager->expects($this->any()) ->method('getDefaultLanguage') @@ -156,76 +156,76 @@ function($module, $key, $to, $langcode, $params, $from) use (&$results) { * Data provider for ::testSendMailMessages. */ public function getSendMailMessages() { - $data = array(); - $recipients = array('admin@drupal.org', 'user@drupal.org'); - $default_result = array( + $data = []; + $recipients = ['admin@drupal.org', 'user@drupal.org']; + $default_result = [ 'module' => 'contact', 'key' => '', 'to' => implode(', ', $recipients), 'langcode' => 'en', - 'params' => array(), + 'params' => [], 'from' => 'anonymous@drupal.org', - ); - $results = array(); + ]; + $results = []; $message = $this->getAnonymousMockMessage($recipients, ''); $sender = $this->getMockSender(); - $result = array( + $result = [ 'key' => 'page_mail', - 'params' => array( + 'params' => [ 'contact_message' => $message, 'sender' => $sender, 'contact_form' => $message->getContactForm(), - ), - ); + ], + ]; $results[] = $result + $default_result; - $data[] = array($message, $sender, $results); + $data[] = [$message, $sender, $results]; - $results = array(); + $results = []; $message = $this->getAnonymousMockMessage($recipients, 'reply'); $sender = $this->getMockSender(); - $result = array( + $result = [ 'key' => 'page_mail', - 'params' => array( + 'params' => [ 'contact_message' => $message, 'sender' => $sender, 'contact_form' => $message->getContactForm(), - ), - ); + ], + ]; $results[] = $result + $default_result; $result['key'] = 'page_autoreply'; $result['to'] = 'anonymous@drupal.org'; $result['from'] = NULL; $results[] = $result + $default_result; - $data[] = array($message, $sender, $results); + $data[] = [$message, $sender, $results]; - $results = array(); + $results = []; $message = $this->getAnonymousMockMessage($recipients, '', TRUE); $sender = $this->getMockSender(); - $result = array( + $result = [ 'key' => 'page_mail', - 'params' => array( + 'params' => [ 'contact_message' => $message, 'sender' => $sender, 'contact_form' => $message->getContactForm(), - ), - ); + ], + ]; $results[] = $result + $default_result; $result['key'] = 'page_copy'; $result['to'] = 'anonymous@drupal.org'; $results[] = $result + $default_result; - $data[] = array($message, $sender, $results); + $data[] = [$message, $sender, $results]; - $results = array(); + $results = []; $message = $this->getAnonymousMockMessage($recipients, 'reply', TRUE); $sender = $this->getMockSender(); - $result = array( + $result = [ 'key' => 'page_mail', - 'params' => array( + 'params' => [ 'contact_message' => $message, 'sender' => $sender, 'contact_form' => $message->getContactForm(), - ), - ); + ], + ]; $results[] = $result + $default_result; $result['key'] = 'page_copy'; $result['to'] = 'anonymous@drupal.org'; @@ -233,48 +233,48 @@ public function getSendMailMessages() { $result['key'] = 'page_autoreply'; $result['from'] = NULL; $results[] = $result + $default_result; - $data[] = array($message, $sender, $results); + $data[] = [$message, $sender, $results]; //For authenticated user. - $results = array(); + $results = []; $message = $this->getAuthenticatedMockMessage(); $sender = $this->getMockSender(FALSE, 'user@drupal.org'); - $result = array( + $result = [ 'module' => 'contact', 'key' => 'user_mail', 'to' => 'user2@drupal.org', 'langcode' => 'en', - 'params' => array( + 'params' => [ 'contact_message' => $message, 'sender' => $sender, 'recipient' => $message->getPersonalRecipient(), - ), + ], 'from' => 'user@drupal.org', - ); + ]; $results[] = $result; - $data[] = array($message, $sender, $results); + $data[] = [$message, $sender, $results]; - $results = array(); + $results = []; $message = $this->getAuthenticatedMockMessage(TRUE); $sender = $this->getMockSender(FALSE, 'user@drupal.org'); - $result = array( + $result = [ 'module' => 'contact', 'key' => 'user_mail', 'to' => 'user2@drupal.org', 'langcode' => 'en', - 'params' => array( + 'params' => [ 'contact_message' => $message, 'sender' => $sender, 'recipient' => $message->getPersonalRecipient(), - ), + ], 'from' => 'user@drupal.org', - ); + ]; $results[] = $result; $result['key'] = 'user_copy'; $result['to'] = $result['from']; $results[] = $result; - $data[] = array($message, $sender, $results); + $data[] = [$message, $sender, $results]; return $data; } diff --git a/core/modules/contact/tests/src/Unit/Plugin/migrate/source/ContactCategoryTest.php b/core/modules/contact/tests/src/Unit/Plugin/migrate/source/ContactCategoryTest.php index cbdd688..8883d42 100644 --- a/core/modules/contact/tests/src/Unit/Plugin/migrate/source/ContactCategoryTest.php +++ b/core/modules/contact/tests/src/Unit/Plugin/migrate/source/ContactCategoryTest.php @@ -14,31 +14,31 @@ class ContactCategoryTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = ContactCategory::class; - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'contact_category', - ), - ); + ], + ]; - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'cid' => 1, 'category' => 'contact category value 1', - 'recipients' => array('admin@example.com', 'user@example.com'), + 'recipients' => ['admin@example.com', 'user@example.com'], 'reply' => 'auto reply value 1', 'weight' => 0, 'selected' => 0, - ), - array( + ], + [ 'cid' => 2, 'category' => 'contact category value 2', - 'recipients' => array('admin@example.com', 'user@example.com'), + 'recipients' => ['admin@example.com', 'user@example.com'], 'reply' => 'auto reply value 2', 'weight' => 0, 'selected' => 0, - ), - ); + ], + ]; /** * {@inheritdoc} diff --git a/core/modules/contact/tests/src/Unit/Plugin/migrate/source/d6/ContactSettingsTest.php b/core/modules/contact/tests/src/Unit/Plugin/migrate/source/d6/ContactSettingsTest.php index 95850cd..49ff1e8 100644 --- a/core/modules/contact/tests/src/Unit/Plugin/migrate/source/d6/ContactSettingsTest.php +++ b/core/modules/contact/tests/src/Unit/Plugin/migrate/source/d6/ContactSettingsTest.php @@ -14,41 +14,41 @@ class ContactSettingsTest extends MigrateSqlSourceTestCase { const PLUGIN_CLASS = ContactSettings::class; - protected $migrationConfiguration = array( + protected $migrationConfiguration = [ 'id' => 'test', - 'source' => array( + 'source' => [ 'plugin' => 'd6_contact_settings', - 'variables' => array('site_name'), - ), - ); + 'variables' => ['site_name'], + ], + ]; - protected $expectedResults = array( - array( + protected $expectedResults = [ + [ 'default_category' => '1', 'site_name' => 'Blorf!', - ), - ); + ], + ]; /** * {@inheritdoc} */ protected function setUp() { - $this->databaseContents['variable'] = array( - array( + $this->databaseContents['variable'] = [ + [ 'name' => 'site_name', 'value' => serialize('Blorf!'), - ), - ); - $this->databaseContents['contact'] = array( - array( + ], + ]; + $this->databaseContents['contact'] = [ + [ 'cid' => '1', 'category' => 'Website feedback', 'recipients' => 'admin@example.com', 'reply' => '', 'weight' => '0', 'selected' => '1', - ) - ); + ] + ]; parent::setUp(); } diff --git a/core/modules/content_moderation/src/ContentModerationStateStorageSchema.php b/core/modules/content_moderation/src/ContentModerationStateStorageSchema.php index 19ec324..cb87cc1 100644 --- a/core/modules/content_moderation/src/ContentModerationStateStorageSchema.php +++ b/core/modules/content_moderation/src/ContentModerationStateStorageSchema.php @@ -19,9 +19,9 @@ protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $res // Creates an index to ensure that the lookup in // \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList::getModerationState() // is performant. - $schema['content_moderation_state_field_data']['indexes'] += array( - 'content_moderation_state__lookup' => array('content_entity_type_id', 'content_entity_id', 'content_entity_revision_id'), - ); + $schema['content_moderation_state_field_data']['indexes'] += [ + 'content_moderation_state__lookup' => ['content_entity_type_id', 'content_entity_id', 'content_entity_revision_id'], + ]; return $schema; } diff --git a/core/modules/content_moderation/src/Entity/ContentModerationState.php b/core/modules/content_moderation/src/Entity/ContentModerationState.php index 1ff7f2a..bf85c9b 100644 --- a/core/modules/content_moderation/src/Entity/ContentModerationState.php +++ b/core/modules/content_moderation/src/Entity/ContentModerationState.php @@ -145,7 +145,7 @@ public static function updateOrCreateFromEntity(ContentModerationState $content_ * An array of default values. */ public static function getCurrentUserId() { - return array(\Drupal::currentUser()->id()); + return [\Drupal::currentUser()->id()]; } /** diff --git a/core/modules/content_moderation/src/Form/ModerationStateDeleteForm.php b/core/modules/content_moderation/src/Form/ModerationStateDeleteForm.php index 43e2b36..b288734 100644 --- a/core/modules/content_moderation/src/Form/ModerationStateDeleteForm.php +++ b/core/modules/content_moderation/src/Form/ModerationStateDeleteForm.php @@ -15,7 +15,7 @@ class ModerationStateDeleteForm extends EntityConfirmFormBase { * {@inheritdoc} */ public function getQuestion() { - return $this->t('Are you sure you want to delete %name?', array('%name' => $this->entity->label())); + return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]); } /** diff --git a/core/modules/content_moderation/src/Form/ModerationStateForm.php b/core/modules/content_moderation/src/Form/ModerationStateForm.php index 32d7a48..c8224c7 100644 --- a/core/modules/content_moderation/src/Form/ModerationStateForm.php +++ b/core/modules/content_moderation/src/Form/ModerationStateForm.php @@ -19,23 +19,23 @@ public function form(array $form, FormStateInterface $form_state) { /* @var \Drupal\content_moderation\ModerationStateInterface $moderation_state */ $moderation_state = $this->entity; - $form['label'] = array( + $form['label'] = [ '#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $moderation_state->label(), '#description' => $this->t('Label for the Moderation state.'), '#required' => TRUE, - ); + ]; - $form['id'] = array( + $form['id'] = [ '#type' => 'machine_name', '#default_value' => $moderation_state->id(), - '#machine_name' => array( + '#machine_name' => [ 'exists' => [ModerationState::class, 'load'], - ), + ], '#disabled' => !$moderation_state->isNew(), - ); + ]; $form['published'] = [ '#type' => 'checkbox', diff --git a/core/modules/content_moderation/src/Form/ModerationStateTransitionDeleteForm.php b/core/modules/content_moderation/src/Form/ModerationStateTransitionDeleteForm.php index f153f1f..aa3ce20 100644 --- a/core/modules/content_moderation/src/Form/ModerationStateTransitionDeleteForm.php +++ b/core/modules/content_moderation/src/Form/ModerationStateTransitionDeleteForm.php @@ -15,7 +15,7 @@ class ModerationStateTransitionDeleteForm extends EntityConfirmFormBase { * {@inheritdoc} */ public function getQuestion() { - return $this->t('Are you sure you want to delete %name?', array('%name' => $this->entity->label())); + return $this->t('Are you sure you want to delete %name?', ['%name' => $this->entity->label()]); } /** diff --git a/core/modules/content_moderation/src/ModerationStateTransitionListBuilder.php b/core/modules/content_moderation/src/ModerationStateTransitionListBuilder.php index 577283e..9340f8a 100644 --- a/core/modules/content_moderation/src/ModerationStateTransitionListBuilder.php +++ b/core/modules/content_moderation/src/ModerationStateTransitionListBuilder.php @@ -111,7 +111,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { // Get all the moderation states and sort them by weight. $states = $this->stateStorage->loadMultiple(); - uasort($states, array($this->entityType->getClass(), 'sort')); + uasort($states, [$this->entityType->getClass(), 'sort']); /** @var \Drupal\content_moderation\ModerationStateTransitionInterface $entity */ $groups = array_fill_keys(array_keys($states), []); @@ -127,18 +127,18 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#open' => $group_name === array_keys($groups)[0], ]; - $form[$group_name][$this->entitiesKey] = array( + $form[$group_name][$this->entitiesKey] = [ '#type' => 'table', '#header' => $this->buildHeader(), - '#empty' => t('There is no @label yet.', array('@label' => $this->entityType->getLabel())), - '#tabledrag' => array( - array( + '#empty' => t('There is no @label yet.', ['@label' => $this->entityType->getLabel()]), + '#tabledrag' => [ + [ 'action' => 'order', 'relationship' => 'sibling', 'group' => 'weight', - ), - ), - ); + ], + ], + ]; $delta = 10; // Change the delta of the weight field if have more than 20 entities. @@ -151,7 +151,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { foreach ($entities as $entity) { $row = $this->buildRow($entity); if (isset($row['label'])) { - $row['label'] = array('#markup' => $row['label']); + $row['label'] = ['#markup' => $row['label']]; } if (isset($row['weight'])) { $row['weight']['#delta'] = $delta; @@ -161,11 +161,11 @@ public function buildForm(array $form, FormStateInterface $form_state) { } $form['actions']['#type'] = 'actions'; - $form['actions']['submit'] = array( + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => t('Save order'), '#button_type' => 'primary', - ); + ]; return $form; } diff --git a/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php b/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php index 980c61e..94f10e9 100644 --- a/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php +++ b/core/modules/content_moderation/src/ParamConverter/EntityRevisionConverter.php @@ -95,7 +95,7 @@ public function convert($value, $definition, $name, array $defaults) { // If the entity type is translatable, ensure we return the proper // translation object for the current context. if ($latest_revision instanceof EntityInterface && $entity instanceof TranslatableInterface) { - $latest_revision = $this->entityManager->getTranslationFromContext($latest_revision, NULL, array('operation' => 'entity_upcast')); + $latest_revision = $this->entityManager->getTranslationFromContext($latest_revision, NULL, ['operation' => 'entity_upcast']); } if ($latest_revision->isRevisionTranslationAffected()) { diff --git a/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php b/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php index d6dc89d..09d70bf 100644 --- a/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php +++ b/core/modules/content_moderation/src/Plugin/Field/FieldWidget/ModerationStateWidget.php @@ -175,7 +175,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen '#published' => $default ? $default_state->isPublishedState() : FALSE, '#key_column' => $this->column, ]; - $element['#element_validate'][] = array(get_class($this), 'validateElement'); + $element['#element_validate'][] = [get_class($this), 'validateElement']; // Use the dropbutton. $element['#process'][] = [get_called_class(), 'processActions']; diff --git a/core/modules/content_moderation/src/Tests/ModerationStateBlockTest.php b/core/modules/content_moderation/src/Tests/ModerationStateBlockTest.php index 001d6b5..3ea5437 100644 --- a/core/modules/content_moderation/src/Tests/ModerationStateBlockTest.php +++ b/core/modules/content_moderation/src/Tests/ModerationStateBlockTest.php @@ -72,11 +72,11 @@ public function testCustomBlockModeration() { $this->assertText(t('basic Moderated block has been created.')); // Place the block in the Sidebar First region. - $instance = array( + $instance = [ 'id' => 'moderated_block', 'settings[label]' => $edit['info[0][value]'], 'region' => 'sidebar_first', - ); + ]; $block = BlockContent::load(1); $url = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . $this->config('system.theme')->get('default'); $this->drupalPostForm($url, $instance, t('Save block')); diff --git a/core/modules/content_moderation/src/Tests/ModerationStateNodeTest.php b/core/modules/content_moderation/src/Tests/ModerationStateNodeTest.php index a819caf..4ccff30 100644 --- a/core/modules/content_moderation/src/Tests/ModerationStateNodeTest.php +++ b/core/modules/content_moderation/src/Tests/ModerationStateNodeTest.php @@ -60,7 +60,7 @@ public function testCreatingContent() { $this->assertNoText('Published'); // Delete the node. - $this->drupalPostForm('node/' . $node->id() . '/delete', array(), t('Delete')); + $this->drupalPostForm('node/' . $node->id() . '/delete', [], t('Delete')); $this->assertText(t('The Moderated content moderated content has been deleted.')); } diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index 057d93a..e09cd3c 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -29,10 +29,10 @@ function content_translation_field_sync_widget(FieldDefinitionInterface $field, $element_name = 'third_party_settings[content_translation][translation_sync]') { // No way to store field sync information on this field. if (!($field instanceof ThirdPartySettingsInterface)) { - return array(); + return []; } - $element = array(); + $element = []; $definition = \Drupal::service('plugin.manager.field.field_type')->getDefinition($field->getType()); $column_groups = $definition['column_groups']; if (!empty($column_groups) && count($column_groups) > 1) { @@ -50,12 +50,12 @@ function content_translation_field_sync_widget(FieldDefinitionInterface $field, $default = $field->getThirdPartySetting('content_translation', 'translation_sync', $default); - $element = array( + $element = [ '#type' => 'checkboxes', '#title' => t('Translatable elements'), '#options' => $options, '#default_value' => $default, - ); + ]; if ($require_all_groups_for_translation) { // The actual checkboxes are sometimes rendered separately and the parent @@ -96,7 +96,7 @@ function _content_translation_form_language_content_settings_form_alter(array &$ $bundle_info_service = \Drupal::service('entity_type.bundle.info'); foreach ($form['#labels'] as $entity_type_id => $label) { $entity_type = $entity_manager->getDefinition($entity_type_id); - $storage_definitions = $entity_type instanceof ContentEntityTypeInterface ? $entity_manager->getFieldStorageDefinitions($entity_type_id) : array(); + $storage_definitions = $entity_type instanceof ContentEntityTypeInterface ? $entity_manager->getFieldStorageDefinitions($entity_type_id) : []; $entity_type_translatable = $content_translation_manager->isSupported($entity_type_id); foreach ($bundle_info_service->getBundleInfo($entity_type_id) as $bundle => $bundle_info) { @@ -106,7 +106,7 @@ function _content_translation_form_language_content_settings_form_alter(array &$ // about UI integration. $form['settings'][$entity_type_id][$bundle]['settings']['language']['#content_translation_skip_alter'] = TRUE; if (!$entity_type_translatable) { - $form['settings'][$entity_type_id]['#title'] = t('@label (Translation is not supported).', array('@label' => $entity_type->getLabel())); + $form['settings'][$entity_type_id]['#title'] = t('@label (Translation is not supported).', ['@label' => $entity_type->getLabel()]); continue; } @@ -114,11 +114,11 @@ function _content_translation_form_language_content_settings_form_alter(array &$ if ($fields) { foreach ($fields as $field_name => $definition) { if (!empty($storage_definitions[$field_name]) && _content_translation_is_field_translatability_configurable($entity_type, $storage_definitions[$field_name])) { - $form['settings'][$entity_type_id][$bundle]['fields'][$field_name] = array( + $form['settings'][$entity_type_id][$bundle]['fields'][$field_name] = [ '#label' => $definition->getLabel(), '#type' => 'checkbox', '#default_value' => $definition->isTranslatable(), - ); + ]; // Display the column translatability configuration widget. $column_element = content_translation_field_sync_widget($definition, "settings[{$entity_type_id}][{$bundle}][columns][{$field_name}]"); if ($column_element) { @@ -129,10 +129,10 @@ function _content_translation_form_language_content_settings_form_alter(array &$ if (!empty($form['settings'][$entity_type_id][$bundle]['fields'])) { // Only show the checkbox to enable translation if the bundles in the // entity might have fields and if there are fields to translate. - $form['settings'][$entity_type_id][$bundle]['translatable'] = array( + $form['settings'][$entity_type_id][$bundle]['translatable'] = [ '#type' => 'checkbox', '#default_value' => $content_translation_manager->isEnabled($entity_type_id, $bundle), - ); + ]; } } } @@ -177,102 +177,102 @@ function _content_translation_preprocess_language_content_settings_table(&$varia $element = $variables['element']; $build = &$variables['build']; - array_unshift($build['#header'], array('data' => t('Translatable'), 'class' => array('translatable'))); - $rows = array(); + array_unshift($build['#header'], ['data' => t('Translatable'), 'class' => ['translatable']]); + $rows = []; foreach (Element::children($element) as $bundle) { - $field_names = !empty($element[$bundle]['fields']) ? Element::children($element[$bundle]['fields']) : array(); + $field_names = !empty($element[$bundle]['fields']) ? Element::children($element[$bundle]['fields']) : []; if (!empty($element[$bundle]['translatable'])) { $checkbox_id = $element[$bundle]['translatable']['#id']; } $rows[$bundle] = $build['#rows'][$bundle]; if (!empty($element[$bundle]['translatable'])) { - $translatable = array( + $translatable = [ 'data' => $element[$bundle]['translatable'], - 'class' => array('translatable'), - ); + 'class' => ['translatable'], + ]; array_unshift($rows[$bundle]['data'], $translatable); $rows[$bundle]['data'][1]['data']['#prefix'] = '
    '; $output .= t('Once the contextual links button for the area of interest is visible, click the button to display the links.'); $output .= '
  • '; @@ -132,10 +132,10 @@ function contextual_preprocess(&$variables, $hook, $info) { // users, contextual_page_attachments() only adds the asset library for // users with the 'access contextual links' permission, thus preventing // unnecessary HTTP requests for users without that permission. - $variables['title_suffix']['contextual_links'] = array( + $variables['title_suffix']['contextual_links'] = [ '#type' => 'contextual_links_placeholder', '#id' => _contextual_links_to_id($element['#contextual_links']), - ); + ]; } } @@ -172,7 +172,7 @@ function contextual_contextual_links_view_alter(&$element, $items) { * use in a data- attribute. */ function _contextual_links_to_id($contextual_links) { - $ids = array(); + $ids = []; $langcode = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId(); foreach ($contextual_links as $group => $args) { $route_parameters = UrlHelper::buildQuery($args['route_parameters']); @@ -199,17 +199,17 @@ function _contextual_links_to_id($contextual_links) { * The value for a #contextual_links property. */ function _contextual_id_to_links($id) { - $contextual_links = array(); + $contextual_links = []; $contexts = explode('|', $id); foreach ($contexts as $context) { list($group, $route_parameters_raw, $metadata_raw) = explode(':', $context); parse_str($route_parameters_raw, $route_parameters); - $metadata = array(); + $metadata = []; parse_str($metadata_raw, $metadata); - $contextual_links[$group] = array( + $contextual_links[$group] = [ 'route_parameters' => $route_parameters, 'metadata' => $metadata, - ); + ]; } return $contextual_links; } diff --git a/core/modules/contextual/contextual.views.inc b/core/modules/contextual/contextual.views.inc index 528b3bb..bac5522 100644 --- a/core/modules/contextual/contextual.views.inc +++ b/core/modules/contextual/contextual.views.inc @@ -9,11 +9,11 @@ * Implements hook_views_data_alter(). */ function contextual_views_data_alter(&$data) { - $data['views']['contextual_links'] = array( + $data['views']['contextual_links'] = [ 'title' => t('Contextual Links'), 'help' => t('Display fields in a contextual links menu.'), - 'field' => array( + 'field' => [ 'id' => 'contextual_links', - ), - ); + ], + ]; } diff --git a/core/modules/contextual/src/ContextualController.php b/core/modules/contextual/src/ContextualController.php index 0812ad1..b1fe245 100644 --- a/core/modules/contextual/src/ContextualController.php +++ b/core/modules/contextual/src/ContextualController.php @@ -32,12 +32,12 @@ public function render(Request $request) { throw new BadRequestHttpException(t('No contextual ids specified.')); } - $rendered = array(); + $rendered = []; foreach ($ids as $id) { - $element = array( + $element = [ '#type' => 'contextual_links', '#contextual_links' => _contextual_id_to_links($id), - ); + ]; $rendered[$id] = $this->container->get('renderer')->renderRoot($element); } diff --git a/core/modules/contextual/src/Element/ContextualLinks.php b/core/modules/contextual/src/Element/ContextualLinks.php index 8f67023..62e8966 100644 --- a/core/modules/contextual/src/Element/ContextualLinks.php +++ b/core/modules/contextual/src/Element/ContextualLinks.php @@ -18,19 +18,19 @@ class ContextualLinks extends RenderElement { */ public function getInfo() { $class = get_class($this); - return array( - '#pre_render' => array( - array($class, 'preRenderLinks'), - ), + return [ + '#pre_render' => [ + [$class, 'preRenderLinks'], + ], '#theme' => 'links__contextual', - '#links' => array(), - '#attributes' => array('class' => array('contextual-links')), - '#attached' => array( - 'library' => array( + '#links' => [], + '#attributes' => ['class' => ['contextual-links']], + '#attached' => [ + 'library' => [ 'contextual/drupal.contextual-links', - ), - ), - ); + ], + ], + ]; } /** @@ -60,26 +60,26 @@ public function getInfo() { */ public static function preRenderLinks(array $element) { // Retrieve contextual menu links. - $items = array(); + $items = []; $contextual_links_manager = static::contextualLinkManager(); foreach ($element['#contextual_links'] as $group => $args) { - $args += array( - 'route_parameters' => array(), - 'metadata' => array(), - ); + $args += [ + 'route_parameters' => [], + 'metadata' => [], + ]; $items += $contextual_links_manager->getContextualLinksArrayByGroup($group, $args['route_parameters'], $args['metadata']); } // Transform contextual links into parameters suitable for links.html.twig. - $links = array(); + $links = []; foreach ($items as $class => $item) { $class = Html::getClass($class); - $links[$class] = array( + $links[$class] = [ 'title' => $item['title'], 'url' => Url::fromRoute(isset($item['route_name']) ? $item['route_name'] : '', isset($item['route_parameters']) ? $item['route_parameters'] : []), - ); + ]; } $element['#links'] = $links; diff --git a/core/modules/contextual/src/Element/ContextualLinksPlaceholder.php b/core/modules/contextual/src/Element/ContextualLinksPlaceholder.php index 92f4b2b..2fba8db 100644 --- a/core/modules/contextual/src/Element/ContextualLinksPlaceholder.php +++ b/core/modules/contextual/src/Element/ContextualLinksPlaceholder.php @@ -18,12 +18,12 @@ class ContextualLinksPlaceholder extends RenderElement { */ public function getInfo() { $class = get_class($this); - return array( - '#pre_render' => array( - array($class, 'preRenderPlaceholder'), - ), + return [ + '#pre_render' => [ + [$class, 'preRenderPlaceholder'], + ], '#id' => NULL, - ); + ]; } /** diff --git a/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php b/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php index 585b7f6..6bd5c01 100644 --- a/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php +++ b/core/modules/contextual/src/Plugin/views/field/ContextualLinks.php @@ -35,8 +35,8 @@ public function usesGroupBy() { protected function defineOptions() { $options = parent::defineOptions(); - $options['fields'] = array('default' => array()); - $options['destination'] = array('default' => 1); + $options['fields'] = ['default' => []]; + $options['destination'] = ['default' => 1]; return $options; } @@ -48,23 +48,23 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { $all_fields = $this->view->display_handler->getFieldLabels(); // Offer to include only those fields that follow this one. $field_options = array_slice($all_fields, 0, array_search($this->options['id'], array_keys($all_fields))); - $form['fields'] = array( + $form['fields'] = [ '#type' => 'checkboxes', '#title' => $this->t('Fields'), '#description' => $this->t('Fields to be included as contextual links.'), '#options' => $field_options, '#default_value' => $this->options['fields'], - ); - $form['destination'] = array( + ]; + $form['destination'] = [ '#type' => 'select', '#title' => $this->t('Include destination'), '#description' => $this->t('Include a "destination" parameter in the link to return the user to the original view upon completing the contextual action.'), - '#options' => array( + '#options' => [ '0' => $this->t('No'), '1' => $this->t('Yes'), - ), + ], '#default_value' => $this->options['destination'], - ); + ]; } /** @@ -93,7 +93,7 @@ public function preRender(&$values) { * @see contextual_contextual_links_view_alter() */ public function render(ResultRow $values) { - $links = array(); + $links = []; foreach ($this->options['fields'] as $field) { $rendered_field = $this->view->style_plugin->getField($values->index, $field); if (empty($rendered_field)) { @@ -109,13 +109,13 @@ public function render(ResultRow $values) { } if (!empty($title) && !empty($path)) { // Make sure that tokens are replaced for this paths as well. - $tokens = $this->getRenderTokens(array()); + $tokens = $this->getRenderTokens([]); $path = strip_tags(Html::decodeEntities(strtr($path, $tokens))); - $links[$field] = array( + $links[$field] = [ 'href' => $path, 'title' => $title, - ); + ]; if (!empty($this->options['destination'])) { $links[$field]['query'] = $this->getDestinationArray(); } @@ -124,20 +124,20 @@ public function render(ResultRow $values) { // Renders a contextual links placeholder. if (!empty($links)) { - $contextual_links = array( - 'contextual' => array( + $contextual_links = [ + 'contextual' => [ '', - array(), - array( + [], + [ 'contextual-views-field-links' => UrlHelper::encodePath(Json::encode($links)), - ) - ) - ); + ] + ] + ]; - $element = array( + $element = [ '#type' => 'contextual_links_placeholder', '#id' => _contextual_links_to_id($contextual_links), - ); + ]; return drupal_render($element); } else { diff --git a/core/modules/contextual/src/Tests/ContextualDynamicContextTest.php b/core/modules/contextual/src/Tests/ContextualDynamicContextTest.php index e5d2c85..e2c57fc 100644 --- a/core/modules/contextual/src/Tests/ContextualDynamicContextTest.php +++ b/core/modules/contextual/src/Tests/ContextualDynamicContextTest.php @@ -42,20 +42,20 @@ class ContextualDynamicContextTest extends WebTestBase { * * @var array */ - public static $modules = array('contextual', 'node', 'views', 'views_ui', 'language', 'menu_test'); + public static $modules = ['contextual', 'node', 'views', 'views_ui', 'language', 'menu_test']; protected function setUp() { parent::setUp(); - $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); - $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); + $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); + $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']); ConfigurableLanguage::createFromLangcode('it')->save(); $this->rebuildContainer(); - $this->editorUser = $this->drupalCreateUser(array('access content', 'access contextual links', 'edit any article content')); - $this->authenticatedUser = $this->drupalCreateUser(array('access content', 'access contextual links')); - $this->anonymousUser = $this->drupalCreateUser(array('access content')); + $this->editorUser = $this->drupalCreateUser(['access content', 'access contextual links', 'edit any article content']); + $this->authenticatedUser = $this->drupalCreateUser(['access content', 'access contextual links']); + $this->anonymousUser = $this->drupalCreateUser(['access content']); } /** @@ -71,9 +71,9 @@ function testDifferentPermissions() { // - An article, which should be user-editable. // - A page, which should not be user-editable. // - A second article, which should also be user-editable. - $node1 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1)); - $node2 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1)); - $node3 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1)); + $node1 = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]); + $node2 = $this->drupalCreateNode(['type' => 'page', 'promote' => 1]); + $node3 = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]); // Now, on the front page, all article nodes should have contextual links // placeholders, as should the view that contains them. @@ -89,7 +89,7 @@ function testDifferentPermissions() { for ($i = 0; $i < count($ids); $i++) { $this->assertContextualLinkPlaceHolder($ids[$i]); } - $this->renderContextualLinks(array(), 'node'); + $this->renderContextualLinks([], 'node'); $this->assertResponse(400); $this->assertRaw('No contextual ids specified.'); $response = $this->renderContextualLinks($ids, 'node'); @@ -112,7 +112,7 @@ function testDifferentPermissions() { for ($i = 0; $i < count($ids); $i++) { $this->assertContextualLinkPlaceHolder($ids[$i]); } - $this->renderContextualLinks(array(), 'node'); + $this->renderContextualLinks([], 'node'); $this->assertResponse(400); $this->assertRaw('No contextual ids specified.'); $response = $this->renderContextualLinks($ids, 'node'); @@ -129,7 +129,7 @@ function testDifferentPermissions() { for ($i = 0; $i < count($ids); $i++) { $this->assertNoContextualLinkPlaceHolder($ids[$i]); } - $this->renderContextualLinks(array(), 'node'); + $this->renderContextualLinks([], 'node'); $this->assertResponse(403); $this->renderContextualLinks($ids, 'node'); $this->assertResponse(403); @@ -150,7 +150,7 @@ function testDifferentPermissions() { * The result of the assertion. */ protected function assertContextualLinkPlaceHolder($id) { - return $this->assertRaw(' $id)) . '>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id))); + return $this->assertRaw(' $id]) . '>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id])); } /** @@ -163,7 +163,7 @@ protected function assertContextualLinkPlaceHolder($id) { * The result of the assertion. */ protected function assertNoContextualLinkPlaceHolder($id) { - return $this->assertNoRaw(' $id)) . '>', format_string('Contextual link placeholder with id @id does not exist.', array('@id' => $id))); + return $this->assertNoRaw(' $id]) . '>', format_string('Contextual link placeholder with id @id does not exist.', ['@id' => $id])); } /** @@ -178,11 +178,11 @@ protected function assertNoContextualLinkPlaceHolder($id) { * The response body. */ protected function renderContextualLinks($ids, $current_path) { - $post = array(); + $post = []; for ($i = 0; $i < count($ids); $i++) { $post['ids[' . $i . ']'] = $ids[$i]; } - return $this->drupalPostWithFormat('contextual/render', 'json', $post, array('query' => array('destination' => $current_path))); + return $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => $current_path]]); } } diff --git a/core/modules/contextual/tests/src/Kernel/ContextualUnitTest.php b/core/modules/contextual/tests/src/Kernel/ContextualUnitTest.php index 680303d..1d86da0 100644 --- a/core/modules/contextual/tests/src/Kernel/ContextualUnitTest.php +++ b/core/modules/contextual/tests/src/Kernel/ContextualUnitTest.php @@ -17,7 +17,7 @@ class ContextualUnitTest extends KernelTestBase { * * @var array */ - public static $modules = array('contextual'); + public static $modules = ['contextual']; /** * Provides testcases for testContextualLinksToId() and @@ -27,82 +27,82 @@ function _contextual_links_id_testcases() { // - one group. // - one dynamic path argument. // - no metadata. - $tests[] = array( - 'links' => array( - 'node' => array( - 'route_parameters' => array( + $tests[] = [ + 'links' => [ + 'node' => [ + 'route_parameters' => [ 'node' => '14031991', - ), - 'metadata' => array('langcode' => 'en'), - ), - ), + ], + 'metadata' => ['langcode' => 'en'], + ], + ], 'id' => 'node:node=14031991:langcode=en', - ); + ]; // Test branch conditions: // - one group. // - multiple dynamic path arguments. // - no metadata. - $tests[] = array( - 'links' => array( - 'foo' => array( - 'route_parameters' => array( + $tests[] = [ + 'links' => [ + 'foo' => [ + 'route_parameters' => [ 'bar', 'key' => 'baz', 'qux', - ), - 'metadata' => array('langcode' => 'en'), - ), - ), + ], + 'metadata' => ['langcode' => 'en'], + ], + ], 'id' => 'foo:0=bar&key=baz&1=qux:langcode=en', - ); + ]; // Test branch conditions: // - one group. // - one dynamic path argument. // - metadata. - $tests[] = array( - 'links' => array( - 'views_ui_edit' => array( - 'route_parameters' => array( + $tests[] = [ + 'links' => [ + 'views_ui_edit' => [ + 'route_parameters' => [ 'view' => 'frontpage' - ), - 'metadata' => array( + ], + 'metadata' => [ 'location' => 'page', 'display' => 'page_1', 'langcode' => 'en', - ), - ), - ), + ], + ], + ], 'id' => 'views_ui_edit:view=frontpage:location=page&display=page_1&langcode=en', - ); + ]; // Test branch conditions: // - multiple groups. // - multiple dynamic path arguments. - $tests[] = array( - 'links' => array( - 'node' => array( - 'route_parameters' => array( + $tests[] = [ + 'links' => [ + 'node' => [ + 'route_parameters' => [ 'node' => '14031991', - ), - 'metadata' => array('langcode' => 'en'), - ), - 'foo' => array( - 'route_parameters' => array( + ], + 'metadata' => ['langcode' => 'en'], + ], + 'foo' => [ + 'route_parameters' => [ 'bar', 'key' => 'baz', 'qux', - ), - 'metadata' => array('langcode' => 'en'), - ), - 'edge' => array( - 'route_parameters' => array('20011988'), - 'metadata' => array('langcode' => 'en'), - ), - ), + ], + 'metadata' => ['langcode' => 'en'], + ], + 'edge' => [ + 'route_parameters' => ['20011988'], + 'metadata' => ['langcode' => 'en'], + ], + ], 'id' => 'node:node=14031991:langcode=en|foo:0=bar&key=baz&1=qux:langcode=en|edge:0=20011988:langcode=en', - ); + ]; return $tests; } diff --git a/core/modules/datetime/datetime.module b/core/modules/datetime/datetime.module index f25140f..53fa108 100644 --- a/core/modules/datetime/datetime.module +++ b/core/modules/datetime/datetime.module @@ -30,13 +30,13 @@ function datetime_help($route_name, RouteMatchInterface $route_match) { case 'help.page.datetime': $output = ''; $output .= '

    ' . t('About') . '

    '; - $output .= '

    ' . t('The Datetime module provides a Date field that stores dates and times. It also provides the Form API elements datetime and datelist for use in programming modules. See the Field module help and the Field UI module help pages for general information on fields and how to create and manage them. For more information, see the online documentation for the Datetime module.', array(':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#', ':datetime_do' => 'https://www.drupal.org/documentation/modules/datetime')) . '

    '; + $output .= '

    ' . t('The Datetime module provides a Date field that stores dates and times. It also provides the Form API elements datetime and datelist for use in programming modules. See the Field module help and the Field UI module help pages for general information on fields and how to create and manage them. For more information, see the online documentation for the Datetime module.', [':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#', ':datetime_do' => 'https://www.drupal.org/documentation/modules/datetime']) . '

    '; $output .= '

    ' . t('Uses') . '

    '; $output .= '
    '; $output .= '
    ' . t('Managing and displaying date fields') . '
    '; - $output .= '
    ' . t('The settings and the display of the Date field can be configured separately. See the Field UI help for more information on how to manage fields and their display.', array(':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '
    '; + $output .= '
    ' . t('The settings and the display of the Date field can be configured separately. See the Field UI help for more information on how to manage fields and their display.', [':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#']) . '
    '; $output .= '
    ' . t('Displaying dates') . '
    '; - $output .= '
    ' . t('Dates can be displayed using the Plain or the Default formatter. The Plain formatter displays the date in the ISO 8601 format. If you choose the Default formatter, you can choose a format from a predefined list that can be managed on the Date and time formats page.', array(':date_format_list' => \Drupal::url('entity.date_format.collection'))) . '
    '; + $output .= '
    ' . t('Dates can be displayed using the Plain or the Default formatter. The Plain formatter displays the date in the ISO 8601 format. If you choose the Default formatter, you can choose a format from a predefined list that can be managed on the Date and time formats page.', [':date_format_list' => \Drupal::url('entity.date_format.collection')]) . '
    '; $output .= '
    '; return $output; } diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php index 678ddc8..445b7ee 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeCustomFormatter.php @@ -23,16 +23,16 @@ class DateTimeCustomFormatter extends DateTimeFormatterBase { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'date_format' => DATETIME_DATETIME_STORAGE_FORMAT, - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; foreach ($items as $delta => $item) { $output = ''; @@ -76,12 +76,12 @@ protected function formatDate($date) { public function settingsForm(array $form, FormStateInterface $form_state) { $form = parent::settingsForm($form, $form_state); - $form['date_format'] = array( + $form['date_format'] = [ '#type' => 'textfield', '#title' => $this->t('Date/time format'), '#description' => $this->t('See the documentation for PHP date formats.'), '#default_value' => $this->getSetting('date_format'), - ); + ]; return $form; } diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php index 03c92ae..360d255 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php @@ -23,16 +23,16 @@ class DateTimeDefaultFormatter extends DateTimeFormatterBase { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'format_type' => 'medium', - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; foreach ($items as $delta => $item) { $output = ''; @@ -56,7 +56,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { } // Display the date using theme datetime. - $elements[$delta] = array( + $elements[$delta] = [ '#cache' => [ 'contexts' => [ 'timezone', @@ -65,10 +65,10 @@ public function viewElements(FieldItemListInterface $items, $langcode) { '#theme' => 'time', '#text' => $output, '#html' => FALSE, - '#attributes' => array( + '#attributes' => [ 'datetime' => $iso_date, - ), - ); + ], + ]; if (!empty($item->_attributes)) { $elements[$delta]['#attributes'] += $item->_attributes; // Unset field item attributes since they have been included in the @@ -104,13 +104,13 @@ public function settingsForm(array $form, FormStateInterface $form_state) { $options[$type] = $type_info->label() . ' (' . $format . ')'; } - $form['format_type'] = array( + $form['format_type'] = [ '#type' => 'select', '#title' => t('Date format'), '#description' => t("Choose a format for displaying the date. Be sure to set a format appropriate for the field, i.e. omitting time for a field that only has a date."), '#options' => $options, '#default_value' => $this->getSetting('format_type'), - ); + ]; return $form; } @@ -122,7 +122,7 @@ public function settingsSummary() { $summary = parent::settingsSummary(); $date = new DrupalDateTime(); - $summary[] = t('Format: @display', array('@display' => $this->formatDate($date, $this->getFormatSettings()))); + $summary[] = t('Format: @display', ['@display' => $this->formatDate($date, $this->getFormatSettings())]); return $summary; } diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php index be9df38..f4e5ff5 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php @@ -82,9 +82,9 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'timezone_override' => '', - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** @@ -93,13 +93,13 @@ public static function defaultSettings() { public function settingsForm(array $form, FormStateInterface $form_state) { $form = parent::settingsForm($form, $form_state); - $form['timezone_override'] = array( + $form['timezone_override'] = [ '#type' => 'select', '#title' => $this->t('Time zone override'), '#description' => $this->t('The time zone selected here will always be used'), '#options' => system_time_zones(TRUE), '#default_value' => $this->getSetting('timezone_override'), - ); + ]; return $form; } @@ -111,7 +111,7 @@ public function settingsSummary() { $summary = parent::settingsSummary(); if ($override = $this->getSetting('timezone_override')) { - $summary[] = $this->t('Time zone: @timezone', array('@timezone' => $override)); + $summary[] = $this->t('Time zone: @timezone', ['@timezone' => $override]); } return $summary; diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php index 683d75c..d35d380 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimePlainFormatter.php @@ -22,7 +22,7 @@ class DateTimePlainFormatter extends DateTimeFormatterBase { * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; foreach ($items as $delta => $item) { $output = ''; diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php index 859ea5d..3fc3157 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php @@ -74,11 +74,11 @@ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInter * {@inheritdoc} */ public static function defaultSettings() { - $settings = array( + $settings = [ 'future_format' => '@interval hence', 'past_format' => '@interval ago', 'granularity' => 2, - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); return $settings; } @@ -104,7 +104,7 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = array(); + $elements = []; foreach ($items as $delta => $item) { $date = $item->date; @@ -128,26 +128,26 @@ public function viewElements(FieldItemListInterface $items, $langcode) { public function settingsForm(array $form, FormStateInterface $form_state) { $form = parent::settingsForm($form, $form_state); - $form['future_format'] = array( + $form['future_format'] = [ '#type' => 'textfield', '#title' => $this->t('Future format'), '#default_value' => $this->getSetting('future_format'), '#description' => $this->t('Use @interval where you want the formatted interval text to appear.'), - ); + ]; - $form['past_format'] = array( + $form['past_format'] = [ '#type' => 'textfield', '#title' => $this->t('Past format'), '#default_value' => $this->getSetting('past_format'), '#description' => $this->t('Use @interval where you want the formatted interval text to appear.'), - ); + ]; - $form['granularity'] = array( + $form['granularity'] = [ '#type' => 'number', '#title' => $this->t('Granularity'), '#default_value' => $this->getSetting('granularity'), '#description' => $this->t('How many time units should be shown in the formatted output.'), - ); + ]; return $form; } @@ -160,8 +160,8 @@ public function settingsSummary() { $future_date = new DrupalDateTime('1 year 1 month 1 week 1 day 1 hour 1 minute'); $past_date = new DrupalDateTime('-1 year -1 month -1 week -1 day -1 hour -1 minute'); - $summary[] = t('Future date: %display', array('%display' => $this->formatDate($future_date))); - $summary[] = t('Past date: %display', array('%display' => $this->formatDate($past_date))); + $summary[] = t('Future date: %display', ['%display' => $this->formatDate($future_date)]); + $summary[] = t('Past date: %display', ['%display' => $this->formatDate($past_date)]); return $summary; } diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php index 0a171de..c716d15 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php @@ -30,31 +30,31 @@ public function defaultValuesForm(array &$form, FormStateInterface $form_state) if (empty($this->getFieldDefinition()->getDefaultValueCallback())) { $default_value = $this->getFieldDefinition()->getDefaultValueLiteral(); - $element = array( - '#parents' => array('default_value_input'), - 'default_date_type' => array( + $element = [ + '#parents' => ['default_value_input'], + 'default_date_type' => [ '#type' => 'select', '#title' => t('Default date'), '#description' => t('Set a default value for this date.'), '#default_value' => isset($default_value[0]['default_date_type']) ? $default_value[0]['default_date_type'] : '', - '#options' => array( + '#options' => [ static::DEFAULT_VALUE_NOW => t('Current date'), static::DEFAULT_VALUE_CUSTOM => t('Relative date'), - ), + ], '#empty_value' => '', - ), - 'default_date' => array( + ], + 'default_date' => [ '#type' => 'textfield', '#title' => t('Relative default value'), '#description' => t("Describe a time by reference to the current day, like '+90 days' (90 days from the day the field is created) or '+1 Saturday' (the next Saturday). See strtotime for more details."), '#default_value' => (isset($default_value[0]['default_date_type']) && $default_value[0]['default_date_type'] == static::DEFAULT_VALUE_CUSTOM) ? $default_value[0]['default_date'] : '', - '#states' => array( - 'visible' => array( - ':input[id="edit-default-value-input-default-date-type"]' => array('value' => static::DEFAULT_VALUE_CUSTOM), - ) - ) - ) - ); + '#states' => [ + 'visible' => [ + ':input[id="edit-default-value-input-default-date-type"]' => ['value' => static::DEFAULT_VALUE_CUSTOM], + ] + ] + ] + ]; return $element; } @@ -65,7 +65,7 @@ public function defaultValuesForm(array &$form, FormStateInterface $form_state) */ public function defaultValuesFormValidate(array $element, array &$form, FormStateInterface $form_state) { if ($form_state->getValue(['default_value_input', 'default_date_type']) == static::DEFAULT_VALUE_CUSTOM) { - $is_strtotime = @strtotime($form_state->getValue(array('default_value_input', 'default_date'))); + $is_strtotime = @strtotime($form_state->getValue(['default_value_input', 'default_date'])); if (!$is_strtotime) { $form_state->setErrorByName('default_value_input][default_date', t('The relative date value entered is invalid.')); } @@ -76,13 +76,13 @@ public function defaultValuesFormValidate(array $element, array &$form, FormStat * {@inheritdoc} */ public function defaultValuesFormSubmit(array $element, array &$form, FormStateInterface $form_state) { - if ($form_state->getValue(array('default_value_input', 'default_date_type'))) { - if ($form_state->getValue(array('default_value_input', 'default_date_type')) == static::DEFAULT_VALUE_NOW) { + if ($form_state->getValue(['default_value_input', 'default_date_type'])) { + if ($form_state->getValue(['default_value_input', 'default_date_type']) == static::DEFAULT_VALUE_NOW) { $form_state->setValueForElement($element['default_date'], static::DEFAULT_VALUE_NOW); } - return array($form_state->getValue('default_value_input')); + return [$form_state->getValue('default_value_input')]; } - return array(); + return []; } /** @@ -100,12 +100,12 @@ public static function processDefaultValue($default_value, FieldableEntityInterf // We only provide a default value for the first item, as do all fields. // Otherwise, there is no way to clear out unwanted values on multiple value // fields. - $default_value = array( - array( + $default_value = [ + [ 'value' => $value, 'date' => $date, - ) - ); + ] + ]; } return $default_value; } diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php index f07d564..f5c06e6 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php @@ -26,9 +26,9 @@ class DateTimeItem extends FieldItemBase { * {@inheritdoc} */ public static function defaultStorageSettings() { - return array( + return [ 'datetime_type' => 'datetime', - ) + parent::defaultStorageSettings(); + ] + parent::defaultStorageSettings(); } /** @@ -63,37 +63,37 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel * {@inheritdoc} */ public static function schema(FieldStorageDefinitionInterface $field_definition) { - return array( - 'columns' => array( - 'value' => array( + return [ + 'columns' => [ + 'value' => [ 'description' => 'The date value.', 'type' => 'varchar', 'length' => 20, - ), - ), - 'indexes' => array( - 'value' => array('value'), - ), - ); + ], + ], + 'indexes' => [ + 'value' => ['value'], + ], + ]; } /** * {@inheritdoc} */ public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) { - $element = array(); + $element = []; - $element['datetime_type'] = array( + $element['datetime_type'] = [ '#type' => 'select', '#title' => t('Date type'), '#description' => t('Choose the type of date to create.'), '#default_value' => $this->getSetting('datetime_type'), - '#options' => array( + '#options' => [ static::DATETIME_TYPE_DATETIME => t('Date and time'), static::DATETIME_TYPE_DATE => t('Date only'), - ), + ], '#disabled' => $has_data, - ); + ]; return $element; } diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php index c88c5c8..b3d0acb 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php +++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDatelistWidget.php @@ -22,11 +22,11 @@ class DateTimeDatelistWidget extends DateTimeWidgetBase { * {@inheritdoc} */ public static function defaultSettings() { - return array( + return [ 'increment' => '15', 'date_order' => 'YMD', 'time_type' => '24', - ) + parent::defaultSettings(); + ] + parent::defaultSettings(); } /** @@ -49,35 +49,35 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // Set up the date part order array. switch ($date_order) { case 'YMD': - $date_part_order = array('year', 'month', 'day'); + $date_part_order = ['year', 'month', 'day']; break; case 'MDY': - $date_part_order = array('month', 'day', 'year'); + $date_part_order = ['month', 'day', 'year']; break; case 'DMY': - $date_part_order = array('day', 'month', 'year'); + $date_part_order = ['day', 'month', 'year']; break; } switch ($time_type) { case '24': - $date_part_order = array_merge($date_part_order, array('hour', 'minute')); + $date_part_order = array_merge($date_part_order, ['hour', 'minute']); break; case '12': - $date_part_order = array_merge($date_part_order, array('hour', 'minute', 'ampm')); + $date_part_order = array_merge($date_part_order, ['hour', 'minute', 'ampm']); break; case 'none': break; } - $element['value'] = array( + $element['value'] = [ '#type' => 'datelist', '#date_increment' => $increment, '#date_part_order' => $date_part_order, - ) + $element['value']; + ] + $element['value']; return $element; } @@ -88,20 +88,20 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen function settingsForm(array $form, FormStateInterface $form_state) { $element = parent::settingsForm($form, $form_state); - $element['date_order'] = array( + $element['date_order'] = [ '#type' => 'select', '#title' => t('Date part order'), '#default_value' => $this->getSetting('date_order'), - '#options' => array('MDY' => t('Month/Day/Year'), 'DMY' => t('Day/Month/Year'), 'YMD' => t('Year/Month/Day')), - ); + '#options' => ['MDY' => t('Month/Day/Year'), 'DMY' => t('Day/Month/Year'), 'YMD' => t('Year/Month/Day')], + ]; if ($this->getFieldSetting('datetime_type') == 'datetime') { - $element['time_type'] = array( + $element['time_type'] = [ '#type' => 'select', '#title' => t('Time type'), '#default_value' => $this->getSetting('time_type'), - '#options' => array('24' => t('24 hour time'), '12' => t('12 hour time')), - ); + '#options' => ['24' => t('24 hour time'), '12' => t('12 hour time')], + ]; $element['increment'] = [ '#type' => 'select', @@ -117,10 +117,10 @@ function settingsForm(array $form, FormStateInterface $form_state) { ]; } else { - $element['time_type'] = array( + $element['time_type'] = [ '#type' => 'hidden', '#value' => 'none', - ); + ]; $element['increment'] = [ '#type' => 'hidden', @@ -135,12 +135,12 @@ function settingsForm(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function settingsSummary() { - $summary = array(); + $summary = []; - $summary[] = t('Date part order: @order', array('@order' => $this->getSetting('date_order'))); + $summary[] = t('Date part order: @order', ['@order' => $this->getSetting('date_order')]); if ($this->getFieldSetting('datetime_type') == 'datetime') { - $summary[] = t('Time type: @time_type', array('@time_type' => $this->getSetting('time_type'))); - $summary[] = t('Time increments: @increment', array('@increment' => $this->getSetting('increment'))); + $summary[] = t('Time type: @time_type', ['@time_type' => $this->getSetting('time_type')]); + $summary[] = t('Time increments: @increment', ['@increment' => $this->getSetting('increment')]); } return $summary; diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php index 89381ab..09342ad 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php +++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeDefaultWidget.php @@ -76,14 +76,14 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen break; } - $element['value'] += array( + $element['value'] += [ '#date_date_format' => $date_format, '#date_date_element' => $date_type, - '#date_date_callbacks' => array(), + '#date_date_callbacks' => [], '#date_time_format' => $time_format, '#date_time_element' => $time_type, - '#date_time_callbacks' => array(), - ); + '#date_time_callbacks' => [], + ]; return $element; } diff --git a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php index aa6175a..5add274 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php +++ b/core/modules/datetime/src/Plugin/Field/FieldWidget/DateTimeWidgetBase.php @@ -26,13 +26,13 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $element['#theme_wrappers'][] = 'datetime_wrapper'; $element['#attributes']['class'][] = 'container-inline'; - $element['value'] = array( + $element['value'] = [ '#type' => 'datetime', '#default_value' => NULL, '#date_increment' => 1, '#date_timezone' => drupal_get_user_timezone(), '#required' => $element['#required'], - ); + ]; if ($this->getFieldSetting('datetime_type') == DateTimeItem::DATETIME_TYPE_DATE) { // A date-only field should have no timezone conversion performed, so diff --git a/core/modules/datetime/src/Tests/DateTimeFieldTest.php b/core/modules/datetime/src/Tests/DateTimeFieldTest.php index ce598bf..1322da7 100644 --- a/core/modules/datetime/src/Tests/DateTimeFieldTest.php +++ b/core/modules/datetime/src/Tests/DateTimeFieldTest.php @@ -25,7 +25,7 @@ class DateTimeFieldTest extends WebTestBase { * * @var array */ - public static $modules = array('node', 'entity_test', 'datetime', 'field_ui'); + public static $modules = ['node', 'entity_test', 'datetime', 'field_ui']; /** * The default display settings to use for the formatters. @@ -81,24 +81,24 @@ class DateTimeFieldTest extends WebTestBase { protected function setUp() { parent::setUp(); - $web_user = $this->drupalCreateUser(array( + $web_user = $this->drupalCreateUser([ 'access content', 'view test entity', 'administer entity_test content', 'administer entity_test form display', 'administer content types', 'administer node fields', - )); + ]); $this->drupalLogin($web_user); // Create a field with settings to validate. $field_name = Unicode::strtolower($this->randomMachineName()); - $this->fieldStorage = FieldStorageConfig::create(array( + $this->fieldStorage = FieldStorageConfig::create([ 'field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'datetime', - 'settings' => array('datetime_type' => 'date'), - )); + 'settings' => ['datetime_type' => 'date'], + ]); $this->fieldStorage->save(); $this->field = FieldConfig::create([ 'field_storage' => $this->fieldStorage, @@ -108,20 +108,20 @@ protected function setUp() { $this->field->save(); entity_get_form_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'default') - ->setComponent($field_name, array( + ->setComponent($field_name, [ 'type' => 'datetime_default', - )) + ]) ->save(); - $this->defaultSettings = array( + $this->defaultSettings = [ 'timezone_override' => '', - ); + ]; - $this->displayOptions = array( + $this->displayOptions = [ 'type' => 'datetime_default', 'label' => 'hidden', - 'settings' => array('format_type' => 'medium') + $this->defaultSettings, - ); + 'settings' => ['format_type' => 'medium'] + $this->defaultSettings, + ]; entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); @@ -155,13 +155,13 @@ function testDateField() { $date_format = DateFormat::load('html_date')->getPattern(); $time_format = DateFormat::load('html_time')->getPattern(); - $edit = array( + $edit = [ "{$field_name}[0][value][date]" => $date->format($date_format), - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); preg_match('|entity_test/manage/(\d+)|', $this->url, $match); $id = $match[1]; - $this->assertText(t('entity_test @id has been created.', array('@id' => $id))); + $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); $this->assertRaw($date->format($date_format)); $this->assertNoRaw($date->format($time_format)); @@ -179,15 +179,15 @@ function testDateField() { $this->assertEqual('2012-12-31', $entity->{$field_name}->value); // Reset display options since these get changed below. - $this->displayOptions = array( + $this->displayOptions = [ 'type' => 'datetime_default', 'label' => 'hidden', - 'settings' => array('format_type' => 'medium') + $this->defaultSettings, - ); + 'settings' => ['format_type' => 'medium'] + $this->defaultSettings, + ]; // Verify that the date is output according to the formatter settings. - $options = array( - 'format_type' => array('short', 'medium', 'long'), - ); + $options = [ + 'format_type' => ['short', 'medium', 'long'], + ]; // Formats that display a time component for date-only fields will display // the default time, so that is applied before calculating the expected // value. @@ -195,7 +195,7 @@ function testDateField() { foreach ($options as $setting => $values) { foreach ($values as $new_value) { // Update the entity display settings. - $this->displayOptions['settings'] = array($setting => $new_value) + $this->defaultSettings; + $this->displayOptions['settings'] = [$setting => $new_value] + $this->defaultSettings; entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); @@ -208,7 +208,7 @@ function testDateField() { $expected = format_date($date->getTimestamp(), $new_value, '', DATETIME_STORAGE_TIMEZONE); $expected_iso = format_date($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', DATETIME_STORAGE_TIMEZONE); $this->renderTestEntity($id); - $this->assertFieldByXPath('//time[@datetime="' . $expected_iso . '"]', $expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', array('%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso))); + $this->assertFieldByXPath('//time[@datetime="' . $expected_iso . '"]', $expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso])); break; } } @@ -222,17 +222,17 @@ function testDateField() { ->save(); $expected = $date->format(DATETIME_DATE_STORAGE_FORMAT); $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected))); + $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'datetime_custom' formatter works. $this->displayOptions['type'] = 'datetime_custom'; - $this->displayOptions['settings'] = array('date_format' => 'm/d/Y') + $this->defaultSettings; + $this->displayOptions['settings'] = ['date_format' => 'm/d/Y'] + $this->defaultSettings; entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $date->format($this->displayOptions['settings']['date_format']); $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', array('%expected' => $expected))); + $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'datetime_time_ago' formatter works for intervals in the // past. First update the test entity so that the date difference always @@ -247,11 +247,11 @@ function testDateField() { $entity->save(); $this->displayOptions['type'] = 'datetime_time_ago'; - $this->displayOptions['settings'] = array( + $this->displayOptions['settings'] = [ 'future_format' => '@interval in the future', 'past_format' => '@interval in the past', 'granularity' => 3, - ); + ]; entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); @@ -259,7 +259,7 @@ function testDateField() { '@interval' => \Drupal::service('date.formatter')->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]) ]); $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', array('%expected' => $expected))); + $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'datetime_time_ago' formatter works for intervals in the // future. First update the test entity so that the date difference always @@ -280,7 +280,7 @@ function testDateField() { '@interval' => \Drupal::service('date.formatter')->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]) ]); $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', array('%expected' => $expected))); + $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected])); } } @@ -309,25 +309,25 @@ function testDatetimeField() { $date_format = DateFormat::load('html_date')->getPattern(); $time_format = DateFormat::load('html_time')->getPattern(); - $edit = array( + $edit = [ "{$field_name}[0][value][date]" => $date->format($date_format), "{$field_name}[0][value][time]" => $date->format($time_format), - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); preg_match('|entity_test/manage/(\d+)|', $this->url, $match); $id = $match[1]; - $this->assertText(t('entity_test @id has been created.', array('@id' => $id))); + $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); $this->assertRaw($date->format($date_format)); $this->assertRaw($date->format($time_format)); // Verify that the date is output according to the formatter settings. - $options = array( - 'format_type' => array('short', 'medium', 'long'), - ); + $options = [ + 'format_type' => ['short', 'medium', 'long'], + ]; foreach ($options as $setting => $values) { foreach ($values as $new_value) { // Update the entity display settings. - $this->displayOptions['settings'] = array($setting => $new_value) + $this->defaultSettings; + $this->displayOptions['settings'] = [$setting => $new_value] + $this->defaultSettings; entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); @@ -339,7 +339,7 @@ function testDatetimeField() { $expected = format_date($date->getTimestamp(), $new_value); $expected_iso = format_date($date->getTimestamp(), 'custom', 'Y-m-d\TH:i:s\Z', 'UTC'); $this->renderTestEntity($id); - $this->assertFieldByXPath('//time[@datetime="' . $expected_iso . '"]', $expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', array('%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso))); + $this->assertFieldByXPath('//time[@datetime="' . $expected_iso . '"]', $expected, SafeMarkup::format('Formatted date field using %value format displayed as %expected with %expected_iso attribute.', ['%value' => $new_value, '%expected' => $expected, '%expected_iso' => $expected_iso])); break; } } @@ -353,27 +353,27 @@ function testDatetimeField() { ->save(); $expected = $date->format(DATETIME_DATETIME_STORAGE_FORMAT); $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', array('%expected' => $expected))); + $this->assertText($expected, SafeMarkup::format('Formatted date field using plain format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'datetime_custom' formatter works. $this->displayOptions['type'] = 'datetime_custom'; - $this->displayOptions['settings'] = array('date_format' => 'm/d/Y g:i:s A') + $this->defaultSettings; + $this->displayOptions['settings'] = ['date_format' => 'm/d/Y g:i:s A'] + $this->defaultSettings; entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); $expected = $date->format($this->displayOptions['settings']['date_format']); $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', array('%expected' => $expected))); + $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'timezone_override' setting works. $this->displayOptions['type'] = 'datetime_custom'; - $this->displayOptions['settings'] = array('date_format' => 'm/d/Y g:i:s A', 'timezone_override' => 'America/New_York') + $this->defaultSettings; + $this->displayOptions['settings'] = ['date_format' => 'm/d/Y g:i:s A', 'timezone_override' => 'America/New_York'] + $this->defaultSettings; entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); - $expected = $date->format($this->displayOptions['settings']['date_format'], array('timezone' => 'America/New_York')); + $expected = $date->format($this->displayOptions['settings']['date_format'], ['timezone' => 'America/New_York']); $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', array('%expected' => $expected))); + $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_custom format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'datetime_time_ago' formatter works for intervals in the // past. First update the test entity so that the date difference always @@ -388,11 +388,11 @@ function testDatetimeField() { $entity->save(); $this->displayOptions['type'] = 'datetime_time_ago'; - $this->displayOptions['settings'] = array( + $this->displayOptions['settings'] = [ 'future_format' => '@interval from now', 'past_format' => '@interval earlier', 'granularity' => 3, - ); + ]; entity_get_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'full') ->setComponent($field_name, $this->displayOptions) ->save(); @@ -400,7 +400,7 @@ function testDatetimeField() { '@interval' => \Drupal::service('date.formatter')->formatTimeDiffSince($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]) ]); $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', array('%expected' => $expected))); + $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected])); // Verify that the 'datetime_time_ago' formatter works for intervals in the // future. First update the test entity so that the date difference always @@ -421,7 +421,7 @@ function testDatetimeField() { '@interval' => \Drupal::service('date.formatter')->formatTimeDiffUntil($timestamp, ['granularity' => $this->displayOptions['settings']['granularity']]) ]); $this->renderTestEntity($id); - $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', array('%expected' => $expected))); + $this->assertText($expected, SafeMarkup::format('Formatted date field using datetime_time_ago format displayed as %expected.', ['%expected' => $expected])); } /** @@ -436,12 +436,12 @@ function testDatelistWidget() { // Change the widget to a datelist widget. entity_get_form_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'default') - ->setComponent($field_name, array( + ->setComponent($field_name, [ 'type' => 'datetime_datelist', - 'settings' => array( + 'settings' => [ 'date_order' => 'YMD', - ), - )) + ], + ]) ->save(); \Drupal::entityManager()->clearCachedFieldDefinitions(); @@ -457,7 +457,7 @@ function testDatelistWidget() { $this->drupalGet($fieldEditUrl); // Click on the widget settings button to open the widget settings form. - $this->drupalPostAjaxForm(NULL, array(), $field_name . "_settings_edit"); + $this->drupalPostAjaxForm(NULL, [], $field_name . "_settings_edit"); $xpathIncr = "//select[starts-with(@id, \"edit-fields-$field_name-settings-edit-form-settings-increment\")]"; $this->assertNoFieldByXPath($xpathIncr, NULL, 'Increment element not found for Date Only.'); @@ -467,14 +467,14 @@ function testDatelistWidget() { // Change the widget to a datelist widget. entity_get_form_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'default') - ->setComponent($field_name, array( + ->setComponent($field_name, [ 'type' => 'datetime_datelist', - 'settings' => array( + 'settings' => [ 'increment' => 1, 'date_order' => 'YMD', 'time_type' => '12', - ), - )) + ], + ]) ->save(); \Drupal::entityManager()->clearCachedFieldDefinitions(); @@ -483,7 +483,7 @@ function testDatelistWidget() { $this->drupalGet($fieldEditUrl); // Click on the widget settings button to open the widget settings form. - $this->drupalPostAjaxForm(NULL, array(), $field_name . "_settings_edit"); + $this->drupalPostAjaxForm(NULL, [], $field_name . "_settings_edit"); $this->assertFieldByXPath($xpathIncr, NULL, 'Increment element found for Date and time.'); // Display creation form. @@ -510,9 +510,9 @@ function testDatelistWidget() { $this->assertOptionByText("edit-$field_name-0-value-ampm", t('AM/PM')); // Submit a valid date and ensure it is accepted. - $date_value = array('year' => 2012, 'month' => 12, 'day' => 31, 'hour' => 5, 'minute' => 15); + $date_value = ['year' => 2012, 'month' => 12, 'day' => 31, 'hour' => 5, 'minute' => 15]; - $edit = array(); + $edit = []; // Add the ampm indicator since we are testing 12 hour time. $date_value['ampm'] = 'am'; foreach ($date_value as $part => $value) { @@ -522,7 +522,7 @@ function testDatelistWidget() { $this->drupalPostForm(NULL, $edit, t('Save')); preg_match('|entity_test/manage/(\d+)|', $this->url, $match); $id = $match[1]; - $this->assertText(t('entity_test @id has been created.', array('@id' => $id))); + $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); $this->assertOptionSelected("edit-$field_name-0-value-year", '2012', 'Correct year selected.'); $this->assertOptionSelected("edit-$field_name-0-value-month", '12', 'Correct month selected.'); @@ -533,14 +533,14 @@ function testDatelistWidget() { // Test the widget using increment other than 1 and 24 hour mode. entity_get_form_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'default') - ->setComponent($field_name, array( + ->setComponent($field_name, [ 'type' => 'datetime_datelist', - 'settings' => array( + 'settings' => [ 'increment' => 15, 'date_order' => 'YMD', 'time_type' => '24', - ), - )) + ], + ]) ->save(); \Drupal::entityManager()->clearCachedFieldDefinitions(); @@ -553,9 +553,9 @@ function testDatelistWidget() { $this->assertNoFieldByXPath("//*[@id=\"edit-$field_name-0-value-ampm\"]", NULL, 'AMPM element not found.'); // Submit a valid date and ensure it is accepted. - $date_value = array('year' => 2012, 'month' => 12, 'day' => 31, 'hour' => 17, 'minute' => 15); + $date_value = ['year' => 2012, 'month' => 12, 'day' => 31, 'hour' => 17, 'minute' => 15]; - $edit = array(); + $edit = []; foreach ($date_value as $part => $value) { $edit["{$field_name}[0][value][$part]"] = $value; } @@ -563,7 +563,7 @@ function testDatelistWidget() { $this->drupalPostForm(NULL, $edit, t('Save')); preg_match('|entity_test/manage/(\d+)|', $this->url, $match); $id = $match[1]; - $this->assertText(t('entity_test @id has been created.', array('@id' => $id))); + $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); $this->assertOptionSelected("edit-$field_name-0-value-year", '2012', 'Correct year selected.'); $this->assertOptionSelected("edit-$field_name-0-value-month", '12', 'Correct month selected.'); @@ -573,14 +573,14 @@ function testDatelistWidget() { // Test the widget for partial completion of fields. entity_get_form_display($this->field->getTargetEntityTypeId(), $this->field->getTargetBundle(), 'default') - ->setComponent($field_name, array( + ->setComponent($field_name, [ 'type' => 'datetime_datelist', - 'settings' => array( + 'settings' => [ 'increment' => 1, 'date_order' => 'YMD', 'time_type' => '24', - ), - )) + ], + ]) ->save(); \Drupal::entityManager()->clearCachedFieldDefinitions(); @@ -592,7 +592,7 @@ function testDatelistWidget() { $this->drupalGet('entity_test/add'); // Submit a partial date and ensure and error message is provided. - $edit = array(); + $edit = []; foreach ($date_value as $part => $value) { $edit["{$field_name}[0][value][$part]"] = $value; } @@ -607,8 +607,8 @@ function testDatelistWidget() { // Test the widget for complete input with zeros as part of selections. $this->drupalGet('entity_test/add'); - $date_value = array('year' => 2012, 'month' => '12', 'day' => '31', 'hour' => '0', 'minute' => '0'); - $edit = array(); + $date_value = ['year' => 2012, 'month' => '12', 'day' => '31', 'hour' => '0', 'minute' => '0']; + $edit = []; foreach ($date_value as $part => $value) { $edit["{$field_name}[0][value][$part]"] = $value; } @@ -617,13 +617,13 @@ function testDatelistWidget() { $this->assertResponse(200); preg_match('|entity_test/manage/(\d+)|', $this->url, $match); $id = $match[1]; - $this->assertText(t('entity_test @id has been created.', array('@id' => $id))); + $this->assertText(t('entity_test @id has been created.', ['@id' => $id])); // Test the widget to ensure zeros are not deselected on validation. $this->drupalGet('entity_test/add'); - $date_value = array('year' => 2012, 'month' => '12', 'day' => '31', 'hour' => '', 'minute' => '0'); - $edit = array(); + $date_value = ['year' => 2012, 'month' => '12', 'day' => '31', 'hour' => '', 'minute' => '0']; + $edit = []; foreach ($date_value as $part => $value) { $edit["{$field_name}[0][value][$part]"] = $value; } @@ -671,16 +671,16 @@ protected function datelistDataProvider() { */ function testDefaultValue() { // Create a test content type. - $this->drupalCreateContentType(array('type' => 'date_content')); + $this->drupalCreateContentType(['type' => 'date_content']); // Create a field storage with settings to validate. $field_name = Unicode::strtolower($this->randomMachineName()); - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'field_name' => $field_name, 'entity_type' => 'node', 'type' => 'datetime', - 'settings' => array('datetime_type' => 'date'), - )); + 'settings' => ['datetime_type' => 'date'], + ]); $field_storage->save(); $field = FieldConfig::create([ @@ -690,9 +690,9 @@ function testDefaultValue() { $field->save(); // Set now as default_value. - $field_edit = array( + $field_edit = [ 'default_value_input[default_date_type]' => 'now', - ); + ]; $this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name, $field_edit, t('Save settings')); // Check that default value is selected in default value form. @@ -702,7 +702,7 @@ function testDefaultValue() { // Check if default_date has been stored successfully. $config_entity = $this->config('field.field.node.date_content.' . $field_name)->get(); - $this->assertEqual($config_entity['default_value'][0], array('default_date_type' => 'now', 'default_date' => 'now'), 'Default value has been stored successfully'); + $this->assertEqual($config_entity['default_value'][0], ['default_date_type' => 'now', 'default_date' => 'now'], 'Default value has been stored successfully'); // Clear field cache in order to avoid stale cache values. \Drupal::entityManager()->clearCachedFieldDefinitions(); @@ -713,19 +713,19 @@ function testDefaultValue() { $this->assertEqual($new_node->get($field_name)->offsetGet(0)->value, $expected_date->format(DATETIME_DATE_STORAGE_FORMAT)); // Set an invalid relative default_value to test validation. - $field_edit = array( + $field_edit = [ 'default_value_input[default_date_type]' => 'relative', 'default_value_input[default_date]' => 'invalid date', - ); + ]; $this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name, $field_edit, t('Save settings')); $this->assertText('The relative date value entered is invalid.'); // Set a relative default_value. - $field_edit = array( + $field_edit = [ 'default_value_input[default_date_type]' => 'relative', 'default_value_input[default_date]' => '+90 days', - ); + ]; $this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name, $field_edit, t('Save settings')); // Check that default value is selected in default value form. @@ -735,7 +735,7 @@ function testDefaultValue() { // Check if default_date has been stored successfully. $config_entity = $this->config('field.field.node.date_content.' . $field_name)->get(); - $this->assertEqual($config_entity['default_value'][0], array('default_date_type' => 'relative', 'default_date' => '+90 days'), 'Default value has been stored successfully'); + $this->assertEqual($config_entity['default_value'][0], ['default_date_type' => 'relative', 'default_date' => '+90 days'], 'Default value has been stored successfully'); // Clear field cache in order to avoid stale cache values. \Drupal::entityManager()->clearCachedFieldDefinitions(); @@ -746,9 +746,9 @@ function testDefaultValue() { $this->assertEqual($new_node->get($field_name)->offsetGet(0)->value, $expected_date->format(DATETIME_DATE_STORAGE_FORMAT)); // Remove default value. - $field_edit = array( + $field_edit = [ 'default_value_input[default_date_type]' => '', - ); + ]; $this->drupalPostForm('admin/structure/types/manage/date_content/fields/node.date_content.' . $field_name, $field_edit, t('Save settings')); // Check that default value is selected in default value form. @@ -784,72 +784,72 @@ function testInvalidField() { // Submit invalid dates and ensure they is not accepted. $date_value = ''; - $edit = array( + $edit = [ "{$field_name}[0][value][date]" => $date_value, "{$field_name}[0][value][time]" => '12:00:00', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertText('date is invalid', 'Empty date value has been caught.'); $date_value = 'aaaa-12-01'; - $edit = array( + $edit = [ "{$field_name}[0][value][date]" => $date_value, "{$field_name}[0][value][time]" => '00:00:00', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText('date is invalid', format_string('Invalid year value %date has been caught.', array('%date' => $date_value))); + $this->assertText('date is invalid', format_string('Invalid year value %date has been caught.', ['%date' => $date_value])); $date_value = '2012-75-01'; - $edit = array( + $edit = [ "{$field_name}[0][value][date]" => $date_value, "{$field_name}[0][value][time]" => '00:00:00', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText('date is invalid', format_string('Invalid month value %date has been caught.', array('%date' => $date_value))); + $this->assertText('date is invalid', format_string('Invalid month value %date has been caught.', ['%date' => $date_value])); $date_value = '2012-12-99'; - $edit = array( + $edit = [ "{$field_name}[0][value][date]" => $date_value, "{$field_name}[0][value][time]" => '00:00:00', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText('date is invalid', format_string('Invalid day value %date has been caught.', array('%date' => $date_value))); + $this->assertText('date is invalid', format_string('Invalid day value %date has been caught.', ['%date' => $date_value])); $date_value = '2012-12-01'; $time_value = ''; - $edit = array( + $edit = [ "{$field_name}[0][value][date]" => $date_value, "{$field_name}[0][value][time]" => $time_value, - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertText('date is invalid', 'Empty time value has been caught.'); $date_value = '2012-12-01'; $time_value = '49:00:00'; - $edit = array( + $edit = [ "{$field_name}[0][value][date]" => $date_value, "{$field_name}[0][value][time]" => $time_value, - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText('date is invalid', format_string('Invalid hour value %time has been caught.', array('%time' => $time_value))); + $this->assertText('date is invalid', format_string('Invalid hour value %time has been caught.', ['%time' => $time_value])); $date_value = '2012-12-01'; $time_value = '12:99:00'; - $edit = array( + $edit = [ "{$field_name}[0][value][date]" => $date_value, "{$field_name}[0][value][time]" => $time_value, - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText('date is invalid', format_string('Invalid minute value %time has been caught.', array('%time' => $time_value))); + $this->assertText('date is invalid', format_string('Invalid minute value %time has been caught.', ['%time' => $time_value])); $date_value = '2012-12-01'; $time_value = '12:15:99'; - $edit = array( + $edit = [ "{$field_name}[0][value][date]" => $date_value, "{$field_name}[0][value][time]" => $time_value, - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertText('date is invalid', format_string('Invalid second value %time has been caught.', array('%time' => $time_value))); + $this->assertText('date is invalid', format_string('Invalid second value %time has been caught.', ['%time' => $time_value])); } /** @@ -907,7 +907,7 @@ public function testDateStorageSettings() { */ protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) { if ($reset) { - \Drupal::entityManager()->getStorage('entity_test')->resetCache(array($id)); + \Drupal::entityManager()->getStorage('entity_test')->resetCache([$id]); } $entity = EntityTest::load($id); $display = EntityViewDisplay::collectRenderDisplay($entity, $view_mode); diff --git a/core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php b/core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php index d26434b..eecddac 100644 --- a/core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php +++ b/core/modules/datetime/tests/src/Kernel/DateTimeItemTest.php @@ -21,25 +21,25 @@ class DateTimeItemTest extends FieldKernelTestBase { * * @var array */ - public static $modules = array('datetime'); + public static $modules = ['datetime']; protected function setUp() { parent::setUp(); // Create a field with settings to validate. - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'field_name' => 'field_datetime', 'type' => 'datetime', 'entity_type' => 'entity_test', - 'settings' => array('datetime_type' => 'date'), - )); + 'settings' => ['datetime_type' => 'date'], + ]); $field_storage->save(); $field = FieldConfig::create([ 'field_storage' => $field_storage, 'bundle' => 'entity_test', - 'settings' => array( + 'settings' => [ 'default_value' => 'blank', - ), + ], ]); $field->save(); } diff --git a/core/modules/dblog/dblog.admin.inc b/core/modules/dblog/dblog.admin.inc index 2b08878..1af89a6 100644 --- a/core/modules/dblog/dblog.admin.inc +++ b/core/modules/dblog/dblog.admin.inc @@ -19,25 +19,25 @@ * - options: Array of options for the select list for the filter. */ function dblog_filters() { - $filters = array(); + $filters = []; foreach (_dblog_get_message_types() as $type) { $types[$type] = t($type); } if (!empty($types)) { - $filters['type'] = array( + $filters['type'] = [ 'title' => t('Type'), 'where' => "w.type = ?", 'options' => $types, - ); + ]; } - $filters['severity'] = array( + $filters['severity'] = [ 'title' => t('Severity'), 'where' => 'w.severity = ?', 'options' => RfcLogLevel::getLevels(), - ); + ]; return $filters; } diff --git a/core/modules/dblog/dblog.install b/core/modules/dblog/dblog.install index 08270d2..f226ed0 100644 --- a/core/modules/dblog/dblog.install +++ b/core/modules/dblog/dblog.install @@ -9,84 +9,84 @@ * Implements hook_schema(). */ function dblog_schema() { - $schema['watchdog'] = array( + $schema['watchdog'] = [ 'description' => 'Table that contains logs of all system events.', - 'fields' => array( - 'wid' => array( + 'fields' => [ + 'wid' => [ 'type' => 'serial', 'not null' => TRUE, 'description' => 'Primary Key: Unique watchdog event ID.', - ), - 'uid' => array( + ], + 'uid' => [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The {users}.uid of the user who triggered the event.', - ), - 'type' => array( + ], + 'type' => [ 'type' => 'varchar_ascii', 'length' => 64, 'not null' => TRUE, 'default' => '', 'description' => 'Type of log message, for example "user" or "page not found."', - ), - 'message' => array( + ], + 'message' => [ 'type' => 'text', 'not null' => TRUE, 'size' => 'big', 'description' => 'Text of log message to be passed into the t() function.', - ), - 'variables' => array( + ], + 'variables' => [ 'type' => 'blob', 'not null' => TRUE, 'size' => 'big', 'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.', - ), - 'severity' => array( + ], + 'severity' => [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'size' => 'tiny', 'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)', - ), - 'link' => array( + ], + 'link' => [ 'type' => 'text', 'not null' => FALSE, 'description' => 'Link to view the result of the event.', - ), - 'location' => array( + ], + 'location' => [ 'type' => 'text', 'not null' => TRUE, 'description' => 'URL of the origin of the event.', - ), - 'referer' => array( + ], + 'referer' => [ 'type' => 'text', 'not null' => FALSE, 'description' => 'URL of referring page.', - ), - 'hostname' => array( + ], + 'hostname' => [ 'type' => 'varchar_ascii', 'length' => 128, 'not null' => TRUE, 'default' => '', 'description' => 'Hostname of the user who triggered the event.', - ), - 'timestamp' => array( + ], + 'timestamp' => [ 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Unix timestamp of when event occurred.', - ), - ), - 'primary key' => array('wid'), - 'indexes' => array( - 'type' => array('type'), - 'uid' => array('uid'), - 'severity' => array('severity'), - ), - ); + ], + ], + 'primary key' => ['wid'], + 'indexes' => [ + 'type' => ['type'], + 'uid' => ['uid'], + 'severity' => ['severity'], + ], + ]; return $schema; } diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module index 06fef10..ed92d6c 100644 --- a/core/modules/dblog/dblog.module +++ b/core/modules/dblog/dblog.module @@ -21,13 +21,13 @@ function dblog_help($route_name, RouteMatchInterface $route_match) { case 'help.page.dblog': $output = ''; $output .= '

    ' . t('About') . '

    '; - $output .= '

    ' . t('The Database Logging module logs system events in the Drupal database. For more information, see the online documentation for the Database Logging module.', array(':dblog' => 'https://www.drupal.org/documentation/modules/dblog')) . '

    '; + $output .= '

    ' . t('The Database Logging module logs system events in the Drupal database. For more information, see the online documentation for the Database Logging module.', [':dblog' => 'https://www.drupal.org/documentation/modules/dblog']) . '

    '; $output .= '

    ' . t('Uses') . '

    '; $output .= '
    '; $output .= '
    ' . t('Monitoring your site') . '
    '; - $output .= '
    ' . t('The Database Logging module allows you to view an event log on the Recent log messages page. The log is a chronological list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the log on a regular basis to ensure their site is working properly.', array(':dblog' => \Drupal::url('dblog.overview'))) . '
    '; + $output .= '
    ' . t('The Database Logging module allows you to view an event log on the Recent log messages page. The log is a chronological list of recorded events containing usage data, performance data, errors, warnings and operational information. Administrators should check the log on a regular basis to ensure their site is working properly.', [':dblog' => \Drupal::url('dblog.overview')]) . '
    '; $output .= '
    ' . t('Debugging site problems') . '
    '; - $output .= '
    ' . t('In case of errors or problems with the site, the Recent log messages page can be useful for debugging, since it shows the sequence of events. The log messages include usage information, warnings, and errors.', array(':dblog' => \Drupal::url('dblog.overview'))) . '
    '; + $output .= '
    ' . t('In case of errors or problems with the site, the Recent log messages page can be useful for debugging, since it shows the sequence of events. The log messages include usage information, warnings, and errors.', [':dblog' => \Drupal::url('dblog.overview')]) . '
    '; $output .= '
    '; return $output; @@ -41,12 +41,12 @@ function dblog_help($route_name, RouteMatchInterface $route_match) { */ function dblog_menu_links_discovered_alter(&$links) { if (\Drupal::moduleHandler()->moduleExists('search')) { - $links['dblog.search'] = array( + $links['dblog.search'] = [ 'title' => new TranslatableMarkup('Top search phrases'), 'route_name' => 'dblog.search', 'description' => new TranslatableMarkup('View most popular search phrases.'), 'parent' => 'system.admin_reports', - ); + ]; } return $links; @@ -66,7 +66,7 @@ function dblog_cron() { // e.g. auto_increment value > 1 or rows deleted directly from the table. if ($row_limit > 0) { $min_row = db_select('watchdog', 'w') - ->fields('w', array('wid')) + ->fields('w', ['wid']) ->orderBy('wid', 'DESC') ->range($row_limit - 1, 1) ->execute()->fetchField(); @@ -95,14 +95,14 @@ function _dblog_get_message_types() { * Implements hook_form_FORM_ID_alter() for system_logging_settings(). */ function dblog_form_system_logging_settings_alter(&$form, FormStateInterface $form_state) { - $row_limits = array(100, 1000, 10000, 100000, 1000000); - $form['dblog_row_limit'] = array( + $row_limits = [100, 1000, 10000, 100000, 1000000]; + $form['dblog_row_limit'] = [ '#type' => 'select', '#title' => t('Database log messages to keep'), '#default_value' => \Drupal::configFactory()->getEditable('dblog.settings')->get('row_limit'), - '#options' => array(0 => t('All')) + array_combine($row_limits, $row_limits), - '#description' => t('The maximum number of messages to keep in the database log. Requires a cron maintenance task.', array(':cron' => \Drupal::url('system.status'))) - ); + '#options' => [0 => t('All')] + array_combine($row_limits, $row_limits), + '#description' => t('The maximum number of messages to keep in the database log. Requires a cron maintenance task.', [':cron' => \Drupal::url('system.status')]) + ]; $form['#submit'][] = 'dblog_logging_settings_submit'; } diff --git a/core/modules/dblog/dblog.views.inc b/core/modules/dblog/dblog.views.inc index dfc1fde..20ad9ce 100644 --- a/core/modules/dblog/dblog.views.inc +++ b/core/modules/dblog/dblog.views.inc @@ -9,208 +9,208 @@ * Implements hook_views_data(). */ function dblog_views_data() { - $data = array(); + $data = []; $data['watchdog']['table']['group'] = t('Watchdog'); $data['watchdog']['table']['wizard_id'] = 'watchdog'; - $data['watchdog']['table']['base'] = array( + $data['watchdog']['table']['base'] = [ 'field' => 'wid', 'title' => t('Log entries'), 'help' => t('Contains a list of log entries.'), - ); + ]; - $data['watchdog']['wid'] = array( + $data['watchdog']['wid'] = [ 'title' => t('WID'), 'help' => t('Unique watchdog event ID.'), - 'field' => array( + 'field' => [ 'id' => 'numeric', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'numeric', - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'numeric', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'standard', - ), - ); + ], + ]; - $data['watchdog']['uid'] = array( + $data['watchdog']['uid'] = [ 'title' => t('UID'), 'help' => t('The user ID of the user on which the log entry was written..'), - 'field' => array( + 'field' => [ 'id' => 'numeric', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'numeric', - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'numeric', - ), - 'relationship' => array( + ], + 'relationship' => [ 'title' => t('User'), 'help' => t('The user on which the log entry as written.'), 'base' => 'users', 'base field' => 'uid', 'id' => 'standard', - ), - ); + ], + ]; - $data['watchdog']['type'] = array( + $data['watchdog']['type'] = [ 'title' => t('Type'), 'help' => t('The type of the log entry, for example "user" or "page not found".'), - 'field' => array( + 'field' => [ 'id' => 'standard', - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'string', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'in_operator', 'options callback' => '_dblog_get_message_types', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'standard', - ), - ); + ], + ]; - $data['watchdog']['message'] = array( + $data['watchdog']['message'] = [ 'title' => t('Message'), 'help' => t('The actual message of the log entry.'), - 'field' => array( + 'field' => [ 'id' => 'dblog_message', - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'string', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'string', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'standard', - ), - ); + ], + ]; - $data['watchdog']['variables'] = array( + $data['watchdog']['variables'] = [ 'title' => t('Variables'), 'help' => t('The variables of the log entry in a serialized format.'), - 'field' => array( + 'field' => [ 'id' => 'serialized', 'click sortable' => FALSE, - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'string', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'string', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'standard', - ), - ); + ], + ]; - $data['watchdog']['severity'] = array( + $data['watchdog']['severity'] = [ 'title' => t('Severity level'), 'help' => t('The severity level of the event; ranges from 0 (Emergency) to 7 (Debug).'), - 'field' => array( + 'field' => [ 'id' => 'machine_name', 'options callback' => 'Drupal\dblog\Controller\DbLogController::getLogLevelClassMap', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'in_operator', 'options callback' => 'Drupal\dblog\Controller\DbLogController::getLogLevelClassMap', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'standard', - ), - ); + ], + ]; - $data['watchdog']['link'] = array( + $data['watchdog']['link'] = [ 'title' => t('Operations'), 'help' => t('Operation links for the event.'), - 'field' => array( + 'field' => [ 'id' => 'dblog_operations', - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'string', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'string', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'standard', - ), - ); + ], + ]; - $data['watchdog']['location'] = array( + $data['watchdog']['location'] = [ 'title' => t('Location'), 'help' => t('URL of the origin of the event.'), - 'field' => array( + 'field' => [ 'id' => 'standard', - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'string', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'string', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'standard', - ), - ); + ], + ]; - $data['watchdog']['referer'] = array( + $data['watchdog']['referer'] = [ 'title' => t('Referer'), 'help' => t('URL of the previous page.'), - 'field' => array( + 'field' => [ 'id' => 'standard', - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'string', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'string', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'standard', - ), - ); + ], + ]; - $data['watchdog']['hostname'] = array( + $data['watchdog']['hostname'] = [ 'title' => t('Hostname'), 'help' => t('Hostname of the user who triggered the event.'), - 'field' => array( + 'field' => [ 'id' => 'standard', - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'string', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'string', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'standard', - ), - ); + ], + ]; - $data['watchdog']['timestamp'] = array( + $data['watchdog']['timestamp'] = [ 'title' => t('Timestamp'), 'help' => t('Date when the event occurred.'), - 'field' => array( + 'field' => [ 'id' => 'date', - ), - 'argument' => array( + ], + 'argument' => [ 'id' => 'date', - ), - 'filter' => array( + ], + 'filter' => [ 'id' => 'date', - ), - 'sort' => array( + ], + 'sort' => [ 'id' => 'date', - ), - ); + ], + ]; return $data; } diff --git a/core/modules/dblog/src/Controller/DbLogController.php b/core/modules/dblog/src/Controller/DbLogController.php index 572b9ae..aca2af8 100644 --- a/core/modules/dblog/src/Controller/DbLogController.php +++ b/core/modules/dblog/src/Controller/DbLogController.php @@ -94,7 +94,7 @@ public function __construct(Connection $database, ModuleHandlerInterface $module * An array of log level classes. */ public static function getLogLevelClassMap() { - return array( + return [ RfcLogLevel::DEBUG => 'dblog-debug', RfcLogLevel::INFO => 'dblog-info', RfcLogLevel::NOTICE => 'dblog-notice', @@ -103,7 +103,7 @@ public static function getLogLevelClassMap() { RfcLogLevel::CRITICAL => 'dblog-critical', RfcLogLevel::ALERT => 'dblog-alert', RfcLogLevel::EMERGENCY => 'dblog-emergency', - ); + ]; } /** @@ -121,7 +121,7 @@ public static function getLogLevelClassMap() { public function overview() { $filter = $this->buildFilterQuery(); - $rows = array(); + $rows = []; $classes = static::getLogLevelClassMap(); @@ -129,32 +129,32 @@ public function overview() { $build['dblog_filter_form'] = $this->formBuilder->getForm('Drupal\dblog\Form\DblogFilterForm'); - $header = array( + $header = [ // Icon column. '', - array( + [ 'data' => $this->t('Type'), 'field' => 'w.type', - 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)), - array( + 'class' => [RESPONSIVE_PRIORITY_MEDIUM]], + [ 'data' => $this->t('Date'), 'field' => 'w.wid', 'sort' => 'desc', - 'class' => array(RESPONSIVE_PRIORITY_LOW)), + 'class' => [RESPONSIVE_PRIORITY_LOW]], $this->t('Message'), - array( + [ 'data' => $this->t('User'), 'field' => 'ufd.name', - 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)), - array( + 'class' => [RESPONSIVE_PRIORITY_MEDIUM]], + [ 'data' => $this->t('Operations'), - 'class' => array(RESPONSIVE_PRIORITY_LOW)), - ); + 'class' => [RESPONSIVE_PRIORITY_LOW]], + ]; $query = $this->database->select('watchdog', 'w') ->extend('\Drupal\Core\Database\Query\PagerSelectExtender') ->extend('\Drupal\Core\Database\Query\TableSortExtender'); - $query->fields('w', array( + $query->fields('w', [ 'wid', 'uid', 'severity', @@ -163,7 +163,7 @@ public function overview() { 'message', 'variables', 'link', - )); + ]); $query->leftJoin('users_field_data', 'ufd', 'w.uid = ufd.uid'); if (!empty($filter['where'])) { @@ -181,45 +181,45 @@ public function overview() { $log_text = Unicode::truncate($title, 56, TRUE, TRUE); // The link generator will escape any unsafe HTML entities in the final // text. - $message = $this->l($log_text, new Url('dblog.event', array('event_id' => $dblog->wid), array( - 'attributes' => array( + $message = $this->l($log_text, new Url('dblog.event', ['event_id' => $dblog->wid], [ + 'attributes' => [ // Provide a title for the link for useful hover hints. The // Attribute object will escape any unsafe HTML entities in the // final text. 'title' => $title, - ), - ))); + ], + ])); } - $username = array( + $username = [ '#theme' => 'username', '#account' => $this->userStorage->load($dblog->uid), - ); - $rows[] = array( - 'data' => array( + ]; + $rows[] = [ + 'data' => [ // Cells. - array('class' => array('icon')), + ['class' => ['icon']], $this->t($dblog->type), $this->dateFormatter->format($dblog->timestamp, 'short'), $message, - array('data' => $username), - array('data' => array('#markup' => $dblog->link)), - ), + ['data' => $username], + ['data' => ['#markup' => $dblog->link]], + ], // Attributes for table row. - 'class' => array(Html::getClass('dblog-' . $dblog->type), $classes[$dblog->severity]), - ); + 'class' => [Html::getClass('dblog-' . $dblog->type), $classes[$dblog->severity]], + ]; } - $build['dblog_table'] = array( + $build['dblog_table'] = [ '#type' => 'table', '#header' => $header, '#rows' => $rows, - '#attributes' => array('id' => 'admin-dblog', 'class' => array('admin-dblog')), + '#attributes' => ['id' => 'admin-dblog', 'class' => ['admin-dblog']], '#empty' => $this->t('No log messages available.'), - '#attached' => array( - 'library' => array('dblog/drupal.dblog'), - ), - ); - $build['dblog_pager'] = array('#type' => 'pager'); + '#attached' => [ + 'library' => ['dblog/drupal.dblog'], + ], + ]; + $build['dblog_pager'] = ['#type' => 'pager']; return $build; @@ -236,60 +236,60 @@ public function overview() { * format expected by drupal_render(); */ public function eventDetails($event_id) { - $build = array(); - if ($dblog = $this->database->query('SELECT w.*, u.uid FROM {watchdog} w LEFT JOIN {users} u ON u.uid = w.uid WHERE w.wid = :id', array(':id' => $event_id))->fetchObject()) { + $build = []; + if ($dblog = $this->database->query('SELECT w.*, u.uid FROM {watchdog} w LEFT JOIN {users} u ON u.uid = w.uid WHERE w.wid = :id', [':id' => $event_id])->fetchObject()) { $severity = RfcLogLevel::getLevels(); $message = $this->formatMessage($dblog); - $username = array( + $username = [ '#theme' => 'username', '#account' => $dblog->uid ? $this->userStorage->load($dblog->uid) : User::getAnonymousUser(), - ); - $rows = array( - array( - array('data' => $this->t('Type'), 'header' => TRUE), + ]; + $rows = [ + [ + ['data' => $this->t('Type'), 'header' => TRUE], $this->t($dblog->type), - ), - array( - array('data' => $this->t('Date'), 'header' => TRUE), + ], + [ + ['data' => $this->t('Date'), 'header' => TRUE], $this->dateFormatter->format($dblog->timestamp, 'long'), - ), - array( - array('data' => $this->t('User'), 'header' => TRUE), - array('data' => $username), - ), - array( - array('data' => $this->t('Location'), 'header' => TRUE), + ], + [ + ['data' => $this->t('User'), 'header' => TRUE], + ['data' => $username], + ], + [ + ['data' => $this->t('Location'), 'header' => TRUE], $this->l($dblog->location, $dblog->location ? Url::fromUri($dblog->location) : Url::fromRoute('')), - ), - array( - array('data' => $this->t('Referrer'), 'header' => TRUE), + ], + [ + ['data' => $this->t('Referrer'), 'header' => TRUE], $this->l($dblog->referer, $dblog->referer ? Url::fromUri($dblog->referer) : Url::fromRoute('')), - ), - array( - array('data' => $this->t('Message'), 'header' => TRUE), + ], + [ + ['data' => $this->t('Message'), 'header' => TRUE], $message, - ), - array( - array('data' => $this->t('Severity'), 'header' => TRUE), + ], + [ + ['data' => $this->t('Severity'), 'header' => TRUE], $severity[$dblog->severity], - ), - array( - array('data' => $this->t('Hostname'), 'header' => TRUE), + ], + [ + ['data' => $this->t('Hostname'), 'header' => TRUE], $dblog->hostname, - ), - array( - array('data' => $this->t('Operations'), 'header' => TRUE), - array('data' => array('#markup' => $dblog->link)), - ), - ); - $build['dblog_table'] = array( + ], + [ + ['data' => $this->t('Operations'), 'header' => TRUE], + ['data' => ['#markup' => $dblog->link]], + ], + ]; + $build['dblog_table'] = [ '#type' => 'table', '#rows' => $rows, - '#attributes' => array('class' => array('dblog-event')), - '#attached' => array( - 'library' => array('dblog/drupal.dblog'), - ), - ); + '#attributes' => ['class' => ['dblog-event']], + '#attached' => [ + 'library' => ['dblog/drupal.dblog'], + ], + ]; } return $build; @@ -311,9 +311,9 @@ protected function buildFilterQuery() { $filters = dblog_filters(); // Build query. - $where = $args = array(); + $where = $args = []; foreach ($_SESSION['dblog_overview_filter'] as $key => $filter) { - $filter_where = array(); + $filter_where = []; foreach ($filter as $value) { $filter_where[] = $filters[$key]['where']; $args[] = $value; @@ -324,10 +324,10 @@ protected function buildFilterQuery() { } $where = !empty($where) ? implode(' AND ', $where) : ''; - return array( + return [ 'where' => $where, 'args' => $args, - ); + ]; } /** @@ -374,10 +374,10 @@ public function formatMessage($row) { * A build array in the format expected by drupal_render(). */ public function topLogMessages($type) { - $header = array( - array('data' => $this->t('Count'), 'field' => 'count', 'sort' => 'desc'), - array('data' => $this->t('Message'), 'field' => 'message'), - ); + $header = [ + ['data' => $this->t('Count'), 'field' => 'count', 'sort' => 'desc'], + ['data' => $this->t('Message'), 'field' => 'message'], + ]; $count_query = $this->database->select('watchdog'); $count_query->addExpression('COUNT(DISTINCT(message))'); @@ -388,7 +388,7 @@ public function topLogMessages($type) { ->extend('\Drupal\Core\Database\Query\TableSortExtender'); $query->addExpression('COUNT(wid)', 'count'); $query = $query - ->fields('w', array('message', 'variables')) + ->fields('w', ['message', 'variables']) ->condition('w.type', $type) ->groupBy('message') ->groupBy('variables') @@ -397,23 +397,23 @@ public function topLogMessages($type) { $query->setCountQuery($count_query); $result = $query->execute(); - $rows = array(); + $rows = []; foreach ($result as $dblog) { if ($message = $this->formatMessage($dblog)) { - $rows[] = array($dblog->count, $message); + $rows[] = [$dblog->count, $message]; } } - $build['dblog_top_table'] = array( + $build['dblog_top_table'] = [ '#type' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => $this->t('No log messages available.'), - '#attached' => array( - 'library' => array('dblog/drupal.dblog'), - ), - ); - $build['dblog_top_pager'] = array('#type' => 'pager'); + '#attached' => [ + 'library' => ['dblog/drupal.dblog'], + ], + ]; + $build['dblog_top_pager'] = ['#type' => 'pager']; return $build; } diff --git a/core/modules/dblog/src/Form/DblogClearLogConfirmForm.php b/core/modules/dblog/src/Form/DblogClearLogConfirmForm.php index b1710df..0f420f0 100644 --- a/core/modules/dblog/src/Form/DblogClearLogConfirmForm.php +++ b/core/modules/dblog/src/Form/DblogClearLogConfirmForm.php @@ -64,7 +64,7 @@ public function getCancelUrl() { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { - $_SESSION['dblog_overview_filter'] = array(); + $_SESSION['dblog_overview_filter'] = []; $this->connection->truncate('watchdog')->execute(); drupal_set_message($this->t('Database log cleared.')); $form_state->setRedirectUrl($this->getCancelUrl()); diff --git a/core/modules/dblog/src/Form/DblogFilterForm.php b/core/modules/dblog/src/Form/DblogFilterForm.php index 0434f12..c8de0fc 100644 --- a/core/modules/dblog/src/Form/DblogFilterForm.php +++ b/core/modules/dblog/src/Form/DblogFilterForm.php @@ -23,39 +23,39 @@ public function getFormId() { public function buildForm(array $form, FormStateInterface $form_state) { $filters = dblog_filters(); - $form['filters'] = array( + $form['filters'] = [ '#type' => 'details', '#title' => $this->t('Filter log messages'), '#open' => TRUE, - ); + ]; foreach ($filters as $key => $filter) { - $form['filters']['status'][$key] = array( + $form['filters']['status'][$key] = [ '#title' => $filter['title'], '#type' => 'select', '#multiple' => TRUE, '#size' => 8, '#options' => $filter['options'], - ); + ]; if (!empty($_SESSION['dblog_overview_filter'][$key])) { $form['filters']['status'][$key]['#default_value'] = $_SESSION['dblog_overview_filter'][$key]; } } - $form['filters']['actions'] = array( + $form['filters']['actions'] = [ '#type' => 'actions', - '#attributes' => array('class' => array('container-inline')), - ); - $form['filters']['actions']['submit'] = array( + '#attributes' => ['class' => ['container-inline']], + ]; + $form['filters']['actions']['submit'] = [ '#type' => 'submit', '#value' => $this->t('Filter'), - ); + ]; if (!empty($_SESSION['dblog_overview_filter'])) { - $form['filters']['actions']['reset'] = array( + $form['filters']['actions']['reset'] = [ '#type' => 'submit', '#value' => $this->t('Reset'), - '#limit_validation_errors' => array(), - '#submit' => array('::resetForm'), - ); + '#limit_validation_errors' => [], + '#submit' => ['::resetForm'], + ]; } return $form; } @@ -90,7 +90,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { * The current state of the form. */ public function resetForm(array &$form, FormStateInterface $form_state) { - $_SESSION['dblog_overview_filter'] = array(); + $_SESSION['dblog_overview_filter'] = []; } } diff --git a/core/modules/dblog/src/Logger/DbLog.php b/core/modules/dblog/src/Logger/DbLog.php index af77be4..97b0b7b 100644 --- a/core/modules/dblog/src/Logger/DbLog.php +++ b/core/modules/dblog/src/Logger/DbLog.php @@ -53,7 +53,7 @@ public function __construct(Connection $connection, LogMessageParserInterface $p /** * {@inheritdoc} */ - public function log($level, $message, array $context = array()) { + public function log($level, $message, array $context = []) { // Remove any backtraces since they may contain an unserializable variable. unset($context['backtrace']); @@ -64,7 +64,7 @@ public function log($level, $message, array $context = array()) { try { $this->connection ->insert('watchdog') - ->fields(array( + ->fields([ 'uid' => $context['uid'], 'type' => Unicode::substr($context['channel'], 0, 64), 'message' => $message, @@ -75,7 +75,7 @@ public function log($level, $message, array $context = array()) { 'referer' => $context['referer'], 'hostname' => Unicode::substr($context['ip'], 0, 128), 'timestamp' => $context['timestamp'], - )) + ]) ->execute(); } catch (\Exception $e) { diff --git a/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php b/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php index 4ac76f0..ed801fc 100644 --- a/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php +++ b/core/modules/dblog/src/Plugin/rest/resource/DBLogResource.php @@ -38,13 +38,13 @@ class DBLogResource extends ResourceBase { */ public function get($id = NULL) { if ($id) { - $record = db_query("SELECT * FROM {watchdog} WHERE wid = :wid", array(':wid' => $id)) + $record = db_query("SELECT * FROM {watchdog} WHERE wid = :wid", [':wid' => $id]) ->fetchAssoc(); if (!empty($record)) { return new ResourceResponse($record); } - throw new NotFoundHttpException(t('Log entry with ID @id was not found', array('@id' => $id))); + throw new NotFoundHttpException(t('Log entry with ID @id was not found', ['@id' => $id])); } throw new BadRequestHttpException(t('No log entry ID was provided')); diff --git a/core/modules/dblog/src/Plugin/views/field/DblogMessage.php b/core/modules/dblog/src/Plugin/views/field/DblogMessage.php index e0558d8..3c68242 100644 --- a/core/modules/dblog/src/Plugin/views/field/DblogMessage.php +++ b/core/modules/dblog/src/Plugin/views/field/DblogMessage.php @@ -34,7 +34,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o */ protected function defineOptions() { $options = parent::defineOptions(); - $options['replace_variables'] = array('default' => TRUE); + $options['replace_variables'] = ['default' => TRUE]; return $options; } @@ -45,11 +45,11 @@ protected function defineOptions() { public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); - $form['replace_variables'] = array( + $form['replace_variables'] = [ '#title' => $this->t('Replace variables'), '#type' => 'checkbox', '#default_value' => $this->options['replace_variables'], - ); + ]; } /** diff --git a/core/modules/dblog/src/Tests/ConnectionFailureTest.php b/core/modules/dblog/src/Tests/ConnectionFailureTest.php index d800224..2c4829e 100644 --- a/core/modules/dblog/src/Tests/ConnectionFailureTest.php +++ b/core/modules/dblog/src/Tests/ConnectionFailureTest.php @@ -12,7 +12,7 @@ */ class ConnectionFailureTest extends WebTestBase { - public static $modules = array('dblog'); + public static $modules = ['dblog']; /** * Tests logging of connection failures. diff --git a/core/modules/dblog/src/Tests/DbLogTest.php b/core/modules/dblog/src/Tests/DbLogTest.php index 90cb6c2..f2f6e91 100644 --- a/core/modules/dblog/src/Tests/DbLogTest.php +++ b/core/modules/dblog/src/Tests/DbLogTest.php @@ -22,7 +22,7 @@ class DbLogTest extends WebTestBase { * * @var array */ - public static $modules = array('dblog', 'node', 'forum', 'help', 'block'); + public static $modules = ['dblog', 'node', 'forum', 'help', 'block']; /** * A user with some relevant administrative permissions. @@ -47,8 +47,8 @@ protected function setUp() { $this->drupalPlaceBlock('page_title_block'); // Create users with specific permissions. - $this->adminUser = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'access site reports', 'administer users')); - $this->webUser = $this->drupalCreateUser(array()); + $this->adminUser = $this->drupalCreateUser(['administer site configuration', 'access administration pages', 'access site reports', 'administer users']); + $this->webUser = $this->drupalCreateUser([]); } /** @@ -70,8 +70,8 @@ function testDbLog() { $this->verifyBreadcrumbs(); $this->verifyLinkEscaping(); // Verify the overview table sorting. - $orders = array('Date', 'Type', 'User'); - $sorts = array('asc', 'desc'); + $orders = ['Date', 'Type', 'User']; + $sorts = ['asc', 'desc']; foreach ($orders as $order) { foreach ($sorts as $sort) { $this->verifySort($sort, $order); @@ -124,14 +124,14 @@ public function testLogEventPage() { */ private function verifyRowLimit($row_limit) { // Change the database log row limit. - $edit = array(); + $edit = []; $edit['dblog_row_limit'] = $row_limit; $this->drupalPostForm('admin/config/development/logging', $edit, t('Save configuration')); $this->assertResponse(200); // Check row limit variable. $current_limit = $this->config('dblog.settings')->get('row_limit'); - $this->assertTrue($current_limit == $row_limit, format_string('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); + $this->assertTrue($current_limit == $row_limit, format_string('[Cache] Row limit variable of @count equals row limit of @limit', ['@count' => $current_limit, '@limit' => $row_limit])); } /** @@ -145,7 +145,7 @@ private function verifyCron($row_limit) { $this->generateLogEntries($row_limit + 10); // Verify that the database log row count exceeds the row limit. $count = db_query('SELECT COUNT(wid) FROM {watchdog}')->fetchField(); - $this->assertTrue($count > $row_limit, format_string('Dblog row count of @count exceeds row limit of @limit', array('@count' => $count, '@limit' => $row_limit))); + $this->assertTrue($count > $row_limit, format_string('Dblog row count of @count exceeds row limit of @limit', ['@count' => $count, '@limit' => $row_limit])); // Get last ID to compare against; log entries get deleted, so we can't // reliably add the number of newly created log entries to the current count @@ -163,7 +163,7 @@ private function verifyCron($row_limit) { $module_count = count($list); $count = $current_id - $last_id; - $this->assertTrue(($current_id - $last_id) == $module_count + 2, format_string('Cron added @count of @expected new log entries', array('@count' => $count, '@expected' => $module_count + 2))); + $this->assertTrue(($current_id - $last_id) == $module_count + 2, format_string('Cron added @count of @expected new log entries', ['@count' => $count, '@expected' => $module_count + 2])); } /** @@ -189,7 +189,7 @@ private function verifyCron($row_limit) { * entry. * - 'timestamp': Int unix timestamp. */ - private function generateLogEntries($count, $options = array()) { + private function generateLogEntries($count, $options = []) { global $base_root; // This long URL makes it just a little bit harder to pass the link part of @@ -198,10 +198,10 @@ private function generateLogEntries($count, $options = array()) { $link = urldecode('/content/xo%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A%E9%85%B1%E5%87%89%E6%8B%8C%E7%B4%A0%E9%B8%A1%E7%85%A7%E7%83%A7%E9%B8%A1%E9%BB%84%E7%8E%AB%E7%91%B0-%E7%A7%91%E5%B7%9E%E7%9A%84%E5%B0%8F%E4%B9%9D%E5%AF%A8%E6%B2%9F%E7%BB%9D%E7%BE%8E%E9%AB%98%E5%B1%B1%E6%B9%96%E6%B3%8A-lake-isabelle'); // Prepare the fields to be logged - $log = $options + array( + $log = $options + [ 'channel' => 'custom', 'message' => 'Dblog test log message', - 'variables' => array(), + 'variables' => [], 'severity' => RfcLogLevel::NOTICE, 'link' => $link, 'user' => $this->adminUser, @@ -210,7 +210,7 @@ private function generateLogEntries($count, $options = array()) { 'referer' => \Drupal::request()->server->get('HTTP_REFERER'), 'ip' => '127.0.0.1', 'timestamp' => REQUEST_TIME, - ); + ]; $logger = $this->container->get('logger.dblog'); $message = $log['message'] . ' Entry #'; @@ -236,7 +236,7 @@ protected function clearLogsEntries() { * (optional) The log entry severity. */ protected function filterLogsEntries($type = NULL, $severity = NULL) { - $edit = array(); + $edit = []; if (!is_null($type)) { $edit['type[]'] = $type; } @@ -307,8 +307,8 @@ private function verifyBreadcrumbs() { private function verifyEvents() { // Invoke events. $this->doUser(); - $this->drupalCreateContentType(array('type' => 'article', 'name' => t('Article'))); - $this->drupalCreateContentType(array('type' => 'page', 'name' => t('Basic page'))); + $this->drupalCreateContentType(['type' => 'article', 'name' => t('Article')]); + $this->drupalCreateContentType(['type' => 'page', 'name' => t('Basic page')]); $this->doNode('article'); $this->doNode('page'); $this->doNode('forum'); @@ -327,7 +327,7 @@ private function verifyEvents() { * The order by which the table should be sorted. */ public function verifySort($sort = 'asc', $order = 'Date') { - $this->drupalGet('admin/reports/dblog', array('query' => array('sort' => $sort, 'order' => $order))); + $this->drupalGet('admin/reports/dblog', ['query' => ['sort' => $sort, 'order' => $order]]); $this->assertResponse(200); $this->assertText(t('Recent log messages'), 'DBLog report was displayed correctly and sorting went fine.'); } @@ -337,12 +337,12 @@ public function verifySort($sort = 'asc', $order = 'Date') { * page. */ private function verifyLinkEscaping() { - $link = \Drupal::l('View', Url::fromRoute('entity.node.canonical', array('node' => 1))); + $link = \Drupal::l('View', Url::fromRoute('entity.node.canonical', ['node' => 1])); $message = 'Log entry added to do the verifyLinkEscaping test.'; - $this->generateLogEntries(1, array( + $this->generateLogEntries(1, [ 'message' => $message, 'link' => $link, - )); + ]); $result = db_query_range('SELECT wid FROM {watchdog} ORDER BY wid DESC', 0, 1); $this->drupalGet('admin/reports/dblog/event/' . $result->fetchField()); @@ -360,7 +360,7 @@ private function doUser() { $pass = user_password(); // Add a user using the form to generate an add user event (which is not // triggered by drupalCreateUser). - $edit = array(); + $edit = []; $edit['name'] = $name; $edit['mail'] = $name . '@example.com'; $edit['pass[pass1]'] = $pass; @@ -370,7 +370,7 @@ private function doUser() { $this->assertResponse(200); // Retrieve the user object. $user = user_load_by_name($name); - $this->assertTrue($user != NULL, format_string('User @name was loaded', array('@name' => $name))); + $this->assertTrue($user != NULL, format_string('User @name was loaded', ['@name' => $name])); // pass_raw property is needed by drupalLogin. $user->pass_raw = $pass; // Log in user. @@ -378,18 +378,18 @@ private function doUser() { // Log out user. $this->drupalLogout(); // Fetch the row IDs in watchdog that relate to the user. - $result = db_query('SELECT wid FROM {watchdog} WHERE uid = :uid', array(':uid' => $user->id())); + $result = db_query('SELECT wid FROM {watchdog} WHERE uid = :uid', [':uid' => $user->id()]); foreach ($result as $row) { $ids[] = $row->wid; } $count_before = (isset($ids)) ? count($ids) : 0; - $this->assertTrue($count_before > 0, format_string('DBLog contains @count records for @name', array('@count' => $count_before, '@name' => $user->getUsername()))); + $this->assertTrue($count_before > 0, format_string('DBLog contains @count records for @name', ['@count' => $count_before, '@name' => $user->getUsername()])); // Log in the admin user. $this->drupalLogin($this->adminUser); // Delete the user created at the start of this test. // We need to POST here to invoke batch_process() in the internal browser. - $this->drupalPostForm('user/' . $user->id() . '/cancel', array('user_cancel_method' => 'user_cancel_reassign'), t('Cancel account')); + $this->drupalPostForm('user/' . $user->id() . '/cancel', ['user_cancel_method' => 'user_cancel_reassign'], t('Cancel account')); // View the database log report. $this->drupalGet('admin/reports/dblog'); @@ -399,13 +399,13 @@ private function doUser() { // Add user. // Default display includes name and email address; if too long, the email // address is replaced by three periods. - $this->assertLogMessage(t('New user: %name %email.', array('%name' => $name, '%email' => '<' . $user->getEmail() . '>')), 'DBLog event was recorded: [add user]'); + $this->assertLogMessage(t('New user: %name %email.', ['%name' => $name, '%email' => '<' . $user->getEmail() . '>']), 'DBLog event was recorded: [add user]'); // Log in user. - $this->assertLogMessage(t('Session opened for %name.', array('%name' => $name)), 'DBLog event was recorded: [login user]'); + $this->assertLogMessage(t('Session opened for %name.', ['%name' => $name]), 'DBLog event was recorded: [login user]'); // Log out user. - $this->assertLogMessage(t('Session closed for %name.', array('%name' => $name)), 'DBLog event was recorded: [logout user]'); + $this->assertLogMessage(t('Session closed for %name.', ['%name' => $name]), 'DBLog event was recorded: [logout user]'); // Delete user. - $message = t('Deleted user: %name %email.', array('%name' => $name, '%email' => '<' . $user->getEmail() . '>')); + $message = t('Deleted user: %name %email.', ['%name' => $name, '%email' => '<' . $user->getEmail() . '>']); $message_text = Unicode::truncate(Html::decodeEntities(strip_tags($message)), 56, TRUE, TRUE); // Verify that the full message displays on the details page. $link = FALSE; @@ -443,7 +443,7 @@ private function doUser() { */ private function doNode($type) { // Create user. - $perm = array('create ' . $type . ' content', 'edit own ' . $type . ' content', 'delete own ' . $type . ' content'); + $perm = ['create ' . $type . ' content', 'edit own ' . $type . ' content', 'delete own ' . $type . ' content']; $user = $this->drupalCreateUser($perm); // Log in user. $this->drupalLogin($user); @@ -456,13 +456,13 @@ private function doNode($type) { $this->assertResponse(200); // Retrieve the node object. $node = $this->drupalGetNodeByTitle($title); - $this->assertTrue($node != NULL, format_string('Node @title was loaded', array('@title' => $title))); + $this->assertTrue($node != NULL, format_string('Node @title was loaded', ['@title' => $title])); // Edit the node. $edit = $this->getContentUpdate($type); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); $this->assertResponse(200); // Delete the node. - $this->drupalPostForm('node/' . $node->id() . '/delete', array(), t('Delete')); + $this->drupalPostForm('node/' . $node->id() . '/delete', [], t('Delete')); $this->assertResponse(200); // View the node (to generate page not found event). $this->drupalGet('node/' . $node->id()); @@ -479,11 +479,11 @@ private function doNode($type) { // Verify that node events were recorded. // Was node content added? - $this->assertLogMessage(t('@type: added %title.', array('@type' => $type, '%title' => $title)), 'DBLog event was recorded: [content added]'); + $this->assertLogMessage(t('@type: added %title.', ['@type' => $type, '%title' => $title]), 'DBLog event was recorded: [content added]'); // Was node content updated? - $this->assertLogMessage(t('@type: updated %title.', array('@type' => $type, '%title' => $title)), 'DBLog event was recorded: [content updated]'); + $this->assertLogMessage(t('@type: updated %title.', ['@type' => $type, '%title' => $title]), 'DBLog event was recorded: [content updated]'); // Was node content deleted? - $this->assertLogMessage(t('@type: deleted %title.', array('@type' => $type, '%title' => $title)), 'DBLog event was recorded: [content deleted]'); + $this->assertLogMessage(t('@type: deleted %title.', ['@type' => $type, '%title' => $title]), 'DBLog event was recorded: [content deleted]'); // View the database log access-denied report page. $this->drupalGet('admin/reports/access-denied'); @@ -510,18 +510,18 @@ private function doNode($type) { private function getContent($type) { switch ($type) { case 'forum': - $content = array( + $content = [ 'title[0][value]' => $this->randomMachineName(8), - 'taxonomy_forums' => array(1), + 'taxonomy_forums' => [1], 'body[0][value]' => $this->randomMachineName(32), - ); + ]; break; default: - $content = array( + $content = [ 'title[0][value]' => $this->randomMachineName(8), 'body[0][value]' => $this->randomMachineName(32), - ); + ]; break; } return $content; @@ -537,9 +537,9 @@ private function getContent($type) { * Random content needed by various node types. */ private function getContentUpdate($type) { - $content = array( + $content = [ 'body[0][value]' => $this->randomMachineName(32), - ); + ]; return $content; } @@ -553,10 +553,10 @@ public function testDBLogAddAndClear() { global $base_root; // Get a count of how many watchdog entries already exist. $count = db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(); - $log = array( + $log = [ 'channel' => 'system', 'message' => 'Log entry added to test the doClearTest clear down.', - 'variables' => array(), + 'variables' => [], 'severity' => RfcLogLevel::NOTICE, 'link' => NULL, 'user' => $this->adminUser, @@ -565,20 +565,20 @@ public function testDBLogAddAndClear() { 'referer' => \Drupal::request()->server->get('HTTP_REFERER'), 'ip' => '127.0.0.1', 'timestamp' => REQUEST_TIME, - ); + ]; // Add a watchdog entry. $this->container->get('logger.dblog')->log($log['severity'], $log['message'], $log); // Make sure the table count has actually been incremented. - $this->assertEqual($count + 1, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), format_string('\Drupal\dblog\Logger\DbLog->log() added an entry to the dblog :count', array(':count' => $count))); + $this->assertEqual($count + 1, db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(), format_string('\Drupal\dblog\Logger\DbLog->log() added an entry to the dblog :count', [':count' => $count])); // Log in the admin user. $this->drupalLogin($this->adminUser); // Post in order to clear the database table. $this->clearLogsEntries(); // Confirm that the logs should be cleared. - $this->drupalPostForm(NULL, array(), 'Confirm'); + $this->drupalPostForm(NULL, [], 'Confirm'); // Count the rows in watchdog that previously related to the deleted user. $count = db_query('SELECT COUNT(*) FROM {watchdog}')->fetchField(); - $this->assertEqual($count, 0, format_string('DBLog contains :count records after a clear.', array(':count' => $count))); + $this->assertEqual($count, 0, format_string('DBLog contains :count records after a clear.', [':count' => $count])); } /** @@ -591,21 +591,21 @@ public function testFilter() { db_delete('watchdog')->execute(); // Generate 9 random watchdog entries. - $type_names = array(); - $types = array(); + $type_names = []; + $types = []; for ($i = 0; $i < 3; $i++) { $type_names[] = $type_name = $this->randomMachineName(); $severity = RfcLogLevel::EMERGENCY; for ($j = 0; $j < 3; $j++) { - $types[] = $type = array( + $types[] = $type = [ 'count' => $j + 1, 'type' => $type_name, 'severity' => $severity++, - ); - $this->generateLogEntries($type['count'], array( + ]; + $this->generateLogEntries($type['count'], [ 'channel' => $type['type'], 'severity' => $type['severity'], - )); + ]); } } @@ -644,14 +644,14 @@ public function testFilter() { $this->assertEqual(array_sum($count), $type['count'], 'Count matched'); } - $this->drupalGet('admin/reports/dblog', array('query' => array('order' => 'Type'))); + $this->drupalGet('admin/reports/dblog', ['query' => ['order' => 'Type']]); $this->assertResponse(200); $this->assertText(t('Operations'), 'Operations text found'); // Clear all logs and make sure the confirmation message is found. $this->clearLogsEntries(); // Confirm that the logs should be cleared. - $this->drupalPostForm(NULL, array(), 'Confirm'); + $this->drupalPostForm(NULL, [], 'Confirm'); $this->assertText(t('Database log cleared.'), 'Confirmation message found'); } @@ -666,16 +666,16 @@ public function testFilter() { * - user: (string) The user associated with this database log event. */ protected function getLogEntries() { - $entries = array(); + $entries = []; if ($table = $this->getLogsEntriesTable()) { $table = array_shift($table); foreach ($table->tbody->tr as $row) { - $entries[] = array( + $entries[] = [ 'severity' => $this->getSeverityConstant($row['class']), 'type' => $this->asText($row->td[1]), 'message' => $this->asText($row->td[3]), 'user' => $this->asText($row->td[4]), - ); + ]; } } return $entries; @@ -781,7 +781,7 @@ public function testTemporaryUser() { $this->drupalLogin($this->adminUser); // Generate a single watchdog entry. - $this->generateLogEntries(1, array('user' => $tempuser, 'uid' => $tempuser_uid)); + $this->generateLogEntries(1, ['user' => $tempuser, 'uid' => $tempuser_uid]); $wid = db_query('SELECT MAX(wid) FROM {watchdog}')->fetchField(); // Check if the full message displays on the details page. diff --git a/core/modules/dblog/src/Tests/Rest/DbLogResourceTest.php b/core/modules/dblog/src/Tests/Rest/DbLogResourceTest.php index 279d202..44dbe99 100644 --- a/core/modules/dblog/src/Tests/Rest/DbLogResourceTest.php +++ b/core/modules/dblog/src/Tests/Rest/DbLogResourceTest.php @@ -18,7 +18,7 @@ class DbLogResourceTest extends RESTTestBase { * * @var array */ - public static $modules = array('hal', 'dblog'); + public static $modules = ['hal', 'dblog']; protected function setUp() { parent::setUp(); @@ -33,12 +33,12 @@ public function testWatchdog() { // Write a log message to the DB. $this->container->get('logger.channel.rest')->notice('Test message'); // Get the ID of the written message. - $id = db_query_range("SELECT wid FROM {watchdog} WHERE type = :type ORDER BY wid DESC", 0, 1, array(':type' => 'rest')) + $id = db_query_range("SELECT wid FROM {watchdog} WHERE type = :type ORDER BY wid DESC", 0, 1, [':type' => 'rest']) ->fetchField(); // Create a user account that has the required permissions to read // the watchdog resource via the REST API. - $account = $this->drupalCreateUser(array('restful get dblog')); + $account = $this->drupalCreateUser(['restful get dblog']); $this->drupalLogin($account); $response = $this->httpRequest(Url::fromRoute('rest.dblog.GET.' . $this->defaultFormat, ['id' => $id, '_format' => $this->defaultFormat]), 'GET'); diff --git a/core/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php b/core/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php index 569cdbf..c0d97be 100644 --- a/core/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php +++ b/core/modules/dblog/tests/src/Kernel/DbLogFormInjectionTest.php @@ -31,7 +31,7 @@ class DbLogFormInjectionTest extends KernelTestBase implements FormInterface { * * @var array */ - public static $modules = array('system', 'dblog', 'user'); + public static $modules = ['system', 'dblog', 'user']; /** * {@inheritdoc} @@ -82,10 +82,10 @@ protected function setUp() { $this->installSchema('system', ['key_value_expire', 'sequences']); $this->installEntitySchema('user'); $this->logger = \Drupal::logger('test_logger'); - $test_user = User::create(array( + $test_user = User::create([ 'name' => 'foobar', 'mail' => 'foobar@example.com', - )); + ]); $test_user->save(); \Drupal::service('current_user')->setAccount($test_user); } diff --git a/core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php b/core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php index 1968a12..7b63394 100644 --- a/core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php +++ b/core/modules/dblog/tests/src/Kernel/Views/ViewsIntegrationTest.php @@ -22,14 +22,14 @@ class ViewsIntegrationTest extends ViewsKernelTestBase { * * @var array */ - public static $testViews = array('test_dblog'); + public static $testViews = ['test_dblog']; /** * Modules to enable. * * @var array */ - public static $modules = array('dblog', 'dblog_test_views', 'user'); + public static $modules = ['dblog', 'dblog_test_views', 'user']; /** * {@inheritdoc} @@ -40,9 +40,9 @@ protected function setUp($import_test_views = TRUE) { // Rebuild the router, otherwise we can't generate links. $this->container->get('router.builder')->rebuild(); - $this->installSchema('dblog', array('watchdog')); + $this->installSchema('dblog', ['watchdog']); - ViewTestData::createTestViews(get_class($this), array('dblog_test_views')); + ViewTestData::createTestViews(get_class($this), ['dblog_test_views']); } /** @@ -53,35 +53,35 @@ public function testIntegration() { // Remove the watchdog entries added by the potential batch process. $this->container->get('database')->truncate('watchdog')->execute(); - $entries = array(); + $entries = []; // Setup a watchdog entry without tokens. - $entries[] = array( + $entries[] = [ 'message' => $this->randomMachineName(), - 'variables' => array('link' => \Drupal::l('Link', new Url(''))), - ); + 'variables' => ['link' => \Drupal::l('Link', new Url(''))], + ]; // Setup a watchdog entry with one token. - $entries[] = array( + $entries[] = [ 'message' => '@token1', - 'variables' => array('@token1' => $this->randomMachineName(), 'link' => \Drupal::l('Link', new Url(''))), - ); + 'variables' => ['@token1' => $this->randomMachineName(), 'link' => \Drupal::l('Link', new Url(''))], + ]; // Setup a watchdog entry with two tokens. - $entries[] = array( + $entries[] = [ 'message' => '@token1 @token2', // Setup a link with a tag which is filtered by // \Drupal\Component\Utility\Xss::filterAdmin() in order to make sure // that strings which are not marked as safe get filtered. - 'variables' => array( + 'variables' => [ '@token1' => $this->randomMachineName(), '@token2' => $this->randomMachineName(), 'link' => 'Link', - ), - ); + ], + ]; $logger_factory = $this->container->get('logger.factory'); foreach ($entries as $entry) { - $entry += array( + $entry += [ 'type' => 'test-views', 'severity' => RfcLogLevel::NOTICE, - ); + ]; $logger_factory->get($entry['type'])->log($entry['severity'], $entry['message'], $entry['variables']); } diff --git a/core/modules/dynamic_page_cache/src/Tests/DynamicPageCacheIntegrationTest.php b/core/modules/dynamic_page_cache/src/Tests/DynamicPageCacheIntegrationTest.php index 067a104..f16c749 100644 --- a/core/modules/dynamic_page_cache/src/Tests/DynamicPageCacheIntegrationTest.php +++ b/core/modules/dynamic_page_cache/src/Tests/DynamicPageCacheIntegrationTest.php @@ -94,11 +94,11 @@ public function testDynamicPageCache() { // Controllers returning render arrays, rendered as anything except a HTML // response, are ignored by Dynamic Page Cache (but only because those // wrapper formats' responses do not implement CacheableResponseInterface). - $this->drupalGet('dynamic-page-cache-test/html', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax'))); + $this->drupalGet('dynamic-page-cache-test/html', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_ajax']]); $this->assertFalse($this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as AJAX response: Dynamic Page Cache is ignoring.'); - $this->drupalGet('dynamic-page-cache-test/html', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog'))); + $this->drupalGet('dynamic-page-cache-test/html', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog']]); $this->assertFalse($this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as dialog response: Dynamic Page Cache is ignoring.'); - $this->drupalGet('dynamic-page-cache-test/html', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal'))); + $this->drupalGet('dynamic-page-cache-test/html', ['query' => [MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal']]); $this->assertFalse($this->drupalGetHeader(DynamicPageCacheSubscriber::HEADER), 'Render array returned, rendered as modal response: Dynamic Page Cache is ignoring.'); // Admin routes are ignored by Dynamic Page Cache. diff --git a/core/modules/editor/editor.admin.inc b/core/modules/editor/editor.admin.inc index 83bc2cf..f91db4b 100644 --- a/core/modules/editor/editor.admin.inc +++ b/core/modules/editor/editor.admin.inc @@ -27,77 +27,77 @@ function editor_image_upload_settings_form(Editor $editor) { // Defaults. $image_upload = $editor->getImageUploadSettings(); - $image_upload += array( + $image_upload += [ 'status' => FALSE, 'scheme' => file_default_scheme(), 'directory' => 'inline-images', 'max_size' => '', - 'max_dimensions' => array('width' => '', 'height' => ''), - ); + 'max_dimensions' => ['width' => '', 'height' => ''], + ]; - $form['status'] = array( + $form['status'] = [ '#type' => 'checkbox', '#title' => t('Enable image uploads'), '#default_value' => $image_upload['status'], - '#attributes' => array( + '#attributes' => [ 'data-editor-image-upload' => 'status', - ), - ); - $show_if_image_uploads_enabled = array( - 'visible' => array( - ':input[data-editor-image-upload="status"]' => array('checked' => TRUE), - ), - ); + ], + ]; + $show_if_image_uploads_enabled = [ + 'visible' => [ + ':input[data-editor-image-upload="status"]' => ['checked' => TRUE], + ], + ]; // Any visible, writable wrapper can potentially be used for uploads, // including a remote file system that integrates with a CDN. $options = \Drupal::service('stream_wrapper_manager')->getDescriptions(StreamWrapperInterface::WRITE_VISIBLE); if (!empty($options)) { - $form['scheme'] = array( + $form['scheme'] = [ '#type' => 'radios', '#title' => t('File storage'), '#default_value' => $image_upload['scheme'], '#options' => $options, '#states' => $show_if_image_uploads_enabled, '#access' => count($options) > 1, - ); + ]; } // Set data- attributes with human-readable names for all possible stream // wrappers, so that drupal.ckeditor.drupalimage.admin's summary rendering // can use that. foreach (\Drupal::service('stream_wrapper_manager')->getNames(StreamWrapperInterface::WRITE_VISIBLE) as $scheme => $name) { - $form['scheme'][$scheme]['#attributes']['data-label'] = t('Storage: @name', array('@name' => $name)); + $form['scheme'][$scheme]['#attributes']['data-label'] = t('Storage: @name', ['@name' => $name]); } - $form['directory'] = array( + $form['directory'] = [ '#type' => 'textfield', '#default_value' => $image_upload['directory'], '#title' => t('Upload directory'), '#description' => t("A directory relative to Drupal's files directory where uploaded images will be stored."), '#states' => $show_if_image_uploads_enabled, - ); + ]; $default_max_size = format_size(file_upload_max_size()); - $form['max_size'] = array( + $form['max_size'] = [ '#type' => 'textfield', '#default_value' => $image_upload['max_size'], '#title' => t('Maximum file size'), - '#description' => t('If this is left empty, then the file size will be limited by the PHP maximum upload size of @size.', array('@size' => $default_max_size)), + '#description' => t('If this is left empty, then the file size will be limited by the PHP maximum upload size of @size.', ['@size' => $default_max_size]), '#maxlength' => 20, '#size' => 10, '#placeholder' => $default_max_size, '#states' => $show_if_image_uploads_enabled, - ); + ]; - $form['max_dimensions'] = array( + $form['max_dimensions'] = [ '#type' => 'item', '#title' => t('Maximum dimensions'), '#field_prefix' => '
    ', '#field_suffix' => '
    ', '#description' => t('Images larger than these dimensions will be scaled down.'), '#states' => $show_if_image_uploads_enabled, - ); - $form['max_dimensions']['width'] = array( + ]; + $form['max_dimensions']['width'] = [ '#title' => t('Width'), '#title_display' => 'invisible', '#type' => 'number', @@ -109,8 +109,8 @@ function editor_image_upload_settings_form(Editor $editor) { '#placeholder' => t('width'), '#field_suffix' => ' x ', '#states' => $show_if_image_uploads_enabled, - ); - $form['max_dimensions']['height'] = array( + ]; + $form['max_dimensions']['height'] = [ '#title' => t('Height'), '#title_display' => 'invisible', '#type' => 'number', @@ -122,7 +122,7 @@ function editor_image_upload_settings_form(Editor $editor) { '#placeholder' => t('height'), '#field_suffix' => t('pixels'), '#states' => $show_if_image_uploads_enabled, - ); + ]; return $form; } diff --git a/core/modules/editor/editor.api.php b/core/modules/editor/editor.api.php index 2fd9fa4..6485a1e 100644 --- a/core/modules/editor/editor.api.php +++ b/core/modules/editor/editor.api.php @@ -36,7 +36,7 @@ function hook_editor_info_alter(array &$editors) { function hook_editor_js_settings_alter(array &$settings) { if (isset($settings['editor']['formats']['basic_html'])) { $settings['editor']['formats']['basic_html']['editor'] = 'MyDifferentEditor'; - $settings['editor']['formats']['basic_html']['editorSettings']['buttons'] = array('strong', 'italic', 'underline'); + $settings['editor']['formats']['basic_html']['editorSettings']['buttons'] = ['strong', 'italic', 'underline']; } } diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index d6fa16c..1966490 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -25,13 +25,13 @@ function editor_help($route_name, RouteMatchInterface $route_match) { case 'help.page.editor': $output = ''; $output .= '

    ' . t('About') . '

    '; - $output .= '

    ' . t('The Text Editor module provides a framework that other modules (such as CKEditor module) can use to provide toolbars and other functionality that allow users to format text more easily than typing HTML tags directly. For more information, see the online documentation for the Text Editor module.', array(':documentation' => 'https://www.drupal.org/documentation/modules/editor', ':ckeditor' => (\Drupal::moduleHandler()->moduleExists('ckeditor')) ? \Drupal::url('help.page', array('name' => 'ckeditor')) : '#')) . '

    '; + $output .= '

    ' . t('The Text Editor module provides a framework that other modules (such as CKEditor module) can use to provide toolbars and other functionality that allow users to format text more easily than typing HTML tags directly. For more information, see the online documentation for the Text Editor module.', [':documentation' => 'https://www.drupal.org/documentation/modules/editor', ':ckeditor' => (\Drupal::moduleHandler()->moduleExists('ckeditor')) ? \Drupal::url('help.page', ['name' => 'ckeditor']) : '#']) . '

    '; $output .= '

    ' . t('Uses') . '

    '; $output .= '
    '; $output .= '
    ' . t('Installing text editors') . '
    '; - $output .= '
    ' . t('The Text Editor module provides a framework for managing editors. To use it, you also need to enable a text editor. This can either be the core CKEditor module, which can be enabled on the Extend page, or a contributed module for any other text editor. When installing a contributed text editor module, be sure to check the installation instructions, because you will most likely need to download and install an external library as well as the Drupal module.', array(':ckeditor' => (\Drupal::moduleHandler()->moduleExists('ckeditor')) ? \Drupal::url('help.page', array('name' => 'ckeditor')) : '#', ':extend' => \Drupal::url('system.modules_list'))) . '
    '; + $output .= '
    ' . t('The Text Editor module provides a framework for managing editors. To use it, you also need to enable a text editor. This can either be the core CKEditor module, which can be enabled on the Extend page, or a contributed module for any other text editor. When installing a contributed text editor module, be sure to check the installation instructions, because you will most likely need to download and install an external library as well as the Drupal module.', [':ckeditor' => (\Drupal::moduleHandler()->moduleExists('ckeditor')) ? \Drupal::url('help.page', ['name' => 'ckeditor']) : '#', ':extend' => \Drupal::url('system.modules_list')]) . '
    '; $output .= '
    ' . t('Enabling a text editor for a text format') . '
    '; - $output .= '
    ' . t('On the Text formats and editors page you can see which text editor is associated with each text format. You can change this by clicking on the Configure link, and then choosing a text editor or none from the Text editor drop-down list. The text editor will then be displayed with any text field for which this text format is chosen.', array(':formats' => \Drupal::url('filter.admin_overview'))) . '
    '; + $output .= '
    ' . t('On the Text formats and editors page you can see which text editor is associated with each text format. You can change this by clicking on the Configure link, and then choosing a text editor or none from the Text editor drop-down list. The text editor will then be displayed with any text field for which this text format is chosen.', [':formats' => \Drupal::url('filter.admin_overview')]) . '
    '; $output .= '
    ' . t('Configuring a text editor') . '
    '; $output .= '
    ' . t('Once a text editor is associated with a text format, you can configure it by clicking on the Configure link for this format. Depending on the specific text editor, you can configure it for example by adding buttons to its toolbar. Typically these buttons provide formatting or editing tools, and they often insert HTML tags into the field source. For details, see the help page of the specific text editor.') . '
    '; $output .= '
    ' . t('Using different text editors and formats') . '
    '; @@ -86,7 +86,7 @@ function editor_form_filter_admin_overview_alter(&$form, FormStateInterface $for // @todo Cleanup column injection: https://www.drupal.org/node/1876718. // Splice in the column for "Text editor" into the header. $position = array_search('name', $form['formats']['#header']) + 1; - $start = array_splice($form['formats']['#header'], 0, $position, array('editor' => t('Text editor'))); + $start = array_splice($form['formats']['#header'], 0, $position, ['editor' => t('Text editor')]); $form['formats']['#header'] = array_merge($start, $form['formats']['#header']); // Then splice in the name of each text editor for each text format. @@ -94,7 +94,7 @@ function editor_form_filter_admin_overview_alter(&$form, FormStateInterface $for foreach (Element::children($form['formats']) as $format_id) { $editor = editor_load($format_id); $editor_name = ($editor && isset($editors[$editor->getEditor()])) ? $editors[$editor->getEditor()]['label'] : '—'; - $editor_column['editor'] = array('#markup' => $editor_name); + $editor_column['editor'] = ['#markup' => $editor_name]; $position = array_search('name', array_keys($form['formats'][$format_id])) + 1; $start = array_splice($form['formats'][$format_id], 0, $position, $editor_column); $form['formats'][$format_id] = array_merge($start, $form['formats'][$format_id]); @@ -116,37 +116,37 @@ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_s // Associate a text editor with this text format. $manager = \Drupal::service('plugin.manager.editor'); $editor_options = $manager->listOptions(); - $form['editor'] = array( + $form['editor'] = [ // Position the editor selection before the filter settings (weight of 0), // but after the filter label and name (weight of -20). '#weight' => -9, - ); - $form['editor']['editor'] = array( + ]; + $form['editor']['editor'] = [ '#type' => 'select', '#title' => t('Text editor'), '#options' => $editor_options, '#empty_option' => t('None'), '#default_value' => $editor ? $editor->getEditor() : '', - '#ajax' => array( - 'trigger_as' => array('name' => 'editor_configure'), + '#ajax' => [ + 'trigger_as' => ['name' => 'editor_configure'], 'callback' => 'editor_form_filter_admin_form_ajax', 'wrapper' => 'editor-settings-wrapper', - ), + ], '#weight' => -10, - ); - $form['editor']['configure'] = array( + ]; + $form['editor']['configure'] = [ '#type' => 'submit', '#name' => 'editor_configure', '#value' => t('Configure'), - '#limit_validation_errors' => array(array('editor')), - '#submit' => array('editor_form_filter_admin_format_editor_configure'), - '#ajax' => array( + '#limit_validation_errors' => [['editor']], + '#submit' => ['editor_form_filter_admin_format_editor_configure'], + '#ajax' => [ 'callback' => 'editor_form_filter_admin_form_ajax', 'wrapper' => 'editor-settings-wrapper', - ), + ], '#weight' => -10, - '#attributes' => array('class' => array('js-hide')), - ); + '#attributes' => ['class' => ['js-hide']], + ]; // If there aren't any options (other than "None"), disable the select list. if (empty($editor_options)) { @@ -154,26 +154,26 @@ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_s $form['editor']['editor']['#description'] = t('This option is disabled because no modules that provide a text editor are currently enabled.'); } - $form['editor']['settings'] = array( + $form['editor']['settings'] = [ '#tree' => TRUE, '#weight' => -8, '#type' => 'container', '#id' => 'editor-settings-wrapper', - '#attached' => array( - 'library' => array( + '#attached' => [ + 'library' => [ 'editor/drupal.editor.admin', - ), - ), - ); + ], + ], + ]; // Add editor-specific validation and submit handlers. if ($editor) { $plugin = $manager->createInstance($editor->getEditor()); - $settings_form = array(); - $settings_form['#element_validate'][] = array($plugin, 'settingsFormValidate'); + $settings_form = []; + $settings_form['#element_validate'][] = [$plugin, 'settingsFormValidate']; $form['editor']['settings']['subform'] = $plugin->settingsForm($settings_form, $form_state, $editor); - $form['editor']['settings']['subform']['#parents'] = array('editor', 'settings'); - $form['actions']['submit']['#submit'][] = array($plugin, 'settingsFormSubmit'); + $form['editor']['settings']['subform']['#parents'] = ['editor', 'settings']; + $form['actions']['submit']['#submit'][] = [$plugin, 'settingsFormSubmit']; } $form['#validate'][] = 'editor_form_filter_admin_format_validate'; @@ -185,7 +185,7 @@ function editor_form_filter_format_form_alter(&$form, FormStateInterface $form_s */ function editor_form_filter_admin_format_editor_configure($form, FormStateInterface $form_state) { $editor = $form_state->get('editor'); - $editor_value = $form_state->getValue(array('editor', 'editor')); + $editor_value = $form_state->getValue(['editor', 'editor']); if ($editor_value !== NULL) { if ($editor_value === '') { $form_state->set('editor', FALSE); @@ -235,7 +235,7 @@ function editor_form_filter_admin_format_submit($form, FormStateInterface $form_ $format = $form_state->getFormObject()->getEntity(); $format_id = $format->isNew() ? NULL : $format->id(); $original_editor = editor_load($format_id); - if ($original_editor && $original_editor->getEditor() != $form_state->getValue(array('editor', 'editor'))) { + if ($original_editor && $original_editor->getEditor() != $form_state->getValue(['editor', 'editor'])) { $original_editor->delete(); } @@ -477,7 +477,7 @@ function _editor_delete_file_usage(array $uuids, EntityInterface $entity, $count * An array of file entity UUIDs. */ function _editor_get_file_uuids_by_field(EntityInterface $entity) { - $uuids = array(); + $uuids = []; $formatted_text_fields = _editor_get_formatted_text_fields($entity); foreach ($formatted_text_fields as $formatted_text_field) { @@ -506,12 +506,12 @@ function _editor_get_file_uuids_by_field(EntityInterface $entity) { function _editor_get_formatted_text_fields(FieldableEntityInterface $entity) { $field_definitions = $entity->getFieldDefinitions(); if (empty($field_definitions)) { - return array(); + return []; } // Only return formatted text fields. return array_keys(array_filter($field_definitions, function (FieldDefinitionInterface $definition) { - return in_array($definition->getType(), array('text', 'text_long', 'text_with_summary'), TRUE); + return in_array($definition->getType(), ['text', 'text_long', 'text_with_summary'], TRUE); })); } @@ -528,7 +528,7 @@ function _editor_get_formatted_text_fields(FieldableEntityInterface $entity) { function _editor_parse_file_uuids($text) { $dom = Html::load($text); $xpath = new \DOMXPath($dom); - $uuids = array(); + $uuids = []; foreach ($xpath->query('//*[@data-entity-type="file" and @data-entity-uuid]') as $node) { $uuids[] = $node->getAttribute('data-entity-uuid'); } diff --git a/core/modules/editor/src/Ajax/EditorDialogSave.php b/core/modules/editor/src/Ajax/EditorDialogSave.php index b4d1c27..48a7867 100644 --- a/core/modules/editor/src/Ajax/EditorDialogSave.php +++ b/core/modules/editor/src/Ajax/EditorDialogSave.php @@ -33,10 +33,10 @@ public function __construct($values) { * {@inheritdoc} */ public function render() { - return array( + return [ 'command' => 'editorDialogSave', 'values' => $this->values, - ); + ]; } } diff --git a/core/modules/editor/src/EditorController.php b/core/modules/editor/src/EditorController.php index 2ef0b04..995ff7c 100644 --- a/core/modules/editor/src/EditorController.php +++ b/core/modules/editor/src/EditorController.php @@ -38,7 +38,7 @@ public function getUntransformedText(EntityInterface $entity, $field_name, $lang // Direct text editing is only supported for single-valued fields. $field = $entity->getTranslation($langcode)->$field_name; - $editable_text = check_markup($field->value, $field->format, $langcode, array(FilterInterface::TYPE_TRANSFORM_REVERSIBLE, FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE)); + $editable_text = check_markup($field->value, $field->format, $langcode, [FilterInterface::TYPE_TRANSFORM_REVERSIBLE, FilterInterface::TYPE_TRANSFORM_IRREVERSIBLE]); $response->addCommand(new GetUntransformedTextCommand($editable_text)); return $response; diff --git a/core/modules/editor/src/EditorXssFilter/Standard.php b/core/modules/editor/src/EditorXssFilter/Standard.php index 9a8b2b1..19d5c06 100644 --- a/core/modules/editor/src/EditorXssFilter/Standard.php +++ b/core/modules/editor/src/EditorXssFilter/Standard.php @@ -35,7 +35,7 @@ public static function filterXss($html, FilterFormatInterface $format, FilterFor // directly. // ', ''); + $data[] = ['', '']; // IFRAME Event based. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#IFRAME_Event_based - $data[] = array('', ''); + $data[] = ['', '']; // FRAME. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#FRAME - $data[] = array('', ''); + $data[] = ['', '']; // TABLE. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#TABLE - $data[] = array('', '
    '); + $data[] = ['
    ', '
    ']; // TD. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#TD - $data[] = array('
    ', '
    '); + $data[] = ['
    ', '', 'The th and td tags was printed correctly.'); @@ -156,14 +156,14 @@ function testThemeTableHeaderCellOption() { * Tests that the 'responsive-table' class is applied correctly. */ public function testThemeTableResponsive() { - $header = array('one', 'two', 'three'); - $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)); - $table = array( + $header = ['one', 'two', 'three']; + $rows = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; + $table = [ '#type' => 'table', '#header' => $header, '#rows' => $rows, '#responsive' => TRUE, - ); + ]; $this->render($table); $this->assertRaw('responsive-enabled', 'The responsive-enabled class was printed correctly.'); } @@ -172,12 +172,12 @@ public function testThemeTableResponsive() { * Tests that the 'responsive-table' class is not applied without headers. */ public function testThemeTableNotResponsiveHeaders() { - $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)); - $table = array( + $rows = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; + $table = [ '#type' => 'table', '#rows' => $rows, '#responsive' => TRUE, - ); + ]; $this->render($table); $this->assertNoRaw('responsive-enabled', 'The responsive-enabled class is not applied without table headers.'); } @@ -186,14 +186,14 @@ public function testThemeTableNotResponsiveHeaders() { * Tests that 'responsive-table' class only applied when responsive is TRUE. */ public function testThemeTableNotResponsiveProperty() { - $header = array('one', 'two', 'three'); - $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)); - $table = array( + $header = ['one', 'two', 'three']; + $rows = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; + $table = [ '#type' => 'table', '#header' => $header, '#rows' => $rows, '#responsive' => FALSE, - ); + ]; $this->render($table); $this->assertNoRaw('responsive-enabled', 'The responsive-enabled class is not applied without the "responsive" property set to TRUE.'); } @@ -202,21 +202,21 @@ public function testThemeTableNotResponsiveProperty() { * Tests 'priority-medium' and 'priority-low' classes. */ public function testThemeTableResponsivePriority() { - $header = array( + $header = [ // Test associative header indices. - 'associative_key' => array('data' => 1, 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)), + 'associative_key' => ['data' => 1, 'class' => [RESPONSIVE_PRIORITY_MEDIUM]], // Test non-associative header indices. - array('data' => 2, 'class' => array(RESPONSIVE_PRIORITY_LOW)), + ['data' => 2, 'class' => [RESPONSIVE_PRIORITY_LOW]], // Test no responsive priorities. - array('data' => 3), - ); - $rows = array(array(4, 5, 6)); - $table = array( + ['data' => 3], + ]; + $rows = [[4, 5, 6]]; + $table = [ '#type' => 'table', '#header' => $header, '#rows' => $rows, '#responsive' => TRUE, - ); + ]; $this->render($table); $this->assertRaw('', 'Header 1: the priority-medium class was applied correctly.'); $this->assertRaw('', 'Header 2: the priority-low class was applied correctly.'); @@ -230,28 +230,28 @@ public function testThemeTableResponsivePriority() { * Tests header elements with a mix of string and render array values. */ public function testThemeTableHeaderRenderArray() { - $header = array( - array ( - 'data' => array( + $header = [ + [ + 'data' => [ '#markup' => 'one', - ), - ), + ], + ], 'two', - array ( - 'data' => array( + [ + 'data' => [ '#type' => 'html_tag', '#tag' => 'b', '#value' => 'three', - ), - ), - ); - $rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9)); - $table = array( + ], + ], + ]; + $rows = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; + $table = [ '#type' => 'table', '#header' => $header, '#rows' => $rows, '#responsive' => FALSE, - ); + ]; $this->render($table); $this->removeWhiteSpace(); $this->assertRaw('', 'Table header found.'); @@ -261,37 +261,37 @@ public function testThemeTableHeaderRenderArray() { * Tests row elements with a mix of string and render array values. */ public function testThemeTableRowRenderArray() { - $header = array('one', 'two', 'three'); - $rows = array( - array( + $header = ['one', 'two', 'three']; + $rows = [ + [ '1-one', - array( + [ 'data' => '1-two' - ), + ], '1-three', - ), - array( - array ( - 'data' => array( + ], + [ + [ + 'data' => [ '#markup' => '2-one', - ), - ), + ], + ], '2-two', - array ( - 'data' => array( + [ + 'data' => [ '#type' => 'html_tag', '#tag' => 'b', '#value' => '2-three', - ), - ), - ), - ); - $table = array( + ], + ], + ], + ]; + $table = [ '#type' => 'table', '#header' => $header, '#rows' => $rows, '#responsive' => FALSE, - ); + ]; $this->render($table); $this->removeWhiteSpace(); $this->assertRaw('', 'Table row 1 found.'); diff --git a/core/tests/Drupal/KernelTests/Core/Render/RenderTest.php b/core/tests/Drupal/KernelTests/Core/Render/RenderTest.php index 8860c19..88f993e 100644 --- a/core/tests/Drupal/KernelTests/Core/Render/RenderTest.php +++ b/core/tests/Drupal/KernelTests/Core/Render/RenderTest.php @@ -16,7 +16,7 @@ class RenderTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'common_test'); + public static $modules = ['system', 'common_test']; /** * Tests theme preprocess functions being able to attach assets. diff --git a/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php b/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php index 7c06df0..d7e798e 100644 --- a/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php +++ b/core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php @@ -123,9 +123,9 @@ public function testDump() { $this->fixtures->createTables($connection); - $dumper->dump(array('provider' => 'test')); + $dumper->dump(['provider' => 'test']); - $record = $connection->query("SELECT * FROM {test_routes} WHERE name= :name", array(':name' => 'test_route'))->fetchObject(); + $record = $connection->query("SELECT * FROM {test_routes} WHERE name= :name", [':name' => 'test_route'])->fetchObject(); $loaded_route = unserialize($record->route); @@ -153,15 +153,15 @@ public function testMenuMasksGeneration() { $this->fixtures->createTables($connection); - $dumper->dump(array('provider' => 'test')); + $dumper->dump(['provider' => 'test']); // Using binary for readability, we expect a 0 at any wildcard slug. They // should be ordered from longest to shortest. - $expected = array( + $expected = [ bindec('1011111'), bindec('10111'), bindec('111'), bindec('101'), - ); + ]; $this->assertEqual($this->state->get('routing.menu_masks.test_routes'), $expected); } diff --git a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php index 710d82f..9d6dae2 100644 --- a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php +++ b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php @@ -115,7 +115,7 @@ public function testCandidateOutlines() { $connection = Database::getConnection(); $provider = new TestRouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes'); - $parts = array('node', '5', 'edit'); + $parts = ['node', '5', 'edit']; $candidates = $provider->getCandidateOutlines($parts); @@ -232,9 +232,9 @@ function testOutlinePathMatchDefaults() { $this->fixtures->createTables($connection); $collection = new RouteCollection(); - $collection->add('poink', new Route('/some/path/{value}', array( + $collection->add('poink', new Route('/some/path/{value}', [ 'value' => 'poink', - ))); + ])); $dumper = new MatcherDumper($connection, $this->state, 'test_routes'); $dumper->addRoutes($collection); @@ -270,9 +270,9 @@ function testOutlinePathMatchDefaultsCollision() { $this->fixtures->createTables($connection); $collection = new RouteCollection(); - $collection->add('poink', new Route('/some/path/{value}', array( + $collection->add('poink', new Route('/some/path/{value}', [ 'value' => 'poink', - ))); + ])); $collection->add('narf', new Route('/some/path/here')); $dumper = new MatcherDumper($connection, $this->state, 'test_routes'); @@ -309,9 +309,9 @@ function testOutlinePathMatchDefaultsCollision2() { $this->fixtures->createTables($connection); $collection = new RouteCollection(); - $collection->add('poink', new Route('/some/path/{value}', array( + $collection->add('poink', new Route('/some/path/{value}', [ 'value' => 'poink', - ))); + ])); $collection->add('narf', new Route('/some/path/here')); $collection->add('eep', new Route('/something/completely/different')); @@ -328,7 +328,7 @@ function testOutlinePathMatchDefaultsCollision2() { $routes_array = $routes->all(); $this->assertEqual(count($routes), 2, 'The correct number of routes was found.'); - $this->assertEqual(array('narf', 'poink'), array_keys($routes_array), 'Ensure the fitness was taken into account.'); + $this->assertEqual(['narf', 'poink'], array_keys($routes_array), 'Ensure the fitness was taken into account.'); $this->assertNotNull($routes->get('narf'), 'The first matching route was found.'); $this->assertNotNull($routes->get('poink'), 'The second matching route was found.'); $this->assertNull($routes->get('eep'), 'Non-matching route was not found.'); @@ -367,7 +367,7 @@ function testOutlinePathMatchDefaultsCollision3() { $routes_array = $routes->all(); $this->assertEqual(count($routes), 2, 'The correct number of routes was found.'); - $this->assertEqual(array('poink', 'poink2'), array_keys($routes_array), 'Ensure the fitness and name were taken into account in the sort.'); + $this->assertEqual(['poink', 'poink2'], array_keys($routes_array), 'Ensure the fitness and name were taken into account in the sort.'); $this->assertNotNull($routes->get('poink'), 'The first matching route was found.'); $this->assertNotNull($routes->get('poink2'), 'The second matching route was found.'); $this->assertNull($routes->get('eep'), 'Non-matching route was not found.'); @@ -528,7 +528,7 @@ public function testRouteByName() { } $this->assertTrue($exception_thrown, 'Random route was not found.'); - $routes = $provider->getRoutesByNames(array('route_c', 'route_d', $this->randomMachineName())); + $routes = $provider->getRoutesByNames(['route_c', 'route_d', $this->randomMachineName()]); $this->assertEqual(count($routes), 2, 'Only two valid routes found.'); $this->assertEqual($routes['route_c']->getPath(), '/path/two'); $this->assertEqual($routes['route_d']->getPath(), '/path/three'); diff --git a/core/tests/Drupal/KernelTests/Core/Routing/UrlIntegrationTest.php b/core/tests/Drupal/KernelTests/Core/Routing/UrlIntegrationTest.php index a70cc1f..053db79 100644 --- a/core/tests/Drupal/KernelTests/Core/Routing/UrlIntegrationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Routing/UrlIntegrationTest.php @@ -19,7 +19,7 @@ class UrlIntegrationTest extends KernelTestBase { * * @var array */ - public static $modules = array('user', 'router_test', 'system'); + public static $modules = ['user', 'router_test', 'system']; /** * Ensures that the access() method on \Drupal\Core\Url objects works. diff --git a/core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php b/core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php index 2995c97..011dfb7 100644 --- a/core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php +++ b/core/tests/Drupal/KernelTests/Core/ServiceProvider/ServiceProviderTest.php @@ -16,7 +16,7 @@ class ServiceProviderTest extends KernelTestBase { * * @var array */ - public static $modules = array('file', 'service_provider_test', 'system'); + public static $modules = ['file', 'service_provider_test', 'system']; /** * Tests that services provided by module service providers get registered to the DIC. @@ -32,11 +32,11 @@ function testServiceProviderRegistration() { */ function testServiceProviderRegistrationDynamic() { // Uninstall the module and ensure the service provider's service is not registered. - \Drupal::service('module_installer')->uninstall(array('service_provider_test')); + \Drupal::service('module_installer')->uninstall(['service_provider_test']); $this->assertFalse(\Drupal::hasService('service_provider_test_class'), 'The service_provider_test_class service does not exist in the DIC.'); // Install the module and ensure the service provider's service is registered. - \Drupal::service('module_installer')->install(array('service_provider_test')); + \Drupal::service('module_installer')->install(['service_provider_test']); $this->assertTrue(\Drupal::hasService('service_provider_test_class'), 'The service_provider_test_class service exists in the DIC.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Session/AccountSwitcherTest.php b/core/tests/Drupal/KernelTests/Core/Session/AccountSwitcherTest.php index 0e6fa8a..0492d77 100644 --- a/core/tests/Drupal/KernelTests/Core/Session/AccountSwitcherTest.php +++ b/core/tests/Drupal/KernelTests/Core/Session/AccountSwitcherTest.php @@ -20,7 +20,7 @@ public function testAccountSwitching() { $original_session_saving = $session_handler->isSessionWritable(); // Switch to user with uid 2. - $switcher->switchTo(new UserSession(array('uid' => 2))); + $switcher->switchTo(new UserSession(['uid' => 2])); // Verify that the active user has changed, and that session saving is // disabled. @@ -28,7 +28,7 @@ public function testAccountSwitching() { $this->assertFalse($session_handler->isSessionWritable(), 'Session saving is disabled.'); // Perform a second (nested) user account switch. - $switcher->switchTo(new UserSession(array('uid' => 3))); + $switcher->switchTo(new UserSession(['uid' => 3])); $this->assertEqual($user->id(), 3, 'Switched to user 3.'); // Revert to the user session that was active between the first and second diff --git a/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php b/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php index 948236b..a015d07 100644 --- a/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php +++ b/core/tests/Drupal/KernelTests/Core/Site/SettingsRewriteTest.php @@ -18,83 +18,83 @@ class SettingsRewriteTest extends KernelTestBase { function testDrupalRewriteSettings() { include_once \Drupal::root() . '/core/includes/install.inc'; $site_path = $this->container->get('site.path'); - $tests = array( - array( + $tests = [ + [ 'original' => '$no_index_value_scalar = TRUE;', - 'settings' => array( - 'no_index_value_scalar' => (object) array( + 'settings' => [ + 'no_index_value_scalar' => (object) [ 'value' => FALSE, 'comment' => 'comment', - ), - ), + ], + ], 'expected' => '$no_index_value_scalar = false; // comment', - ), - array( + ], + [ 'original' => '$no_index_value_scalar = TRUE;', - 'settings' => array( - 'no_index_value_foo' => array( - 'foo' => array( - 'value' => (object) array( + 'settings' => [ + 'no_index_value_foo' => [ + 'foo' => [ + 'value' => (object) [ 'value' => NULL, 'required' => TRUE, 'comment' => 'comment', - ), - ), - ), - ), + ], + ], + ], + ], 'expected' => <<<'EXPECTED' $no_index_value_scalar = TRUE; $no_index_value_foo['foo']['value'] = NULL; // comment EXPECTED - ), - array( + ], + [ 'original' => '$no_index_value_array = array("old" => "value");', - 'settings' => array( - 'no_index_value_array' => (object) array( + 'settings' => [ + 'no_index_value_array' => (object) [ 'value' => FALSE, 'required' => TRUE, 'comment' => 'comment', - ), - ), + ], + ], 'expected' => '$no_index_value_array = array("old" => "value"); $no_index_value_array = false; // comment', - ), - array( + ], + [ 'original' => '$has_index_value_scalar["foo"]["bar"] = NULL;', - 'settings' => array( - 'has_index_value_scalar' => array( - 'foo' => array( - 'bar' => (object) array( + 'settings' => [ + 'has_index_value_scalar' => [ + 'foo' => [ + 'bar' => (object) [ 'value' => FALSE, 'required' => TRUE, 'comment' => 'comment', - ), - ), - ), - ), + ], + ], + ], + ], 'expected' => '$has_index_value_scalar["foo"]["bar"] = false; // comment', - ), - array( + ], + [ 'original' => '$has_index_value_scalar["foo"]["bar"] = "foo";', - 'settings' => array( - 'has_index_value_scalar' => array( - 'foo' => array( - 'value' => (object) array( - 'value' => array('value' => 2), + 'settings' => [ + 'has_index_value_scalar' => [ + 'foo' => [ + 'value' => (object) [ + 'value' => ['value' => 2], 'required' => TRUE, 'comment' => 'comment', - ), - ), - ), - ), + ], + ], + ], + ], 'expected' => <<<'EXPECTED' $has_index_value_scalar["foo"]["bar"] = "foo"; $has_index_value_scalar['foo']['value'] = array ( 'value' => 2, ); // comment EXPECTED - ), - ); + ], + ]; foreach ($tests as $test) { $filename = Settings::get('file_public_path', $site_path . '/files') . '/mock_settings.php'; file_put_contents($filename, " array( - 'no_index' => (object) array( + $test = [ + 'settings' => [ + 'no_index' => (object) [ 'value' => TRUE, 'required' => TRUE, - ), - ), + ], + ], 'expected' => '$no_index = true;' - ); + ]; // Make an empty file. $filename = Settings::get('file_public_path', $site_path . '/files') . '/mock_settings.php'; file_put_contents($filename, ""); diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php index 51608eb..dd8ef7c 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/ImageTest.php @@ -17,7 +17,7 @@ class ImageTest extends KernelTestBase { * * @var array */ - public static $modules = array('system'); + public static $modules = ['system']; /* * The images to test with. @@ -36,10 +36,10 @@ protected function setUp() { $this->container = \Drupal::service('kernel')->getContainer(); $this->container->get('request_stack')->push($request); - $this->testImages = array( + $this->testImages = [ 'core/misc/druplicon.png', 'core/misc/loading.gif', - ); + ]; } /** @@ -48,7 +48,7 @@ protected function setUp() { function testThemeImageWithSizes() { // Test with multipliers. $sizes = '(max-width: ' . rand(10, 30) . 'em) 100vw, (max-width: ' . rand(30, 50) . 'em) 50vw, 30vw'; - $image = array( + $image = [ '#theme' => 'image', '#sizes' => $sizes, '#uri' => reset($this->testImages), @@ -56,7 +56,7 @@ function testThemeImageWithSizes() { '#height' => rand(0, 500) . 'px', '#alt' => $this->randomMachineName(), '#title' => $this->randomMachineName(), - ); + ]; $this->render($image); // Make sure sizes is set. @@ -68,14 +68,14 @@ function testThemeImageWithSizes() { */ function testThemeImageWithSrc() { - $image = array( + $image = [ '#theme' => 'image', '#uri' => reset($this->testImages), '#width' => rand(0, 1000) . 'px', '#height' => rand(0, 500) . 'px', '#alt' => $this->randomMachineName(), '#title' => $this->randomMachineName(), - ); + ]; $this->render($image); // Make sure the src attribute has the correct value. @@ -87,23 +87,23 @@ function testThemeImageWithSrc() { */ function testThemeImageWithSrcsetMultiplier() { // Test with multipliers. - $image = array( + $image = [ '#theme' => 'image', - '#srcset' => array( - array( + '#srcset' => [ + [ 'uri' => $this->testImages[0], 'multiplier' => '1x', - ), - array( + ], + [ 'uri' => $this->testImages[1], 'multiplier' => '2x', - ), - ), + ], + ], '#width' => rand(0, 1000) . 'px', '#height' => rand(0, 500) . 'px', '#alt' => $this->randomMachineName(), '#title' => $this->randomMachineName(), - ); + ]; $this->render($image); // Make sure the srcset attribute has the correct value. @@ -115,27 +115,27 @@ function testThemeImageWithSrcsetMultiplier() { */ function testThemeImageWithSrcsetWidth() { // Test with multipliers. - $widths = array( + $widths = [ rand(0, 500) . 'w', rand(500, 1000) . 'w', - ); - $image = array( + ]; + $image = [ '#theme' => 'image', - '#srcset' => array( - array( + '#srcset' => [ + [ 'uri' => $this->testImages[0], 'width' => $widths[0], - ), - array( + ], + [ 'uri' => $this->testImages[1], 'width' => $widths[1], - ), - ), + ], + ], '#width' => rand(0, 1000) . 'px', '#height' => rand(0, 500) . 'px', '#alt' => $this->randomMachineName(), '#title' => $this->randomMachineName(), - ); + ]; $this->render($image); // Make sure the srcset attribute has the correct value. diff --git a/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php b/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php index a9d6150..985a57a 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/MessageTest.php @@ -14,7 +14,7 @@ class MessageTest extends KernelTestBase { /** * {@inheritdoc} */ - public static $modules = array('system'); + public static $modules = ['system']; /** * Tests setting messages output. @@ -26,9 +26,9 @@ function testMessages() { drupal_set_message('An error occurred', 'error'); drupal_set_message('But then something nice happened'); - $messages = array( + $messages = [ '#type' => 'status_messages', - ); + ]; $this->render($messages); $this->assertRaw('messages messages--error'); $this->assertRaw('messages messages--status'); diff --git a/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php b/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php index 257c61e..5024058 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/RegistryTest.php @@ -18,7 +18,7 @@ class RegistryTest extends KernelTestBase { * * @var array */ - public static $modules = array('theme_test', 'system'); + public static $modules = ['theme_test', 'system']; protected $profile = 'testing'; @@ -35,7 +35,7 @@ function testRaceCondition() { // entry to be written in __construct(). $cache = \Drupal::cache(); $lock_backend = \Drupal::lock(); - $registry = new ThemeRegistry($cid, $cache, $lock_backend, array('theme_registry'), $this->container->get('module_handler')->isLoaded()); + $registry = new ThemeRegistry($cid, $cache, $lock_backend, ['theme_registry'], $this->container->get('module_handler')->isLoaded()); $this->assertTrue(\Drupal::cache()->get($cid), 'Cache entry was created.'); @@ -55,7 +55,7 @@ function testRaceCondition() { // Create a new instance of the class. Confirm that both the offset // requested previously, and one that has not yet been requested are both // available. - $registry = new ThemeRegistry($cid, $cache, $lock_backend, array('theme_registry'), $this->container->get('module_handler')->isLoaded()); + $registry = new ThemeRegistry($cid, $cache, $lock_backend, ['theme_registry'], $this->container->get('module_handler')->isLoaded()); $this->assertTrue($registry->get('theme_test_template_test'), 'Offset was returned correctly from the theme registry'); $this->assertTrue($registry->get('theme_test_template_test_2'), 'Offset was returned correctly from the theme registry'); } diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php index f3e2ade..cbaf0a3 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeInstallerTest.php @@ -18,7 +18,7 @@ class ThemeInstallerTest extends KernelTestBase { * * @var array */ - public static $modules = array('system'); + public static $modules = ['system']; /** * {@inheritdoc} @@ -33,7 +33,7 @@ public function register(ContainerBuilder $container) { protected function setUp() { parent::setUp(); - $this->installConfig(array('system')); + $this->installConfig(['system']); } /** @@ -61,7 +61,7 @@ function testInstall() { $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name])); - $this->themeInstaller()->install(array($name)); + $this->themeInstaller()->install([$name]); $this->assertIdentical($this->extensionConfig()->get("theme.$name"), 0); @@ -87,13 +87,13 @@ function testInstallSubTheme() { $themes = $this->themeHandler()->listInfo(); $this->assertFalse(array_keys($themes)); - $this->themeInstaller()->install(array($name)); + $this->themeInstaller()->install([$name]); $themes = $this->themeHandler()->listInfo(); $this->assertTrue(isset($themes[$name])); $this->assertTrue(isset($themes[$base_name])); - $this->themeInstaller()->uninstall(array($name)); + $this->themeInstaller()->uninstall([$name]); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name])); @@ -111,7 +111,7 @@ function testInstallNonExisting() { try { $message = 'ThemeHandler::install() throws InvalidArgumentException upon installing a non-existing theme.'; - $this->themeInstaller()->install(array($name)); + $this->themeInstaller()->install([$name]); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -130,7 +130,7 @@ function testInstallNameTooLong() { try { $message = 'ThemeHandler::install() throws ExtensionNameLengthException upon installing a theme with a too long name.'; - $this->themeInstaller()->install(array($name)); + $this->themeInstaller()->install([$name]); $this->fail($message); } catch (ExtensionNameLengthException $e) { @@ -144,7 +144,7 @@ function testInstallNameTooLong() { function testUninstallDefault() { $name = 'stark'; $other_name = 'bartik'; - $this->themeInstaller()->install(array($name, $other_name)); + $this->themeInstaller()->install([$name, $other_name]); $this->config('system.theme')->set('default', $name)->save(); $themes = $this->themeHandler()->listInfo(); @@ -153,7 +153,7 @@ function testUninstallDefault() { try { $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon disabling default theme.'; - $this->themeHandler()->uninstall(array($name)); + $this->themeHandler()->uninstall([$name]); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -171,7 +171,7 @@ function testUninstallDefault() { function testUninstallAdmin() { $name = 'stark'; $other_name = 'bartik'; - $this->themeInstaller()->install(array($name, $other_name)); + $this->themeInstaller()->install([$name, $other_name]); $this->config('system.theme')->set('admin', $name)->save(); $themes = $this->themeHandler()->listInfo(); @@ -180,7 +180,7 @@ function testUninstallAdmin() { try { $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon disabling admin theme.'; - $this->themeHandler()->uninstall(array($name)); + $this->themeHandler()->uninstall([$name]); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -199,8 +199,8 @@ function testUninstallSubTheme() { $name = 'test_subtheme'; $base_name = 'test_basetheme'; - $this->themeInstaller()->install(array($name)); - $this->themeInstaller()->uninstall(array($name)); + $this->themeInstaller()->install([$name]); + $this->themeInstaller()->uninstall([$name]); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name])); @@ -214,11 +214,11 @@ function testUninstallBaseBeforeSubTheme() { $name = 'test_basetheme'; $sub_name = 'test_subtheme'; - $this->themeInstaller()->install(array($sub_name)); + $this->themeInstaller()->install([$sub_name]); try { $message = 'ThemeHandler::install() throws InvalidArgumentException upon uninstalling base theme before sub theme.'; - $this->themeInstaller()->uninstall(array($name)); + $this->themeInstaller()->uninstall([$name]); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -230,7 +230,7 @@ function testUninstallBaseBeforeSubTheme() { $this->assertTrue(isset($themes[$sub_name])); // Verify that uninstalling both at the same time works. - $this->themeInstaller()->uninstall(array($name, $sub_name)); + $this->themeInstaller()->uninstall([$name, $sub_name]); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name])); @@ -248,7 +248,7 @@ function testUninstallNonExisting() { try { $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon uninstalling a non-existing theme.'; - $this->themeInstaller()->uninstall(array($name)); + $this->themeInstaller()->uninstall([$name]); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -265,10 +265,10 @@ function testUninstallNonExisting() { function testUninstall() { $name = 'test_basetheme'; - $this->themeInstaller()->install(array($name)); + $this->themeInstaller()->install([$name]); $this->assertTrue($this->config("$name.settings")->get()); - $this->themeInstaller()->uninstall(array($name)); + $this->themeInstaller()->uninstall([$name]); $this->assertFalse(array_keys($this->themeHandler()->listInfo())); $this->assertFalse(array_keys(system_list('theme'))); @@ -276,7 +276,7 @@ function testUninstall() { $this->assertFalse($this->config("$name.settings")->get()); // Ensure that the uninstalled theme can be installed again. - $this->themeInstaller()->install(array($name)); + $this->themeInstaller()->install([$name]); $themes = $this->themeHandler()->listInfo(); $this->assertTrue(isset($themes[$name])); $this->assertEqual($themes[$name]->getName(), $name); @@ -292,7 +292,7 @@ function testUninstallNotInstalled() { try { $message = 'ThemeHandler::uninstall() throws InvalidArgumentException upon uninstalling a theme that is not installed.'; - $this->themeInstaller()->uninstall(array($name)); + $this->themeInstaller()->uninstall([$name]); $this->fail($message); } catch (\InvalidArgumentException $e) { @@ -309,7 +309,7 @@ function testThemeInfoAlter() { $name = 'seven'; $this->container->get('state')->set('module_test.hook_system_info_alter', TRUE); - $this->themeInstaller()->install(array($name)); + $this->themeInstaller()->install([$name]); $themes = $this->themeHandler()->listInfo(); $this->assertFalse(isset($themes[$name]->info['regions']['test_region'])); @@ -317,7 +317,7 @@ function testThemeInfoAlter() { // Rebuild module data so we know where module_test is located. // @todo Remove as part of https://www.drupal.org/node/2186491 system_rebuild_module_data(); - $this->moduleInstaller()->install(array('module_test'), FALSE); + $this->moduleInstaller()->install(['module_test'], FALSE); $this->assertTrue($this->moduleHandler()->moduleExists('module_test')); $themes = $this->themeHandler()->listInfo(); @@ -333,7 +333,7 @@ function testThemeInfoAlter() { $system_list = system_list('theme'); $this->assertTrue(isset($system_list[$name]->info['regions']['test_region'])); - $this->moduleInstaller()->uninstall(array('module_test')); + $this->moduleInstaller()->uninstall(['module_test']); $this->assertFalse($this->moduleHandler()->moduleExists('module_test')); $themes = $this->themeHandler()->listInfo(); diff --git a/core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php b/core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php index 6c2dfb3..d74df14 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php @@ -18,7 +18,7 @@ class ThemeSettingsTest extends KernelTestBase { * * @var array */ - public static $modules = array('system'); + public static $modules = ['system']; /** * List of discovered themes. @@ -30,7 +30,7 @@ class ThemeSettingsTest extends KernelTestBase { protected function setUp() { parent::setUp(); // Theme settings rely on System module's system.theme.global configuration. - $this->installConfig(array('system')); + $this->installConfig(['system']); if (!isset($this->availableThemes)) { $discovery = new ExtensionDiscovery(\Drupal::root()); @@ -45,7 +45,7 @@ function testDefaultConfig() { $name = 'test_basetheme'; $path = $this->availableThemes[$name]->getPath(); $this->assertTrue(file_exists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml")); - $this->container->get('theme_handler')->install(array($name)); + $this->container->get('theme_handler')->install([$name]); $this->assertIdentical(theme_get_setting('base', $name), 'only'); } @@ -56,7 +56,7 @@ function testNoDefaultConfig() { $name = 'stark'; $path = $this->availableThemes[$name]->getPath(); $this->assertFalse(file_exists("$path/" . InstallStorage::CONFIG_INSTALL_DIRECTORY . "/$name.settings.yml")); - $this->container->get('theme_handler')->install(array($name)); + $this->container->get('theme_handler')->install([$name]); $this->assertNotNull(theme_get_setting('features.favicon', $name)); } diff --git a/core/tests/Drupal/KernelTests/Core/Theme/TwigEnvironmentTest.php b/core/tests/Drupal/KernelTests/Core/Theme/TwigEnvironmentTest.php index deaf033..6cf851b 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/TwigEnvironmentTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/TwigEnvironmentTest.php @@ -19,7 +19,7 @@ class TwigEnvironmentTest extends KernelTestBase { * * @var array */ - public static $modules = array('system'); + public static $modules = ['system']; /** * Tests inline templates. @@ -30,15 +30,15 @@ public function testInlineTemplate() { /** @var \Drupal\Core\Template\TwigEnvironment $environment */ $environment = \Drupal::service('twig'); $this->assertEqual($environment->renderInline('test-no-context'), 'test-no-context'); - $this->assertEqual($environment->renderInline('test-with-context {{ llama }}', array('llama' => 'muuh')), 'test-with-context muuh'); + $this->assertEqual($environment->renderInline('test-with-context {{ llama }}', ['llama' => 'muuh']), 'test-with-context muuh'); - $element = array(); + $element = []; $unsafe_string = ''; - $element['test'] = array( + $element['test'] = [ '#type' => 'inline_template', '#template' => 'test-with-context ', - '#context' => array('unsafe_content' => $unsafe_string), - ); + '#context' => ['unsafe_content' => $unsafe_string], + ]; $this->assertEqual($renderer->renderRoot($element), 'test-with-context '); // Enable twig_auto_reload and twig_debug. @@ -50,12 +50,12 @@ public function testInlineTemplate() { $this->container = \Drupal::service('kernel')->rebuildContainer(); \Drupal::setContainer($this->container); - $element = array(); - $element['test'] = array( + $element = []; + $element['test'] = [ '#type' => 'inline_template', '#template' => 'test-with-context {{ llama }}', - '#context' => array('llama' => 'muuh'), - ); + '#context' => ['llama' => 'muuh'], + ]; $element_copy = $element; // Render it twice so that twig caching is triggered. $this->assertEqual($renderer->renderRoot($element), 'test-with-context muuh'); @@ -99,7 +99,7 @@ public function testTemplateNotFoundException() { $environment = \Drupal::service('twig'); try { - $environment->loadTemplate('this-template-does-not-exist.html.twig')->render(array()); + $environment->loadTemplate('this-template-does-not-exist.html.twig')->render([]); $this->fail('Did not throw an exception as expected.'); } catch (\Twig_Error_Loader $e) { diff --git a/core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php b/core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php index 2e6e5a4..d30d2de 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/TwigMarkupInterfaceTest.php @@ -90,7 +90,7 @@ protected function renderObjectWithTwig($variable) { $elements = [ '#type' => 'inline_template', '#template' => '{%- if variable is not empty -%}{{ variable }}{%- endif -%}', - '#context' => array('variable' => $variable), + '#context' => ['variable' => $variable], ]; return $renderer->render($elements); }); diff --git a/core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php b/core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php index 41984d6..f0bbb82 100644 --- a/core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php +++ b/core/tests/Drupal/KernelTests/Core/Theme/TwigWhiteListTest.php @@ -42,7 +42,7 @@ class TwigWhiteListTest extends KernelTestBase { */ protected function setUp() { parent::setUp(); - $this->installSchema('system', array('sequences')); + $this->installSchema('system', ['sequences']); $this->installEntitySchema('node'); $this->installEntitySchema('user'); $this->installEntitySchema('taxonomy_term'); @@ -71,38 +71,38 @@ protected function setUp() { $this->term->save(); // Create a field. - $handler_settings = array( - 'target_bundles' => array( + $handler_settings = [ + 'target_bundles' => [ $vocabulary->id() => $vocabulary->id(), - ), + ], 'auto_create' => TRUE, - ); + ]; // Add the term field. - FieldStorageConfig::create(array( + FieldStorageConfig::create([ 'field_name' => 'field_term', 'type' => 'entity_reference', 'entity_type' => 'node', 'cardinality' => 1, - 'settings' => array( + 'settings' => [ 'target_type' => 'taxonomy_term', - ), - ))->save(); - FieldConfig::create(array( + ], + ])->save(); + FieldConfig::create([ 'field_name' => 'field_term', 'entity_type' => 'node', 'bundle' => 'page', 'label' => 'Terms', - 'settings' => array( + 'settings' => [ 'handler' => 'default', 'handler_settings' => $handler_settings, - ), - ))->save(); + ], + ])->save(); // Show on default display and teaser. entity_get_display('node', 'page', 'default') - ->setComponent('field_term', array( + ->setComponent('field_term', [ 'type' => 'entity_reference_label', - )) + ]) ->save(); // Boot twig environment. $this->twig = \Drupal::service('twig'); diff --git a/core/tests/Drupal/KernelTests/Core/TypedData/AllowedValuesConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/TypedData/AllowedValuesConstraintValidatorTest.php index 4a23fbb..05a36ba 100644 --- a/core/tests/Drupal/KernelTests/Core/TypedData/AllowedValuesConstraintValidatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/TypedData/AllowedValuesConstraintValidatorTest.php @@ -32,7 +32,7 @@ protected function setUp() { public function testValidation() { // Create a definition that specifies some AllowedValues. $definition = DataDefinition::create('integer') - ->addConstraint('AllowedValues', array(1, 2, 3)); + ->addConstraint('AllowedValues', [1, 2, 3]); // Test the validation. $typed_data = $this->typedData->create($definition, 1); diff --git a/core/tests/Drupal/KernelTests/Core/TypedData/ComplexDataConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/TypedData/ComplexDataConstraintValidatorTest.php index 078cb7a..bbdf109 100644 --- a/core/tests/Drupal/KernelTests/Core/TypedData/ComplexDataConstraintValidatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/TypedData/ComplexDataConstraintValidatorTest.php @@ -35,19 +35,19 @@ public function testValidation() { // Create a definition that specifies some ComplexData constraint. $definition = MapDataDefinition::create() ->setPropertyDefinition('key', DataDefinition::create('integer')) - ->addConstraint('ComplexData', array( - 'key' => array( - 'AllowedValues' => array(1, 2, 3) - ), - )); + ->addConstraint('ComplexData', [ + 'key' => [ + 'AllowedValues' => [1, 2, 3] + ], + ]); // Test the validation. - $typed_data = $this->typedData->create($definition, array('key' => 1)); + $typed_data = $this->typedData->create($definition, ['key' => 1]); $violations = $typed_data->validate(); $this->assertEqual($violations->count(), 0, 'Validation passed for correct value.'); // Test the validation when an invalid value is passed. - $typed_data = $this->typedData->create($definition, array('key' => 4)); + $typed_data = $this->typedData->create($definition, ['key' => 4]); $violations = $typed_data->validate(); $this->assertEqual($violations->count(), 1, 'Validation failed for incorrect value.'); @@ -59,19 +59,19 @@ public function testValidation() { // Test using the constraint with a map without the specified key. This // should be ignored as long as there is no NotNull or NotBlank constraint. - $typed_data = $this->typedData->create($definition, array('foo' => 'bar')); + $typed_data = $this->typedData->create($definition, ['foo' => 'bar']); $violations = $typed_data->validate(); $this->assertEqual($violations->count(), 0, 'Constraint on non-existing key is ignored.'); $definition = MapDataDefinition::create() ->setPropertyDefinition('key', DataDefinition::create('integer')) - ->addConstraint('ComplexData', array( - 'key' => array( - 'NotNull' => array() - ), - )); + ->addConstraint('ComplexData', [ + 'key' => [ + 'NotNull' => [] + ], + ]); - $typed_data = $this->typedData->create($definition, array('foo' => 'bar')); + $typed_data = $this->typedData->create($definition, ['foo' => 'bar']); $violations = $typed_data->validate(); $this->assertEqual($violations->count(), 1, 'Key is required.'); } diff --git a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataDefinitionTest.php b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataDefinitionTest.php index 4ff9ff6..8aeab57 100644 --- a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataDefinitionTest.php +++ b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataDefinitionTest.php @@ -66,7 +66,7 @@ public function testMaps() { $this->assertTrue($map_definition instanceof ComplexDataDefinitionInterface); // Test retrieving metadata about contained properties. - $this->assertEqual(array_keys($map_definition->getPropertyDefinitions()), array('one', 'two', 'three')); + $this->assertEqual(array_keys($map_definition->getPropertyDefinitions()), ['one', 'two', 'three']); $this->assertEqual($map_definition->getPropertyDefinition('one')->getDataType(), 'string'); $this->assertNull($map_definition->getMainPropertyName()); $this->assertNull($map_definition->getPropertyDefinition('invalid')); diff --git a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php index 08f27b3..c79f2cf 100644 --- a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php +++ b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php @@ -38,7 +38,7 @@ class TypedDataTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'field', 'file', 'user'); + public static $modules = ['system', 'field', 'file', 'user']; protected function setUp() { parent::setup(); @@ -66,7 +66,7 @@ protected function createTypedData($definition, $value = NULL, $name = NULL) { */ public function testGetAndSet() { // Boolean type. - $typed_data = $this->createTypedData(array('type' => 'boolean'), TRUE); + $typed_data = $this->createTypedData(['type' => 'boolean'], TRUE); $this->assertTrue($typed_data instanceof BooleanInterface, 'Typed data object is an instance of BooleanInterface.'); $this->assertTrue($typed_data->getValue() === TRUE, 'Boolean value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); @@ -82,7 +82,7 @@ public function testGetAndSet() { // String type. $value = $this->randomString(); - $typed_data = $this->createTypedData(array('type' => 'string'), $value); + $typed_data = $this->createTypedData(['type' => 'string'], $value); $this->assertTrue($typed_data instanceof StringInterface, 'Typed data object is an instance of StringInterface.'); $this->assertTrue($typed_data->getValue() === $value, 'String value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); @@ -95,12 +95,12 @@ public function testGetAndSet() { $typed_data->setValue(NULL); $this->assertNull($typed_data->getValue(), 'String wrapper is null-able.'); $this->assertEqual($typed_data->validate()->count(), 0); - $typed_data->setValue(array('no string')); + $typed_data->setValue(['no string']); $this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.'); // Integer type. $value = rand(); - $typed_data = $this->createTypedData(array('type' => 'integer'), $value); + $typed_data = $this->createTypedData(['type' => 'integer'], $value); $this->assertTrue($typed_data instanceof IntegerInterface, 'Typed data object is an instance of IntegerInterface.'); $this->assertTrue($typed_data->getValue() === $value, 'Integer value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); @@ -117,7 +117,7 @@ public function testGetAndSet() { // Float type. $value = 123.45; - $typed_data = $this->createTypedData(array('type' => 'float'), $value); + $typed_data = $this->createTypedData(['type' => 'float'], $value); $this->assertTrue($typed_data instanceof FloatInterface, 'Typed data object is an instance of FloatInterface.'); $this->assertTrue($typed_data->getValue() === $value, 'Float value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); @@ -134,7 +134,7 @@ public function testGetAndSet() { // Date Time type. $value = '2014-01-01T20:00:00+00:00'; - $typed_data = $this->createTypedData(array('type' => 'datetime_iso8601'), $value); + $typed_data = $this->createTypedData(['type' => 'datetime_iso8601'], $value); $this->assertTrue($typed_data instanceof DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.'); $this->assertTrue($typed_data->getValue() == $value, 'Date value was fetched.'); $this->assertEqual($typed_data->getValue(), $typed_data->getDateTime()->format('c'), 'Value representation of a date is ISO 8601'); @@ -151,7 +151,7 @@ public function testGetAndSet() { $typed_data->setValue('invalid'); $this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.'); // Check implementation of DateTimeInterface. - $typed_data = $this->createTypedData(array('type' => 'datetime_iso8601'), '2014-01-01T20:00:00+00:00'); + $typed_data = $this->createTypedData(['type' => 'datetime_iso8601'], '2014-01-01T20:00:00+00:00'); $this->assertTrue($typed_data->getDateTime() instanceof DrupalDateTime); $typed_data->setDateTime(new DrupalDateTime('2014-01-02T20:00:00+00:00')); $this->assertEqual($typed_data->getValue(), '2014-01-02T20:00:00+00:00'); @@ -160,7 +160,7 @@ public function testGetAndSet() { // Timestamp type. $value = REQUEST_TIME; - $typed_data = $this->createTypedData(array('type' => 'timestamp'), $value); + $typed_data = $this->createTypedData(['type' => 'timestamp'], $value); $this->assertTrue($typed_data instanceof DateTimeInterface, 'Typed data object is an instance of DateTimeInterface.'); $this->assertTrue($typed_data->getValue() == $value, 'Timestamp value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); @@ -174,7 +174,7 @@ public function testGetAndSet() { $typed_data->setValue('invalid'); $this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.'); // Check implementation of DateTimeInterface. - $typed_data = $this->createTypedData(array('type' => 'timestamp'), REQUEST_TIME); + $typed_data = $this->createTypedData(['type' => 'timestamp'], REQUEST_TIME); $this->assertTrue($typed_data->getDateTime() instanceof DrupalDateTime); $typed_data->setDateTime(DrupalDateTime::createFromTimestamp(REQUEST_TIME + 1)); $this->assertEqual($typed_data->getValue(), REQUEST_TIME + 1); @@ -183,7 +183,7 @@ public function testGetAndSet() { // DurationIso8601 type. $value = 'PT20S'; - $typed_data = $this->createTypedData(array('type' => 'duration_iso8601'), $value); + $typed_data = $this->createTypedData(['type' => 'duration_iso8601'], $value); $this->assertTrue($typed_data instanceof DurationInterface, 'Typed data object is an instance of DurationInterface.'); $this->assertIdentical($typed_data->getValue(), $value, 'DurationIso8601 value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); @@ -197,7 +197,7 @@ public function testGetAndSet() { $typed_data->setValue('invalid'); $this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.'); // Check implementation of DurationInterface. - $typed_data = $this->createTypedData(array('type' => 'duration_iso8601'), 'PT20S'); + $typed_data = $this->createTypedData(['type' => 'duration_iso8601'], 'PT20S'); $this->assertTrue($typed_data->getDuration() instanceof \DateInterval); $typed_data->setDuration(new \DateInterval('P40D')); // @todo: Should we make this "nicer"? @@ -207,7 +207,7 @@ public function testGetAndSet() { // Time span type. $value = 20; - $typed_data = $this->createTypedData(array('type' => 'timespan'), $value); + $typed_data = $this->createTypedData(['type' => 'timespan'], $value); $this->assertTrue($typed_data instanceof DurationInterface, 'Typed data object is an instance of DurationInterface.'); $this->assertIdentical($typed_data->getValue(), $value, 'Time span value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); @@ -221,7 +221,7 @@ public function testGetAndSet() { $typed_data->setValue('invalid'); $this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.'); // Check implementation of DurationInterface. - $typed_data = $this->createTypedData(array('type' => 'timespan'), 20); + $typed_data = $this->createTypedData(['type' => 'timespan'], 20); $this->assertTrue($typed_data->getDuration() instanceof \DateInterval); $typed_data->setDuration(new \DateInterval('PT4H')); $this->assertEqual($typed_data->getValue(), 60 * 60 * 4); @@ -230,7 +230,7 @@ public function testGetAndSet() { // URI type. $uri = 'http://example.com/foo/'; - $typed_data = $this->createTypedData(array('type' => 'uri'), $uri); + $typed_data = $this->createTypedData(['type' => 'uri'], $uri); $this->assertTrue($typed_data instanceof UriInterface, 'Typed data object is an instance of UriInterface.'); $this->assertTrue($typed_data->getValue() === $uri, 'URI value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); @@ -247,7 +247,7 @@ public function testGetAndSet() { $this->assertEqual($typed_data->validate()->count(), 0, 'Filename with spaces is valid.'); // Generate some files that will be used to test the binary data type. - $files = array(); + $files = []; for ($i = 0; $i < 3; $i++) { $path = "public://example_$i.png"; file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', $path); @@ -258,7 +258,7 @@ public function testGetAndSet() { // Email type. $value = $this->randomString(); - $typed_data = $this->createTypedData(array('type' => 'email'), $value); + $typed_data = $this->createTypedData(['type' => 'email'], $value); $this->assertTrue($typed_data instanceof StringInterface, 'Typed data object is an instance of StringInterface.'); $this->assertIdentical($typed_data->getValue(), $value, 'Email value was fetched.'); $new_value = 'test@example.com'; @@ -273,7 +273,7 @@ public function testGetAndSet() { $this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.'); // Binary type. - $typed_data = $this->createTypedData(array('type' => 'binary'), $files[0]->getFileUri()); + $typed_data = $this->createTypedData(['type' => 'binary'], $files[0]->getFileUri()); $this->assertTrue($typed_data instanceof BinaryInterface, 'Typed data object is an instance of BinaryInterface.'); $this->assertTrue(is_resource($typed_data->getValue()), 'Binary value was fetched.'); $this->assertEqual($typed_data->validate()->count(), 0); @@ -294,8 +294,8 @@ public function testGetAndSet() { $this->assertEqual($typed_data->validate()->count(), 1, 'Validation detected invalid value.'); // Any type. - $value = array('foo'); - $typed_data = $this->createTypedData(array('type' => 'any'), $value); + $value = ['foo']; + $typed_data = $this->createTypedData(['type' => 'any'], $value); $this->assertIdentical($typed_data->getValue(), $value, 'Any value was fetched.'); $new_value = 'test@example.com'; $typed_data->setValue($new_value); @@ -307,9 +307,9 @@ public function testGetAndSet() { $this->assertEqual($typed_data->validate()->count(), 0); // We cannot test invalid values as everything is valid for the any type, // but make sure an array or object value passes validation also. - $typed_data->setValue(array('entry')); + $typed_data->setValue(['entry']); $this->assertEqual($typed_data->validate()->count(), 0); - $typed_data->setValue((object) array('entry')); + $typed_data->setValue((object) ['entry']); $this->assertEqual($typed_data->validate()->count(), 0); } @@ -318,7 +318,7 @@ public function testGetAndSet() { */ public function testTypedDataLists() { // Test working with an existing list of strings. - $value = array('one', 'two', 'three'); + $value = ['one', 'two', 'three']; $typed_data = $this->createTypedData(ListDataDefinition::create('string'), $value); $this->assertEqual($typed_data->getValue(), $value, 'List value has been set.'); // Test iterating. @@ -347,14 +347,14 @@ public function testTypedDataLists() { $clone = clone $typed_data; $this->assertTrue($typed_data->getValue() === $clone->getValue()); $this->assertTrue($typed_data[0] !== $clone[0]); - $clone->setValue(array()); + $clone->setValue([]); $this->assertTrue($clone->isEmpty()); // Make sure that resetting the value using NULL results in an empty array. - $clone->setValue(array()); + $clone->setValue([]); $typed_data->setValue(NULL); - $this->assertIdentical($typed_data->getValue(), array()); - $this->assertIdentical($clone->getValue(), array()); + $this->assertIdentical($typed_data->getValue(), []); + $this->assertIdentical($clone->getValue(), []); // Test dealing with NULL items. $typed_data[] = NULL; @@ -367,7 +367,7 @@ public function testTypedDataLists() { $this->assertFalse($typed_data->isEmpty()); $this->assertEqual(count($typed_data), 3); - $this->assertEqual($typed_data->getValue(), array(NULL, '', 'three')); + $this->assertEqual($typed_data->getValue(), [NULL, '', 'three']); // Test unsetting. unset($typed_data[1]); $this->assertEqual(count($typed_data), 2); @@ -379,7 +379,7 @@ public function testTypedDataLists() { $this->assertEqual(count($typed_data), 2); // Test setting the list with less values. - $typed_data->setValue(array('one')); + $typed_data->setValue(['one']); $this->assertEqual($typed_data->count(), 1); // Test setting invalid values. @@ -397,7 +397,7 @@ public function testTypedDataLists() { */ public function testTypedDataListsFilter() { // Check that an all-pass filter leaves the list untouched. - $value = array('zero', 'one'); + $value = ['zero', 'one']; $typed_data = $this->createTypedData(ListDataDefinition::create('string'), $value); $typed_data->filter(function(TypedDataInterface $item) { return TRUE; @@ -409,7 +409,7 @@ public function testTypedDataListsFilter() { $this->assertEqual($typed_data[1]->getName(), 1); // Check that a none-pass filter empties the list. - $value = array('zero', 'one'); + $value = ['zero', 'one']; $typed_data = $this->createTypedData(ListDataDefinition::create('string'), $value); $typed_data->filter(function(TypedDataInterface $item) { return FALSE; @@ -417,7 +417,7 @@ public function testTypedDataListsFilter() { $this->assertEqual($typed_data->count(), 0); // Check that filtering correctly renumbers elements. - $value = array('zero', 'one', 'two'); + $value = ['zero', 'one', 'two']; $typed_data = $this->createTypedData(ListDataDefinition::create('string'), $value); $typed_data->filter(function(TypedDataInterface $item) { return $item->getValue() !== 'one'; @@ -434,11 +434,11 @@ public function testTypedDataListsFilter() { */ public function testTypedDataMaps() { // Test working with a simple map. - $value = array( + $value = [ 'one' => 'eins', 'two' => 'zwei', 'three' => 'drei', - ); + ]; $definition = MapDataDefinition::create() ->setPropertyDefinition('one', DataDefinition::create('string')) ->setPropertyDefinition('two', DataDefinition::create('string')) @@ -467,11 +467,11 @@ public function testTypedDataMaps() { $this->assertEqual($typed_data->get('one')->getValue(), 'uno'); // Make sure the update is reflected in the value of the map also. $value = $typed_data->getValue(); - $this->assertEqual($value, array( + $this->assertEqual($value, [ 'one' => 'uno', 'two' => 'zwei', 'three' => 'drei' - )); + ]); $properties = $typed_data->getProperties(); $this->assertEqual(array_keys($properties), array_keys($value)); @@ -479,12 +479,12 @@ public function testTypedDataMaps() { // Test setting a not defined property. It shouldn't show up in the // properties, but be kept in the values. - $typed_data->setValue(array('foo' => 'bar')); - $this->assertEqual(array_keys($typed_data->getProperties()), array('one', 'two', 'three')); - $this->assertEqual(array_keys($typed_data->getValue()), array('foo', 'one', 'two', 'three')); + $typed_data->setValue(['foo' => 'bar']); + $this->assertEqual(array_keys($typed_data->getProperties()), ['one', 'two', 'three']); + $this->assertEqual(array_keys($typed_data->getValue()), ['foo', 'one', 'two', 'three']); // Test getting the string representation. - $typed_data->setValue(array('one' => 'eins', 'two' => '', 'three' => 'drei')); + $typed_data->setValue(['one' => 'eins', 'two' => '', 'three' => 'drei']); $this->assertEqual($typed_data->getString(), 'eins, drei'); // Test isEmpty and cloning. @@ -492,14 +492,14 @@ public function testTypedDataMaps() { $clone = clone $typed_data; $this->assertTrue($typed_data->getValue() === $clone->getValue()); $this->assertTrue($typed_data->get('one') !== $clone->get('one')); - $clone->setValue(array()); + $clone->setValue([]); $this->assertTrue($clone->isEmpty()); // Make sure the difference between NULL (not set) and an empty array is // kept. $typed_data->setValue(NULL); $this->assertNull($typed_data->getValue()); - $typed_data->setValue(array()); + $typed_data->setValue([]); $value = $typed_data->getValue(); $this->assertTrue(isset($value) && is_array($value)); @@ -535,9 +535,9 @@ public function testTypedDataMaps() { */ public function testTypedDataValidation() { $definition = DataDefinition::create('integer') - ->setConstraints(array( - 'Range' => array('min' => 5), - )); + ->setConstraints([ + 'Range' => ['min' => 5], + ]); $violations = $this->typedDataManager->create($definition, 10)->validate(); $this->assertEqual($violations->count(), 0); @@ -546,27 +546,27 @@ public function testTypedDataValidation() { $this->assertEqual($violations->count(), 1); // Test translating violation messages. - $message = t('This value should be %limit or more.', array('%limit' => 5)); + $message = t('This value should be %limit or more.', ['%limit' => 5]); $this->assertEqual($violations[0]->getMessage(), $message, 'Translated violation message retrieved.'); $this->assertEqual($violations[0]->getPropertyPath(), ''); $this->assertIdentical($violations[0]->getRoot(), $integer, 'Root object returned.'); // Test translating violation messages when pluralization is used. $definition = DataDefinition::create('string') - ->setConstraints(array( - 'Length' => array('min' => 10), - )); + ->setConstraints([ + 'Length' => ['min' => 10], + ]); $violations = $this->typedDataManager->create($definition, "short")->validate(); $this->assertEqual($violations->count(), 1); - $message = t('This value is too short. It should have %limit characters or more.', array('%limit' => 10)); + $message = t('This value is too short. It should have %limit characters or more.', ['%limit' => 10]); $this->assertEqual($violations[0]->getMessage(), $message, 'Translated violation message retrieved.'); // Test having multiple violations. $definition = DataDefinition::create('integer') - ->setConstraints(array( - 'Range' => array('min' => 5), - 'Null' => array(), - )); + ->setConstraints([ + 'Range' => ['min' => 5], + 'Null' => [], + ]); $violations = $this->typedDataManager->create($definition, 10)->validate(); $this->assertEqual($violations->count(), 1); $violations = $this->typedDataManager->create($definition, 1)->validate(); @@ -575,12 +575,12 @@ public function testTypedDataValidation() { // Test validating property containers and make sure the NotNull and Null // constraints work with typed data containers. $definition = BaseFieldDefinition::create('integer') - ->setConstraints(array('NotNull' => array())); - $field_item = $this->typedDataManager->create($definition, array('value' => 10)); + ->setConstraints(['NotNull' => []]); + $field_item = $this->typedDataManager->create($definition, ['value' => 10]); $violations = $field_item->validate(); $this->assertEqual($violations->count(), 0); - $field_item = $this->typedDataManager->create($definition, array('value' => 'no integer')); + $field_item = $this->typedDataManager->create($definition, ['value' => 'no integer']); $violations = $field_item->validate(); $this->assertEqual($violations->count(), 1); $this->assertEqual($violations[0]->getPropertyPath(), '0.value'); @@ -592,8 +592,8 @@ public function testTypedDataValidation() { // Test the Null constraint with typed data containers. $definition = BaseFieldDefinition::create('float') - ->setConstraints(array('Null' => array())); - $field_item = $this->typedDataManager->create($definition, array('value' => 11.5)); + ->setConstraints(['Null' => []]); + $field_item = $this->typedDataManager->create($definition, ['value' => 11.5]); $violations = $field_item->validate(); $this->assertEqual($violations->count(), 1); $field_item = $this->typedDataManager->create($definition); @@ -622,9 +622,9 @@ public function testTypedDataValidation() { // Test validating a list of a values and make sure property paths starting // with "0" are created. $definition = BaseFieldDefinition::create('integer'); - $violations = $this->typedDataManager->create($definition, array(array('value' => 10)))->validate(); + $violations = $this->typedDataManager->create($definition, [['value' => 10]])->validate(); $this->assertEqual($violations->count(), 0); - $violations = $this->typedDataManager->create($definition, array(array('value' => 'string')))->validate(); + $violations = $this->typedDataManager->create($definition, [['value' => 'string']])->validate(); $this->assertEqual($violations->count(), 1); $this->assertEqual($violations[0]->getInvalidValue(), 'string'); diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php index 0146607..bfadc95 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBase.php +++ b/core/tests/Drupal/KernelTests/KernelTestBase.php @@ -145,7 +145,7 @@ * * @var array */ - public static $modules = array(); + public static $modules = []; /** * The virtual filesystem root directory. @@ -191,7 +191,7 @@ * * @var string[] */ - protected static $configSchemaCheckerExclusions = array( + protected static $configSchemaCheckerExclusions = [ // Following are used to test lack of or partial schema. Where partial // schema is provided, that is explicitly tested in specific tests. 'config_schema_test.noschema', @@ -200,7 +200,7 @@ 'config_schema_test.no_schema_data_types', // Used to test application of schema to filtering of configuration. 'config_test.dynamic.system', - ); + ]; /** * {@inheritdoc} @@ -243,7 +243,7 @@ protected function setUp() { * @internal */ protected function bootEnvironment() { - $this->streamWrappers = array(); + $this->streamWrappers = []; \Drupal::unsetContainer(); $this->classLoader = require $this->root . '/autoload.php'; @@ -266,13 +266,13 @@ protected function bootEnvironment() { $this->databasePrefix = 'simpletest' . $suffix; drupal_valid_test_ua($this->databasePrefix); - $settings = array( + $settings = [ 'hash_salt' => get_class($this), 'file_public_path' => $this->siteDirectory . '/files', // Disable Twig template caching/dumping. 'twig_cache' => FALSE, // @see \Drupal\KernelTests\KernelTestBase::register() - ); + ]; new Settings($settings); $this->setUpFilesystem(); @@ -288,13 +288,13 @@ protected function bootEnvironment() { */ protected function setUpFilesystem() { $suffix = str_replace('simpletest', '', $this->databasePrefix); - $this->vfsRoot = vfsStream::setup('root', NULL, array( - 'sites' => array( - 'simpletest' => array( - $suffix => array(), - ), - ), - )); + $this->vfsRoot = vfsStream::setup('root', NULL, [ + 'sites' => [ + 'simpletest' => [ + $suffix => [], + ], + ], + ]); $this->siteDirectory = vfsStream::url('root/sites/simpletest/' . $suffix); mkdir($this->siteDirectory . '/files', 0775); @@ -304,9 +304,9 @@ protected function setUpFilesystem() { $settings['file_public_path'] = $this->siteDirectory . '/files'; new Settings($settings); - $GLOBALS['config_directories'] = array( + $GLOBALS['config_directories'] = [ CONFIG_SYNC_DIRECTORY => $this->siteDirectory . '/files/config/sync', - ); + ]; } /** @@ -395,10 +395,10 @@ private function bootKernel() { // Write the core.extension configuration. // Required for ConfigInstaller::installDefaultConfig() to work. - $this->container->get('config.storage')->write('core.extension', array( + $this->container->get('config.storage')->write('core.extension', [ 'module' => array_fill_keys($modules, 0), - 'theme' => array(), - )); + 'theme' => [], + ]); $settings = Settings::getAll(); $settings['php_storage']['default'] = [ @@ -461,9 +461,9 @@ protected function getDatabaseConnectionInfo() { foreach ($connection_info as $target => $value) { // Replace the full table prefix definition to ensure that no table // prefixes of the test runner leak into the test. - $connection_info[$target]['prefix'] = array( + $connection_info[$target]['prefix'] = [ 'default' => $value['prefix']['default'] . $this->databasePrefix, - ); + ]; } } return $connection_info; @@ -568,9 +568,9 @@ protected function initFileCache() { * @see \Drupal\Core\Extension\ModuleHandler::add() */ private function getExtensionsForModules(array $modules) { - $extensions = array(); + $extensions = []; $discovery = new ExtensionDiscovery($this->root); - $discovery->setProfileDirectories(array()); + $discovery->setProfileDirectories([]); $list = $discovery->scan('module'); foreach ($modules as $name) { if (!isset($list[$name])) { @@ -633,7 +633,7 @@ public function register(ContainerBuilder $container) { if ($container->hasDefinition('password')) { $container->getDefinition('password') - ->setArguments(array(1)); + ->setArguments([1]); } TestServiceProvider::addRouteProvider($container); } @@ -711,7 +711,7 @@ protected function tearDown() { // Free up memory: Custom test class properties. // Note: Private properties cannot be cleaned up. $rc = new \ReflectionClass(__CLASS__); - $blacklist = array(); + $blacklist = []; foreach ($rc->getProperties() as $property) { $blacklist[$property->name] = $property->getDeclaringClass()->name; } @@ -731,7 +731,7 @@ protected function tearDown() { } \Drupal::unsetContainer(); $this->container = NULL; - new Settings(array()); + new Settings([]); parent::tearDown(); } @@ -834,18 +834,18 @@ protected function installEntitySchema($entity_type_id) { $all_tables_exist = TRUE; foreach ($tables as $table) { if (!$db_schema->tableExists($table)) { - $this->fail(SafeMarkup::format('Installed entity type table for the %entity_type entity type: %table', array( + $this->fail(SafeMarkup::format('Installed entity type table for the %entity_type entity type: %table', [ '%entity_type' => $entity_type_id, '%table' => $table, - ))); + ])); $all_tables_exist = FALSE; } } if ($all_tables_exist) { - $this->pass(SafeMarkup::format('Installed entity type tables for the %entity_type entity type: %tables', array( + $this->pass(SafeMarkup::format('Installed entity type tables for the %entity_type entity type: %tables', [ '%entity_type' => $entity_type_id, '%tables' => '{' . implode('}, {', $tables) . '}', - ))); + ])); } } } @@ -1032,7 +1032,7 @@ protected function vfsDump() { * @return array */ private static function getModulesToEnable($class) { - $modules = array(); + $modules = []; while ($class) { if (property_exists($class, 'modules')) { // Only add the modules, if the $modules property was not inherited. @@ -1064,11 +1064,11 @@ protected function prepareTemplate(\Text_Template $template) { // @see /core/tests/bootstrap.php $bootstrap_globals .= '$namespaces = ' . var_export($GLOBALS['namespaces'], TRUE) . ";\n"; - $template->setVar(array( + $template->setVar([ 'constants' => '', 'included_files' => '', 'globals' => $bootstrap_globals, - )); + ]); } /** @@ -1091,12 +1091,12 @@ protected function isTestInIsolation() { * @deprecated in Drupal 8.0.x, will be removed before Drupal 8.2.0. */ public function __get($name) { - if (in_array($name, array( + if (in_array($name, [ 'public_files_directory', 'private_files_directory', 'temp_files_directory', 'translation_files_directory', - ))) { + ])) { // @comment it in again. trigger_error(sprintf("KernelTestBase::\$%s no longer exists. Use the regular API method to retrieve it instead (e.g., Settings).", $name), E_USER_DEPRECATED); switch ($name) { @@ -1116,12 +1116,12 @@ public function __get($name) { if ($name === 'configDirectories') { trigger_error(sprintf("KernelTestBase::\$%s no longer exists. Use config_get_config_directory() directly instead.", $name), E_USER_DEPRECATED); - return array( + return [ CONFIG_SYNC_DIRECTORY => config_get_config_directory(CONFIG_SYNC_DIRECTORY), - ); + ]; } - $denied = array( + $denied = [ // @see \Drupal\simpletest\TestBase 'testId', 'timeLimit', @@ -1139,7 +1139,7 @@ public function __get($name) { 'generatedTestFiles', // Properties from the old KernelTestBase class that has been removed. 'keyValueFactory', - ); + ]; if (in_array($name, $denied) || strpos($name, 'original') === 0) { throw new \RuntimeException(sprintf('TestBase::$%s property no longer exists', $name)); } diff --git a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php index 30f05b2..ac509b5 100644 --- a/core/tests/Drupal/KernelTests/KernelTestBaseTest.php +++ b/core/tests/Drupal/KernelTests/KernelTestBaseTest.php @@ -27,21 +27,21 @@ public function testSetUpBeforeClass() { public function testBootEnvironment() { $this->assertRegExp('/^simpletest\d{6}$/', $this->databasePrefix); $this->assertStringStartsWith('vfs://root/sites/simpletest/', $this->siteDirectory); - $this->assertEquals(array( - 'root' => array( - 'sites' => array( - 'simpletest' => array( - substr($this->databasePrefix, 10) => array( - 'files' => array( - 'config' => array( - 'sync' => array(), - ), - ), - ), - ), - ), - ), - ), vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure()); + $this->assertEquals([ + 'root' => [ + 'sites' => [ + 'simpletest' => [ + substr($this->databasePrefix, 10) => [ + 'files' => [ + 'config' => [ + 'sync' => [], + ], + ], + ], + ], + ], + ], + ], vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure()); } /** @@ -70,15 +70,15 @@ public function testSetUp() { $this->assertArrayHasKey('destroy-me', $GLOBALS); $database = $this->container->get('database'); - $database->schema()->createTable('foo', array( - 'fields' => array( - 'number' => array( + $database->schema()->createTable('foo', [ + 'fields' => [ + 'number' => [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, - ), - ), - )); + ], + ], + ]); $this->assertTrue($database->schema()->tableExists('foo')); // Ensure that the database tasks have been run during set up. Neither MySQL @@ -120,7 +120,7 @@ public function testRegister() { $this->assertSame($request, \Drupal::request()); // Trigger a container rebuild. - $this->enableModules(array('system')); + $this->enableModules(['system']); // Verify that this container is identical to the actual container. $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $this->container); @@ -165,16 +165,16 @@ public function testRender() { $element_info = $this->container->get('element_info'); $this->assertSame(['#defaults_loaded' => TRUE], $element_info->getInfo($type)); - $this->enableModules(array('filter')); + $this->enableModules(['filter']); $this->assertNotSame($element_info, $this->container->get('element_info')); $this->assertNotEmpty($this->container->get('element_info')->getInfo($type)); - $build = array( + $build = [ '#type' => 'html_tag', '#tag' => 'h3', '#value' => 'Inner', - ); + ]; $expected = "

    Inner

    \n"; $this->assertEquals('core', \Drupal::theme()->getActiveTheme()->getName()); @@ -189,12 +189,12 @@ public function testRender() { * @covers ::render */ public function testRenderWithTheme() { - $this->enableModules(array('system')); + $this->enableModules(['system']); - $build = array( + $build = [ '#type' => 'textfield', '#name' => 'test', - ); + ]; $expected = '/' . preg_quote('assertArrayNotHasKey('theme', $GLOBALS); @@ -220,11 +220,11 @@ protected function tearDown() { $this->assertTrue(empty($tables), 'All test tables have been removed.'); } else { - $result = $connection->query("SELECT name FROM " . $this->databasePrefix . ".sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", array( + $result = $connection->query("SELECT name FROM " . $this->databasePrefix . ".sqlite_master WHERE type = :type AND name LIKE :table_name AND name NOT LIKE :pattern", [ ':type' => 'table', ':table_name' => '%', ':pattern' => 'sqlite_%', - ))->fetchAllKeyed(0, 0); + ])->fetchAllKeyed(0, 0); $this->assertTrue(empty($result), 'All test tables have been removed.'); } diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php index c8df47c..7720823 100644 --- a/core/tests/Drupal/Tests/BrowserTestBase.php +++ b/core/tests/Drupal/Tests/BrowserTestBase.php @@ -169,7 +169,7 @@ * * @var string[] */ - protected static $configSchemaCheckerExclusions = array( + protected static $configSchemaCheckerExclusions = [ // Following are used to test lack of or partial schema. Where partial // schema is provided, that is explicitly tested in specific tests. 'config_schema_test.noschema', @@ -178,7 +178,7 @@ 'config_schema_test.no_schema_data_types', // Used to test application of schema to filtering of configuration. 'config_test.dynamic.system', - ); + ]; /** * The profile to install as a basis for testing. @@ -206,7 +206,7 @@ * * @var array */ - protected $configDirectories = array(); + protected $configDirectories = []; /** * An array of custom translations suitable for drupal_rewrite_settings(). @@ -540,7 +540,7 @@ protected function cleanupEnvironment() { } // Delete test site directory. - file_unmanaged_delete_recursive($this->siteDirectory, array($this, 'filePreDeleteCallback')); + file_unmanaged_delete_recursive($this->siteDirectory, [$this, 'filePreDeleteCallback']); } /** @@ -619,7 +619,7 @@ protected function prepareRequest() { * @return string * An absolute URL stsring. */ - protected function buildUrl($path, array $options = array()) { + protected function buildUrl($path, array $options = []) { if ($path instanceof Url) { $url_options = $path->getOptions(); $options = $url_options + $options; @@ -667,7 +667,7 @@ protected function buildUrl($path, array $options = array()) { * @return string * The retrieved HTML string, also available as $this->getRawContent() */ - protected function drupalGet($path, array $options = array(), array $headers = array()) { + protected function drupalGet($path, array $options = [], array $headers = []) { $options['absolute'] = TRUE; $url = $this->buildUrl($path, $options); @@ -760,14 +760,14 @@ protected function drupalLogin(AccountInterface $account) { $this->drupalGet('user'); $this->assertSession()->statusCodeEquals(200); - $this->submitForm(array( + $this->submitForm([ 'name' => $account->getUsername(), 'pass' => $account->passRaw, - ), t('Log in')); + ], t('Log in')); // @see BrowserTestBase::drupalUserIsLoggedIn() $account->sessionId = $this->getSession()->getCookie($this->getSessionName()); - $this->assertTrue($this->drupalUserIsLoggedIn($account), SafeMarkup::format('User %name successfully logged in.', array('name' => $account->getUsername()))); + $this->assertTrue($this->drupalUserIsLoggedIn($account), SafeMarkup::format('User %name successfully logged in.', ['name' => $account->getUsername()])); $this->loggedInUser = $account; $this->container->get('current_user')->setAccount($account); @@ -783,7 +783,7 @@ protected function drupalLogout() { // idea being if you were properly logged out you should be seeing a login // screen. $assert_session = $this->assertSession(); - $this->drupalGet('user/logout', array('query' => array('destination' => 'user'))); + $this->drupalGet('user/logout', ['query' => ['destination' => 'user']]); $assert_session->statusCodeEquals(200); $assert_session->fieldExists('name'); $assert_session->fieldExists('pass'); @@ -932,7 +932,7 @@ protected function submitForm(array $edit, $submit, $form_html_id = NULL) { * @param array $options * Options to be forwarded to the url generator. */ - protected function drupalPostForm($path, array $edit, $submit, array $options = array()) { + protected function drupalPostForm($path, array $edit, $submit, array $options = []) { if (is_object($submit)) { // Cast MarkupInterface objects to string. $submit = (string) $submit; @@ -978,12 +978,12 @@ protected function getOptions($select, Element $container = NULL) { */ public function installDrupal() { // Define information about the user 1 account. - $this->rootUser = new UserSession(array( + $this->rootUser = new UserSession([ 'uid' => 1, 'name' => 'admin', 'mail' => 'admin@example.com', 'passRaw' => $this->randomMachineName(), - )); + ]); // The child site derives its session name from the database prefix when // running web tests. @@ -1002,10 +1002,10 @@ public function installDrupal() { // All file system paths are created by System module during installation. // @see system_requirements() // @see TestBase::prepareEnvironment() - $settings['settings']['file_public_path'] = (object) array( + $settings['settings']['file_public_path'] = (object) [ 'value' => $this->publicFilesDirectory, 'required' => TRUE, - ); + ]; $settings['settings']['file_private_path'] = (object) [ 'value' => $this->privateFilesDirectory, 'required' => TRUE, @@ -1109,7 +1109,7 @@ public function installDrupal() { // Collect modules to install. $class = get_class($this); - $modules = array(); + $modules = []; while ($class) { if (property_exists($class, 'modules')) { $modules = array_merge($modules, $class::$modules); @@ -1119,7 +1119,7 @@ public function installDrupal() { if ($modules) { $modules = array_unique($modules); $success = $container->get('module_installer')->install($modules, TRUE); - $this->assertTrue($success, SafeMarkup::format('Enabled modules: %modules', array('%modules' => implode(', ', $modules)))); + $this->assertTrue($success, SafeMarkup::format('Enabled modules: %modules', ['%modules' => implode(', ', $modules)])); $this->rebuildContainer(); } @@ -1148,37 +1148,37 @@ protected function installParameters() { unset($connection_info['default']['namespace']); unset($connection_info['default']['pdo']); unset($connection_info['default']['init_commands']); - $parameters = array( + $parameters = [ 'interactive' => FALSE, - 'parameters' => array( + 'parameters' => [ 'profile' => $this->profile, 'langcode' => 'en', - ), - 'forms' => array( - 'install_settings_form' => array( + ], + 'forms' => [ + 'install_settings_form' => [ 'driver' => $driver, $driver => $connection_info['default'], - ), - 'install_configure_form' => array( + ], + 'install_configure_form' => [ 'site_name' => 'Drupal', 'site_mail' => 'simpletest@example.com', - 'account' => array( + 'account' => [ 'name' => $this->rootUser->name, 'mail' => $this->rootUser->getEmail(), - 'pass' => array( + 'pass' => [ 'pass1' => $this->rootUser->passRaw, 'pass2' => $this->rootUser->passRaw, - ), - ), + ], + ], // form_type_checkboxes_value() requires NULL instead of FALSE values // for programmatic form submissions to disable a checkbox. - 'update_status_module' => array( + 'update_status_module' => [ 1 => NULL, 2 => NULL, - ), - ), - ), - ); + ], + ], + ], + ]; return $parameters; } @@ -1238,9 +1238,9 @@ private function changeDatabasePrefix() { foreach ($connection_info as $target => $value) { // Replace the full table prefix definition to ensure that no table // prefixes of the test runner leak into the test. - $connection_info[$target]['prefix'] = array( + $connection_info[$target]['prefix'] = [ 'default' => $value['prefix']['default'] . $this->databasePrefix, - ); + ]; } Database::addConnectionInfo('default', 'default', $connection_info['default']); } @@ -1312,10 +1312,10 @@ protected function prepareEnvironment() { drupal_valid_test_ua($this->databasePrefix); // Reset settings. - new Settings(array( + new Settings([ // For performance, simply use the database prefix as hash salt. 'hash_salt' => $this->databasePrefix, - )); + ]); drupal_set_time_limit($this->timeLimit); @@ -1400,7 +1400,7 @@ protected function rebuildContainer() { * @return Request * The mocked request object. */ - protected function prepareRequestForGenerator($clean_urls = TRUE, $override_server_vars = array()) { + protected function prepareRequestForGenerator($clean_urls = TRUE, $override_server_vars = []) { $request = Request::createFromGlobals(); $server = $request->server->all(); if (basename($server['SCRIPT_FILENAME']) != basename($server['SCRIPT_NAME'])) { @@ -1422,7 +1422,7 @@ protected function prepareRequestForGenerator($clean_urls = TRUE, $override_serv } $server = array_merge($server, $override_server_vars); - $request = Request::create($request_path, 'GET', array(), array(), array(), $server); + $request = Request::create($request_path, 'GET', [], [], [], $server); // Ensure the request time is REQUEST_TIME to ensure that API calls // in the test use the right timestamp. $request->server->set('REQUEST_TIME', REQUEST_TIME); @@ -1476,7 +1476,7 @@ protected function refreshVariables() { drupal_static_reset('Drupal\Core\Cache\DatabaseBackend::deletedTags'); drupal_static_reset('Drupal\Core\Cache\DatabaseBackend::invalidatedTags'); foreach (Cache::getBins() as $backend) { - if (is_callable(array($backend, 'reset'))) { + if (is_callable([$backend, 'reset'])) { $backend->reset(); } } diff --git a/core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php b/core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php index 9efbf4e..c14bdfb 100644 --- a/core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php +++ b/core/tests/Drupal/Tests/Component/Bridge/ZfExtensionManagerSfContainerTest.php @@ -80,41 +80,41 @@ public function testCanonicalizeName($name, $canonical_name) { * array('-' => '', '_' => '', ' ' => '', '\\' => '', '/' => '') */ public function canonicalizeNameProvider() { - return array( - array( + return [ + [ 'foobar', 'foobar', - ), - array( + ], + [ 'foo-bar', 'foobar', - ), - array( + ], + [ 'foo_bar', 'foobar', - ), - array( + ], + [ 'foo bar', 'foobar', - ), - array( + ], + [ 'foo\\bar', 'foobar', - ), - array( + ], + [ 'foo/bar', 'foobar', - ), + ], // There is also a strtolower in canonicalizeName. - array( + [ 'Foo/bAr', 'foobar', - ), - array( + ], + [ 'foo/-_\\ bar', 'foobar', - ), - ); + ], + ]; } } diff --git a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php index b8be130..3a647ef 100644 --- a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php +++ b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php @@ -289,21 +289,21 @@ public function testDateTimezoneWithDateTimeObject() { * @see DateTimePlusTest::testDates() */ public function providerTestDates() { - return array( + return [ // String input. // Create date object from datetime string. - array('2009-03-07 10:30', 'America/Chicago', '2009-03-07T10:30:00-06:00'), + ['2009-03-07 10:30', 'America/Chicago', '2009-03-07T10:30:00-06:00'], // Same during daylight savings time. - array('2009-06-07 10:30', 'America/Chicago', '2009-06-07T10:30:00-05:00'), + ['2009-06-07 10:30', 'America/Chicago', '2009-06-07T10:30:00-05:00'], // Create date object from date string. - array('2009-03-07', 'America/Chicago', '2009-03-07T00:00:00-06:00'), + ['2009-03-07', 'America/Chicago', '2009-03-07T00:00:00-06:00'], // Same during daylight savings time. - array('2009-06-07', 'America/Chicago', '2009-06-07T00:00:00-05:00'), + ['2009-06-07', 'America/Chicago', '2009-06-07T00:00:00-05:00'], // Create date object from date string. - array('2009-03-07 10:30', 'Australia/Canberra', '2009-03-07T10:30:00+11:00'), + ['2009-03-07 10:30', 'Australia/Canberra', '2009-03-07T10:30:00+11:00'], // Same during daylight savings time. - array('2009-06-07 10:30', 'Australia/Canberra', '2009-06-07T10:30:00+10:00'), - ); + ['2009-06-07 10:30', 'Australia/Canberra', '2009-06-07T10:30:00+10:00'], + ]; } /** @@ -316,17 +316,17 @@ public function providerTestDates() { * @see DateTimePlusTest::testDates() */ public function providerTestDateArrays() { - return array( + return [ // Array input. // Create date object from date array, date only. - array(array('year' => 2010, 'month' => 2, 'day' => 28), 'America/Chicago', '2010-02-28T00:00:00-06:00'), + [['year' => 2010, 'month' => 2, 'day' => 28], 'America/Chicago', '2010-02-28T00:00:00-06:00'], // Create date object from date array with hour. - array(array('year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 10), 'America/Chicago', '2010-02-28T10:00:00-06:00'), + [['year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 10], 'America/Chicago', '2010-02-28T10:00:00-06:00'], // Create date object from date array, date only. - array(array('year' => 2010, 'month' => 2, 'day' => 28), 'Europe/Berlin', '2010-02-28T00:00:00+01:00'), + [['year' => 2010, 'month' => 2, 'day' => 28], 'Europe/Berlin', '2010-02-28T00:00:00+01:00'], // Create date object from date array with hour. - array(array('year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 10), 'Europe/Berlin', '2010-02-28T10:00:00+01:00'), - ); + [['year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 10], 'Europe/Berlin', '2010-02-28T10:00:00+01:00'], + ]; } /** @@ -343,16 +343,16 @@ public function providerTestDateArrays() { * @see testDateFormats() */ public function providerTestDateFormat() { - return array( + return [ // Create a year-only date. - array('2009', NULL, 'Y', 'Y', '2009'), + ['2009', NULL, 'Y', 'Y', '2009'], // Create a month and year-only date. - array('2009-10', NULL, 'Y-m', 'Y-m', '2009-10'), + ['2009-10', NULL, 'Y-m', 'Y-m', '2009-10'], // Create a time-only date. - array('T10:30:00', NULL, '\TH:i:s', 'H:i:s', '10:30:00'), + ['T10:30:00', NULL, '\TH:i:s', 'H:i:s', '10:30:00'], // Create a time-only date. - array('10:30:00', NULL, 'H:i:s', 'H:i:s', '10:30:00'), - ); + ['10:30:00', NULL, 'H:i:s', 'H:i:s', '10:30:00'], + ]; } /** @@ -368,20 +368,20 @@ public function providerTestDateFormat() { * @see testInvalidDates */ public function providerTestInvalidDates() { - return array( + return [ // Test for invalid month names when we are using a short version // of the month. - array('23 abc 2012', NULL, 'd M Y', "23 abc 2012 contains an invalid month name and did not produce errors."), + ['23 abc 2012', NULL, 'd M Y', "23 abc 2012 contains an invalid month name and did not produce errors."], // Test for invalid hour. - array('0000-00-00T45:30:00', NULL, 'Y-m-d\TH:i:s', "0000-00-00T45:30:00 contains an invalid hour and did not produce errors."), + ['0000-00-00T45:30:00', NULL, 'Y-m-d\TH:i:s', "0000-00-00T45:30:00 contains an invalid hour and did not produce errors."], // Test for invalid day. - array('0000-00-99T05:30:00', NULL, 'Y-m-d\TH:i:s', "0000-00-99T05:30:00 contains an invalid day and did not produce errors."), + ['0000-00-99T05:30:00', NULL, 'Y-m-d\TH:i:s', "0000-00-99T05:30:00 contains an invalid day and did not produce errors."], // Test for invalid month. - array('0000-75-00T15:30:00', NULL, 'Y-m-d\TH:i:s', "0000-75-00T15:30:00 contains an invalid month and did not produce errors."), + ['0000-75-00T15:30:00', NULL, 'Y-m-d\TH:i:s', "0000-75-00T15:30:00 contains an invalid month and did not produce errors."], // Test for invalid year. - array('11-08-01T15:30:00', NULL, 'Y-m-d\TH:i:s', "11-08-01T15:30:00 contains an invalid year and did not produce errors."), + ['11-08-01T15:30:00', NULL, 'Y-m-d\TH:i:s', "11-08-01T15:30:00 contains an invalid year and did not produce errors."], - ); + ]; } /** @@ -395,20 +395,20 @@ public function providerTestInvalidDates() { * @see testInvalidDateArrays */ public function providerTestInvalidDateArrays() { - return array( + return [ // One year larger than the documented upper limit of checkdate(). - array(array('year' => 32768, 'month' => 1, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0), 'America/Chicago'), + [['year' => 32768, 'month' => 1, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0], 'America/Chicago'], // One year smaller than the documented lower limit of checkdate(). - array(array('year' => 0, 'month' => 1, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0), 'America/Chicago'), + [['year' => 0, 'month' => 1, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0], 'America/Chicago'], // Test for invalid month from date array. - array(array('year' => 2010, 'month' => 27, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0), 'America/Chicago'), + [['year' => 2010, 'month' => 27, 'day' => 8, 'hour' => 8, 'minute' => 0, 'second' => 0], 'America/Chicago'], // Test for invalid hour from date array. - array(array('year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 80, 'minute' => 0, 'second' => 0), 'America/Chicago'), + [['year' => 2010, 'month' => 2, 'day' => 28, 'hour' => 80, 'minute' => 0, 'second' => 0], 'America/Chicago'], // Test for invalid minute from date array. - array(array('year' => 2010, 'month' => 7, 'day' => 8, 'hour' => 8, 'minute' => 88, 'second' => 0), 'America/Chicago'), + [['year' => 2010, 'month' => 7, 'day' => 8, 'hour' => 8, 'minute' => 88, 'second' => 0], 'America/Chicago'], // Regression test for https://www.drupal.org/node/2084455. - array(array('hour' => 59, 'minute' => 1, 'second' => 1), 'America/Chicago'), - ); + [['hour' => 59, 'minute' => 1, 'second' => 1], 'America/Chicago'], + ]; } /** @@ -430,17 +430,17 @@ public function providerTestDateTimezone() { // Detect the system timezone. $system_timezone = date_default_timezone_get(); - return array( + return [ // Create a date object with an unspecified timezone, which should // end up using the system timezone. - array($date_string, NULL, $system_timezone, 'DateTimePlus uses the system timezone when there is no site timezone.'), + [$date_string, NULL, $system_timezone, 'DateTimePlus uses the system timezone when there is no site timezone.'], // Create a date object with a specified timezone name. - array($date_string, 'America/Yellowknife', 'America/Yellowknife', 'DateTimePlus uses the specified timezone if provided.'), + [$date_string, 'America/Yellowknife', 'America/Yellowknife', 'DateTimePlus uses the specified timezone if provided.'], // Create a date object with a timezone object. - array($date_string, new \DateTimeZone('Australia/Canberra'), 'Australia/Canberra', 'DateTimePlus uses the specified timezone if provided.'), + [$date_string, new \DateTimeZone('Australia/Canberra'), 'Australia/Canberra', 'DateTimePlus uses the specified timezone if provided.'], // Create a date object with another date object. - array(new DateTimePlus('now', 'Pacific/Midway'), NULL, 'Pacific/Midway', 'DateTimePlus uses the specified timezone if provided.'), - ); + [new DateTimePlus('now', 'Pacific/Midway'), NULL, 'Pacific/Midway', 'DateTimePlus uses the specified timezone if provided.'], + ]; } /** @@ -453,46 +453,46 @@ public function providerTestDateTimezone() { * @see testTimestamp() */ public function providerTestTimestamp() { - return array( + return [ // Create date object from a unix timestamp and display it in // local time. - array( + [ 'input' => 0, - 'initial' => array( + 'initial' => [ 'timezone' => 'UTC', 'format' => 'c', 'expected_date' => '1970-01-01T00:00:00+00:00', 'expected_timezone' => 'UTC', 'expected_offset' => 0, - ), - 'transform' => array( + ], + 'transform' => [ 'timezone' => 'America/Los_Angeles', 'format' => 'c', 'expected_date' => '1969-12-31T16:00:00-08:00', 'expected_timezone' => 'America/Los_Angeles', 'expected_offset' => '-28800', - ), - ), + ], + ], // Create a date using the timestamp of zero, then display its // value both in UTC and the local timezone. - array( + [ 'input' => 0, - 'initial' => array( + 'initial' => [ 'timezone' => 'America/Los_Angeles', 'format' => 'c', 'expected_date' => '1969-12-31T16:00:00-08:00', 'expected_timezone' => 'America/Los_Angeles', 'expected_offset' => '-28800', - ), - 'transform' => array( + ], + 'transform' => [ 'timezone' => 'UTC', 'format' => 'c', 'expected_date' => '1970-01-01T00:00:00+00:00', 'expected_timezone' => 'UTC', 'expected_offset' => 0, - ), - ), - ); + ], + ], + ]; } /** @@ -505,63 +505,63 @@ public function providerTestTimestamp() { * @see testDateTimestamp() */ public function providerTestDateTimestamp() { - return array( + return [ // Create date object from datetime string in UTC, and convert // it to a local date. - array( + [ 'input' => '1970-01-01 00:00:00', - 'initial' => array( + 'initial' => [ 'timezone' => 'UTC', 'format' => 'c', 'expected_date' => '1970-01-01T00:00:00+00:00', 'expected_timezone' => 'UTC', 'expected_offset' => 0, - ), - 'transform' => array( + ], + 'transform' => [ 'timezone' => 'America/Los_Angeles', 'format' => 'c', 'expected_date' => '1969-12-31T16:00:00-08:00', 'expected_timezone' => 'America/Los_Angeles', 'expected_offset' => '-28800', - ), - ), + ], + ], // Convert the local time to UTC using string input. - array( + [ 'input' => '1969-12-31 16:00:00', - 'initial' => array( + 'initial' => [ 'timezone' => 'America/Los_Angeles', 'format' => 'c', 'expected_date' => '1969-12-31T16:00:00-08:00', 'expected_timezone' => 'America/Los_Angeles', 'expected_offset' => '-28800', - ), - 'transform' => array( + ], + 'transform' => [ 'timezone' => 'UTC', 'format' => 'c', 'expected_date' => '1970-01-01T00:00:00+00:00', 'expected_timezone' => 'UTC', 'expected_offset' => 0, - ), - ), + ], + ], // Convert the local time to UTC using string input. - array( + [ 'input' => '1969-12-31 16:00:00', - 'initial' => array( + 'initial' => [ 'timezone' => 'Europe/Warsaw', 'format' => 'c', 'expected_date' => '1969-12-31T16:00:00+01:00', 'expected_timezone' => 'Europe/Warsaw', 'expected_offset' => '+3600', - ), - 'transform' => array( + ], + 'transform' => [ 'timezone' => 'UTC', 'format' => 'c', 'expected_date' => '1969-12-31T15:00:00+00:00', 'expected_timezone' => 'UTC', 'expected_offset' => 0, - ), - ), - ); + ], + ], + ]; } /** @@ -586,60 +586,60 @@ public function providerTestDateDiff() { $negative_1_hour = new \DateInterval('PT1H'); $negative_1_hour->invert = 1; - return array( + return [ // There should be a 19 hour time interval between // new years in Sydney and new years in LA in year 2000. - array( + [ 'input2' => DateTimePlus::createFromFormat('Y-m-d H:i:s', '2000-01-01 00:00:00', new \DateTimeZone('Australia/Sydney')), 'input1' => DateTimePlus::createFromFormat('Y-m-d H:i:s', '2000-01-01 00:00:00', new \DateTimeZone('America/Los_Angeles')), 'absolute' => FALSE, 'expected' => $positive_19_hours, - ), + ], // In 1970 Sydney did not observe daylight savings time // So there is only a 18 hour time interval. - array( + [ 'input2' => DateTimePlus::createFromFormat('Y-m-d H:i:s', '1970-01-01 00:00:00', new \DateTimeZone('Australia/Sydney')), 'input1' => DateTimePlus::createFromFormat('Y-m-d H:i:s', '1970-01-01 00:00:00', new \DateTimeZone('America/Los_Angeles')), 'absolute' => FALSE, 'expected' => $positive_18_hours, - ), - array( + ], + [ 'input1' => DateTimePlus::createFromFormat('U', 3600, new \DateTimeZone('America/Los_Angeles')), 'input2' => DateTimePlus::createFromFormat('U', 0, new \DateTimeZone('UTC')), 'absolute' => FALSE, 'expected' => $negative_1_hour, - ), - array( + ], + [ 'input1' => DateTimePlus::createFromFormat('U', 3600), 'input2' => DateTimePlus::createFromFormat('U', 0), 'absolute' => FALSE, 'expected' => $negative_1_hour, - ), - array( + ], + [ 'input1' => DateTimePlus::createFromFormat('U', 3600), 'input2' => \DateTime::createFromFormat('U', 0), 'absolute' => FALSE, 'expected' => $negative_1_hour, - ), - array( + ], + [ 'input1' => DateTimePlus::createFromFormat('U', 3600), 'input2' => DateTimePlus::createFromFormat('U', 0), 'absolute' => TRUE, 'expected' => $positive_1_hour, - ), - array( + ], + [ 'input1' => DateTimePlus::createFromFormat('U', 3600), 'input2' => \DateTime::createFromFormat('U', 0), 'absolute' => TRUE, 'expected' => $positive_1_hour, - ), - array( + ], + [ 'input1' => DateTimePlus::createFromFormat('U', 0), 'input2' => DateTimePlus::createFromFormat('U', 0), 'absolute' => FALSE, 'expected' => $empty_interval, - ), - ); + ], + ]; } /** @@ -652,18 +652,18 @@ public function providerTestDateDiff() { * @see DateTimePlusTest::testInvalidDateDiff() */ public function providerTestInvalidDateDiff() { - return array( - array( + return [ + [ 'input1' => DateTimePlus::createFromFormat('U', 3600), 'input2' => '1970-01-01 00:00:00', 'absolute' => FALSE, - ), - array( + ], + [ 'input1' => DateTimePlus::createFromFormat('U', 3600), 'input2' => NULL, 'absolute' => FALSE, - ), - ); + ], + ]; } } diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php index 3c89804..7751094 100644 --- a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php +++ b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php @@ -451,7 +451,7 @@ public function testGetWithFileInclude() { * @covers ::resolveServicesAndParameters */ public function testGetForInstantiationWithVariousArgumentLengths() { - $args = array(); + $args = []; for ($i = 0; $i < 12; $i++) { $instantiation_service = $this->container->get('service_test_instantiation_' . $i); $this->assertEquals($args, $instantiation_service->getArguments()); @@ -676,10 +676,10 @@ public function testInitializedForAliases() { * @dataProvider scopeExceptionTestProvider */ public function testScopeFunctionsWithException($method, $argument) { - $callable = array( + $callable = [ $this->container, $method, - ); + ]; $callable($argument); } @@ -694,13 +694,13 @@ public function testScopeFunctionsWithException($method, $argument) { */ public function scopeExceptionTestProvider() { $scope = $this->prophesize('\Symfony\Component\DependencyInjection\ScopeInterface')->reveal(); - return array( - array('enterScope', 'test_scope'), - array('leaveScope', 'test_scope'), - array('hasScope', 'test_scope'), - array('isScopeActive', 'test_scope'), - array('addScope', $scope), - ); + return [ + ['enterScope', 'test_scope'], + ['leaveScope', 'test_scope'], + ['hasScope', 'test_scope'], + ['isScopeActive', 'test_scope'], + ['addScope', $scope], + ]; } /** @@ -728,7 +728,7 @@ public function testGetServiceIds() { */ protected function getMockContainerDefinition() { $fake_service = new \stdClass(); - $parameters = array(); + $parameters = []; $parameters['some_parameter_class'] = get_class($fake_service); $parameters['some_private_config'] = 'really_private_lama'; $parameters['some_config'] = 'foo'; @@ -737,262 +737,262 @@ protected function getMockContainerDefinition() { // Also test alias resolving. $parameters['service_from_parameter'] = $this->getServiceCall('service.provider_alias'); - $services = array(); - $services['service_container'] = array( + $services = []; + $services['service_container'] = [ 'class' => '\Drupal\service_container\DependencyInjection\Container', - ); - $services['other.service'] = array( + ]; + $services['other.service'] = [ 'class' => get_class($fake_service), - ); + ]; - $services['non_shared_service'] = array( + $services['non_shared_service'] = [ 'class' => get_class($fake_service), 'shared' => FALSE, - ); + ]; - $services['other.service_class_from_parameter'] = array( + $services['other.service_class_from_parameter'] = [ 'class' => $this->getParameterCall('some_parameter_class'), - ); - $services['late.service'] = array( + ]; + $services['late.service'] = [ 'class' => get_class($fake_service), - ); - $services['service.provider'] = array( + ]; + $services['service.provider'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => $this->getCollection(array( + 'arguments' => $this->getCollection([ $this->getServiceCall('other.service'), $this->getParameterCall('some_config'), - )), - 'properties' => $this->getCollection(array('_someProperty' => 'foo')), - 'calls' => array( - array('setContainer', $this->getCollection(array( + ]), + 'properties' => $this->getCollection(['_someProperty' => 'foo']), + 'calls' => [ + ['setContainer', $this->getCollection([ $this->getServiceCall('service_container'), - ))), - array('setOtherConfigParameter', $this->getCollection(array( + ])], + ['setOtherConfigParameter', $this->getCollection([ $this->getParameterCall('some_other_config'), - ))), - ), + ])], + ], 'priority' => 0, - ); + ]; // Test private services. - $private_service = array( + $private_service = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => $this->getCollection(array( + 'arguments' => $this->getCollection([ $this->getServiceCall('other.service'), $this->getParameterCall('some_private_config'), - )), + ]), 'public' => FALSE, - ); + ]; - $services['service_using_private'] = array( + $services['service_using_private'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => $this->getCollection(array( + 'arguments' => $this->getCollection([ $this->getPrivateServiceCall(NULL, $private_service), $this->getParameterCall('some_config'), - )), - ); - $services['another_service_using_private'] = array( + ]), + ]; + $services['another_service_using_private'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => $this->getCollection(array( + 'arguments' => $this->getCollection([ $this->getPrivateServiceCall(NULL, $private_service), $this->getParameterCall('some_config'), - )), - ); + ]), + ]; // Test shared private services. $id = 'private_service_shared_1'; - $services['service_using_shared_private'] = array( + $services['service_using_shared_private'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => $this->getCollection(array( + 'arguments' => $this->getCollection([ $this->getPrivateServiceCall($id, $private_service, TRUE), $this->getParameterCall('some_config'), - )), - ); - $services['another_service_using_shared_private'] = array( + ]), + ]; + $services['another_service_using_shared_private'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => $this->getCollection(array( + 'arguments' => $this->getCollection([ $this->getPrivateServiceCall($id, $private_service, TRUE), $this->getParameterCall('some_config'), - )), - ); + ]), + ]; // Tests service with invalid argument. - $services['invalid_argument_service'] = array( + $services['invalid_argument_service'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => $this->getCollection(array( + 'arguments' => $this->getCollection([ 1, // Test passing non-strings, too. - (object) array( + (object) [ 'type' => 'invalid', - ), - )), - ); + ], + ]), + ]; - $services['invalid_arguments_service'] = array( + $services['invalid_arguments_service'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => (object) array( + 'arguments' => (object) [ 'type' => 'invalid', - ), - ); + ], + ]; // Test service that needs deep-traversal. - $services['service_using_array'] = array( + $services['service_using_array'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => $this->getCollection(array( - $this->getCollection(array( + 'arguments' => $this->getCollection([ + $this->getCollection([ $this->getServiceCall('other.service'), - )), + ]), $this->getParameterCall('some_private_config'), - )), - ); + ]), + ]; - $services['service_with_optional_dependency'] = array( + $services['service_with_optional_dependency'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => $this->getCollection(array( + 'arguments' => $this->getCollection([ $this->getServiceCall('service.does_not_exist', ContainerInterface::NULL_ON_INVALID_REFERENCE), $this->getParameterCall('some_private_config'), - )), + ]), - ); + ]; - $services['factory_service'] = array( + $services['factory_service'] = [ 'class' => '\Drupal\service_container\ServiceContainer\ControllerInterface', - 'factory' => array( + 'factory' => [ $this->getServiceCall('service.provider'), 'getFactoryMethod', - ), - 'arguments' => $this->getCollection(array( + ], + 'arguments' => $this->getCollection([ $this->getParameterCall('factory_service_class'), - )), - ); - $services['factory_class'] = array( + ]), + ]; + $services['factory_class'] = [ 'class' => '\Drupal\service_container\ServiceContainer\ControllerInterface', 'factory' => '\Drupal\Tests\Component\DependencyInjection\MockService::getFactoryMethod', - 'arguments' => array( + 'arguments' => [ '\Drupal\Tests\Component\DependencyInjection\MockService', - array(NULL, 'bar'), - ), - 'calls' => array( - array('setContainer', $this->getCollection(array( + [NULL, 'bar'], + ], + 'calls' => [ + ['setContainer', $this->getCollection([ $this->getServiceCall('service_container'), - ))), - ), - ); + ])], + ], + ]; - $services['wrong_factory'] = array( + $services['wrong_factory'] = [ 'class' => '\Drupal\service_container\ServiceContainer\ControllerInterface', - 'factory' => (object) array('I am not a factory, but I pretend to be.'), - ); + 'factory' => (object) ['I am not a factory, but I pretend to be.'], + ]; - $services['circular_dependency'] = array( + $services['circular_dependency'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => $this->getCollection(array( + 'arguments' => $this->getCollection([ $this->getServiceCall('circular_dependency'), - )), - ); - $services['synthetic'] = array( + ]), + ]; + $services['synthetic'] = [ 'synthetic' => TRUE, - ); + ]; // The file could have been named as a .php file. The reason it is a .data // file is that SimpleTest tries to load it. SimpleTest does not like such // fixtures and hence we use a neutral name like .data. - $services['container_test_file_service_test'] = array( + $services['container_test_file_service_test'] = [ 'class' => '\stdClass', 'file' => __DIR__ . '/Fixture/container_test_file_service_test_service_function.data', - ); + ]; // Test multiple arguments. - $args = array(); + $args = []; for ($i = 0; $i < 12; $i++) { - $services['service_test_instantiation_' . $i] = array( + $services['service_test_instantiation_' . $i] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockInstantiationService', // Also test a collection that does not need resolving. 'arguments' => $this->getCollection($args, FALSE), - ); + ]; $args[] = 'arg_' . $i; } - $services['service_parameter_not_exists'] = array( + $services['service_parameter_not_exists'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => $this->getCollection(array( + 'arguments' => $this->getCollection([ $this->getServiceCall('service.provider'), $this->getParameterCall('not_exists'), - )), - ); - $services['service_dependency_not_exists'] = array( + ]), + ]; + $services['service_dependency_not_exists'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => $this->getCollection(array( + 'arguments' => $this->getCollection([ $this->getServiceCall('service_not_exists'), $this->getParameterCall('some_config'), - )), - ); + ]), + ]; - $services['service_with_parameter_service'] = array( + $services['service_with_parameter_service'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => $this->getCollection(array( + 'arguments' => $this->getCollection([ $this->getParameterCall('service_from_parameter'), // Also test deep collections that don't need resolving. - $this->getCollection(array( + $this->getCollection([ 1, - ), FALSE), - )), - ); + ], FALSE), + ]), + ]; // To ensure getAlternatives() finds something. - $services['service_not_exists_similar'] = array( + $services['service_not_exists_similar'] = [ 'synthetic' => TRUE, - ); + ]; // Test configurator. - $services['configurator'] = array( + $services['configurator'] = [ 'synthetic' => TRUE, - ); - $services['configurable_service'] = array( + ]; + $services['configurable_service'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => array(), - 'configurator' => array( + 'arguments' => [], + 'configurator' => [ $this->getServiceCall('configurator'), 'configureService' - ), - ); - $services['configurable_service_exception'] = array( + ], + ]; + $services['configurable_service_exception'] = [ 'class' => '\Drupal\Tests\Component\DependencyInjection\MockService', - 'arguments' => array(), + 'arguments' => [], 'configurator' => 'configurator_service_test_does_not_exist', - ); + ]; - $aliases = array(); + $aliases = []; $aliases['service.provider_alias'] = 'service.provider'; $aliases['late.service_alias'] = 'late.service'; - return array( + return [ 'aliases' => $aliases, 'parameters' => $parameters, 'services' => $services, 'frozen' => TRUE, 'machine_format' => $this->machineFormat, - ); + ]; } /** * Helper function to return a service definition. */ protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { - return (object) array( + return (object) [ 'type' => 'service', 'id' => $id, 'invalidBehavior' => $invalid_behavior, - ); + ]; } /** * Helper function to return a service definition. */ protected function getParameterCall($name) { - return (object) array( + return (object) [ 'type' => 'parameter', 'name' => $name, - ); + ]; } /** @@ -1003,23 +1003,23 @@ protected function getPrivateServiceCall($id, $service_definition, $shared = FAL $hash = sha1(serialize($service_definition)); $id = 'private__' . $hash; } - return (object) array( + return (object) [ 'type' => 'private_service', 'id' => $id, 'value' => $service_definition, 'shared' => $shared, - ); + ]; } /** * Helper function to return a machine-optimized collection. */ protected function getCollection($collection, $resolve = TRUE) { - return (object) array( + return (object) [ 'type' => 'collection', 'value' => $collection, 'resolve' => $resolve, - ); + ]; } } @@ -1188,7 +1188,7 @@ public function getSomeOtherParameter() { * @return object * The instantiated service object. */ - public static function getFactoryMethod($class, $arguments = array()) { + public static function getFactoryMethod($class, $arguments = []) { $r = new \ReflectionClass($class); $service = ($r->getConstructor() === NULL) ? $r->newInstance() : $r->newInstanceArgs($arguments); diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php index 49b6556..b7b1e0e 100644 --- a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php +++ b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php @@ -61,15 +61,15 @@ class OptimizedPhpArrayDumperTest extends \PHPUnit_Framework_TestCase { protected function setUp() { // Setup a mock container builder. $this->containerBuilder = $this->prophesize('\Symfony\Component\DependencyInjection\ContainerBuilder'); - $this->containerBuilder->getAliases()->willReturn(array()); + $this->containerBuilder->getAliases()->willReturn([]); $this->containerBuilder->getParameterBag()->willReturn(new ParameterBag()); $this->containerBuilder->getDefinitions()->willReturn(NULL); $this->containerBuilder->isFrozen()->willReturn(TRUE); - $definition = array(); - $definition['aliases'] = array(); - $definition['parameters'] = array(); - $definition['services'] = array(); + $definition = []; + $definition['aliases'] = []; + $definition['parameters'] = []; + $definition['services'] = []; $definition['frozen'] = TRUE; $definition['machine_format'] = $this->machineFormat; @@ -113,17 +113,17 @@ public function testGetAliases($aliases, $definition_aliases) { * - aliases as expected in the container definition. */ public function getAliasesDataProvider() { - return array( - array(array(), array()), - array( - array('foo' => 'foo.alias'), - array('foo' => 'foo.alias'), - ), - array( - array('foo' => 'foo.alias', 'foo.alias' => 'foo.alias.alias'), - array('foo' => 'foo.alias.alias', 'foo.alias' => 'foo.alias.alias'), - ), - ); + return [ + [[], []], + [ + ['foo' => 'foo.alias'], + ['foo' => 'foo.alias'], + ], + [ + ['foo' => 'foo.alias', 'foo.alias' => 'foo.alias.alias'], + ['foo' => 'foo.alias.alias', 'foo.alias' => 'foo.alias.alias'], + ], + ]; } /** @@ -163,34 +163,34 @@ public function testGetParameters($parameters, $definition_parameters, $is_froze * - frozen value */ public function getParametersDataProvider() { - return array( - array(array(), array(), TRUE), - array( - array('foo' => 'value_foo'), - array('foo' => 'value_foo'), + return [ + [[], [], TRUE], + [ + ['foo' => 'value_foo'], + ['foo' => 'value_foo'], TRUE, - ), - array( - array('foo' => array('llama' => 'yes')), - array('foo' => array('llama' => 'yes')), + ], + [ + ['foo' => ['llama' => 'yes']], + ['foo' => ['llama' => 'yes']], TRUE, - ), - array( - array('foo' => '%llama%', 'llama' => 'yes'), - array('foo' => '%%llama%%', 'llama' => 'yes'), + ], + [ + ['foo' => '%llama%', 'llama' => 'yes'], + ['foo' => '%%llama%%', 'llama' => 'yes'], TRUE, - ), - array( - array('foo' => '%llama%', 'llama' => 'yes'), - array('foo' => '%llama%', 'llama' => 'yes'), + ], + [ + ['foo' => '%llama%', 'llama' => 'yes'], + ['foo' => '%llama%', 'llama' => 'yes'], FALSE, - ), - array( - array('reference' => new Reference('referenced_service')), - array('reference' => $this->getServiceCall('referenced_service')), + ], + [ + ['reference' => new Reference('referenced_service')], + ['reference' => $this->getServiceCall('referenced_service')], TRUE, - ), - ); + ], + ]; } /** @@ -235,164 +235,164 @@ public function testGetServiceDefinitions($services, $definition_services) { * - frozen value */ public function getDefinitionsDataProvider() { - $base_service_definition = array( + $base_service_definition = [ 'class' => '\stdClass', 'public' => TRUE, 'file' => FALSE, 'synthetic' => FALSE, 'lazy' => FALSE, - 'arguments' => array(), + 'arguments' => [], 'arguments_count' => 0, - 'properties' => array(), - 'calls' => array(), + 'properties' => [], + 'calls' => [], 'scope' => ContainerInterface::SCOPE_CONTAINER, 'shared' => TRUE, 'factory' => FALSE, 'configurator' => FALSE, - ); + ]; // Test basic flags. - $service_definitions[] = array() + $base_service_definition; + $service_definitions[] = [] + $base_service_definition; - $service_definitions[] = array( + $service_definitions[] = [ 'public' => FALSE, - ) + $base_service_definition; + ] + $base_service_definition; - $service_definitions[] = array( + $service_definitions[] = [ 'file' => 'test_include.php', - ) + $base_service_definition; + ] + $base_service_definition; - $service_definitions[] = array( + $service_definitions[] = [ 'synthetic' => TRUE, - ) + $base_service_definition; + ] + $base_service_definition; - $service_definitions[] = array( + $service_definitions[] = [ 'shared' => FALSE, - ) + $base_service_definition; + ] + $base_service_definition; - $service_definitions[] = array( + $service_definitions[] = [ 'lazy' => TRUE, - ) + $base_service_definition; + ] + $base_service_definition; // Test a basic public Reference. - $service_definitions[] = array( - 'arguments' => array('foo', new Reference('bar')), + $service_definitions[] = [ + 'arguments' => ['foo', new Reference('bar')], 'arguments_count' => 2, - 'arguments_expected' => $this->getCollection(array('foo', $this->getServiceCall('bar'))), - ) + $base_service_definition; + 'arguments_expected' => $this->getCollection(['foo', $this->getServiceCall('bar')]), + ] + $base_service_definition; // Test a public reference that should not throw an Exception. $reference = new Reference('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE); - $service_definitions[] = array( - 'arguments' => array($reference), + $service_definitions[] = [ + 'arguments' => [$reference], 'arguments_count' => 1, - 'arguments_expected' => $this->getCollection(array($this->getServiceCall('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE))), - ) + $base_service_definition; + 'arguments_expected' => $this->getCollection([$this->getServiceCall('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE)]), + ] + $base_service_definition; // Test a private shared service, denoted by having a Reference. - $private_definition = array( + $private_definition = [ 'class' => '\stdClass', 'public' => FALSE, 'arguments_count' => 0, - ); + ]; - $service_definitions[] = array( - 'arguments' => array('foo', new Reference('private_definition')), + $service_definitions[] = [ + 'arguments' => ['foo', new Reference('private_definition')], 'arguments_count' => 2, - 'arguments_expected' => $this->getCollection(array( + 'arguments_expected' => $this->getCollection([ 'foo', $this->getPrivateServiceCall('private_definition', $private_definition, TRUE), - )), - ) + $base_service_definition; + ]), + ] + $base_service_definition; // Test a private non-shared service, denoted by having a Definition. $private_definition_object = new Definition('\stdClass'); $private_definition_object->setPublic(FALSE); - $service_definitions[] = array( - 'arguments' => array('foo', $private_definition_object), + $service_definitions[] = [ + 'arguments' => ['foo', $private_definition_object], 'arguments_count' => 2, - 'arguments_expected' => $this->getCollection(array( + 'arguments_expected' => $this->getCollection([ 'foo', $this->getPrivateServiceCall(NULL, $private_definition), - )), - ) + $base_service_definition; + ]), + ] + $base_service_definition; // Test a deep collection without a reference. - $service_definitions[] = array( - 'arguments' => array(array(array('foo'))), + $service_definitions[] = [ + 'arguments' => [[['foo']]], 'arguments_count' => 1, - ) + $base_service_definition; + ] + $base_service_definition; // Test a deep collection with a reference to resolve. - $service_definitions[] = array( - 'arguments' => array(array(new Reference('bar'))), + $service_definitions[] = [ + 'arguments' => [[new Reference('bar')]], 'arguments_count' => 1, - 'arguments_expected' => $this->getCollection(array($this->getCollection(array($this->getServiceCall('bar'))))), - ) + $base_service_definition; + 'arguments_expected' => $this->getCollection([$this->getCollection([$this->getServiceCall('bar')])]), + ] + $base_service_definition; // Test a collection with a variable to resolve. - $service_definitions[] = array( - 'arguments' => array(new Parameter('llama_parameter')), + $service_definitions[] = [ + 'arguments' => [new Parameter('llama_parameter')], 'arguments_count' => 1, - 'arguments_expected' => $this->getCollection(array($this->getParameterCall('llama_parameter'))), - ) + $base_service_definition; + 'arguments_expected' => $this->getCollection([$this->getParameterCall('llama_parameter')]), + ] + $base_service_definition; // Test objects that have _serviceId property. $drupal_service = new \stdClass(); $drupal_service->_serviceId = 'bar'; - $service_definitions[] = array( - 'arguments' => array($drupal_service), + $service_definitions[] = [ + 'arguments' => [$drupal_service], 'arguments_count' => 1, - 'arguments_expected' => $this->getCollection(array($this->getServiceCall('bar'))), - ) + $base_service_definition; + 'arguments_expected' => $this->getCollection([$this->getServiceCall('bar')]), + ] + $base_service_definition; // Test getMethodCalls. - $calls = array( - array('method', $this->getCollection(array())), - array('method2', $this->getCollection(array())), - ); - $service_definitions[] = array( + $calls = [ + ['method', $this->getCollection([])], + ['method2', $this->getCollection([])], + ]; + $service_definitions[] = [ 'calls' => $calls, - ) + $base_service_definition; + ] + $base_service_definition; - $service_definitions[] = array( + $service_definitions[] = [ 'scope' => ContainerInterface::SCOPE_PROTOTYPE, 'shared' => FALSE, - ) + $base_service_definition; + ] + $base_service_definition; - $service_definitions[] = array( + $service_definitions[] = [ 'shared' => FALSE, - ) + $base_service_definition; + ] + $base_service_definition; // Test factory. - $service_definitions[] = array( - 'factory' => array(new Reference('bar'), 'factoryMethod'), - 'factory_expected' => array($this->getServiceCall('bar'), 'factoryMethod'), - ) + $base_service_definition; + $service_definitions[] = [ + 'factory' => [new Reference('bar'), 'factoryMethod'], + 'factory_expected' => [$this->getServiceCall('bar'), 'factoryMethod'], + ] + $base_service_definition; // Test invalid factory - needed to test deep dumpValue(). - $service_definitions[] = array( - 'factory' => array(array('foo', 'llama'), 'factoryMethod'), - ) + $base_service_definition; + $service_definitions[] = [ + 'factory' => [['foo', 'llama'], 'factoryMethod'], + ] + $base_service_definition; // Test properties. - $service_definitions[] = array( - 'properties' => array('_value' => 'llama'), - ) + $base_service_definition; + $service_definitions[] = [ + 'properties' => ['_value' => 'llama'], + ] + $base_service_definition; // Test configurator. - $service_definitions[] = array( - 'configurator' => array(new Reference('bar'), 'configureService'), - 'configurator_expected' => array($this->getServiceCall('bar'), 'configureService'), - ) + $base_service_definition; + $service_definitions[] = [ + 'configurator' => [new Reference('bar'), 'configureService'], + 'configurator_expected' => [$this->getServiceCall('bar'), 'configureService'], + ] + $base_service_definition; - $services_provided = array(); - $services_provided[] = array( - array(), - array(), - ); + $services_provided = []; + $services_provided[] = [ + [], + [], + ]; foreach ($service_definitions as $service_definition) { $definition = $this->prophesize('\Symfony\Component\DependencyInjection\Definition'); @@ -411,7 +411,7 @@ public function getDefinitionsDataProvider() { $definition->getConfigurator()->willReturn($service_definition['configurator']); // Preserve order. - $filtered_service_definition = array(); + $filtered_service_definition = []; foreach ($base_service_definition as $key => $value) { $filtered_service_definition[$key] = $service_definition[$key]; unset($service_definition[$key]); @@ -429,7 +429,7 @@ public function getDefinitionsDataProvider() { $filtered_service_definition += $service_definition; // Allow to set _expected values. - foreach (array('arguments', 'factory', 'configurator') as $key) { + foreach (['arguments', 'factory', 'configurator'] as $key) { $expected = $key . '_expected'; if (isset($filtered_service_definition[$expected])) { $filtered_service_definition[$key] = $filtered_service_definition[$expected]; @@ -441,17 +441,17 @@ public function getDefinitionsDataProvider() { unset($filtered_service_definition['scope']); if (isset($filtered_service_definition['public']) && $filtered_service_definition['public'] === FALSE) { - $services_provided[] = array( - array('foo_service' => $definition->reveal()), - array(), - ); + $services_provided[] = [ + ['foo_service' => $definition->reveal()], + [], + ]; continue; } - $services_provided[] = array( - array('foo_service' => $definition->reveal()), - array('foo_service' => $this->serializeDefinition($filtered_service_definition)), - ); + $services_provided[] = [ + ['foo_service' => $definition->reveal()], + ['foo_service' => $this->serializeDefinition($filtered_service_definition)], + ]; } return $services_provided; @@ -470,11 +470,11 @@ protected function serializeDefinition(array $service_definition) { * Helper function to return a service definition. */ protected function getServiceCall($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { - return (object) array( + return (object) [ 'type' => 'service', 'id' => $id, 'invalidBehavior' => $invalid_behavior, - ); + ]; } /** @@ -502,9 +502,9 @@ public function testGetServiceDefinitionWithInvalidScope() { */ public function testGetServiceDefinitionWithReferenceToAlias($public) { $bar_definition = new Definition('\stdClass'); - $bar_definition_php_array = array( + $bar_definition_php_array = [ 'class' => '\stdClass', - ); + ]; if (!$public) { $bar_definition->setPublic(FALSE); $bar_definition_php_array['public'] = FALSE; @@ -530,21 +530,21 @@ public function testGetServiceDefinitionWithReferenceToAlias($public) { else { $service_definition = $this->getPrivateServiceCall('bar', $bar_definition_php_array, TRUE); } - $data = array( + $data = [ 'class' => '\stdClass', - 'arguments' => $this->getCollection(array( + 'arguments' => $this->getCollection([ $service_definition, - )), + ]), 'arguments_count' => 1, - ); + ]; $this->assertEquals($this->serializeDefinition($data), $dump['services']['foo'], 'Expected definition matches dump.'); } public function publicPrivateDataProvider() { - return array( - array(TRUE), - array(FALSE), - ); + return [ + [TRUE], + [FALSE], + ]; } /** @@ -628,33 +628,33 @@ protected function getPrivateServiceCall($id, $service_definition, $shared = FAL $hash = sha1(serialize($service_definition)); $id = 'private__' . $hash; } - return (object) array( + return (object) [ 'type' => 'private_service', 'id' => $id, 'value' => $service_definition, 'shared' => $shared, - ); + ]; } /** * Helper function to return a machine-optimized collection. */ protected function getCollection($collection, $resolve = TRUE) { - return (object) array( + return (object) [ 'type' => 'collection', 'value' => $collection, 'resolve' => $resolve, - ); + ]; } /** * Helper function to return a parameter definition. */ protected function getParameterCall($name) { - return (object) array( + return (object) [ 'type' => 'parameter', 'name' => $name, - ); + ]; } } diff --git a/core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php b/core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php index 68b16ee..897a788 100644 --- a/core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php +++ b/core/tests/Drupal/Tests/Component/Discovery/YamlDiscoveryTest.php @@ -34,12 +34,12 @@ public function testDiscovery() { file_put_contents($url . '/test_2/test_4.test.yml', ''); // Set up the directories to search. - $directories = array( + $directories = [ 'test_1' => $url . '/test_1', 'test_2' => $url . '/test_1', 'test_3' => $url . '/test_2', 'test_4' => $url . '/test_2', - ); + ]; $discovery = new YamlDiscovery('test', $directories); $data = $discovery->findAll(); @@ -50,12 +50,12 @@ public function testDiscovery() { $this->assertArrayHasKey('test_3', $data); $this->assertArrayHasKey('test_4', $data); - foreach (array('test_1', 'test_2', 'test_3') as $key) { + foreach (['test_1', 'test_2', 'test_3'] as $key) { $this->assertArrayHasKey('name', $data[$key]); $this->assertEquals($data[$key]['name'], 'test'); } - $this->assertSame(array(), $data['test_4']); + $this->assertSame([], $data['test_4']); } } diff --git a/core/tests/Drupal/Tests/Component/DrupalComponentTest.php b/core/tests/Drupal/Tests/Component/DrupalComponentTest.php index 11ce86f..7e746d73 100644 --- a/core/tests/Drupal/Tests/Component/DrupalComponentTest.php +++ b/core/tests/Drupal/Tests/Component/DrupalComponentTest.php @@ -42,7 +42,7 @@ public function testNoCoreInComponentTests() { * An array of class paths. */ protected function findPhpClasses($dir) { - $classes = array(); + $classes = []; foreach (new \DirectoryIterator($dir) as $file) { if ($file->isDir() && !$file->isDot()) { $classes = array_merge($classes, $this->findPhpClasses($file->getPathname())); @@ -80,26 +80,26 @@ protected function assertNoCoreUsage($class_path) { * - File data as a string. This will be used as a virtual file. */ public function providerAssertNoCoreUseage() { - return array( - array( + return [ + [ TRUE, '@see \\Drupal\\Core\\Something', - ), - array( + ], + [ FALSE, '\\Drupal\\Core\\Something', - ), - array( + ], + [ FALSE, "@see \\Drupal\\Core\\Something\n" . '\\Drupal\\Core\\Something', - ), - array( + ], + [ FALSE, "\\Drupal\\Core\\Something\n" . '@see \\Drupal\\Core\\Something', - ), - ); + ], + ]; } /** diff --git a/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php b/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php index eab85b3..113f6cd 100644 --- a/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php +++ b/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php @@ -48,22 +48,22 @@ public function testPluralsFormula($plural, $expected) { * value. */ public function providerTestPluralsFormula() { - return array( - array( + return [ + [ 'nplurals=1; plural=0;', - array('default' => 0), - ), - array( + ['default' => 0], + ], + [ 'nplurals=2; plural=(n > 1);', - array(0 => 0, 1 => 0, 'default' => 1), - ), - array( + [0 => 0, 1 => 0, 'default' => 1], + ], + [ 'nplurals=2; plural=(n!=1);', - array(1 => 0, 'default' => 1), - ), - array( + [1 => 0, 'default' => 1], + ], + [ 'nplurals=2; plural=(((n==1)||((n%10)==1))?(0):1);', - array( + [ 1 => 0, 11 => 0, 21 => 0, @@ -85,11 +85,11 @@ public function providerTestPluralsFormula() { 181 => 0, 191 => 0, 'default' => 1, - ), - ), - array( + ], + ], + [ 'nplurals=3; plural=((((n%10)==1)&&((n%100)!=11))?(0):(((((n%10)>=2)&&((n%10)<=4))&&(((n%100)<10)||((n%100)>=20)))?(1):2));', - array( + [ 1 => 0, 2 => 1, 3 => 1, @@ -163,21 +163,21 @@ public function providerTestPluralsFormula() { 193 => 1, 194 => 1, 'default' => 2, - ), - ), - array( + ], + ], + [ 'nplurals=3; plural=((n==1)?(0):(((n>=2)&&(n<=4))?(1):2));', - array( + [ 1 => 0, 2 => 1, 3 => 1, 4 => 1, 'default' => 2, - ), - ), - array( + ], + ], + [ 'nplurals=3; plural=((n==1)?(0):(((n==0)||(((n%100)>0)&&((n%100)<20)))?(1):2));', - array( + [ 0 => 1, 1 => 0, 2 => 1, @@ -218,11 +218,11 @@ public function providerTestPluralsFormula() { 118 => 1, 119 => 1, 'default' => 2, - ), - ), - array( + ], + ], + [ 'nplurals=3; plural=((n==1)?(0):(((((n%10)>=2)&&((n%10)<=4))&&(((n%100)<10)||((n%100)>=20)))?(1):2));', - array( + [ 1 => 0, 2 => 1, 3 => 1, @@ -279,10 +279,10 @@ public function providerTestPluralsFormula() { 193 => 1, 194 => 1, 'default' => 2, - ),), - array( + ], ], + [ 'nplurals=4; plural=(((n==1)||(n==11))?(0):(((n==2)||(n==12))?(1):(((n>2)&&(n<20))?(2):3)));', - array( + [ 1 => 0, 2 => 1, 3 => 2, @@ -303,11 +303,11 @@ public function providerTestPluralsFormula() { 18 => 2, 19 => 2, 'default' => 3, - ), - ), - array( + ], + ], + [ 'nplurals=4; plural=(((n%100)==1)?(0):(((n%100)==2)?(1):((((n%100)==3)||((n%100)==4))?(2):3)));', - array( + [ 1 => 0, 2 => 1, 3 => 2, @@ -317,11 +317,11 @@ public function providerTestPluralsFormula() { 103 => 2, 104 => 2, 'default' => 3, - ), - ), - array( + ], + ], + [ 'nplurals=5; plural=((n==1)?(0):((n==2)?(1):((n<7)?(2):((n<11)?(3):4))));', - array( + [ 0 => 2, 1 => 0, 2 => 1, @@ -334,11 +334,11 @@ public function providerTestPluralsFormula() { 9 => 3, 10 => 3, 'default' => 4, - ), - ), - array( + ], + ], + [ 'nplurals=6; plural=((n==1)?(0):((n==0)?(1):((n==2)?(2):((((n%100)>=3)&&((n%100)<=10))?(3):((((n%100)>=11)&&((n%100)<=99))?(4):5)))));', - array( + [ 0 => 1, 1 => 0, 2 => 2, @@ -362,9 +362,9 @@ public function providerTestPluralsFormula() { 109 => 3, 110 => 3, 'default' => 4, - ), - ), - ); + ], + ], + ]; } } diff --git a/core/tests/Drupal/Tests/Component/Graph/GraphTest.php b/core/tests/Drupal/Tests/Component/Graph/GraphTest.php index e17c7ff..9c4a7a5 100644 --- a/core/tests/Drupal/Tests/Component/Graph/GraphTest.php +++ b/core/tests/Drupal/Tests/Component/Graph/GraphTest.php @@ -21,59 +21,59 @@ public function testDepthFirstSearch() { // | | | // | | | // +---> 4 <-- 7 8 ---> 9 - $graph = $this->normalizeGraph(array( - 1 => array(2), - 2 => array(3, 4), - 3 => array(), - 4 => array(3), - 5 => array(6), - 7 => array(4, 5), - 8 => array(9), - 9 => array(), - )); + $graph = $this->normalizeGraph([ + 1 => [2], + 2 => [3, 4], + 3 => [], + 4 => [3], + 5 => [6], + 7 => [4, 5], + 8 => [9], + 9 => [], + ]); $graph_object = new Graph($graph); $graph = $graph_object->searchAndSort(); - $expected_paths = array( - 1 => array(2, 3, 4), - 2 => array(3, 4), - 3 => array(), - 4 => array(3), - 5 => array(6), - 7 => array(4, 3, 5, 6), - 8 => array(9), - 9 => array(), - ); + $expected_paths = [ + 1 => [2, 3, 4], + 2 => [3, 4], + 3 => [], + 4 => [3], + 5 => [6], + 7 => [4, 3, 5, 6], + 8 => [9], + 9 => [], + ]; $this->assertPaths($graph, $expected_paths); - $expected_reverse_paths = array( - 1 => array(), - 2 => array(1), - 3 => array(2, 1, 4, 7), - 4 => array(2, 1, 7), - 5 => array(7), - 7 => array(), - 8 => array(), - 9 => array(8), - ); + $expected_reverse_paths = [ + 1 => [], + 2 => [1], + 3 => [2, 1, 4, 7], + 4 => [2, 1, 7], + 5 => [7], + 7 => [], + 8 => [], + 9 => [8], + ]; $this->assertReversePaths($graph, $expected_reverse_paths); // Assert that DFS didn't created "missing" vertexes automatically. $this->assertFalse(isset($graph[6]), 'Vertex 6 has not been created'); - $expected_components = array( - array(1, 2, 3, 4, 5, 7), - array(8, 9), - ); + $expected_components = [ + [1, 2, 3, 4, 5, 7], + [8, 9], + ]; $this->assertComponents($graph, $expected_components); - $expected_weights = array( - array(1, 2, 3), - array(2, 4, 3), - array(7, 4, 3), - array(7, 5), - array(8, 9), - ); + $expected_weights = [ + [1, 2, 3], + [2, 4, 3], + [7, 4, 3], + [7, 5], + [8, 9], + ]; $this->assertWeights($graph, $expected_weights); } @@ -87,10 +87,10 @@ public function testDepthFirstSearch() { * The normalized version of a graph. */ protected function normalizeGraph($graph) { - $normalized_graph = array(); + $normalized_graph = []; foreach ($graph as $vertex => $edges) { // Create vertex even if it hasn't any edges. - $normalized_graph[$vertex] = array(); + $normalized_graph[$vertex] = []; foreach ($edges as $edge) { $normalized_graph[$vertex]['edges'][$edge] = TRUE; } @@ -110,7 +110,7 @@ protected function assertPaths($graph, $expected_paths) { foreach ($expected_paths as $vertex => $paths) { // Build an array with keys = $paths and values = TRUE. $expected = array_fill_keys($paths, TRUE); - $result = isset($graph[$vertex]['paths']) ? $graph[$vertex]['paths'] : array(); + $result = isset($graph[$vertex]['paths']) ? $graph[$vertex]['paths'] : []; $this->assertEquals($expected, $result, sprintf('Expected paths for vertex %s: %s, got %s', $vertex, $this->displayArray($expected, TRUE), $this->displayArray($result, TRUE))); } } @@ -128,7 +128,7 @@ protected function assertReversePaths($graph, $expected_reverse_paths) { foreach ($expected_reverse_paths as $vertex => $paths) { // Build an array with keys = $paths and values = TRUE. $expected = array_fill_keys($paths, TRUE); - $result = isset($graph[$vertex]['reverse_paths']) ? $graph[$vertex]['reverse_paths'] : array(); + $result = isset($graph[$vertex]['reverse_paths']) ? $graph[$vertex]['reverse_paths'] : []; $this->assertEquals($expected, $result, sprintf('Expected reverse paths for vertex %s: %s, got %s', $vertex, $this->displayArray($expected, TRUE), $this->displayArray($result, TRUE))); } } @@ -144,14 +144,14 @@ protected function assertReversePaths($graph, $expected_reverse_paths) { protected function assertComponents($graph, $expected_components) { $unassigned_vertices = array_fill_keys(array_keys($graph), TRUE); foreach ($expected_components as $component) { - $result_components = array(); + $result_components = []; foreach ($component as $vertex) { $result_components[] = $graph[$vertex]['component']; unset($unassigned_vertices[$vertex]); } $this->assertEquals(1, count(array_unique($result_components)), sprintf('Expected one unique component for vertices %s, got %s', $this->displayArray($component), $this->displayArray($result_components))); } - $this->assertEquals(array(), $unassigned_vertices, sprintf('Vertices not assigned to a component: %s', $this->displayArray($unassigned_vertices, TRUE))); + $this->assertEquals([], $unassigned_vertices, sprintf('Vertices not assigned to a component: %s', $this->displayArray($unassigned_vertices, TRUE))); } /** diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php index eca1241..8b8c95a 100644 --- a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php +++ b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageReadOnlyTest.php @@ -33,15 +33,15 @@ class FileStorageReadOnlyTest extends PhpStorageTestBase { protected function setUp() { parent::setUp(); - $this->standardSettings = array( + $this->standardSettings = [ 'directory' => $this->directory, 'bin' => 'test', - ); - $this->readonlyStorage = array( + ]; + $this->readonlyStorage = [ 'directory' => $this->directory, // Let this read from the bin where the other instance is writing. 'bin' => 'test', - ); + ]; } /** diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php index 25a0ed0..a1a11ec 100644 --- a/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php +++ b/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php @@ -24,10 +24,10 @@ class FileStorageTest extends PhpStorageTestBase { protected function setUp() { parent::setUp(); - $this->standardSettings = array( + $this->standardSettings = [ 'directory' => $this->directory, 'bin' => 'test', - ); + ]; } /** diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFastFileStorageTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFastFileStorageTest.php index 726cd1c..577241d 100644 --- a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFastFileStorageTest.php +++ b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFastFileStorageTest.php @@ -19,7 +19,7 @@ class MTimeProtectedFastFileStorageTest extends MTimeProtectedFileStorageBase { * include the hacked file on the first try but the second test will change * the directory mtime and so on the second try the file will not be included. */ - protected $expected = array(TRUE, FALSE); + protected $expected = [TRUE, FALSE]; /** * The PHP storage class to test. diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageBase.php b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageBase.php index 64d17eb..bab4900 100644 --- a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageBase.php +++ b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageBase.php @@ -36,11 +36,11 @@ protected function setUp() { $this->secret = $this->randomMachineName(); - $this->settings = array( + $this->settings = [ 'directory' => $this->directory, 'bin' => 'test', 'secret' => $this->secret, - ); + ]; } /** @@ -88,7 +88,7 @@ public function testSecurity() { // Ensure the root directory for the bin has a .htaccess file denying web // access. - $this->assertSame(file_get_contents($expected_root_directory . '/.htaccess'), call_user_func(array($this->storageClass, 'htaccessLines'))); + $this->assertSame(file_get_contents($expected_root_directory . '/.htaccess'), call_user_func([$this->storageClass, 'htaccessLines'])); // Ensure that if the file is replaced with an untrusted one (due to another // script's file upload vulnerability), it does not get loaded. Since mtime diff --git a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageTest.php b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageTest.php index 15b75e7..bc88c33 100644 --- a/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageTest.php +++ b/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFileStorageTest.php @@ -18,7 +18,7 @@ class MTimeProtectedFileStorageTest extends MTimeProtectedFileStorageBase { * The default implementation protects against even the filemtime change so * both iterations will return FALSE. */ - protected $expected = array(FALSE, FALSE); + protected $expected = [FALSE, FALSE]; /** * The PHP storage class to test. diff --git a/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php b/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php index 917379e..f320c55 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/Context/ContextTest.php @@ -30,7 +30,7 @@ public function testGetContextValue($expected, $context_value, $is_required, $da // Mock a Context object. $mock_context = $this->getMockBuilder('Drupal\Component\Plugin\Context\Context') ->disableOriginalConstructor() - ->setMethods(array('getContextDefinition')) + ->setMethods(['getContextDefinition']) ->getMock(); // If the context value exists, getContextValue() behaves like a normal @@ -49,7 +49,7 @@ public function testGetContextValue($expected, $context_value, $is_required, $da else { // Create a mock definition. $mock_definition = $this->getMockBuilder('Drupal\Component\Plugin\Context\ContextDefinitionInterface') - ->setMethods(array('isRequired', 'getDataType')) + ->setMethods(['isRequired', 'getDataType']) ->getMockForAbstractClass(); // Set expectation for isRequired(). @@ -87,7 +87,7 @@ public function testGetContextValue($expected, $context_value, $is_required, $da */ public function testDefaultValue() { $mock_definition = $this->getMockBuilder('Drupal\Component\Plugin\Context\ContextDefinitionInterface') - ->setMethods(array('getDefaultValue')) + ->setMethods(['getDefaultValue']) ->getMockForAbstractClass(); $mock_definition->expects($this->once()) diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php index 5218ec2..0f112fb 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryCachedTraitTest.php @@ -21,11 +21,11 @@ class DiscoveryCachedTraitTest extends UnitTestCase { * - Plugin name to query for. */ public function providerGetDefinition() { - return array( + return [ ['definition', [], ['plugin_name' => 'definition'], 'plugin_name'], ['definition', ['plugin_name' => 'definition'], [], 'plugin_name'], [NULL, ['plugin_name' => 'definition'], [], 'bad_plugin_name'], - ); + ]; } /** diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php index 9f747f9..74a8c43 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/DiscoveryTraitTest.php @@ -19,10 +19,10 @@ class DiscoveryTraitTest extends UnitTestCase { * - Plugin ID to get, passed to doGetDefinition(). */ public function providerDoGetDefinition() { - return array( + return [ ['definition', ['plugin_name' => 'definition'], 'plugin_name'], [NULL, ['plugin_name' => 'definition'], 'bad_plugin_name'], - ); + ]; } /** @@ -51,9 +51,9 @@ public function testDoGetDefinition($expected, $definitions, $plugin_id) { * - Plugin ID to get, passed to doGetDefinition(). */ public function providerDoGetDefinitionException() { - return array( + return [ [FALSE, ['plugin_name' => 'definition'], 'bad_plugin_name'], - ); + ]; } /** @@ -123,10 +123,10 @@ public function testGetDefinitionException($expected, $definitions, $plugin_id) * - Plugin ID to look for. */ public function providerHasDefinition() { - return array( + return [ [TRUE, 'valid'], [FALSE, 'not_valid'], - ); + ]; } /** @@ -135,16 +135,16 @@ public function providerHasDefinition() { */ public function testHasDefinition($expected, $plugin_id) { $trait = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\DiscoveryTrait') - ->setMethods(array('getDefinition')) + ->setMethods(['getDefinition']) ->getMockForTrait(); // Set up our mocked getDefinition() to return TRUE for 'valid' and FALSE // for 'not_valid'. $trait->expects($this->once()) ->method('getDefinition') - ->will($this->returnValueMap(array( + ->will($this->returnValueMap([ ['valid', FALSE, TRUE], ['not_valid', FALSE, FALSE], - ))); + ])); // Call hasDefinition(). $this->assertSame( $expected, diff --git a/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php b/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php index bdab19c..1828d73 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/Discovery/StaticDiscoveryDecoratorTest.php @@ -23,7 +23,7 @@ class StaticDiscoveryDecoratorTest extends UnitTestCase { */ public function getRegisterDefinitionsCallback() { $mock_callable = $this->getMockBuilder('\stdClass') - ->setMethods(array('registerDefinitionsCallback')) + ->setMethods(['registerDefinitionsCallback']) ->getMock(); // Set expectations for the callback method. $mock_callable->expects($this->once()) @@ -62,7 +62,7 @@ public function testGetDefinition($expected, $has_register_definitions, $excepti // Mock our StaticDiscoveryDecorator. $mock_decorator = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\StaticDiscoveryDecorator') ->disableOriginalConstructor() - ->setMethods(array('registeredDefintionCallback')) + ->setMethods(['registeredDefintionCallback']) ->getMock(); // Set up the ::$registerDefinitions property. @@ -72,7 +72,7 @@ public function testGetDefinition($expected, $has_register_definitions, $excepti // Set the callback object on the mocked decorator. $ref_register_definitions->setValue( $mock_decorator, - array($this->getRegisterDefinitionsCallback(), 'registerDefinitionsCallback') + [$this->getRegisterDefinitionsCallback(), 'registerDefinitionsCallback'] ); } else { @@ -83,11 +83,11 @@ public function testGetDefinition($expected, $has_register_definitions, $excepti // Set up ::$definitions to an empty array. $ref_definitions = new \ReflectionProperty($mock_decorator, 'definitions'); $ref_definitions->setAccessible(TRUE); - $ref_definitions->setValue($mock_decorator, array()); + $ref_definitions->setValue($mock_decorator, []); // Mock a decorated object. $mock_decorated = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\DiscoveryInterface') - ->setMethods(array('getDefinitions')) + ->setMethods(['getDefinitions']) ->getMockForAbstractClass(); // Return our definitions from getDefinitions(). $mock_decorated->expects($this->once()) @@ -132,7 +132,7 @@ public function testGetDefinitions($has_register_definitions, $definitions) { // Mock our StaticDiscoveryDecorator. $mock_decorator = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\StaticDiscoveryDecorator') ->disableOriginalConstructor() - ->setMethods(array('registeredDefintionCallback')) + ->setMethods(['registeredDefintionCallback']) ->getMock(); // Set up the ::$registerDefinitions property. @@ -142,7 +142,7 @@ public function testGetDefinitions($has_register_definitions, $definitions) { // Set the callback object on the mocked decorator. $ref_register_definitions->setValue( $mock_decorator, - array($this->getRegisterDefinitionsCallback(), 'registerDefinitionsCallback') + [$this->getRegisterDefinitionsCallback(), 'registerDefinitionsCallback'] ); } else { @@ -153,11 +153,11 @@ public function testGetDefinitions($has_register_definitions, $definitions) { // Set up ::$definitions to an empty array. $ref_definitions = new \ReflectionProperty($mock_decorator, 'definitions'); $ref_definitions->setAccessible(TRUE); - $ref_definitions->setValue($mock_decorator, array()); + $ref_definitions->setValue($mock_decorator, []); // Mock a decorated object. $mock_decorated = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\DiscoveryInterface') - ->setMethods(array('getDefinitions')) + ->setMethods(['getDefinitions']) ->getMockForAbstractClass(); // Our mocked method will return any arguments sent to it. $mock_decorated->expects($this->once()) @@ -199,7 +199,7 @@ public function providerCall() { public function testCall($method, $args) { // Mock a decorated object. $mock_decorated = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\DiscoveryInterface') - ->setMethods(array($method)) + ->setMethods([$method]) ->getMockForAbstractClass(); // Our mocked method will return any arguments sent to it. $mock_decorated->expects($this->once()) @@ -222,7 +222,7 @@ function () { // Exercise __call. $this->assertArrayEquals( $args, - \call_user_func_array(array($mock_decorated, $method), $args) + \call_user_func_array([$mock_decorated, $method], $args) ); } diff --git a/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php b/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php index 8130b2d..c6a0adf 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php @@ -88,7 +88,7 @@ public function providerGetInstanceArguments() { public function testCreateInstance($expected, $reflector_name, $plugin_id, $plugin_definition, $configuration) { // Create a mock DiscoveryInterface which can return our plugin definition. $mock_discovery = $this->getMockBuilder('Drupal\Component\Plugin\Discovery\DiscoveryInterface') - ->setMethods(array('getDefinition', 'getDefinitions', 'hasDefinition')) + ->setMethods(['getDefinition', 'getDefinitions', 'hasDefinition']) ->getMock(); $mock_discovery->expects($this->never())->method('getDefinitions'); $mock_discovery->expects($this->never())->method('hasDefinition'); diff --git a/core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php b/core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php index 6009932..0ef8451 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/PluginBaseTest.php @@ -15,11 +15,11 @@ class PluginBaseTest extends UnitTestCase { * @covers ::getPluginId */ public function testGetPluginId($plugin_id, $expected) { - $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', array( - array(), + $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', [ + [], $plugin_id, - array(), - )); + [], + ]); $this->assertEquals($expected, $plugin_base->getPluginId()); } @@ -30,10 +30,10 @@ public function testGetPluginId($plugin_id, $expected) { * @return array */ public function providerTestGetPluginId() { - return array( - array('base_id', 'base_id'), - array('base_id:derivative', 'base_id:derivative'), - ); + return [ + ['base_id', 'base_id'], + ['base_id:derivative', 'base_id:derivative'], + ]; } /** @@ -42,11 +42,11 @@ public function providerTestGetPluginId() { */ public function testGetBaseId($plugin_id, $expected) { /** @var \Drupal\Component\Plugin\PluginBase|\PHPUnit_Framework_MockObject_MockObject $plugin_base */ - $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', array( - array(), + $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', [ + [], $plugin_id, - array(), - )); + [], + ]); $this->assertEquals($expected, $plugin_base->getBaseId()); } @@ -57,10 +57,10 @@ public function testGetBaseId($plugin_id, $expected) { * @return array */ public function providerTestGetBaseId() { - return array( - array('base_id', 'base_id'), - array('base_id:derivative', 'base_id'), - ); + return [ + ['base_id', 'base_id'], + ['base_id:derivative', 'base_id'], + ]; } @@ -70,11 +70,11 @@ public function providerTestGetBaseId() { */ public function testGetDerivativeId($plugin_id = NULL, $expected = NULL) { /** @var \Drupal\Component\Plugin\PluginBase|\PHPUnit_Framework_MockObject_MockObject $plugin_base */ - $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', array( - array(), + $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', [ + [], $plugin_id, - array(), - )); + [], + ]); $this->assertEquals($expected, $plugin_base->getDerivativeId()); } @@ -85,23 +85,23 @@ public function testGetDerivativeId($plugin_id = NULL, $expected = NULL) { * @return array */ public function providerTestGetDerivativeId() { - return array( - array('base_id', NULL), - array('base_id:derivative', 'derivative'), - ); + return [ + ['base_id', NULL], + ['base_id:derivative', 'derivative'], + ]; } /** * @covers ::getPluginDefinition */ public function testGetPluginDefinition() { - $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', array( - array(), + $plugin_base = $this->getMockForAbstractClass('Drupal\Component\Plugin\PluginBase', [ + [], 'plugin_id', - array('value', array('key' => 'value')), - )); + ['value', ['key' => 'value']], + ]); - $this->assertEquals(array('value', array('key' => 'value')), $plugin_base->getPluginDefinition()); + $this->assertEquals(['value', ['key' => 'value']], $plugin_base->getPluginDefinition()); } } diff --git a/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php b/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php index 608479a..24a7b08 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php +++ b/core/tests/Drupal/Tests/Component/Plugin/PluginManagerBaseTest.php @@ -21,10 +21,10 @@ public function createInstanceCallback() { if ('invalid' == $plugin_id) { throw new PluginNotFoundException($plugin_id); } - return array( + return [ 'plugin_id' => $plugin_id, 'configuration' => $configuration, - ); + ]; } /** @@ -32,11 +32,11 @@ public function createInstanceCallback() { */ public function getMockFactoryInterface($expects_count) { $mock_factory = $this->getMockBuilder('Drupal\Component\Plugin\Factory\FactoryInterface') - ->setMethods(array('createInstance')) + ->setMethods(['createInstance']) ->getMockForAbstractClass(); $mock_factory->expects($this->exactly($expects_count)) ->method('createInstance') - ->willReturnCallback(array($this, 'createInstanceCallback')); + ->willReturnCallback([$this, 'createInstanceCallback']); return $mock_factory; } @@ -55,7 +55,7 @@ public function testCreateInstance() { $factory_ref->setValue($manager, $this->getMockFactoryInterface(1)); // Finally the test. - $configuration_array = array('config' => 'something'); + $configuration_array = ['config' => 'something']; $result = $manager->createInstance('valid', $configuration_array); $this->assertEquals('valid', $result['plugin_id']); $this->assertArrayEquals($configuration_array, $result['configuration']); @@ -75,7 +75,7 @@ public function testCreateInstanceFallback() { $factory_ref->setAccessible(TRUE); // Set up the configuration array. - $configuration_array = array('config' => 'something'); + $configuration_array = ['config' => 'something']; // Test with fallback interface and valid plugin_id. $factory_ref->setValue($manager, $this->getMockFactoryInterface(1)); diff --git a/core/tests/Drupal/Tests/Component/Plugin/StubFallbackPluginManager.php b/core/tests/Drupal/Tests/Component/Plugin/StubFallbackPluginManager.php index 8dc4f08..50283c6 100644 --- a/core/tests/Drupal/Tests/Component/Plugin/StubFallbackPluginManager.php +++ b/core/tests/Drupal/Tests/Component/Plugin/StubFallbackPluginManager.php @@ -20,7 +20,7 @@ class StubFallbackPluginManager extends PluginManagerBase implements FallbackPlu /** * {@inheritdoc} */ - public function getFallbackPluginId($plugin_id, array $configuration = array()) { + public function getFallbackPluginId($plugin_id, array $configuration = []) { // Minimally implement getFallbackPluginId so that we can test it. return $plugin_id . '_fallback'; } diff --git a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php index 53a14f5..375cd75 100644 --- a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php +++ b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php @@ -381,7 +381,7 @@ public function methodWithParameter($parameter) { class TestServiceComplexMethod { - public function complexMethod($parameter, callable $function, TestServiceNoMethod $test_service = NULL, array &$elements = array()) { + public function complexMethod($parameter, callable $function, TestServiceNoMethod $test_service = NULL, array &$elements = []) { } diff --git a/core/tests/Drupal/Tests/Component/Render/HtmlEscapedTextTest.php b/core/tests/Drupal/Tests/Component/Render/HtmlEscapedTextTest.php index fa6c325..bdbe2b3 100644 --- a/core/tests/Drupal/Tests/Component/Render/HtmlEscapedTextTest.php +++ b/core/tests/Drupal/Tests/Component/Render/HtmlEscapedTextTest.php @@ -33,21 +33,21 @@ public function testToString($text, $expected, $message) { */ function providerToString() { // Checks that invalid multi-byte sequences are escaped. - $tests[] = array("Foo\xC0barbaz", 'Foo�barbaz', 'Escapes invalid sequence "Foo\xC0barbaz"'); - $tests[] = array("\xc2\"", '�"', 'Escapes invalid sequence "\xc2\""'); - $tests[] = array("Fooÿñ", "Fooÿñ", 'Does not escape valid sequence "Fooÿñ"'); + $tests[] = ["Foo\xC0barbaz", 'Foo�barbaz', 'Escapes invalid sequence "Foo\xC0barbaz"']; + $tests[] = ["\xc2\"", '�"', 'Escapes invalid sequence "\xc2\""']; + $tests[] = ["Fooÿñ", "Fooÿñ", 'Does not escape valid sequence "Fooÿñ"']; // Checks that special characters are escaped. $script_tag = $this->prophesize(MarkupInterface::class); $script_tag->__toString()->willReturn('', 'script', 'HTML tag stripping -- simple script without special characters.', - ), - array( + ], + [ '', 'script', 'HTML tag stripping evasion -- non whitespace character after tag name.', - ), - array( + ], + [ '', 'script', 'HTML tag stripping evasion -- no space between tag and attribute.', - ), + ], // Null between < and tag name works at least with IE6. - array( + [ "<\0scr\0ipt>alert(0)", 'ipt', 'HTML tag stripping evasion -- breaking HTML with nulls.', - ), - array( + ], + [ "", 'script', 'HTML tag stripping evasion -- filter just removing "script".', - ), - array( + ], + [ '<', 'script', 'HTML tag stripping evasion -- double opening brackets.', - ), - array( + ], + [ '', 'script', 'HTML tag stripping evasion -- a malformed image tag.', - array('img'), - ), - array( + ['img'], + ], + [ '
    ', 'script', 'HTML tag stripping evasion -- script in a blockqoute.', - array('blockquote'), - ), - array( + ['blockquote'], + ], + [ "", 'script', 'HTML tag stripping evasion -- script within a comment.', - ), + ], // Dangerous attributes removal. - array( + [ '

    ', 'onmouseover', 'HTML filter attributes removal -- events, no evasion.', - array('p'), - ), - array( + ['p'], + ], + [ '

  • ', 'style', 'HTML filter attributes removal -- style, no evasion.', - array('li'), - ), - array( + ['li'], + ], + [ '', 'onerror', 'HTML filter attributes removal evasion -- spaces before equals sign.', - array('img'), - ), - array( + ['img'], + ], + [ '', 'onabort', 'HTML filter attributes removal evasion -- non alphanumeric characters before equals sign.', - array('img'), - ), - array( + ['img'], + ], + [ '', 'onmediaerror', 'HTML filter attributes removal evasion -- varying case.', - array('img'), - ), + ['img'], + ], // Works at least with IE6. - array( + [ "", 'focus', 'HTML filter attributes removal evasion -- breaking with nulls.', - array('img'), - ), + ['img'], + ], // Only whitelisted scheme names allowed in attributes. - array( + [ '', 'javascript', 'HTML scheme clearing -- no evasion.', - array('img'), - ), - array( + ['img'], + ], + [ '', 'javascript', 'HTML scheme clearing evasion -- no quotes.', - array('img'), - ), + ['img'], + ], // A bit like CVE-2006-0070. - array( + [ '', 'javascript', 'HTML scheme clearing evasion -- no alert ;)', - array('img'), - ), - array( + ['img'], + ], + [ '', 'javascript', 'HTML scheme clearing evasion -- grave accents.', - array('img'), - ), - array( + ['img'], + ], + [ '', 'javascript', 'HTML scheme clearing -- rare attribute.', - array('img'), - ), - array( + ['img'], + ], + [ '
  • ']; // DIV background-image. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#DIV_background-image - $data[] = array('
    ', '
    '); + $data[] = ['
    ', '
    ']; // DIV background-image with unicoded XSS exploit. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#DIV_background-image_with_unicoded_XSS_exploit - $data[] = array('
    ', '
    '); + $data[] = ['
    ', '
    ']; // DIV background-image plus extra characters. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#DIV_background-image_plus_extra_characters - $data[] = array('
    ', '
    '); + $data[] = ['
    ', '
    ']; // DIV expression. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#DIV_expression - $data[] = array('
    ', '
    '); + $data[] = ['
    ', '
    ']; // Downlevel-Hidden block. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Downlevel-Hidden_block - $data[] = array('', "\n alert('XSS');\n "); + ', "\n alert('XSS');\n "]; // BASE tag. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#BASE_tag - $data[] = array('', ''); + $data[] = ['', '']; // OBJECT tag. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#OBJECT_tag - $data[] = array('', ''); + $data[] = ['', '']; // Using an EMBED tag you can embed a Flash movie that contains XSS. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Using_an_EMBED_tag_you_can_embed_a_Flash_movie_that_contains_XSS - $data[] = array('', ''); + $data[] = ['', '']; // You can EMBED SVG which can contain your XSS vector. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#You_can_EMBED_SVG_which_can_contain_your_XSS_vector - $data[] = array('', ''); + $data[] = ['', '']; // XML data island with CDATA obfuscation. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#XML_data_island_with_CDATA_obfuscation - $data[] = array('', 'cript:alert(\'XSS\')">'); + $data[] = ['', 'cript:alert(\'XSS\')">']; // Locally hosted XML with embedded JavaScript that is generated using an XML data island. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Locally_hosted_XML_with_embedded_JavaScript_that_is_generated_using_an_XML_data_island @@ -472,11 +472,11 @@ public function providerTestFilterXss() { // HTML+TIME in XML. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#HTML.2BTIME_in_XML - $data[] = array('">', '<?xml:namespace prefix="t" ns="urn:schemas-microsoft-com:time"><?import namespace="t" implementation="#default#time2">alert("XSS")">'); + $data[] = ['">', '<?xml:namespace prefix="t" ns="urn:schemas-microsoft-com:time"><?import namespace="t" implementation="#default#time2">alert("XSS")">']; // Assuming you can only fit in a few characters and it filters against ".js". // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Assuming_you_can_only_fit_in_a_few_characters_and_it_filters_against_.22.js.22 - $data[] = array('', ''); + $data[] = ['', '']; // IMG Embedded commands. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#IMG_Embedded_commands @@ -485,7 +485,7 @@ public function providerTestFilterXss() { // Cookie manipulation. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#Cookie_manipulation - $data[] = array('', 'alert(\'XSS\')">'); + $data[] = ['', 'alert(\'XSS\')">']; // UTF-7 encoding. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#UTF-7_encoding @@ -493,13 +493,13 @@ public function providerTestFilterXss() { // XSS using HTML quote encapsulation. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#XSS_using_HTML_quote_encapsulation - $data[] = array('', '" SRC="http://ha.ckers.org/xss.js">'); - $data[] = array('', '" SRC="http://ha.ckers.org/xss.js">'); - $data[] = array('', '" \'\' SRC="http://ha.ckers.org/xss.js">'); - $data[] = array('', '\'" SRC="http://ha.ckers.org/xss.js">'); - $data[] = array('', '` SRC="http://ha.ckers.org/xss.js">'); - $data[] = array('', '\'>" SRC="http://ha.ckers.org/xss.js">'); - $data[] = array('PT SRC="http://ha.ckers.org/xss.js">', 'document.write("PT SRC="http://ha.ckers.org/xss.js">'); + $data[] = ['', '" SRC="http://ha.ckers.org/xss.js">']; + $data[] = ['', '" SRC="http://ha.ckers.org/xss.js">']; + $data[] = ['', '" \'\' SRC="http://ha.ckers.org/xss.js">']; + $data[] = ['', '\'" SRC="http://ha.ckers.org/xss.js">']; + $data[] = ['', '` SRC="http://ha.ckers.org/xss.js">']; + $data[] = ['', '\'>" SRC="http://ha.ckers.org/xss.js">']; + $data[] = ['PT SRC="http://ha.ckers.org/xss.js">', 'document.write("PT SRC="http://ha.ckers.org/xss.js">']; // URL string evasion. // @see https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet#URL_string_evasion @@ -511,12 +511,12 @@ public function providerTestFilterXss() { // @see \Drupal\editor\EditorXssFilter::filterXssDataAttributes() // The following two test cases verify that XSS attack vectors are filtered. - $data[] = array('', ''); - $data[] = array('', ''); + $data[] = ['', '']; + $data[] = ['', '']; // When including HTML-tags as visible content, they are double-escaped. // This test case ensures that we leave that content unchanged. - $data[] = array('', ''); + $data[] = ['', '']; return $data; } @@ -573,27 +573,27 @@ public function testBlacklistMode($value, $expected, $message, array $disallowed * - (optional) The disallowed HTML tags to be passed to \Drupal\Component\Utility\Xss::filter(). */ public function providerTestBlackListMode() { - return array( - array( + return [ + [ 'Pink Fairy Armadillo
    11112
    onetwothree
    1-one1-two1-three
    ', 'javascript', 'HTML scheme clearing -- another tag.', - array('table'), - ), - array( + ['table'], + ], + [ '', 'javascript', 'HTML scheme clearing -- one more attribute and tag.', - array('base'), - ), - array( + ['base'], + ], + [ '', 'javascript', 'HTML scheme clearing evasion -- varying case.', - array('img'), - ), - array( + ['img'], + ], + [ '', 'javascript', 'HTML scheme clearing evasion -- UTF-8 decimal encoding.', - array('img'), - ), - array( + ['img'], + ], + [ '', 'javascript', 'HTML scheme clearing evasion -- long UTF-8 encoding.', - array('img'), - ), - array( + ['img'], + ], + [ '', 'javascript', 'HTML scheme clearing evasion -- UTF-8 hex encoding.', - array('img'), - ), - array( + ['img'], + ], + [ "", 'script', 'HTML scheme clearing evasion -- an embedded tab.', - array('img'), - ), - array( + ['img'], + ], + [ '', 'script', 'HTML scheme clearing evasion -- an encoded, embedded tab.', - array('img'), - ), - array( + ['img'], + ], + [ '', 'script', 'HTML scheme clearing evasion -- an encoded, embedded newline.', - array('img'), - ), + ['img'], + ], // With this test would fail, but the entity gets turned into // &#xD;, so it's OK. - array( + [ '', 'script', 'HTML scheme clearing evasion -- an encoded, embedded carriage return.', - array('img'), - ), - array( + ['img'], + ], + [ "", 'cript', 'HTML scheme clearing evasion -- broken into many lines.', - array('img'), - ), - array( + ['img'], + ], + [ "", 'cript', 'HTML scheme clearing evasion -- embedded nulls.', - array('img'), - ), - array( + ['img'], + ], + [ '', 'vbscript', 'HTML scheme clearing evasion -- another scheme.', - array('img'), - ), - array( + ['img'], + ], + [ '', 'nosuchscheme', 'HTML scheme clearing evasion -- unknown scheme.', - array('img'), - ), + ['img'], + ], // Netscape 4.x javascript entities. - array( + [ '
    ', 'alert', 'Netscape 4.x javascript entities.', - array('br'), - ), + ['br'], + ], // DRUPAL-SA-2008-006: Invalid UTF-8, these only work as reflected XSS with // Internet Explorer 6. - array( + [ "

    \" style=\"background-image: url(javascript:alert(0));\"\xe0

    ", 'style', 'HTML filter -- invalid UTF-8.', - array('p'), - ), - ); + ['p'], + ], + ]; // @fixme This dataset currently fails under 5.4 because of // https://www.drupal.org/node/1210798. Restore after its fixed. if (version_compare(PHP_VERSION, '5.4.0', '<')) { - $cases[] = array( + $cases[] = [ '', 'javascript', 'HTML scheme clearing evasion -- spaces and metacharacters before scheme.', - array('img'), - ); + ['img'], + ]; } return $cases; } @@ -468,11 +468,11 @@ public function testInvalidMultiByte($value, $expected, $message) { * - The assertion message. */ public function providerTestInvalidMultiByte() { - return array( - array("Foo\xC0barbaz", '', 'Xss::filter() accepted invalid sequence "Foo\xC0barbaz"'), - array("Fooÿñ", "Fooÿñ", 'Xss::filter() rejects valid sequence Fooÿñ"'), - array("\xc0aaa", '', 'HTML filter -- overlong UTF-8 sequences.'), - ); + return [ + ["Foo\xC0barbaz", '', 'Xss::filter() accepted invalid sequence "Foo\xC0barbaz"'], + ["Fooÿñ", "Fooÿñ", 'Xss::filter() rejects valid sequence Fooÿñ"'], + ["\xc0aaa", '', 'HTML filter -- overlong UTF-8 sequences.'], + ]; } /** @@ -498,26 +498,26 @@ public function testAttribute($value, $expected, $message, $allowed_tags = NULL) * Data provider for testFilterXssAdminNotNormalized(). */ public function providerTestAttributes() { - return array( - array( + return [ + [ 'Example: alt', 'Example: alt', 'Image tag with alt and title attribute', - array('img') - ), - array( + ['img'] + ], + [ '', '', 'Image tag with data attribute', - array('img') - ), - array( + ['img'] + ], + [ '', '', 'Link tag with numeric data attribute', - array('a') - ), - ); + ['a'] + ], + ]; } /** @@ -556,11 +556,11 @@ public function testFilterXssAdminNotNormalized($value, $expected, $message) { * - The assertion message. */ public function providerTestFilterXssAdminNotNormalized() { - return array( + return [ // DRUPAL-SA-2008-044 - array('', 'object', 'Admin HTML filter -- should not allow object tag.'), - array(' 'value', - ); - $tags[] = array($element, "value\n"); + ]; + $tags[] = [$element, "value\n"]; // Ensure that #value is not filtered if it is marked as safe. - $element = array( + $element = [ '#tag' => 'p', '#value' => Markup::create(''), - ); - $tags[] = array($element, "

    \n"); + ]; + $tags[] = [$element, "

    \n"]; // Ensure that #value is filtered if it is not safe. - $element = array( + $element = [ '#tag' => 'p', '#value' => '', - ); - $tags[] = array($element, "

    value

    \n"); + ]; + $tags[] = [$element, "

    value

    \n"]; return $tags; } @@ -112,74 +112,74 @@ public function testPreRenderConditionalComments($element, $expected, $set_safe */ public function providerPreRenderConditionalComments() { // No browser specification. - $element = array( + $element = [ '#tag' => 'link', - ); - $tags[] = array($element, $element); + ]; + $tags[] = [$element, $element]; // Specify all browsers. - $element['#browsers'] = array( + $element['#browsers'] = [ 'IE' => TRUE, '!IE' => TRUE, - ); - $tags[] = array($element, $element); + ]; + $tags[] = [$element, $element]; // All IE. - $element = array( + $element = [ '#tag' => 'link', - '#browsers' => array( + '#browsers' => [ 'IE' => TRUE, '!IE' => FALSE, - ), - ); + ], + ]; $expected = $element; $expected['#prefix'] = "\n\n"; - $tags[] = array($element, $expected); + $tags[] = [$element, $expected]; // Exclude IE. - $element = array( + $element = [ '#tag' => 'link', - '#browsers' => array( + '#browsers' => [ 'IE' => FALSE, - ), - ); + ], + ]; $expected = $element; $expected['#prefix'] = "\n\n"; $expected['#suffix'] = "\n"; - $tags[] = array($element, $expected); + $tags[] = [$element, $expected]; // IE gt 8 - $element = array( + $element = [ '#tag' => 'link', - '#browsers' => array( + '#browsers' => [ 'IE' => 'gt IE 8', - ), - ); + ], + ]; $expected = $element; $expected['#prefix'] = "\n\n"; $expected['#suffix'] = "\n"; - $tags[] = array($element, $expected); + $tags[] = [$element, $expected]; // Prefix and suffix filtering if not safe. - $element = array( + $element = [ '#tag' => 'link', - '#browsers' => array( + '#browsers' => [ 'IE' => FALSE, - ), + ], '#prefix' => 'prefix', '#suffix' => 'suffix', - ); + ]; $expected = $element; $expected['#prefix'] = "\n\nprefix"; $expected['#suffix'] = "suffix\n"; - $tags[] = array($element, $expected); + $tags[] = [$element, $expected]; // Prefix and suffix filtering if marked as safe. This has to come after the // previous test case. $expected['#prefix'] = "\n\nprefix"; $expected['#suffix'] = "suffix\n"; - $tags[] = array($element, $expected, TRUE); + $tags[] = [$element, $expected, TRUE]; return $tags; } diff --git a/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php b/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php index 0d5aec6..c305830 100644 --- a/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Render/ElementInfoManagerTest.php @@ -85,13 +85,13 @@ public function testGetInfoElementPlugin($plugin_class, $expected_info) { $plugin = $this->getMock($plugin_class); $plugin->expects($this->once()) ->method('getInfo') - ->willReturn(array( + ->willReturn([ '#theme' => 'page', - )); + ]); $element_info = $this->getMockBuilder('Drupal\Core\Render\ElementInfoManager') - ->setConstructorArgs(array(new \ArrayObject(), $this->cache, $this->cacheTagsInvalidator, $this->moduleHandler, $this->themeManager)) - ->setMethods(array('getDefinitions', 'createInstance')) + ->setConstructorArgs([new \ArrayObject(), $this->cache, $this->cacheTagsInvalidator, $this->moduleHandler, $this->themeManager]) + ->setMethods(['getDefinitions', 'createInstance']) ->getMock(); $this->themeManager->expects($this->any()) @@ -104,9 +104,9 @@ public function testGetInfoElementPlugin($plugin_class, $expected_info) { ->willReturn($plugin); $element_info->expects($this->once()) ->method('getDefinitions') - ->willReturn(array( - 'page' => array('class' => 'TestElementPlugin'), - )); + ->willReturn([ + 'page' => ['class' => 'TestElementPlugin'], + ]); $this->assertEquals($expected_info, $element_info->getInfo('page')); } @@ -117,26 +117,26 @@ public function testGetInfoElementPlugin($plugin_class, $expected_info) { * @return array */ public function providerTestGetInfoElementPlugin() { - $data = array(); - $data[] = array( + $data = []; + $data[] = [ 'Drupal\Core\Render\Element\ElementInterface', - array( + [ '#type' => 'page', '#theme' => 'page', '#defaults_loaded' => TRUE, - ), - ); + ], + ]; - $data[] = array( + $data[] = [ 'Drupal\Core\Render\Element\FormElementInterface', - array( + [ '#type' => 'page', '#theme' => 'page', '#input' => TRUE, - '#value_callback' => array('TestElementPlugin', 'valueCallback'), + '#value_callback' => ['TestElementPlugin', 'valueCallback'], '#defaults_loaded' => TRUE, - ), - ); + ], + ]; return $data; } @@ -164,12 +164,12 @@ class TestElementInfoManager extends ElementInfoManager { /** * {@inheritdoc} */ - protected $elementInfo = array( - 'test' => array( - 'foo' => array( + protected $elementInfo = [ + 'test' => [ + 'foo' => [ '#bar' => 'baz', - ), - ), - ); + ], + ], + ]; } diff --git a/core/tests/Drupal/Tests/Core/Render/ElementTest.php b/core/tests/Drupal/Tests/Core/Render/ElementTest.php index 604d391..b9f86ac 100644 --- a/core/tests/Drupal/Tests/Core/Render/ElementTest.php +++ b/core/tests/Drupal/Tests/Core/Render/ElementTest.php @@ -25,11 +25,11 @@ public function testProperty() { * Tests the properties() method. */ public function testProperties() { - $element = array( + $element = [ '#property1' => 'property1', '#property2' => 'property2', 'property3' => 'property3' - ); + ]; $properties = Element::properties($element); @@ -51,51 +51,51 @@ public function testChild() { * Tests the children() method. */ public function testChildren() { - $element = array( - 'child2' => array('#weight' => 10), - 'child1' => array('#weight' => 0), - 'child3' => array('#weight' => 20), + $element = [ + 'child2' => ['#weight' => 10], + 'child1' => ['#weight' => 0], + 'child3' => ['#weight' => 20], '#property' => 'property', - ); + ]; - $expected = array('child2', 'child1', 'child3'); + $expected = ['child2', 'child1', 'child3']; $element_copy = $element; $this->assertSame($expected, Element::children($element_copy)); // If #sorted is already set, no sorting should happen. $element_copy = $element; $element_copy['#sorted'] = TRUE; - $expected = array('child2', 'child1', 'child3'); + $expected = ['child2', 'child1', 'child3']; $this->assertSame($expected, Element::children($element_copy, TRUE)); // Test with weight sorting, #sorted property should be added. - $expected = array('child1', 'child2', 'child3'); + $expected = ['child1', 'child2', 'child3']; $element_copy = $element; $this->assertSame($expected, Element::children($element_copy, TRUE)); $this->assertArrayHasKey('#sorted', $element_copy); $this->assertTrue($element_copy['#sorted']); // The order should stay the same if no weights present. - $element_no_weight = array( - 'child2' => array(), - 'child1' => array(), - 'child3' => array(), + $element_no_weight = [ + 'child2' => [], + 'child1' => [], + 'child3' => [], '#property' => 'property', - ); + ]; - $expected = array('child2', 'child1', 'child3'); + $expected = ['child2', 'child1', 'child3']; $this->assertSame($expected, Element::children($element_no_weight, TRUE)); // The order of children with same weight should be preserved. - $element_mixed_weight = array( - 'child5' => array('#weight' => 10), - 'child3' => array('#weight' => -10), - 'child1' => array(), - 'child4' => array('#weight' => 10), - 'child2' => array(), - ); - - $expected = array('child3', 'child1', 'child2', 'child5', 'child4'); + $element_mixed_weight = [ + 'child5' => ['#weight' => 10], + 'child3' => ['#weight' => -10], + 'child1' => [], + 'child4' => ['#weight' => 10], + 'child2' => [], + ]; + + $expected = ['child3', 'child1', 'child2', 'child5', 'child4']; $this->assertSame($expected, Element::children($element_mixed_weight, TRUE)); } @@ -106,9 +106,9 @@ public function testChildren() { * @expectedExceptionMessage "foo" is an invalid render array key */ public function testInvalidChildren() { - $element = array( + $element = [ 'foo' => 'bar', - ); + ]; Element::children($element); } @@ -116,10 +116,10 @@ public function testInvalidChildren() { * Tests the children() method with an ignored key/value pair. */ public function testIgnoredChildren() { - $element = array( + $element = [ 'foo' => NULL, - ); - $this->assertSame(array(), Element::children($element)); + ]; + $this->assertSame([], Element::children($element)); } /** @@ -142,17 +142,17 @@ public function testVisibleChildren(array $element, array $expected_keys) { * @return array */ public function providerVisibleChildren() { - return array( - array(array('#property1' => '', '#property2' => array()), array()), - array(array('#property1' => '', 'child1' => array()), array('child1')), - array(array('#property1' => '', 'child1' => array(), 'child2' => array('#access' => TRUE)), array('child1', 'child2')), - array(array('#property1' => '', 'child1' => array(), 'child2' => array('#access' => FALSE)), array('child1')), - 'access_result_object_allowed' => array(array('#property1' => '', 'child1' => array(), 'child2' => array('#access' => AccessResult::allowed())), array('child1', 'child2')), - 'access_result_object_forbidden' => array(array('#property1' => '', 'child1' => array(), 'child2' => array('#access' => AccessResult::forbidden())), array('child1')), - array(array('#property1' => '', 'child1' => array(), 'child2' => array('#type' => 'textfield')), array('child1', 'child2')), - array(array('#property1' => '', 'child1' => array(), 'child2' => array('#type' => 'value')), array('child1')), - array(array('#property1' => '', 'child1' => array(), 'child2' => array('#type' => 'hidden')), array('child1')), - ); + return [ + [['#property1' => '', '#property2' => []], []], + [['#property1' => '', 'child1' => []], ['child1']], + [['#property1' => '', 'child1' => [], 'child2' => ['#access' => TRUE]], ['child1', 'child2']], + [['#property1' => '', 'child1' => [], 'child2' => ['#access' => FALSE]], ['child1']], + 'access_result_object_allowed' => [['#property1' => '', 'child1' => [], 'child2' => ['#access' => AccessResult::allowed()]], ['child1', 'child2']], + 'access_result_object_forbidden' => [['#property1' => '', 'child1' => [], 'child2' => ['#access' => AccessResult::forbidden()]], ['child1']], + [['#property1' => '', 'child1' => [], 'child2' => ['#type' => 'textfield']], ['child1', 'child2']], + [['#property1' => '', 'child1' => [], 'child2' => ['#type' => 'value']], ['child1']], + [['#property1' => '', 'child1' => [], 'child2' => ['#type' => 'hidden']], ['child1']], + ]; } /** @@ -169,12 +169,12 @@ public function testSetAttributes($element, $map, $expected_element) { * Data provider for testSetAttributes(). */ public function providerTestSetAttributes() { - $base = array('#id' => 'id', '#class' => array()); - return array( - array($base, array(), $base), - array($base, array('id', 'class'), $base + array('#attributes' => array('id' => 'id', 'class' => array()))), - array($base + array('#attributes' => array('id' => 'id-not-overwritten')), array('id', 'class'), $base + array('#attributes' => array('id' => 'id-not-overwritten', 'class' => array()))), - ); + $base = ['#id' => 'id', '#class' => []]; + return [ + [$base, [], $base], + [$base, ['id', 'class'], $base + ['#attributes' => ['id' => 'id', 'class' => []]]], + [$base + ['#attributes' => ['id' => 'id-not-overwritten']], ['id', 'class'], $base + ['#attributes' => ['id' => 'id-not-overwritten', 'class' => []]]], + ]; } /** diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php index bed7d3d..dc25507 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererTest.php @@ -382,17 +382,17 @@ public function testRenderSortingWithSetHashSorted() { $first = $this->randomMachineName(); $second = $this->randomMachineName(); // The same array structure again, but with #sorted set to TRUE. - $elements = array( - 'second' => array( + $elements = [ + 'second' => [ '#weight' => 10, '#markup' => $second, - ), - 'first' => array( + ], + 'first' => [ '#weight' => 0, '#markup' => $first, - ), + ], '#sorted' => TRUE, - ); + ]; $output = $this->renderer->renderRoot($elements); // The elements should appear in output in the same order as the array. @@ -571,9 +571,9 @@ protected function setupThemeContainerMultiSuggestion($matcher = NULL) { * @covers ::doRender */ public function testRenderWithoutThemeArguments() { - $element = array( + $element = [ '#theme' => 'common_test_foo', - ); + ]; $this->themeManager->expects($this->once()) ->method('render') @@ -589,11 +589,11 @@ public function testRenderWithoutThemeArguments() { * @covers ::doRender */ public function testRenderWithThemeArguments() { - $element = array( + $element = [ '#theme' => 'common_test_foo', '#foo' => $this->randomMachineName(), '#bar' => $this->randomMachineName(), - ); + ]; $this->themeManager->expects($this->once()) ->method('render') diff --git a/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php index dadf612..96a01b4 100644 --- a/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php +++ b/core/tests/Drupal/Tests/Core/Route/RoleAccessCheckTest.php @@ -27,54 +27,54 @@ class RoleAccessCheckTest extends UnitTestCase { protected function getTestRouteCollection() { $route_collection = new RouteCollection(); $route_collection->add('role_test_1', new Route('/role_test_1', - array( + [ '_controller' => '\Drupal\router_test\TestControllers::test1', - ), - array( + ], + [ '_role' => 'role_test_1', - ) + ] )); $route_collection->add('role_test_2', new Route('/role_test_2', - array( + [ '_controller' => '\Drupal\router_test\TestControllers::test1', - ), - array( + ], + [ '_role' => 'role_test_2', - ) + ] )); $route_collection->add('role_test_3', new Route('/role_test_3', - array( + [ '_controller' => '\Drupal\router_test\TestControllers::test1', - ), - array( + ], + [ '_role' => 'role_test_1,role_test_2', - ) + ] )); // Ensure that trimming the values works on "OR" conjunctions. $route_collection->add('role_test_4', new Route('/role_test_4', - array( + [ '_controller' => '\Drupal\router_test\TestControllers::test1', - ), - array( + ], + [ '_role' => 'role_test_1 , role_test_2', - ) + ] )); $route_collection->add('role_test_5', new Route('/role_test_5', - array( + [ '_controller' => '\Drupal\router_test\TestControllers::test1', - ), - array( + ], + [ '_role' => 'role_test_1+role_test_2', - ) + ] )); // Ensure that trimming the values works on "AND" conjunctions. $route_collection->add('role_test_6', new Route('/role_test_6', - array( + [ '_controller' => '\Drupal\router_test\TestControllers::test1', - ), - array( + ], + [ '_role' => 'role_test_1 + role_test_2', - ) + ] )); return $route_collection; @@ -93,35 +93,35 @@ public function roleAccessProvider() { // Setup one user with the first role, one with the second, one with both // and one final without any of these two roles. - $account_1 = new UserSession(array( + $account_1 = new UserSession([ 'uid' => 1, - 'roles' => array($rid_1), - )); + 'roles' => [$rid_1], + ]); - $account_2 = new UserSession(array( + $account_2 = new UserSession([ 'uid' => 2, - 'roles' => array($rid_2), - )); + 'roles' => [$rid_2], + ]); - $account_12 = new UserSession(array( + $account_12 = new UserSession([ 'uid' => 3, - 'roles' => array($rid_1, $rid_2), - )); + 'roles' => [$rid_1, $rid_2], + ]); - $account_none = new UserSession(array( + $account_none = new UserSession([ 'uid' => 1, - 'roles' => array(), - )); + 'roles' => [], + ]); // Setup expected values; specify which paths can be accessed by which user. - return array( - array('role_test_1', array($account_1, $account_12), array($account_2, $account_none)), - array('role_test_2', array($account_2, $account_12), array($account_1, $account_none)), - array('role_test_3', array($account_12), array($account_1, $account_2, $account_none)), - array('role_test_4', array($account_12), array($account_1, $account_2, $account_none)), - array('role_test_5', array($account_1, $account_2, $account_12), array()), - array('role_test_6', array($account_1, $account_2, $account_12), array()), - ); + return [ + ['role_test_1', [$account_1, $account_12], [$account_2, $account_none]], + ['role_test_2', [$account_2, $account_12], [$account_1, $account_none]], + ['role_test_3', [$account_12], [$account_1, $account_2, $account_none]], + ['role_test_4', [$account_12], [$account_1, $account_2, $account_none]], + ['role_test_5', [$account_1, $account_2, $account_12], []], + ['role_test_6', [$account_1, $account_2, $account_12], []], + ]; } /** diff --git a/core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php b/core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php index 5bc2be0..1de1745 100644 --- a/core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php +++ b/core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php @@ -30,14 +30,14 @@ protected function setUp() { */ public function testRouteProcessorManager() { $route = new Route(''); - $parameters = array('test' => 'test'); + $parameters = ['test' => 'test']; $route_name = 'test_name'; - $processors = array( + $processors = [ 10 => $this->getMockProcessor($route_name, $route, $parameters), 5 => $this->getMockProcessor($route_name, $route, $parameters), 0 => $this->getMockProcessor($route_name, $route, $parameters), - ); + ]; // Add the processors in reverse order. foreach ($processors as $priority => $processor) { diff --git a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php index 0b7bcc6..d73513e 100644 --- a/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/AccessAwareRouterTest.php @@ -61,7 +61,7 @@ protected function setupRouter() { ->getMock(); $this->chainRouter->expects($this->once()) ->method('matchRequest') - ->will($this->returnValue(array(RouteObjectInterface::ROUTE_OBJECT => $this->route))); + ->will($this->returnValue([RouteObjectInterface::ROUTE_OBJECT => $this->route])); $this->router = new AccessAwareRouter($this->chainRouter, $this->accessManager, $this->currentUser); } diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php index a1095cd..980d301 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/RouteBuilderTest.php @@ -106,7 +106,7 @@ public function testRebuildLockingUnlocking() { $this->yamlDiscovery->expects($this->any()) ->method('findAll') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $this->assertTrue($this->routeBuilder->rebuild()); } @@ -149,7 +149,7 @@ public function testRebuildWithStaticModuleRoutes() { $this->yamlDiscovery->expects($this->once()) ->method('findAll') - ->will($this->returnValue(array('test_module' => $routes))); + ->will($this->returnValue(['test_module' => $routes])); $route_collection = $routing_fixtures->sampleRouteCollection(); $route_build_event = new RouteBuildEvent($route_collection); @@ -192,14 +192,14 @@ public function testRebuildWithProviderBasedRoutes() { $this->yamlDiscovery->expects($this->once()) ->method('findAll') - ->will($this->returnValue(array( - 'test_module' => array( - 'route_callbacks' => array( + ->will($this->returnValue([ + 'test_module' => [ + 'route_callbacks' => [ '\Drupal\Tests\Core\Routing\TestRouteSubscriber::routesFromArray', 'test_module.route_service:routesFromCollection', - ), - ), - ))); + ], + ], + ])); $container = new ContainerBuilder(); $container->set('test_module.route_service', new TestRouteSubscriber()); @@ -215,7 +215,7 @@ public function testRebuildWithProviderBasedRoutes() { list($class, $method) = explode('::', $controller, 2); $object = new $class(); } - return array($object, $method); + return [$object, $method]; })); $route_collection_filled = new RouteCollection(); @@ -263,7 +263,7 @@ public function testRebuildIfNeeded() { $this->yamlDiscovery->expects($this->any()) ->method('findAll') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $this->routeBuilder->setRebuildNeeded(); @@ -312,9 +312,9 @@ protected function getRouteDefinitions() { */ class TestRouteSubscriber { public function routesFromArray() { - return array( + return [ 'test_route.1' => new Route('/test-route/1'), - ); + ]; } public function routesFromCollection() { $collection = new RouteCollection(); diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php index 271e313..2ddfdca 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/RouteCompilerTest.php @@ -38,15 +38,15 @@ public function testGetFit($path, $expected) { * value. */ public function providerTestGetFit() { - return array( - array('test', 1), - array('/testwithleadingslash', 1), - array('testwithtrailingslash/', 1), - array('/testwithslashes/', 1), - array('test/with/multiple/parts', 15), - array('test/with/{some}/slugs', 13), - array('test/very/long/path/that/drupal/7/could/not/have/handled', 2047), - ); + return [ + ['test', 1], + ['/testwithleadingslash', 1], + ['testwithtrailingslash/', 1], + ['/testwithslashes/', 1], + ['test/with/multiple/parts', 15], + ['test/with/{some}/slugs', 13], + ['test/very/long/path/that/drupal/7/could/not/have/handled', 2047], + ]; } /** @@ -67,9 +67,9 @@ public function testCompilation() { public function testCompilationDefaultValue() { // Because "here" has a default value, it should not factor into the outline // or the fitness. - $route = new Route('/test/{something}/more/{here}', array( + $route = new Route('/test/{something}/more/{here}', [ 'here' => 'there', - )); + ]); $route->setOption('compiler_class', 'Drupal\Core\Routing\RouteCompiler'); $compiled = $route->compile(); diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php b/core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php index 22055c9..0a3c65c 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/RouteMatchTest.php @@ -32,9 +32,9 @@ public function testRouteMatchFromRequest() { $route_match = RouteMatch::createFromRequest($request); $this->assertNull($route_match->getRouteName()); $this->assertNull($route_match->getRouteObject()); - $this->assertSame(array(), $route_match->getParameters()->all()); + $this->assertSame([], $route_match->getParameters()->all()); $this->assertNull($route_match->getParameter('foo')); - $this->assertSame(array(), $route_match->getRawParameters()->all()); + $this->assertSame([], $route_match->getRawParameters()->all()); $this->assertNull($route_match->getRawParameter('foo')); // A routed request without parameter upcasting. @@ -45,17 +45,17 @@ public function testRouteMatchFromRequest() { $route_match = RouteMatch::createFromRequest($request); $this->assertSame('test_route', $route_match->getRouteName()); $this->assertSame($route, $route_match->getRouteObject()); - $this->assertSame(array('foo' => '1'), $route_match->getParameters()->all()); - $this->assertSame(array(), $route_match->getRawParameters()->all()); + $this->assertSame(['foo' => '1'], $route_match->getParameters()->all()); + $this->assertSame([], $route_match->getRawParameters()->all()); // A routed request with parameter upcasting. $foo = new \stdClass(); $foo->value = 1; $request->attributes->set('foo', $foo); - $request->attributes->set('_raw_variables', new ParameterBag(array('foo' => '1'))); + $request->attributes->set('_raw_variables', new ParameterBag(['foo' => '1'])); $route_match = RouteMatch::createFromRequest($request); - $this->assertSame(array('foo' => $foo), $route_match->getParameters()->all()); - $this->assertSame(array('foo' => '1'), $route_match->getRawParameters()->all()); + $this->assertSame(['foo' => $foo], $route_match->getParameters()->all()); + $this->assertSame(['foo' => '1'], $route_match->getRawParameters()->all()); } } diff --git a/core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php b/core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php index 6af8397..2678fd3 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php +++ b/core/tests/Drupal/Tests/Core/Routing/RouteMatchTestBase.php @@ -31,46 +31,46 @@ * Provide sets of parameters and expected parameters for parameter tests. */ public function routeMatchProvider() { - $base_data = array( - array( + $base_data = [ + [ new Route( '/test-route/{param_without_leading_underscore}/{_param_with_leading_underscore}', - array( + [ 'default_without_leading_underscore' => NULL, '_default_with_leading_underscore' => NULL, - ) + ] ), - array( + [ 'param_without_leading_underscore' => 'value', '_param_with_leading_underscore' => 'value', 'default_without_leading_underscore' => 'value', '_default_with_leading_underscore' => 'value', 'foo' => 'value', - ), + ], // Parameters should be filtered to only those defined by the route. // Specifically: // - Path parameters, regardless of name. // - Defaults that are not path parameters only if they do not start with // an underscore. - array( + [ 'param_without_leading_underscore' => 'value', '_param_with_leading_underscore' => 'value', 'default_without_leading_underscore' => 'value', - ), - ), - ); + ], + ], + ]; - $data = array(); + $data = []; foreach ($base_data as $entry) { $route = $entry[0]; $params = $entry[1]; $expected_params = $entry[2]; - $data[] = array( + $data[] = [ $this->getRouteMatch('test_route', $route, $params, $params), $route, $params, $expected_params, - ); + ]; } return $data; diff --git a/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php b/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php index 4db4297..90b4a9d 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/RoutePreloaderTest.php @@ -61,15 +61,15 @@ public function testOnAlterRoutesWithAdminRoutes() { ->disableOriginalConstructor() ->getMock(); $route_collection = new RouteCollection(); - $route_collection->add('test', new Route('/admin/foo', array('_controller' => 'Drupal\ExampleController'))); - $route_collection->add('test2', new Route('/admin/bar', array('_controller' => 'Drupal\ExampleController'))); + $route_collection->add('test', new Route('/admin/foo', ['_controller' => 'Drupal\ExampleController'])); + $route_collection->add('test2', new Route('/admin/bar', ['_controller' => 'Drupal\ExampleController'])); $event->expects($this->once()) ->method('getRouteCollection') ->will($this->returnValue($route_collection)); $this->state->expects($this->once()) ->method('set') - ->with('routing.non_admin_routes', array()); + ->with('routing.non_admin_routes', []); $this->preloader->onAlterRoutes($event); $this->preloader->onFinishedRoutes(new Event()); } @@ -82,17 +82,17 @@ public function testOnAlterRoutesWithAdminPathNoAdminRoute() { ->disableOriginalConstructor() ->getMock(); $route_collection = new RouteCollection(); - $route_collection->add('test', new Route('/foo/admin/foo', array('_controller' => 'Drupal\ExampleController'))); - $route_collection->add('test2', new Route('/bar/admin/bar', array('_controller' => 'Drupal\ExampleController'))); - $route_collection->add('test3', new Route('/administrator/a', array('_controller' => 'Drupal\ExampleController'))); - $route_collection->add('test4', new Route('/admin', array('_controller' => 'Drupal\ExampleController'))); + $route_collection->add('test', new Route('/foo/admin/foo', ['_controller' => 'Drupal\ExampleController'])); + $route_collection->add('test2', new Route('/bar/admin/bar', ['_controller' => 'Drupal\ExampleController'])); + $route_collection->add('test3', new Route('/administrator/a', ['_controller' => 'Drupal\ExampleController'])); + $route_collection->add('test4', new Route('/admin', ['_controller' => 'Drupal\ExampleController'])); $event->expects($this->once()) ->method('getRouteCollection') ->will($this->returnValue($route_collection)); $this->state->expects($this->once()) ->method('set') - ->with('routing.non_admin_routes', array('test', 'test2', 'test3')); + ->with('routing.non_admin_routes', ['test', 'test2', 'test3']); $this->preloader->onAlterRoutes($event); $this->preloader->onFinishedRoutes(new Event()); } @@ -106,17 +106,17 @@ public function testOnAlterRoutesWithNonAdminRoutes() { ->disableOriginalConstructor() ->getMock(); $route_collection = new RouteCollection(); - $route_collection->add('test', new Route('/admin/foo', array('_controller' => 'Drupal\ExampleController'))); - $route_collection->add('test2', new Route('/bar', array('_controller' => 'Drupal\ExampleController'))); + $route_collection->add('test', new Route('/admin/foo', ['_controller' => 'Drupal\ExampleController'])); + $route_collection->add('test2', new Route('/bar', ['_controller' => 'Drupal\ExampleController'])); // Non content routes, like ajax callbacks should be ignored. - $route_collection->add('test3', new Route('/bar', array('_controller' => 'Drupal\ExampleController'))); + $route_collection->add('test3', new Route('/bar', ['_controller' => 'Drupal\ExampleController'])); $event->expects($this->once()) ->method('getRouteCollection') ->will($this->returnValue($route_collection)); $this->state->expects($this->once()) ->method('set') - ->with('routing.non_admin_routes', array('test2', 'test3')); + ->with('routing.non_admin_routes', ['test2', 'test3']); $this->preloader->onAlterRoutes($event); $this->preloader->onFinishedRoutes(new Event()); } @@ -161,7 +161,7 @@ public function testOnRequestOnHtml() { $this->state->expects($this->once()) ->method('get') ->with('routing.non_admin_routes') - ->will($this->returnValue(array('test2'))); + ->will($this->returnValue(['test2'])); $this->preloader->onRequest($event); } diff --git a/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php b/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php index d1826ed..6bdd11d 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php +++ b/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php @@ -47,32 +47,32 @@ public function dropTables(Connection $connection) { * Returns a static version of the routes. */ public function staticSampleRouteCollection() { - $routes = array(); - $routes['route_a'] = array( + $routes = []; + $routes['route_a'] = [ 'path' => '/path/one', - 'methods' => array('GET'), - ); - $routes['route_b'] = array( + 'methods' => ['GET'], + ]; + $routes['route_b'] = [ 'path' => '/path/one', - 'methods' => array('PUT'), - ); - $routes['route_c'] = array( + 'methods' => ['PUT'], + ]; + $routes['route_c'] = [ 'path' => '/path/two', - 'methods' => array('GET'), - 'requirements' => array( + 'methods' => ['GET'], + 'requirements' => [ '_format' => 'json' - ), - ); - $routes['route_d'] = array( + ], + ]; + $routes['route_d'] = [ 'path' => '/path/three', - ); - $routes['route_e'] = array( + ]; + $routes['route_e'] = [ 'path' => '/path/two', - 'methods' => array('GET', 'HEAD'), - 'requirements' => array( + 'methods' => ['GET', 'HEAD'], + 'requirements' => [ '_format' => 'html' - ), - ); + ], + ]; return $routes; } @@ -167,74 +167,74 @@ public function contentRouteCollection() { */ public function routingTableDefinition() { - $tables['test_routes'] = array( + $tables['test_routes'] = [ 'description' => 'Maps paths to various callbacks (access, page and title)', - 'fields' => array( - 'name' => array( + 'fields' => [ + 'name' => [ 'description' => 'Primary Key: Machine name of this route', 'type' => 'varchar_ascii', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), - 'path' => array( + ], + 'path' => [ 'description' => 'The path for this URI', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), - 'pattern_outline' => array( + ], + 'pattern_outline' => [ 'description' => 'The pattern', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), - 'provider' => array( + ], + 'provider' => [ 'description' => 'The provider grouping to which a route belongs.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), - 'access_callback' => array( + ], + 'access_callback' => [ 'description' => 'The callback which determines the access to this router path. Defaults to \Drupal\Core\Session\AccountInterface::hasPermission.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', - ), - 'access_arguments' => array( + ], + 'access_arguments' => [ 'description' => 'A serialized array of arguments for the access callback.', 'type' => 'blob', 'not null' => FALSE, - ), - 'fit' => array( + ], + 'fit' => [ 'description' => 'A numeric representation of how specific the path is.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, - ), - 'number_parts' => array( + ], + 'number_parts' => [ 'description' => 'Number of parts in this router path.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small', - ), - 'route' => array( + ], + 'route' => [ 'description' => 'A serialized Route object', 'type' => 'text', - ), - ), - 'indexes' => array( - 'fit' => array('fit'), - 'pattern_outline' => array('pattern_outline'), - 'provider' => array('provider'), - ), - 'primary key' => array('name'), - ); + ], + ], + 'indexes' => [ + 'fit' => ['fit'], + 'pattern_outline' => ['pattern_outline'], + 'provider' => ['provider'], + ], + 'primary key' => ['name'], + ]; return $tables; } diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php index 06e8c17..4fc6cd3 100644 --- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php @@ -100,8 +100,8 @@ protected function setUp() { // We need to set up return value maps for both the getRouteByName() and the // getRoutesByNames() method calls on the route provider. The parameters // are not passed in and default to an empty array. - $route_name_return_map = $routes_names_return_map = array(); - $return_map_values = array( + $route_name_return_map = $routes_names_return_map = []; + $return_map_values = [ [ 'route_name' => 'test_1', 'return' => $first_route, @@ -122,10 +122,10 @@ protected function setUp() { 'route_name' => '', 'return' => $none_route, ], - ); + ]; foreach ($return_map_values as $values) { - $route_name_return_map[] = array($values['route_name'], $values['return']); - $routes_names_return_map[] = array(array($values['route_name']), $values['return']); + $route_name_return_map[] = [$values['route_name'], $values['return']]; + $routes_names_return_map[] = [[$values['route_name']], $values['return']]; } $this->provider = $provider; $this->provider->expects($this->any()) @@ -142,7 +142,7 @@ protected function setUp() { $alias_manager->expects($this->any()) ->method('getAliasByPath') - ->will($this->returnCallback(array($this, 'aliasManagerCallback'))); + ->will($this->returnCallback([$this, 'aliasManagerCallback'])); $this->aliasManager = $alias_manager; @@ -215,7 +215,7 @@ public function testAliasGeneration() { * Confirms that generated routes will have aliased paths using interface constants. */ public function testAliasGenerationUsingInterfaceConstants() { - $url = $this->generator->generate('test_1', array(), UrlGenerator::ABSOLUTE_PATH); + $url = $this->generator->generate('test_1', [], UrlGenerator::ABSOLUTE_PATH); $this->assertEquals('/hello/world', $url); // No cacheability to test; UrlGenerator::generate() doesn't support // collecting cacheability metadata. @@ -295,7 +295,7 @@ public function testGetPathFromRouteWithSubdirectory() { * Confirms that generated routes will have aliased paths. */ public function testAliasGenerationWithParameters() { - $url = $this->generator->generate('test_2', array('narf' => '5')); + $url = $this->generator->generate('test_2', ['narf' => '5']); $this->assertEquals('/goodbye/cruel/world', $url); // No cacheability to test; UrlGenerator::generate() doesn't support // collecting cacheability metadata. @@ -304,17 +304,17 @@ public function testAliasGenerationWithParameters() { ->method('processOutbound') ->with($this->anything()); - $options = array('fragment' => 'top'); + $options = ['fragment' => 'top']; // Extra parameters should appear in the query string. $this->assertGenerateFromRoute('test_1', ['zoo' => 5], $options, '/hello/world?zoo=5#top', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)); - $options = array('query' => array('page' => '1'), 'fragment' => 'bottom'); + $options = ['query' => ['page' => '1'], 'fragment' => 'bottom']; $this->assertGenerateFromRoute('test_2', ['narf' => 5], $options, '/goodbye/cruel/world?page=1#bottom', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)); // Changing the parameters, the route still matches but there is no alias. $this->assertGenerateFromRoute('test_2', ['narf' => 7], $options, '/test/two/7?page=1#bottom', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)); - $path = $this->generator->getPathFromRoute('test_2', array('narf' => '5')); + $path = $this->generator->getPathFromRoute('test_2', ['narf' => '5']); $this->assertEquals('test/two/5', $path); // Specify a query parameter with NULL. @@ -381,7 +381,7 @@ public function testGetPathFromRouteTrailing() { * Confirms that absolute URLs work with generated routes. */ public function testAbsoluteURLGeneration() { - $url = $this->generator->generate('test_1', array(), TRUE); + $url = $this->generator->generate('test_1', [], TRUE); $this->assertEquals('http://localhost/hello/world', $url); // No cacheability to test; UrlGenerator::generate() doesn't support // collecting cacheability metadata. @@ -390,7 +390,7 @@ public function testAbsoluteURLGeneration() { ->method('processOutbound') ->with($this->anything()); - $options = array('absolute' => TRUE, 'fragment' => 'top'); + $options = ['absolute' => TRUE, 'fragment' => 'top']; // Extra parameters should appear in the query string. $this->assertGenerateFromRoute('test_1', ['zoo' => 5], $options, 'http://localhost/hello/world?zoo=5#top', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)->setCacheContexts(['url.site'])); } @@ -399,7 +399,7 @@ public function testAbsoluteURLGeneration() { * Confirms that absolute URLs work with generated routes using interface constants. */ public function testAbsoluteURLGenerationUsingInterfaceConstants() { - $url = $this->generator->generate('test_1', array(), UrlGenerator::ABSOLUTE_URL); + $url = $this->generator->generate('test_1', [], UrlGenerator::ABSOLUTE_URL); $this->assertEquals('http://localhost/hello/world', $url); // No cacheability to test; UrlGenerator::generate() doesn't support // collecting cacheability metadata. @@ -408,7 +408,7 @@ public function testAbsoluteURLGenerationUsingInterfaceConstants() { ->method('processOutbound') ->with($this->anything()); - $options = array('absolute' => TRUE, 'fragment' => 'top'); + $options = ['absolute' => TRUE, 'fragment' => 'top']; // Extra parameters should appear in the query string. $this->assertGenerateFromRoute('test_1', ['zoo' => 5], $options, 'http://localhost/hello/world?zoo=5#top', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)->setCacheContexts(['url.site'])); } @@ -417,20 +417,20 @@ public function testAbsoluteURLGenerationUsingInterfaceConstants() { * Confirms that explicitly setting the base_url works with generated routes */ public function testBaseURLGeneration() { - $options = array('base_url' => 'http://www.example.com:8888'); + $options = ['base_url' => 'http://www.example.com:8888']; $this->assertGenerateFromRoute('test_1', [], $options, 'http://www.example.com:8888/hello/world', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)); - $options = array('base_url' => 'http://www.example.com:8888', 'https' => TRUE); + $options = ['base_url' => 'http://www.example.com:8888', 'https' => TRUE]; $this->assertGenerateFromRoute('test_1', [], $options, 'https://www.example.com:8888/hello/world', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)); - $options = array('base_url' => 'https://www.example.com:8888', 'https' => FALSE); + $options = ['base_url' => 'https://www.example.com:8888', 'https' => FALSE]; $this->assertGenerateFromRoute('test_1', [], $options, 'http://www.example.com:8888/hello/world', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)); $this->routeProcessorManager->expects($this->exactly(2)) ->method('processOutbound') ->with($this->anything()); - $options = array('base_url' => 'http://www.example.com:8888', 'fragment' => 'top'); + $options = ['base_url' => 'http://www.example.com:8888', 'fragment' => 'top']; // Extra parameters should appear in the query string. $this->assertGenerateFromRoute('test_1', ['zoo' => 5], $options, 'http://www.example.com:8888/hello/world?zoo=5#top', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)); } @@ -439,7 +439,7 @@ public function testBaseURLGeneration() { * Test that the 'scheme' route requirement is respected during url generation. */ public function testUrlGenerationWithHttpsRequirement() { - $url = $this->generator->generate('test_4', array(), TRUE); + $url = $this->generator->generate('test_4', [], TRUE); $this->assertEquals('https://localhost/test/four', $url); // No cacheability to test; UrlGenerator::generate() doesn't support // collecting cacheability metadata. @@ -448,7 +448,7 @@ public function testUrlGenerationWithHttpsRequirement() { ->method('processOutbound') ->with($this->anything()); - $options = array('absolute' => TRUE, 'https' => TRUE); + $options = ['absolute' => TRUE, 'https' => TRUE]; $this->assertGenerateFromRoute('test_1', [], $options, 'https://localhost/hello/world', (new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT)->setCacheContexts(['url.site'])); } diff --git a/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php b/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php index 0840e00..031de82 100644 --- a/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php +++ b/core/tests/Drupal/Tests/Core/Session/AnonymousUserSessionTest.php @@ -20,8 +20,8 @@ class AnonymousUserSessionTest extends UnitTestCase { */ public function testUserGetRoles() { $anonymous_user = new AnonymousUserSession(); - $this->assertEquals(array(RoleInterface::ANONYMOUS_ID), $anonymous_user->getRoles()); - $this->assertEquals(array(), $anonymous_user->getRoles(TRUE)); + $this->assertEquals([RoleInterface::ANONYMOUS_ID], $anonymous_user->getRoles()); + $this->assertEquals([], $anonymous_user->getRoles(TRUE)); } } diff --git a/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php b/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php index 3bb4f3a..0d9725c 100644 --- a/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Session/PermissionsHashGeneratorTest.php @@ -75,12 +75,12 @@ class PermissionsHashGeneratorTest extends UnitTestCase { protected function setUp() { parent::setUp(); - new Settings(array('hash_salt' => 'test')); + new Settings(['hash_salt' => 'test']); // The mocked super user account, with the same roles as Account 2. $this->account1 = $this->getMockBuilder('Drupal\user\Entity\User') ->disableOriginalConstructor() - ->setMethods(array('getRoles', 'id')) + ->setMethods(['getRoles', 'id']) ->getMock(); $this->account1->expects($this->any()) ->method('id') @@ -89,10 +89,10 @@ protected function setUp() { ->method('getRoles'); // Account 2: 'administrator' and 'authenticated' roles. - $roles_1 = array('administrator', 'authenticated'); + $roles_1 = ['administrator', 'authenticated']; $this->account2 = $this->getMockBuilder('Drupal\user\Entity\User') ->disableOriginalConstructor() - ->setMethods(array('getRoles', 'id')) + ->setMethods(['getRoles', 'id']) ->getMock(); $this->account2->expects($this->any()) ->method('getRoles') @@ -102,10 +102,10 @@ protected function setUp() { ->willReturn(2); // Account 3: 'authenticated' and 'administrator' roles (different order). - $roles_3 = array('authenticated', 'administrator'); + $roles_3 = ['authenticated', 'administrator']; $this->account3 = $this->getMockBuilder('Drupal\user\Entity\User') ->disableOriginalConstructor() - ->setMethods(array('getRoles', 'id')) + ->setMethods(['getRoles', 'id']) ->getMock(); $this->account3->expects($this->any()) ->method('getRoles') @@ -115,10 +115,10 @@ protected function setUp() { ->willReturn(3); // Updated account 2: now also 'editor' role. - $roles_2_updated = array('editor', 'administrator', 'authenticated'); + $roles_2_updated = ['editor', 'administrator', 'authenticated']; $this->account2Updated = $this->getMockBuilder('Drupal\user\Entity\User') ->disableOriginalConstructor() - ->setMethods(array('getRoles', 'id')) + ->setMethods(['getRoles', 'id']) ->getMock(); $this->account2Updated->expects($this->any()) ->method('getRoles') @@ -131,7 +131,7 @@ protected function setUp() { $random = Crypt::randomBytesBase64(55); $this->privateKey = $this->getMockBuilder('Drupal\Core\PrivateKey') ->disableOriginalConstructor() - ->setMethods(array('get')) + ->setMethods(['get']) ->getMock(); $this->privateKey->expects($this->any()) ->method('get') @@ -253,9 +253,9 @@ public function testGenerateNoCache() { // @todo remove once user_role_permissions() can be injected. if (!function_exists('user_role_permissions')) { function user_role_permissions(array $roles) { - $role_permissions = array(); + $role_permissions = []; foreach ($roles as $rid) { - $role_permissions[$rid] = array(); + $role_permissions[$rid] = []; } return $role_permissions; } diff --git a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php index f83515c..fb889e2 100644 --- a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php +++ b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php @@ -18,7 +18,7 @@ class UserSessionTest extends UnitTestCase { * * @var \Drupal\Core\Session\AccountInterface[] */ - protected $users = array(); + protected $users = []; /** * Provides test data for getHasPermission(). @@ -26,10 +26,10 @@ class UserSessionTest extends UnitTestCase { * @return array */ public function providerTestHasPermission() { - $data = array(); - $data[] = array('example permission', array('user_one', 'user_two'), array('user_last')); - $data[] = array('another example permission', array('user_two'), array('user_one', 'user_last')); - $data[] = array('final example permission', array(), array('user_one', 'user_two', 'user_last')); + $data = []; + $data[] = ['example permission', ['user_one', 'user_two'], ['user_last']]; + $data[] = ['another example permission', ['user_two'], ['user_one', 'user_last']]; + $data[] = ['final example permission', [], ['user_one', 'user_two', 'user_last']]; return $data; } @@ -45,9 +45,9 @@ public function providerTestHasPermission() { * @return \Drupal\Core\Session\AccountInterface * The created user session. */ - protected function createUserSession(array $rids = array(), $authenticated = FALSE) { + protected function createUserSession(array $rids = [], $authenticated = FALSE) { array_unshift($rids, $authenticated ? RoleInterface::AUTHENTICATED_ID : RoleInterface::ANONYMOUS_ID); - return new UserSession(array('roles' => $rids)); + return new UserSession(['roles' => $rids]); } /** @@ -56,57 +56,57 @@ protected function createUserSession(array $rids = array(), $authenticated = FAL protected function setUp() { parent::setUp(); - $roles = array(); + $roles = []; $roles['role_one'] = $this->getMockBuilder('Drupal\user\Entity\Role') ->disableOriginalConstructor() - ->setMethods(array('hasPermission')) + ->setMethods(['hasPermission']) ->getMock(); $roles['role_one']->expects($this->any()) ->method('hasPermission') - ->will($this->returnValueMap(array( - array('example permission', TRUE), - array('another example permission', FALSE), - array('last example permission', FALSE), - ))); + ->will($this->returnValueMap([ + ['example permission', TRUE], + ['another example permission', FALSE], + ['last example permission', FALSE], + ])); $roles['role_two'] = $this->getMockBuilder('Drupal\user\Entity\Role') ->disableOriginalConstructor() - ->setMethods(array('hasPermission')) + ->setMethods(['hasPermission']) ->getMock(); $roles['role_two']->expects($this->any()) ->method('hasPermission') - ->will($this->returnValueMap(array( - array('example permission', TRUE), - array('another example permission', TRUE), - array('last example permission', FALSE), - ))); + ->will($this->returnValueMap([ + ['example permission', TRUE], + ['another example permission', TRUE], + ['last example permission', FALSE], + ])); $roles['anonymous'] = $this->getMockBuilder('Drupal\user\Entity\Role') ->disableOriginalConstructor() - ->setMethods(array('hasPermission')) + ->setMethods(['hasPermission']) ->getMock(); $roles['anonymous']->expects($this->any()) ->method('hasPermission') - ->will($this->returnValueMap(array( - array('example permission', FALSE), - array('another example permission', FALSE), - array('last example permission', FALSE), - ))); + ->will($this->returnValueMap([ + ['example permission', FALSE], + ['another example permission', FALSE], + ['last example permission', FALSE], + ])); $role_storage = $this->getMockBuilder('Drupal\user\RoleStorage') ->disableOriginalConstructor() - ->setMethods(array('loadMultiple')) + ->setMethods(['loadMultiple']) ->getMock(); $role_storage->expects($this->any()) ->method('loadMultiple') - ->will($this->returnValueMap(array( - array(array(), array()), - array(NULL, $roles), - array(array('anonymous'), array($roles['anonymous'])), - array(array('anonymous', 'role_one'), array($roles['role_one'])), - array(array('anonymous', 'role_two'), array($roles['role_two'])), - array(array('anonymous', 'role_one', 'role_two'), array($roles['role_one'], $roles['role_two'])), - ))); + ->will($this->returnValueMap([ + [[], []], + [NULL, $roles], + [['anonymous'], [$roles['anonymous']]], + [['anonymous', 'role_one'], [$roles['role_one']]], + [['anonymous', 'role_two'], [$roles['role_two']]], + [['anonymous', 'role_one', 'role_two'], [$roles['role_one'], $roles['role_two']]], + ])); $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $entity_manager->expects($this->any()) @@ -117,9 +117,9 @@ protected function setUp() { $container->set('entity.manager', $entity_manager); \Drupal::setContainer($container); - $this->users['user_one'] = $this->createUserSession(array('role_one')); - $this->users['user_two'] = $this->createUserSession(array('role_one', 'role_two')); - $this->users['user_three'] = $this->createUserSession(array('role_two'), TRUE); + $this->users['user_one'] = $this->createUserSession(['role_one']); + $this->users['user_two'] = $this->createUserSession(['role_one', 'role_two']); + $this->users['user_three'] = $this->createUserSession(['role_two'], TRUE); $this->users['user_last'] = $this->createUserSession(); } @@ -153,8 +153,8 @@ public function testHasPermission($permission, array $sessions_with_access, arra * @todo Move roles constants to a class/interface */ public function testUserGetRoles() { - $this->assertEquals(array(RoleInterface::AUTHENTICATED_ID, 'role_two'), $this->users['user_three']->getRoles()); - $this->assertEquals(array('role_two'), $this->users['user_three']->getRoles(TRUE)); + $this->assertEquals([RoleInterface::AUTHENTICATED_ID, 'role_two'], $this->users['user_three']->getRoles()); + $this->assertEquals(['role_two'], $this->users['user_three']->getRoles(TRUE)); } } diff --git a/core/tests/Drupal/Tests/Core/Site/SettingsTest.php b/core/tests/Drupal/Tests/Core/Site/SettingsTest.php index 2c987f3..a40d916 100644 --- a/core/tests/Drupal/Tests/Core/Site/SettingsTest.php +++ b/core/tests/Drupal/Tests/Core/Site/SettingsTest.php @@ -16,7 +16,7 @@ class SettingsTest extends UnitTestCase { * * @var array */ - protected $config = array(); + protected $config = []; /** * The class under test. @@ -29,11 +29,11 @@ class SettingsTest extends UnitTestCase { * @covers ::__construct */ protected function setUp(){ - $this->config = array( + $this->config = [ 'one' => '1', 'two' => '2', 'hash_salt' => $this->randomMachineName(), - ); + ]; $this->settings = new Settings($this->config); } @@ -95,11 +95,11 @@ public function testGetHashSaltEmpty(array $config) { * @return array */ public function providerTestGetHashSaltEmpty() { - return array( - array(array()), - array(array('hash_salt' => '')), - array(array('hash_salt' => NULL)), - ); + return [ + [[]], + [['hash_salt' => '']], + [['hash_salt' => NULL]], + ]; } /** @@ -119,10 +119,10 @@ public function testSerialize() { * @covers ::getApcuPrefix */ public function testGetApcuPrefix() { - $settings = new Settings(array('hash_salt' => 123)); + $settings = new Settings(['hash_salt' => 123]); $this->assertNotEquals($settings::getApcuPrefix('cache_test', '/test/a'), $settings::getApcuPrefix('cache_test', '/test/b')); - $settings = new Settings(array('hash_salt' => 123, 'apcu_ensure_unique_prefix' => FALSE)); + $settings = new Settings(['hash_salt' => 123, 'apcu_ensure_unique_prefix' => FALSE]); $this->assertNotEquals($settings::getApcuPrefix('cache_test', '/test/a'), $settings::getApcuPrefix('cache_test', '/test/b')); } diff --git a/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php index 9bbf2e1..87efe7b 100644 --- a/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php +++ b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php @@ -30,12 +30,12 @@ protected function setUp() { * Tests that subscriber does not act when reverse proxy is not set. */ public function testNoProxy() { - $settings = new Settings(array()); + $settings = new Settings([]); $this->assertEquals(0, $settings->get('reverse_proxy')); $middleware = new ReverseProxyMiddleware($this->mockHttpKernel, $settings); // Mock a request object. - $request = $this->getMock('Symfony\Component\HttpFoundation\Request', array('setTrustedHeaderName', 'setTrustedProxies')); + $request = $this->getMock('Symfony\Component\HttpFoundation\Request', ['setTrustedHeaderName', 'setTrustedProxies']); // setTrustedHeaderName() should never fire. $request->expects($this->never()) ->method('setTrustedHeaderName'); @@ -50,7 +50,7 @@ public function testNoProxy() { */ public function testReverseProxyEnabled($provided_settings) { // Enable reverse proxy and add test values. - $settings = new Settings(array('reverse_proxy' => 1) + $provided_settings); + $settings = new Settings(['reverse_proxy' => 1] + $provided_settings); $this->trustedHeadersAreSet($settings); } @@ -58,18 +58,18 @@ public function testReverseProxyEnabled($provided_settings) { * Data provider for testReverseProxyEnabled. */ public function reverseProxyEnabledProvider() { - return array( - array( - array( + return [ + [ + [ 'reverse_proxy_header' => 'X_FORWARDED_FOR_CUSTOMIZED', 'reverse_proxy_proto_header' => 'X_FORWARDED_PROTO_CUSTOMIZED', 'reverse_proxy_host_header' => 'X_FORWARDED_HOST_CUSTOMIZED', 'reverse_proxy_port_header' => 'X_FORWARDED_PORT_CUSTOMIZED', 'reverse_proxy_forwarded_header' => 'FORWARDED_CUSTOMIZED', - 'reverse_proxy_addresses' => array('127.0.0.2', '127.0.0.3'), - ), - ), - ); + 'reverse_proxy_addresses' => ['127.0.0.2', '127.0.0.3'], + ], + ], + ]; } /** diff --git a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php index 8ab6874..2cd750b 100644 --- a/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php +++ b/core/tests/Drupal/Tests/Core/StringTranslation/TranslationManagerTest.php @@ -36,21 +36,21 @@ protected function setUp() { * @return array */ public function providerTestFormatPlural() { - return array( - [1, 'Singular', '@count plural', array(), array(), 'Singular'], - [2, 'Singular', '@count plural', array(), array(), '2 plural'], + return [ + [1, 'Singular', '@count plural', [], [], 'Singular'], + [2, 'Singular', '@count plural', [], [], '2 plural'], // @todo support locale_get_plural - [2, 'Singular', '@count @arg', array('@arg' => '