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 68f4636..22447df 100644 --- a/core/core.api.php +++ b/core/core.api.php @@ -2103,39 +2103,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 84291ae..5d05cd5 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. diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 9c976eb..293f25a 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -197,7 +197,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 @@ -213,7 +213,7 @@ function drupal_get_filename($type, $name, $filename = NULL) { $type = 'module'; } if (!isset($files[$type])) { - $files[$type] = array(); + $files[$type] = []; } if (isset($filename)) { @@ -233,11 +233,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); } } @@ -301,7 +301,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); } @@ -376,7 +376,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)) { @@ -447,7 +447,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. @@ -501,7 +501,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 { @@ -511,7 +511,7 @@ function drupal_get_messages($type = NULL, $clear_queue = TRUE) { return $messages; } } - return array(); + return []; } /** @@ -899,7 +899,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. @@ -978,7 +978,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. @@ -989,7 +989,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 67122a2..45eaa3d 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 0dcd141..c78ee5b 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -367,7 +367,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; } @@ -456,7 +456,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. @@ -501,12 +501,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; } @@ -527,8 +527,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; } } @@ -536,8 +536,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; } @@ -545,8 +545,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. @@ -652,7 +652,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; } } @@ -721,7 +721,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])); } } @@ -762,7 +762,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://". @@ -810,7 +810,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]); } /** @@ -852,18 +852,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; } @@ -999,14 +999,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); @@ -1025,8 +1025,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)) { @@ -1067,7 +1067,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]); } } diff --git a/core/includes/form.inc b/core/includes/form.inc index 2e2d2be..05f2a9e 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; @@ -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,11 +429,11 @@ 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(), - '#label_attributes' => array(), - ); + '#wrapper_attributes' => [], + '#label_attributes' => [], + ]; $variables['attributes'] = $element['#wrapper_attributes']; // Add element #id for #type 'item'. @@ -478,8 +478,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['label']['#attributes'] = $element['#label_attributes']; $variables['children'] = $element['#children']; @@ -717,26 +717,26 @@ 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.'), - ); + ]; $batch_set = $init + $batch_definition + $defaults; // Tweak init_message to avoid the bottom of the page flickering down after @@ -760,7 +760,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); } } @@ -800,7 +800,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'), @@ -808,7 +808,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 @@ -839,7 +839,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. @@ -886,7 +886,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; } @@ -907,12 +907,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(); @@ -937,7 +937,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 ca66c11..cfc0497 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -92,11 +92,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'; } @@ -106,7 +106,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 @@ -121,10 +121,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 @@ -182,7 +182,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 @@ -207,7 +207,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 @@ -224,16 +224,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. @@ -261,11 +261,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; } @@ -353,7 +353,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')) @@ -429,7 +429,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. @@ -453,7 +453,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']); } @@ -596,7 +596,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); @@ -726,26 +726,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, @@ -753,39 +753,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'])) { @@ -806,16 +806,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'])) { @@ -830,13 +830,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; } @@ -857,7 +857,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']; @@ -971,39 +971,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; @@ -1069,13 +1069,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; } @@ -1142,13 +1142,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 @@ -1260,10 +1260,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); @@ -1384,7 +1384,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; @@ -1491,14 +1491,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) { @@ -1518,15 +1518,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; } @@ -1569,7 +1569,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 @@ -1612,21 +1612,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; @@ -1649,26 +1649,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; } } @@ -1683,11 +1683,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)) { @@ -1700,17 +1700,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]); } } } @@ -1739,16 +1739,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; } @@ -1785,9 +1785,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); } @@ -1797,9 +1797,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]); } /** @@ -1816,7 +1816,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; @@ -1845,12 +1845,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); @@ -1874,73 +1874,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]), + ]; } } @@ -1948,12 +1948,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']]), + ]; } } @@ -1975,14 +1975,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; @@ -2004,15 +2004,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. @@ -2063,68 +2063,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' - )), - ); + ]), + ]; } } } @@ -2162,17 +2162,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 @@ -2207,10 +2207,10 @@ function install_write_profile($install_state) { $settings_path = \Drupal::service('site.path') . '/settings.php'; if (is_writable($settings_path)) { // 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); } elseif (($settings_profile = Settings::get('install_profile')) && $settings_profile !== $install_state['parameters']['profile']) { diff --git a/core/includes/install.inc b/core/includes/install.inc index 6bb6c11..c5b93b5 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; } @@ -628,7 +628,7 @@ function drupal_install_system($install_state) { ->save(); // 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. @@ -669,7 +669,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) { @@ -735,7 +735,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) { @@ -789,7 +789,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 @@ -851,10 +851,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(); } @@ -886,7 +886,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)) { @@ -916,7 +916,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) { @@ -937,7 +937,7 @@ function drupal_requirements_url($severity) { 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. // @todo Remove as part of https://www.drupal.org/node/2186491 @@ -1000,14 +1000,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'); } @@ -1066,27 +1066,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 aa3984b..a2f9d23 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) { - $versions = &drupal_static(__FUNCTION__, array()); + $versions = &drupal_static(__FUNCTION__, []); 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 51d10a7..498c490 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']; } @@ -664,34 +664,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. @@ -779,7 +779,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'])); @@ -794,7 +794,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. @@ -908,11 +908,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)) { @@ -924,10 +924,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']); @@ -979,7 +979,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; @@ -988,12 +988,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'])) { @@ -1007,9 +1007,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; @@ -1019,7 +1019,7 @@ function template_preprocess_table(&$variables) { if (!is_array($cell)) { $cell_content = $cell; - $cell_attributes = array(); + $cell_attributes = []; $is_header = FALSE; } else { @@ -1079,7 +1079,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. @@ -1118,10 +1118,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), - ); + ]; } } @@ -1139,7 +1139,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'])) { @@ -1228,16 +1228,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); @@ -1302,19 +1302,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')]; @@ -1354,7 +1354,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] = []; } } @@ -1414,7 +1414,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 _ @@ -1429,7 +1429,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)) { @@ -1562,7 +1562,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]; @@ -1597,29 +1597,29 @@ 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' => '', '#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]; @@ -1632,40 +1632,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']; @@ -1678,7 +1678,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]; } @@ -1695,10 +1695,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()]; } } @@ -1717,39 +1717,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 @@ -1763,107 +1763,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 b09ddb7..f6b3ee7 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.'); @@ -97,7 +97,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) { @@ -105,7 +105,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 a9b5de9..6e0707f 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 de22297..1acfc12 100644 --- a/core/lib/Drupal.php +++ b/core/lib/Drupal.php @@ -566,7 +566,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 879f13b..b350ac0 100644 --- a/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php +++ b/core/lib/Drupal/Component/Annotation/Plugin/Discovery/AnnotatedClassDiscovery.php @@ -69,7 +69,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; @@ -105,7 +105,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 3f59b59..d3cb15e 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 \InvalidArgumentException * 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 \InvalidArgumentException * 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 \InvalidArgumentException('The timestamp must be numeric.'); } @@ -207,7 +207,7 @@ public static function createFromTimestamp($timestamp, $timezone = NULL, $settin * @throws \UnexpectedValueException * 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; } @@ -258,7 +258,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; @@ -310,7 +310,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); } /** @@ -346,7 +346,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); } /** @@ -529,24 +529,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; } @@ -577,7 +577,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) { @@ -628,7 +628,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 76a43fd..7673cef 100644 --- a/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php +++ b/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php @@ -49,7 +49,7 @@ class OptimizedPhpArrayDumper extends Dumper { /** * {@inheritdoc} */ - public function dump(array $options = array()) { + public function dump(array $options = []) { return serialize($this->getArray()); } @@ -60,7 +60,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(); @@ -77,7 +77,7 @@ public function getArray() { * The aliases. */ protected function getAliases() { - $alias_definitions = array(); + $alias_definitions = []; $aliases = $this->container->getAliases(); foreach ($aliases as $alias => $id) { @@ -99,7 +99,7 @@ protected function getAliases() { */ protected function getParameters() { if (!$this->container->getParameterBag()->all()) { - return array(); + return []; } $parameters = $this->container->getParameterBag()->all(); @@ -115,10 +115,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(). @@ -143,7 +143,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); @@ -168,7 +168,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)) { @@ -199,7 +199,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(); } @@ -279,11 +279,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]); } @@ -309,7 +309,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)) { @@ -332,11 +332,11 @@ protected function dumpCollection($collection, &$resolve = FALSE) { return $collection; } - return (object) array( + return (object) [ 'type' => 'collection', 'value' => $code, 'resolve' => $resolve, - ); + ]; } /** @@ -351,7 +351,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; @@ -377,12 +377,12 @@ protected function getPrivateServiceCall($id, Definition $definition, $shared = $hash = Crypt::hashBase64(serialize($service_definition)); $id = 'private__' . $hash; } - return (object) array( + return (object) [ 'type' => 'private_service', 'id' => $id, 'value' => $service_definition, 'shared' => $shared, - ); + ]; } /** @@ -399,7 +399,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); } @@ -482,11 +482,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, - ); + ]; } /** @@ -499,10 +499,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 edcb84d..d70f3e6 100644 --- a/core/lib/Drupal/Component/Diff/DiffFormatter.php +++ b/core/lib/Drupal/Component/Diff/DiffFormatter.php @@ -41,10 +41,10 @@ class DiffFormatter { * * @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], + ]; /** * Format a diff. @@ -58,7 +58,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; @@ -87,7 +87,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/FileSystem/FileSystem.php b/core/lib/Drupal/Component/FileSystem/FileSystem.php index 26989cd..7a1c551 100644 --- a/core/lib/Drupal/Component/FileSystem/FileSystem.php +++ b/core/lib/Drupal/Component/FileSystem/FileSystem.php @@ -15,7 +15,7 @@ class FileSystem { * suitable temporary directory can be found. */ public static function getOsTemporaryDirectory() { - $directories = array(); + $directories = []; // Has PHP been set with an upload_tmp_dir? if (ini_get('upload_tmp_dir')) { 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 6cedff1..6d76d6c 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 f23c0c0..e82ec2d 100644 --- a/core/lib/Drupal/Component/PhpStorage/FileStorage.php +++ b/core/lib/Drupal/Component/PhpStorage/FileStorage.php @@ -238,7 +238,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 0cee170..6b47af0 100644 --- a/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php +++ b/core/lib/Drupal/Component/Plugin/Discovery/DerivativeDiscoveryDecorator.php @@ -21,7 +21,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. @@ -94,7 +94,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) { @@ -137,7 +137,7 @@ protected function decodePluginId($plugin_id) { return explode(':', $plugin_id, 2); } - return array($plugin_id, NULL); + return [$plugin_id, NULL]; } /** @@ -239,7 +239,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; } @@ -248,7 +248,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 1aeeb95..3c98b83 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 d9f24b4..f5e99fe 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,12 +221,12 @@ 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', 'rel', 'property', - )); + ]); $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 d87872a..1cd6b8b 100644 --- a/core/lib/Drupal/Core/Access/AccessResult.php +++ b/core/lib/Drupal/Core/Access/AccessResult.php @@ -261,7 +261,7 @@ public function setCacheMaxAge($max_age) { * @return $this */ public function cachePerPermissions() { - $this->addCacheContexts(array('user.permissions')); + $this->addCacheContexts(['user.permissions']); return $this; } @@ -271,7 +271,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 5548c7f..563355a 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 2bbc912..3d372fe 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 30b65fa..2b0fcdd 100644 --- a/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php +++ b/core/lib/Drupal/Core/Ajax/OpenDialogCommand.php @@ -70,9 +70,9 @@ 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) { + public function __construct($selector, $title, $content, array $dialog_options = [], $settings = NULL) { $title = PlainTextOutput::renderFromHtml($title); - $dialog_options += array('title' => $title); + $dialog_options += ['title' => $title]; $this->selector = $selector; $this->content = $content; $this->dialogOptions = $dialog_options; @@ -128,13 +128,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 eb47cb2..5f23af4 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 63721e6..c3c83e1 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 d25fb83..4ad7ba1 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); } /** @@ -230,7 +230,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 566722d..4d49d87 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 2e47d0f..d3a062c 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 4d47afa..ee90783 100644 --- a/core/lib/Drupal/Core/Block/BlockBase.php +++ b/core/lib/Drupal/Core/Block/BlockBase.php @@ -82,19 +82,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' => static::BLOCK_LABEL_VISIBLE, - ); + ]; } /** * {@inheritdoc} */ public function defaultConfiguration() { - return array(); + return []; } /** @@ -108,7 +108,7 @@ public function setConfigurationValue($key, $value) { * {@inheritdoc} */ public function calculateDependencies() { - return array(); + return []; } /** @@ -151,29 +151,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'] === static::BLOCK_LABEL_VISIBLE), '#return_value' => static::BLOCK_LABEL_VISIBLE, - ); + ]; // Add context mapping UI form elements. $contexts = $form_state->getTemporaryValue('gathered_contexts') ?: []; @@ -187,7 +187,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 d905132..f02a4e7 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 62839c2..9f6be9d 100644 --- a/core/lib/Drupal/Core/Cache/ChainedFastBackend.php +++ b/core/lib/Drupal/Core/Cache/ChainedFastBackend.php @@ -99,7 +99,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); } @@ -109,7 +109,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 @@ -142,7 +142,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 @@ -176,7 +176,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 @@ -202,7 +202,7 @@ public function setMultiple(array $items) { * {@inheritdoc} */ public function delete($cid) { - $this->consistentBackend->deleteMultiple(array($cid)); + $this->consistentBackend->deleteMultiple([$cid]); $this->markAsOutdated(); } @@ -226,7 +226,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 aa2409c..76bff41 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 b2dc781..1ca6262 100644 --- a/core/lib/Drupal/Core/Composer/Composer.php +++ b/core/lib/Drupal/Core/Composer/Composer.php @@ -84,22 +84,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 483c96d..dfdd0b8 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 7b938fa..c632aa8 100644 --- a/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -425,7 +425,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 b5b1c90..65da2e9 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 @@ -411,12 +411,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])) { @@ -465,8 +465,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']); @@ -479,11 +479,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 f6a6261..c4b4230 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/Development/ConfigSchemaChecker.php b/core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php index e639966..ba69001 100644 --- a/core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php +++ b/core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php @@ -38,14 +38,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. @@ -55,7 +55,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; } @@ -90,7 +90,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)); } @@ -101,7 +101,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/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 0dc1971..237929d 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; } @@ -281,7 +281,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) { @@ -304,7 +304,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 3aed1ec..f6bf463 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. @@ -62,7 +62,7 @@ public function __construct(EntityTypeInterface $entity_type, EntityStorageInter * {@inheritdoc} */ public function buildHeader() { - $header = array(); + $header = []; if (!empty($this->weightKey)) { $header['weight'] = t('Weight'); } @@ -73,19 +73,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); } @@ -104,18 +104,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; @@ -129,7 +129,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; @@ -138,11 +138,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 0327e90..ac12f56 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 16fecbc..9103ab8 100644 --- a/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php +++ b/core/lib/Drupal/Core/Config/ExtensionInstallStorage.php @@ -88,7 +88,7 @@ public function createCollection($collection) { */ protected function getAllFolders() { if (!isset($this->folders)) { - $this->folders = array(); + $this->folders = []; $this->folders += $this->getCoreNames(); $extensions = $this->configStorage->read('core.extension'); @@ -107,7 +107,7 @@ protected function getAllFolders() { drupal_get_filename('profile', $this->installProfile, $profile_list[$this->installProfile]->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]; @@ -134,7 +134,7 @@ protected function getAllFolders() { $profile_list = $listing->scan('profile'); } if (isset($profile_list[$this->installProfile])) { - $profile_folders = $this->getComponentNames(array($profile_list[$this->installProfile])); + $profile_folders = $this->getComponentNames([$profile_list[$this->installProfile]]); $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/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php index b90e463..22795ad 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'], ']')) { @@ -181,10 +181,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; } @@ -270,7 +270,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 9ce487b..6c37c76 100644 --- a/core/lib/Drupal/Core/Config/UnmetDependenciesException.php +++ b/core/lib/Drupal/Core/Config/UnmetDependenciesException.php @@ -90,10 +90,10 @@ public function getTranslatedMessage(TranslationInterface $string_translation, $ */ public static function create($extension, array $config_objects) { $message = new FormattableMarkup('Configuration objects provided by %extension have unmet dependencies: %config_names', - array( + [ '%config_names' => static::formatConfigObjectList($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 daf4668..f6963c5 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. @@ -171,7 +171,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; @@ -187,7 +187,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. @@ -202,7 +202,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; } @@ -259,13 +259,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, - ); + ]; } /** @@ -293,16 +293,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 . '}'; @@ -596,7 +596,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(); @@ -670,7 +670,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 @@ -732,7 +732,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) { @@ -796,7 +796,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); } @@ -814,7 +814,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); } @@ -832,7 +832,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); } @@ -850,7 +850,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); } @@ -868,7 +868,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); } @@ -886,7 +886,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); } @@ -904,7 +904,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); } @@ -1237,7 +1237,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. @@ -1274,7 +1274,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. @@ -1421,7 +1421,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 fd46438..164f68a 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php @@ -67,7 +67,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. @@ -82,7 +82,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); } @@ -101,7 +101,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'; @@ -125,10 +125,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, @@ -138,7 +138,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. @@ -176,12 +176,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); @@ -212,11 +212,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; @@ -258,7 +258,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 @@ -268,8 +268,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; @@ -287,7 +287,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 @@ -333,7 +333,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 c952630..5dcd487 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 59f3bd5..3769e54 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php @@ -96,7 +96,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; @@ -120,10 +120,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, @@ -134,7 +134,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, - ); + ]; try { $pdo = new \PDO($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']); @@ -157,7 +157,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 @@ -211,11 +211,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; @@ -441,7 +441,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 77e0a47..33579de 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php @@ -20,22 +20,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' => [], + ]; } /** @@ -94,13 +94,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; } } @@ -116,10 +116,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) { @@ -161,12 +161,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)); } } @@ -214,12 +214,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 4a5f404..19efe50 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 \Drupal\Core\Database\Driver\pgsql\Schema::queryTableInformation() * @var array */ - protected $tableInformation = array(); + protected $tableInformation = []; /** * The maximum allowed length for index, primary key and constraint names. @@ -108,10 +108,10 @@ public function queryTableInformation($table) { } if (!isset($this->tableInformation[$key])) { - $table_information = (object) array( - 'blob_fields' => array(), - 'sequences' => array(), - ); + $table_information = (object) [ + 'blob_fields' => [], + 'sequences' => [], + ]; $this->connection->addSavepoint(); try { @@ -215,11 +215,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(); @@ -244,12 +244,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']) . ')'; } @@ -309,7 +309,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'])) { @@ -391,7 +391,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', @@ -425,12 +425,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] . ')'; @@ -450,7 +450,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] . '"'; @@ -468,24 +468,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 @@ -535,12 +535,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; @@ -553,7 +553,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'])) { @@ -586,7 +586,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); @@ -596,7 +596,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'); @@ -644,10 +644,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) . ')'); @@ -666,10 +666,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) . ')'); @@ -691,10 +691,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)); @@ -711,12 +711,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); @@ -724,14 +724,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'])) { @@ -782,7 +782,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. @@ -852,10 +852,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(); } } @@ -872,7 +872,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 267a8c9..52e077a 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 e71b74d..a14a83f 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php @@ -41,7 +41,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 @@ -82,10 +82,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]); } } @@ -101,16 +101,16 @@ 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, - ); + ]; try { $pdo = new \PDO('sqlite:' . $connection_options['database'], '', '', $connection_options['pdo']); @@ -126,37 +126,37 @@ public static function open(array &$connection_options = array()) { // 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'])) { @@ -179,7 +179,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) { @@ -325,21 +325,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 @@ -353,11 +353,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(); @@ -414,13 +414,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 52a5700..d04fec5 100644 --- a/core/lib/Drupal/Core/Database/Query/Condition.php +++ b/core/lib/Drupal/Core/Database/Query/Condition.php @@ -13,41 +13,41 @@ class Condition implements ConditionInterface, \Countable { /** * Provides a map of condition operators to condition operator options. */ - protected static $conditionOperatorMap = array( - 'BETWEEN' => array('delimiter' => ' AND '), - 'NOT BETWEEN' => array('delimiter' => ' AND '), - 'IN' => array('delimiter' => ', ', 'prefix' => '(', 'postfix' => ')'), - 'NOT IN' => array('delimiter' => ', ', 'prefix' => '(', 'postfix' => ')'), - 'IS NULL' => array('use_value' => FALSE), - 'IS NOT NULL' => array('use_value' => FALSE), + protected static $conditionOperatorMap = [ + 'BETWEEN' => ['delimiter' => ' AND '], + 'NOT BETWEEN' => ['delimiter' => ' AND '], + 'IN' => ['delimiter' => ', ', 'prefix' => '(', 'postfix' => ')'], + 'NOT IN' => ['delimiter' => ', ', '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 '\\\\'"], // Exists expects an already bracketed subquery as right hand part. Do // not define additional brackets. - 'EXISTS' => array(), - 'NOT EXISTS' => array(), + 'EXISTS' => [], + 'NOT EXISTS' => [], // These ones are here for performance reasons. - '=' => array(), - '<' => array(), - '>' => array(), - '>=' => array(), - '<=' => array(), - ); + '=' => [], + '<' => [], + '>' => [], + '>=' => [], + '<=' => [], + ]; /** * Array of conditions. * * @var array */ - protected $conditions = array(); + protected $conditions = []; /** * Array of arguments. * * @var array */ - protected $arguments = array(); + protected $arguments = []; /** * Whether the conditions have been changed. @@ -103,11 +103,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; @@ -117,12 +117,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; @@ -183,8 +183,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']; @@ -224,7 +224,7 @@ public function compile(Connection $connection, PlaceholderInterface $queryPlace // Process operator. if ($ignore_operator) { - $operator = array('operator' => '', 'use_value' => FALSE); + $operator = ['operator' => '', 'use_value' => FALSE]; } else { // Remove potentially dangerous characters. @@ -255,15 +255,15 @@ public function compile(Connection $connection, PlaceholderInterface $queryPlace if (!isset($operator)) { $operator = $this->mapConditionOperator($condition['operator']); } - $operator += array('operator' => $condition['operator']); + $operator += ['operator' => $condition['operator']]; } // Add defaults. - $operator += array( + $operator += [ 'prefix' => '', 'postfix' => '', 'delimiter' => '', 'use_value' => TRUE, - ); + ]; $operator_fragment = $operator['operator']; // Process value. @@ -279,10 +279,10 @@ public function compile(Connection $connection, PlaceholderInterface $queryPlace $operator['prefix'] = ''; $operator['postfix'] = ''; } - $condition['value'] = array($condition['value']); + $condition['value'] = [$condition['value']]; } // Process all individual values. - $value_fragment = array(); + $value_fragment = []; foreach ($condition['value'] as $value) { if ($value instanceof SelectInterface) { // Right hand part is a subquery. Compile, put brackets around it @@ -303,7 +303,7 @@ public function compile(Connection $connection, PlaceholderInterface $queryPlace } // Concatenate the left hand part, operator and right hand part. - $condition_fragments[] = trim(implode(' ', array($field_fragment, $operator_fragment, $value_fragment))); + $condition_fragments[] = trim(implode(' ', [$field_fragment, $operator_fragment, $value_fragment])); } // Concatenate all conditions using the conjunction and brackets around @@ -377,10 +377,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(static::$conditionOperatorMap[$operator]) ? static::$conditionOperatorMap[$operator] : array(); + $return = isset(static::$conditionOperatorMap[$operator]) ? static::$conditionOperatorMap[$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 0c82a10..aa5090a 100644 --- a/core/lib/Drupal/Core/Database/Query/ConditionInterface.php +++ b/core/lib/Drupal/Core/Database/Query/ConditionInterface.php @@ -86,7 +86,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 c8f9921..3af2d2a 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 04efcf4..b3426e6 100644 --- a/core/lib/Drupal/Core/Database/Query/Select.php +++ b/core/lib/Drupal/Core/Database/Query/Select.php @@ -19,14 +19,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. @@ -52,7 +52,7 @@ class Select extends Query implements SelectInterface { * * @var array */ - protected $tables = array(); + protected $tables = []; /** * The fields by which to order this query. @@ -62,14 +62,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. @@ -103,7 +103,7 @@ class Select extends Query implements SelectInterface { * * @var array */ - protected $union = array(); + protected $union = []; /** * Indicates if preExecute() has already been called. @@ -128,7 +128,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'; @@ -300,7 +300,7 @@ public function havingArguments() { /** * {@inheritdoc} */ - public function having($snippet, $args = array()) { + public function having($snippet, $args = []) { $this->having->where($snippet, $args); return $this; } @@ -467,11 +467,11 @@ public function preExecute(SelectInterface $query = NULL) { // issue. // - Emit E_USER_DEPRECATED if term_access is used. // https://www.drupal.org/node/2575081 - $term_access_tags = array('term_access' => 1, 'taxonomy_term_access' => 1); + $term_access_tags = ['term_access' => 1, 'taxonomy_term_access' => 1]; if (array_intersect_key($this->alterTags, $term_access_tags)) { $this->alterTags += $term_access_tags; } - $hooks = array('query'); + $hooks = ['query']; foreach ($this->alterTags as $tag => $value) { $hooks[] = 'query_' . $tag; } @@ -538,11 +538,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; } @@ -550,7 +550,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. @@ -568,7 +568,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'; } @@ -580,11 +580,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; } @@ -592,35 +592,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'; @@ -641,13 +641,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; } @@ -675,7 +675,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; } @@ -696,10 +696,10 @@ public function union(SelectInterface $query, $type = '') { default: } - $this->union[] = array( + $this->union[] = [ 'type' => $type, 'query' => $query, - ); + ]; return $this; } @@ -770,7 +770,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 @@ -809,7 +809,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) . '.*'; @@ -886,7 +886,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 971d031..c0ee929 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 6864f00..8025220 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 bf2f1fd..45a5618 100644 --- a/core/lib/Drupal/Core/Database/database.api.php +++ b/core/lib/Drupal/Core/Database/database.api.php @@ -484,60 +484,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 421b03b..7729080 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. @@ -136,9 +136,9 @@ public function format($timestamp, $type = 'medium', $format = '', $timezone = N } // Call $date->format(). - $settings = array( + $settings = [ 'langcode' => $langcode, - ); + ]; return $date->format($format, $settings); } @@ -150,7 +150,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--; } @@ -164,7 +164,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]); } /** @@ -183,7 +183,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); } @@ -191,7 +191,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); } @@ -199,14 +199,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'); @@ -231,18 +231,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; @@ -253,14 +253,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 { @@ -271,17 +271,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; @@ -327,7 +327,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 3386e6a..bb87d5e 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php @@ -108,17 +108,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); @@ -143,7 +143,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 8ebe2f4..a613711 100644 --- a/core/lib/Drupal/Core/Diff/DiffFormatter.php +++ b/core/lib/Drupal/Core/Diff/DiffFormatter.php @@ -17,7 +17,7 @@ class DiffFormatter extends DiffFormatterBase { * * @var array */ - protected $rows = array(); + protected $rows = []; /** * Creates a DiffFormatter to render diffs in a table. @@ -35,7 +35,7 @@ public function __construct(ConfigFactoryInterface $config_factory) { * {@inheritdoc} */ protected function _start_diff() { - $this->rows = array(); + $this->rows = []; } /** @@ -49,16 +49,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, - ) - ); + ] + ]; } /** @@ -86,16 +86,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', - ) - ); + ] + ]; } /** @@ -108,16 +108,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', - ) - ); + ] + ]; } /** @@ -130,13 +130,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', - ) - ); + ] + ]; } /** @@ -146,10 +146,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 b8130b3..db773ed 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -142,7 +142,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface { * * @var \Drupal\Core\Extension\Extension[] */ - protected $moduleData = array(); + protected $moduleData = []; /** * The class loader object. @@ -387,7 +387,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); @@ -480,7 +480,7 @@ public function shutdown() { $this->booted = FALSE; $this->container = NULL; $this->moduleList = NULL; - $this->moduleData = array(); + $this->moduleData = []; } /** @@ -569,21 +569,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)); @@ -732,7 +732,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); @@ -743,7 +743,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) { @@ -763,7 +763,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 = []) { $pre_existing_module_namespaces = []; if ($this->booted && is_array($this->moduleList)) { $pre_existing_module_namespaces = $this->getModuleNamespacesPsr4($this->getModuleFileNames()); @@ -814,7 +814,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); } @@ -824,9 +824,9 @@ protected function getContainerCacheKey() { * @return array An array of kernel parameters */ protected function getKernelParameters() { - return array( + return [ 'kernel.environment' => $this->environment, - ); + ]; } /** @@ -1023,7 +1023,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.'); @@ -1109,7 +1109,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)) { @@ -1138,7 +1138,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(); } @@ -1170,7 +1170,7 @@ public function invalidateContainer() { * @return ContainerInterface */ protected function attachSynthetic(ContainerInterface $container) { - $persist = array(); + $persist = []; if (isset($this->container)) { $persist = $this->getServicesToPersist($this->container); } @@ -1213,7 +1213,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) { @@ -1238,7 +1238,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); @@ -1272,7 +1272,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'))) { @@ -1292,10 +1292,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)) { @@ -1375,14 +1375,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; @@ -1396,7 +1396,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(); @@ -1417,7 +1417,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'; } @@ -1436,7 +1436,7 @@ protected function getModuleNamespacesPsr4($module_file_names) { * the front controller, but may also be decorated; e.g., * \Symfony\Component\ClassLoader\ApcClassLoader. */ - protected function classLoaderAddMultiplePsr4(array $namespaces = array(), $class_loader = NULL) { + protected function classLoaderAddMultiplePsr4(array $namespaces = [], $class_loader = NULL) { if ($class_loader === NULL) { $class_loader = $this->classLoader; } diff --git a/core/lib/Drupal/Core/DrupalKernelInterface.php b/core/lib/Drupal/Core/DrupalKernelInterface.php index 862fbec..c38fff5 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 70ea520..971e551 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -32,14 +32,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. @@ -97,7 +97,7 @@ * * @var array */ - protected $translations = array(); + protected $translations = []; /** * A flag indicating whether a translation object is being initialized. @@ -125,14 +125,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. @@ -158,7 +158,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'); @@ -243,7 +243,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; @@ -445,7 +445,7 @@ public function __sleep() { $this->values[$name][$langcode] = $field->getValue(); } } - $this->fields = array(); + $this->fields = []; $this->fieldDefinitions = NULL; $this->languages = NULL; $this->clearTranslationCache(); @@ -554,7 +554,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); @@ -609,7 +609,7 @@ public function getFieldDefinitions() { * {@inheritdoc} */ public function toArray() { - $values = array(); + $values = []; foreach ($this->getFields() as $name => $property) { $values[$name] = $property->getValue(); } @@ -721,7 +721,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); @@ -732,7 +732,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); } } @@ -743,7 +743,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; @@ -853,7 +853,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(); @@ -1021,7 +1021,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 { @@ -1107,13 +1107,13 @@ public function __clone() { $this->fields = &$fields; 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; @@ -1141,7 +1141,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) { @@ -1260,7 +1260,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 2b3bbec..9d6b8d6 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; } @@ -605,11 +605,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); } @@ -638,10 +638,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); } @@ -692,7 +692,7 @@ public function loadUnchanged($id) { */ public function resetCache(array $ids = NULL) { if ($ids) { - $cids = array(); + $cids = []; foreach ($ids as $id) { unset($this->entities[$id]); $cids[] = $this->buildCacheId($id); @@ -702,9 +702,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 6103a56..0e26c3b 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityType.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityType.php @@ -19,10 +19,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 9c3e705..3e10f4a 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)) + $params)); + $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)] + $params)); } 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 cd90ecc..faa6d0d 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 1530693..d1d43ee 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 b6c73e5..ca106b2 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. 'view', 'form'). @@ -158,14 +158,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; @@ -359,7 +359,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(); @@ -396,7 +396,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) { @@ -406,7 +406,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; } @@ -428,7 +428,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 b4f6bd6..3506218 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($form_state->prepareCallback($function), array($entity->getEntityTypeId(), $entity, &$form, &$form_state)); + call_user_func_array($form_state->prepareCallback($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 847a480..e9a87d6 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; } } @@ -170,7 +170,7 @@ protected function setParametersFromEntityInformation(Route $route) { // parameter in the first place. This is the case for add forms, for // example. if (isset($entity_type) && isset($this->getEntityTypes()[$entity_type]) && (strpos($route->getPath(), '{' . $entity_type . '}') !== FALSE)) { - $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. @@ -185,11 +185,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 9f2587e..f9555a8 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -43,7 +43,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { * * @var array */ - protected $entity_keys = array(); + protected $entity_keys = []; /** * The unique identifier of this entity type. @@ -66,7 +66,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { * * @var array */ - protected $handlers = array(); + protected $handlers = []; /** * The name of the default administrative permission. @@ -88,7 +88,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { * * @var array */ - protected $links = array(); + protected $links = []; /** * The name of a callback that returns the label of the entity. @@ -258,7 +258,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface { * * @var array[] */ - protected $constraints = array(); + protected $constraints = []; /** * Any additional properties and values. @@ -287,15 +287,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']); } @@ -804,7 +804,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 1b3e6c0..2c3340e 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -108,14 +108,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; } @@ -123,11 +123,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 @@ -137,7 +137,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++; } @@ -160,16 +160,16 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode) { $context = []; $this->moduleHandler()->alter('entity_view_mode', $view_mode, $entity, $context); - $build = array( + $build = [ "#{$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(), - ), - ); + ], + ]; // Add the default #theme key if a template exists for it. if ($this->themeRegistry->getRuntime()->has($this->entityTypeId)) { @@ -179,15 +179,15 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode) { // 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(); @@ -241,7 +241,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"; @@ -282,7 +282,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); } } @@ -293,7 +293,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 @@ -304,7 +304,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 = []; } } } @@ -313,7 +313,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) { @@ -343,7 +343,7 @@ protected function alterBuild(array &$build, EntityInterface $entity, EntityView * {@inheritdoc} */ public function getCacheTags() { - return array($this->entityTypeId . '_view'); + return [$this->entityTypeId . '_view']; } /** @@ -394,12 +394,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]; @@ -411,7 +411,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(); @@ -420,11 +420,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']; } @@ -465,11 +465,11 @@ protected function getSingleFieldDisplay($entity, $field_name, $display_options) $bundle = $entity->bundle(); $key = $entity_type_id . ':' . $bundle . ':' . $field_name . ':' . Crypt::hashBase64(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 d924e1a..e3b41b1 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php +++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php @@ -109,26 +109,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, @@ -139,7 +139,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', @@ -152,14 +152,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->entityClassImplements(FieldableEntityInterface::class)) { - $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(); @@ -172,57 +172,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'])); @@ -288,10 +288,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(); @@ -315,7 +315,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); @@ -336,10 +336,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); @@ -433,9 +433,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 c574781..7860c90 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 78f831a..cd245ef 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 e813cde..e218247 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php @@ -28,7 +28,7 @@ class Tables implements TablesInterface { * * @var array */ - protected $entityTables = array(); + protected $entityTables = []; /** * Field table array, key is table name, value is alias. @@ -37,7 +37,7 @@ class Tables implements TablesInterface { * * @var array */ - protected $fieldTables = array(); + protected $fieldTables = []; /** * The entity manager. @@ -51,7 +51,7 @@ class Tables implements TablesInterface { * * @var array */ - protected $caseSensitiveFields = array(); + protected $caseSensitiveFields = []; /** * @param \Drupal\Core\Database\Query\SelectInterface $sql_query @@ -80,7 +80,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); @@ -183,7 +183,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(); @@ -274,7 +274,7 @@ public function addField($field, $type, $langcode) { $field_storage_definitions = $this->entityManager->getFieldStorageDefinitions($entity_type_id); // Add the new entity base table using the table and sql column. $base_table = $this->addNextBaseTable($entity_type, $table, $sql_column); - $propertyDefinitions = array(); + $propertyDefinitions = []; $key++; $index_prefix .= "$next_index_prefix."; } @@ -340,7 +340,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 5c03b65..d696a94 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(); @@ -310,7 +310,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) { @@ -322,7 +322,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 @@ -337,14 +337,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)); } @@ -352,21 +352,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); } } @@ -409,7 +409,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 @@ -444,12 +444,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. @@ -469,13 +469,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. @@ -499,7 +499,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); @@ -508,7 +508,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 @@ -535,7 +535,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]; } @@ -578,7 +578,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)) { @@ -649,7 +649,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}"); @@ -832,7 +832,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 @@ -944,7 +944,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; @@ -1031,7 +1031,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 @@ -1041,7 +1041,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(); } @@ -1082,9 +1082,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]; @@ -1094,8 +1094,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); @@ -1134,14 +1134,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) { @@ -1169,7 +1169,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(); @@ -1224,7 +1224,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); } @@ -1233,7 +1233,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); @@ -1241,13 +1241,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. @@ -1434,11 +1434,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(); } } @@ -1484,12 +1484,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(); } @@ -1518,27 +1518,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']) ->condition('deleted', 1) @@ -1552,7 +1552,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]; } @@ -1625,7 +1625,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); } } @@ -1650,7 +1650,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 96cea9f..85d6fbe 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -522,7 +522,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])) { @@ -583,12 +583,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(), - )); + ]); } /** @@ -693,7 +693,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 = []; $entity_type_id = $this->entityType->id(); foreach ($field_schema[$schema_key] as $key => $columns) { @@ -708,7 +708,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]; @@ -761,7 +761,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 @@ -790,7 +790,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', []); } /** @@ -826,7 +826,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(), []); } /** @@ -863,21 +863,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); @@ -899,19 +899,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); @@ -931,23 +931,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); @@ -969,23 +969,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); @@ -999,12 +999,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' => [], + ]; } /** @@ -1149,7 +1149,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) { @@ -1329,15 +1329,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); @@ -1403,7 +1403,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) { @@ -1598,7 +1598,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. @@ -1670,7 +1670,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; } @@ -1690,7 +1690,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; } @@ -1709,10 +1709,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], + ]; } /** @@ -1742,20 +1742,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. @@ -1764,61 +1764,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(); @@ -1845,10 +1845,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); @@ -1863,10 +1863,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); @@ -1884,17 +1884,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 5ee5af6..f9f4271 100644 --- a/core/lib/Drupal/Core/Entity/entity.api.php +++ b/core/lib/Drupal/Core/Entity/entity.api.php @@ -939,12 +939,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(); } @@ -963,11 +963,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(); } @@ -987,9 +987,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(); @@ -1011,9 +1011,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(); } @@ -1063,10 +1063,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); } @@ -1083,10 +1083,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); } @@ -1102,10 +1102,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); } @@ -1121,10 +1121,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); } @@ -1151,8 +1151,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(); } @@ -1179,8 +1179,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(); } @@ -1283,10 +1283,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', - ); + ]; } } @@ -1315,10 +1315,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', - ); + ]; } } @@ -1423,7 +1423,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; @@ -1634,9 +1634,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', [ 'region' => 'hidden', - )); + ]); } } @@ -1657,7 +1657,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.')) @@ -1721,7 +1721,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) @@ -1776,7 +1776,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; } @@ -1815,12 +1815,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; } @@ -1836,9 +1836,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; } @@ -1964,7 +1964,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'); @@ -1977,19 +1977,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 24b4c70..e948aa5 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php @@ -54,13 +54,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); } } @@ -88,7 +88,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. @@ -105,7 +105,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,12 +131,12 @@ protected function validateModules(ConfigImporter $config_importer) { // Ensure that the install profile is not being uninstalled. if (in_array($install_profile, $uninstalls, TRUE)) { $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])); } // Ensure the profile is not changing. if ($install_profile !== $core_extension['profile']) { - $config_importer->logError($this->t('Cannot change the install profile from %new_profile to %profile once Drupal is installed.', array('%profile' => $install_profile, '%new_profile' => $core_extension['profile']))); + $config_importer->logError($this->t('Cannot change the install profile from %new_profile to %profile once Drupal is installed.', ['%profile' => $install_profile, '%new_profile' => $core_extension['profile']])); } } @@ -153,7 +153,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]); @@ -166,7 +166,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])); } } } @@ -179,7 +179,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])); } } } @@ -212,22 +212,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) { @@ -254,7 +254,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': @@ -262,7 +262,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': @@ -270,7 +270,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 3c37195..ae8dafc 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/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 5898d17..9ea7a83 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -298,10 +298,10 @@ protected function setExpiresNoCache(Response $response) { * An array of event listener definitions. */ public static function getSubscribedEvents() { - $events[KernelEvents::RESPONSE][] = array('onRespond'); + $events[KernelEvents::RESPONSE][] = ['onRespond']; // There is no specific reason for choosing 16 beside it should be executed // before ::onRespond(). - $events[KernelEvents::RESPONSE][] = array('onAllResponds', 16); + $events[KernelEvents::RESPONSE][] = ['onAllResponds', 16]; return $events; } diff --git a/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php index 7b10dde..79d7dd5 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. @@ -62,7 +62,7 @@ static function getSubscribedEvents() { // Run this subscriber after others as those might use services that need // to be terminated as well or run code that needs to run before // termination. - $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 dc84a57..1bc662c 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 a0bd7b0..0ded041 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 9970bf0..0b758c6 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 177f011..836bee8 100644 --- a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php +++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php @@ -61,7 +61,7 @@ class ExtensionDiscovery { * * @var array */ - protected static $files = array(); + protected static $files = []; /** * List of installation profile directories to additionally scan. @@ -198,7 +198,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])) { @@ -227,7 +227,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 @@ -316,8 +316,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. @@ -371,7 +371,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) { @@ -397,7 +397,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 c3dbcc8..f9500a5 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 c76e76c..db1226f 100644 --- a/core/lib/Drupal/Core/Extension/ThemeInstaller.php +++ b/core/lib/Drupal/Core/Extension/ThemeInstaller.php @@ -115,7 +115,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; @@ -147,10 +147,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; @@ -179,7 +179,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); @@ -200,14 +200,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); } @@ -244,7 +244,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"); @@ -284,7 +284,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 e703b38..5194d85 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 @@ -420,7 +420,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('region' => 'hidden'); + $this->definition['display'][$display_context]['options'] = ['region' => 'hidden']; } $this->definition['display'][$display_context]['configurable'] = $configurable; return $this; @@ -469,9 +469,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(); @@ -488,10 +488,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; @@ -639,12 +639,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 97dd493..a1a1ebd 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 4e77202..c350432 100644 --- a/core/lib/Drupal/Core/Field/FieldItemListInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemListInterface.php @@ -181,7 +181,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 2170b36..08a27cb 100644 --- a/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php +++ b/core/lib/Drupal/Core/Field/FieldModuleUninstallValidator.php @@ -35,7 +35,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. @@ -49,10 +49,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 84bb4c0..905cdb4 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 2692d84..af99436 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 @@ -199,7 +199,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 e3af1b5..12a349a 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 4cb5d14..011e305 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php @@ -25,20 +25,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; } @@ -47,7 +47,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; } @@ -56,7 +56,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) { @@ -85,7 +85,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. @@ -93,7 +93,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 3babf42..72c0532 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -44,19 +44,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(); } /** @@ -116,32 +116,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->entityClassImplements(FieldableEntityInterface::class) && $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; } @@ -272,12 +272,12 @@ public static function generateSampleValue(FieldDefinitionInterface $field_defin // Instead of calling $manager->getSelectionHandler($field_definition) // replicate the behavior to be able to override the sorting settings. - $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' => NULL, - ); + ]; $entity_type = \Drupal::entityManager()->getDefinition($options['target_type']); $options['handler_settings']['sort'] = [ @@ -299,7 +299,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), @@ -307,7 +307,7 @@ public function storageSettingsForm(array &$form, FormStateInterface $form_state '#required' => TRUE, '#disabled' => $has_data, '#size' => 1, - ); + ]; return $element; } @@ -320,7 +320,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', @@ -334,46 +334,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')), - ); + '#limit_validation_errors' => [], + '#attributes' => [ + 'class' => ['js-hide'], + ], + '#submit' => [[get_class($this), 'settingsAjaxSubmit']], + ]; - $form['handler']['handler_settings'] = array( + $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; } @@ -556,14 +556,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. @@ -593,11 +593,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) { @@ -641,7 +641,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..8469126 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 8bd33ce..a5f9401 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UuidItem.php @@ -24,10 +24,10 @@ class UuidItem extends StringItem { * {@inheritdoc} */ public static function defaultStorageSettings() { - return array( + return [ 'max_length' => 128, 'is_ascii' => TRUE, - ) + parent::defaultStorageSettings(); + ] + parent::defaultStorageSettings(); } /** @@ -36,7 +36,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; } @@ -45,7 +45,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 3824810..11f048e 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'); @@ -90,7 +90,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // Append the match operation to the selection settings. $selection_settings = $this->getFieldSetting('handler_settings') + ['match_operator' => $this->getSetting('match_operator')]; - $element += array( + $element += [ '#type' => 'entity_autocomplete', '#target_type' => $this->getFieldSetting('target_type'), '#selection_handler' => $this->getFieldSetting('handler'), @@ -102,16 +102,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 697c603..0872ba3 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' => $this->getSetting('include_locked') ? LanguageInterface::STATE_ALL : LanguageInterface::STATE_CONFIGURABLE, - ); + ]; 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 ca00bcc..bb773cd 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 4978895..b1579f2 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', - ), - ); + ], + ]; } } @@ -311,26 +311,26 @@ public static function addMoreAjax(array $form, FormStateInterface $form_state) * Generates the form element for a single copy of the widget. */ protected function formSingleElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { - $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; @@ -343,7 +343,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); @@ -410,7 +410,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()); @@ -473,21 +473,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 a2fafbb..9f92d0b 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 8e5c95a..cc54d6c 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 85d0261..a8ad401 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 d1e125e..506884f 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 803b4f1..c4a1fd2 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -496,7 +496,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. @@ -509,7 +509,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 @@ -716,7 +716,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'], @@ -724,8 +724,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 @@ -748,14 +748,14 @@ public function prepareForm($form_id, &$form, FormStateInterface &$form_state) { $placeholder = 'form_token_placeholder_' . Crypt::hashBase64($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 @@ -770,20 +770,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); @@ -793,7 +793,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'; @@ -803,7 +803,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']; } @@ -811,7 +811,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']; } @@ -901,13 +901,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') { @@ -949,7 +949,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'])) { @@ -979,7 +979,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; } @@ -1016,7 +1016,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]; } @@ -1026,7 +1026,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']; @@ -1050,7 +1050,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; } @@ -1236,7 +1236,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; @@ -1255,7 +1255,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 33ca1fa..b78efb3 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 b1e3f3b..43b2d8e 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 d4f3ee5..8e976f5 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. @@ -278,7 +278,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]); } } @@ -295,7 +295,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); @@ -330,7 +330,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'])) { @@ -341,11 +341,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']]); } } } @@ -364,7 +364,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']]); } } } @@ -402,7 +402,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 2a1e61e..c9a93ff 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 8720b00..c28b7f8 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,37 +207,37 @@ 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'), - '#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')), - ); - $form['update_notifications']['enable_update_status_module'] = array( + '#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']), + ]; + $form['update_notifications']['enable_update_status_module'] = [ '#type' => 'checkbox', '#title' => $this->t('Check for updates automatically'), '#default_value' => 1, - ); - $form['update_notifications']['enable_update_status_emails'] = array( + ]; + $form['update_notifications']['enable_update_status_emails'] = [ '#type' => 'checkbox', '#title' => $this->t('Receive email notifications'), '#default_value' => 1, - '#states' => array( - 'visible' => array( - 'input[name="enable_update_status_module"]' => array('checked' => TRUE), - ), - ), - ); + '#states' => [ + 'visible' => [ + 'input[name="enable_update_status_module"]' => ['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; } @@ -246,7 +246,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); } } @@ -270,7 +270,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // Enable update.module if this option was selected. $update_status_module = $form_state->getValue('enable_update_status_module'); if ($update_status_module) { - $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. @@ -278,7 +278,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { if ($email_update_status_emails) { // 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 f5d1c7f..5442d15 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 ef54217..7f3ddc8 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', /* Left-to-right marker "‭" */ 'ئۇيغۇرچە', LanguageInterface::DIRECTION_RTL), - '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', /* Left-to-right marker "‭" */ 'ئۇيغۇرچە', LanguageInterface::DIRECTION_RTL], + '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 e7c9e3a..e435d44 100644 --- a/core/lib/Drupal/Core/Link.php +++ b/core/lib/Drupal/Core/Link.php @@ -57,7 +57,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 3dffe83..021028f 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 e264036..057f7de 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 c74e380..7eefd12 100644 --- a/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php +++ b/core/lib/Drupal/Core/Menu/DefaultMenuLinkTreeManipulators.php @@ -130,7 +130,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); @@ -225,7 +225,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); @@ -255,7 +255,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 bfa088e..ab562e6 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 26b2ed5..c14d1de 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 e7e12c4..f58dd91 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 3cd0b8c..0b11f86 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 0a580d6..0e36e13 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 ddb5673..12e85ee 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', - ); + ]; } } @@ -308,18 +308,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'), - ), - ), - ), - ); + ], + ], + ], + ]; } /** @@ -391,7 +391,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 3a31917..6773e79 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 8622db9..f9acafb 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php +++ b/core/lib/Drupal/Core/Plugin/DefaultPluginManager.php @@ -149,7 +149,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; @@ -291,7 +291,7 @@ protected function findDefinitions() { // plugin definition. foreach ($definitions as $plugin_id => $plugin_definition) { $provider = $this->extractProviderFromDefinition($plugin_definition); - if ($provider && !in_array($provider, array('core', 'component')) && !$this->providerExists($provider)) { + if ($provider && !in_array($provider, ['core', 'component']) && !$this->providerExists($provider)) { unset($definitions[$plugin_id]); } } 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 7a0801d..11e15d8 100644 --- a/core/lib/Drupal/Core/Render/Element/Date.php +++ b/core/lib/Drupal/Core/Render/Element/Date.php @@ -88,8 +88,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 2ae6f1d..92bbb32 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 2479676..dce2a34 100644 --- a/core/lib/Drupal/Core/Render/Element/Email.php +++ b/core/lib/Drupal/Core/Render/Element/Email.php @@ -43,25 +43,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'], + ]; } /** @@ -74,7 +74,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])); } } @@ -91,8 +91,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 3888c79..216f068 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 6cf4559..ace452b 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 788aa1e..b7b2524 100644 --- a/core/lib/Drupal/Core/Render/Element/Number.php +++ b/core/lib/Drupal/Core/Render/Element/Number.php @@ -38,21 +38,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'], + ]; } /** @@ -70,18 +70,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') { @@ -90,7 +90,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])); } } } @@ -108,8 +108,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 06d5532..4ba2058 100644 --- a/core/lib/Drupal/Core/Render/Element/Password.php +++ b/core/lib/Drupal/Core/Render/Element/Password.php @@ -32,20 +32,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'], + ]; } /** @@ -61,8 +61,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 0d5e0e2..07c3149 100644 --- a/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php +++ b/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php @@ -33,14 +33,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'], + ]; } /** @@ -68,23 +68,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 d28d787..24595ab 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 b1e0f4a..300c244 100644 --- a/core/lib/Drupal/Core/Render/Element/Select.php +++ b/core/lib/Drupal/Core/Render/Element/Select.php @@ -65,20 +65,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' => [], + ]; } /** @@ -118,14 +118,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']; } } @@ -142,10 +142,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 @@ -167,8 +167,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 298a27f..c6c08b1 100644 --- a/core/lib/Drupal/Core/Render/Element/Table.php +++ b/core/lib/Drupal/Core/Render/Element/Table.php @@ -65,9 +65,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, @@ -77,24 +77,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', - ); + ]; } /** @@ -108,12 +108,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) : []; } } } @@ -135,7 +135,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 { @@ -145,7 +145,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. @@ -154,7 +154,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 @@ -165,7 +165,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 @@ -202,23 +202,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; @@ -339,7 +339,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']; @@ -350,7 +350,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. @@ -364,7 +364,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 0909393..9289a1d 100644 --- a/core/lib/Drupal/Core/Render/Element/Tel.php +++ b/core/lib/Drupal/Core/Render/Element/Tel.php @@ -32,22 +32,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'], + ]; } /** @@ -63,8 +63,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 c66cadc..c3574b0 100644 --- a/core/lib/Drupal/Core/Render/Element/Url.php +++ b/core/lib/Drupal/Core/Render/Element/Url.php @@ -34,25 +34,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'], + ]; } /** @@ -65,7 +65,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])); } } @@ -82,8 +82,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 358b1f1..7b171f8 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 503359e..257349f 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 2970b27..fec05d1 100644 --- a/core/lib/Drupal/Core/Render/theme.api.php +++ b/core/lib/Drupal/Core/Render/theme.api.php @@ -528,12 +528,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.'), - ); + ]; } /** @@ -603,7 +603,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']; } /** @@ -630,7 +630,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']; @@ -962,10 +962,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; @@ -1178,21 +1178,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 5c3d931..d8487c6 100644 --- a/core/lib/Drupal/Core/Routing/AccessAwareRouter.php +++ b/core/lib/Drupal/Core/Routing/AccessAwareRouter.php @@ -127,7 +127,7 @@ public function getRouteCollection() { /** * {@inheritdoc} */ - public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) { + public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) { if ($this->router instanceof UrlGeneratorInterface) { return $this->router->generate($name, $parameters, $referenceType); } diff --git a/core/lib/Drupal/Core/Routing/CompiledRoute.php b/core/lib/Drupal/Core/Routing/CompiledRoute.php index 76d6ef1..a1366a6 100644 --- a/core/lib/Drupal/Core/Routing/CompiledRoute.php +++ b/core/lib/Drupal/Core/Routing/CompiledRoute.php @@ -62,7 +62,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 82c7074..5e329f7 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 9d6db83..74db5c9 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 f16aa9f..1ba5f0d 100644 --- a/core/lib/Drupal/Core/Routing/RouteProvider.php +++ b/core/lib/Drupal/Core/Routing/RouteProvider.php @@ -48,7 +48,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. @@ -185,7 +185,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)); } @@ -210,7 +210,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']); @@ -252,14 +252,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 @@ -269,11 +269,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). @@ -346,9 +346,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) { @@ -357,7 +357,7 @@ protected function getRoutesByPath($path) { // We sort by fit and name in PHP to avoid a SQL filesort and avoid any // difference in the sorting behavior of SQL back-ends. - usort($routes, array($this, 'routeProviderRouteCompare')); + usort($routes, [$this, 'routeProviderRouteCompare']); foreach ($routes as $row) { $collection->add($row['name'], unserialize($row['route'])); @@ -389,8 +389,8 @@ public function getAllRoutes() { * {@inheritdoc} */ public function reset() { - $this->routes = array(); - $this->serializedRoutes = array(); + $this->routes = []; + $this->serializedRoutes = []; $this->cacheTagInvalidator->invalidateTags(['routes']); } @@ -398,7 +398,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/Router.php b/core/lib/Drupal/Core/Routing/Router.php index dc724bc..e949c5e 100644 --- a/core/lib/Drupal/Core/Routing/Router.php +++ b/core/lib/Drupal/Core/Routing/Router.php @@ -214,7 +214,7 @@ protected function doMatchCollection($pathinfo, RouteCollection $routes, $case_s continue; } - $hostMatches = array(); + $hostMatches = []; if ($compiledRoute->getHostRegex() && !preg_match($compiledRoute->getHostRegex(), $this->context->getHost(), $hostMatches)) { $routes->remove($name); continue; @@ -383,7 +383,7 @@ public function getRouteCollection() { /** * {@inheritdoc} */ - public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) { + public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) { @trigger_error('Use the \Drupal\Core\Url object instead', E_USER_DEPRECATED); return $this->urlGenerator->generate($name, $parameters, $referenceType); } 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 36ed0f6..63dcd47 100644 --- a/core/lib/Drupal/Core/Routing/UrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -124,7 +124,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); @@ -241,7 +241,7 @@ protected function doGenerate(array $variables, array $defaults, array $tokens, * The URL path corresponding to the route, without the base path, not URL * encoded. */ - 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(); @@ -252,7 +252,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); } @@ -260,10 +260,10 @@ 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' => '']; if (!isset($options['query']) || !is_array($options['query'])) { - $options['query'] = array(); + $options['query'] = []; } $route = $this->getRoute($name); @@ -284,7 +284,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); @@ -306,7 +306,7 @@ public function generateFromRoute($name, $parameters = array(), $options = array // 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 - $path = strtr($path, array('/../' => '/%2E%2E/', '/./' => '/%2E/')); + $path = strtr($path, ['/../' => '/%2E%2E/', '/./' => '/%2E/']); if ('/..' === substr($path, -3)) { $path = substr($path, 0, -2) . '%2E%2E'; } @@ -377,7 +377,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) { $actual_path = $path === '/' ? $path : rtrim($path, '/'); return $this->pathProcessor->processOutbound($actual_path, $options, $this->requestStack->getCurrentRequest(), $bubbleable_metadata); } @@ -433,7 +433,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 b2b8196..e63383d 100644 --- a/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php +++ b/core/lib/Drupal/Core/Routing/UrlGeneratorInterface.php @@ -24,7 +24,7 @@ * The internal Drupal path corresponding to the route. This string is * not urlencoded and will be an empty string for the front page. */ - 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. @@ -78,6 +78,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 5f98602..95495cf 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 @@ -305,7 +305,7 @@ protected function isSessionObsolete() { */ protected function getSessionDataMask() { if (empty($_SESSION)) { - return array(); + return []; } // Start out with a completely filled mask. @@ -330,7 +330,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 2673fe8..a1a6c38 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. @@ -114,9 +114,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 8b3b106..572e5cb 100644 --- a/core/lib/Drupal/Core/State/State.php +++ b/core/lib/Drupal/Core/State/State.php @@ -56,7 +56,7 @@ protected function resolveCacheMiss($key) { * {@inheritdoc} */ public function getMultiple(array $keys) { - $values = array(); + $values = []; foreach ($keys as $key) { $values[$key] = $this->get($key); } @@ -86,7 +86,7 @@ public function setMultiple(array $data) { */ public function delete($key) { parent::delete($key); - $this->deleteMultiple(array($key)); + $this->deleteMultiple([$key]); } /** 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 6741456..4600c17 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); } @@ -161,7 +161,7 @@ protected function getPluralIndex() { * {@inheritdoc} */ public function __sleep() { - return array_merge(parent::__sleep(), array('count')); + return array_merge(parent::__sleep(), ['count']); } } 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 8e733d5..286ab61 100644 --- a/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php +++ b/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php @@ -37,7 +37,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 f5ee459..21755a5 100644 --- a/core/lib/Drupal/Core/Template/TwigEnvironment.php +++ b/core/lib/Drupal/Core/Template/TwigEnvironment.php @@ -42,19 +42,19 @@ class TwigEnvironment extends \Twig_Environment { * @param array $options * The options for the Twig environment. */ - public function __construct($root, CacheBackendInterface $cache, $twig_extension_hash, StateInterface $state, \Twig_LoaderInterface $loader = NULL, $options = array()) { + public function __construct($root, CacheBackendInterface $cache, $twig_extension_hash, StateInterface $state, \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'; @@ -137,7 +137,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 9f25959..520a8be 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -137,12 +137,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)); }), @@ -157,19 +157,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: @@ -183,9 +183,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']), + ]; } /** @@ -194,18 +194,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(), - ); + ]; } /** @@ -231,7 +231,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); } @@ -252,7 +252,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); @@ -356,10 +356,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/FunctionalTestSetupTrait.php b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php index 25571b9..e9d8d66 100644 --- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php +++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php @@ -37,7 +37,7 @@ /** * The config directories used in this test. */ - protected $configDirectories = array(); + protected $configDirectories = []; /** * Prepares site settings and services before installation. @@ -218,7 +218,7 @@ protected function refreshVariables() { // Clear the tag cache. \Drupal::service('cache_tags.invalidator')->resetChecksums(); foreach (Cache::getBins() as $backend) { - if (is_callable(array($backend, 'reset'))) { + if (is_callable([$backend, 'reset'])) { $backend->reset(); } } @@ -244,7 +244,7 @@ protected function refreshVariables() { * @return \Symfony\Component\HttpFoundation\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'])) { @@ -266,7 +266,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); @@ -361,14 +361,14 @@ protected function initConfig(ContainerInterface $container) { protected function initUserSession() { $password = $this->randomMachineName(); // Define information about the user 1 account. - $this->rootUser = new UserSession(array( + $this->rootUser = new UserSession([ 'uid' => 1, 'name' => 'admin', 'mail' => 'admin@example.com', 'pass_raw' => $password, 'passRaw' => $password, 'timezone' => date_default_timezone_get(), - )); + ]); // The child site derives its session name from the database prefix when // running web tests. diff --git a/core/lib/Drupal/Core/Test/TestRunnerKernel.php b/core/lib/Drupal/Core/Test/TestRunnerKernel.php index f76e82c..5be2b83 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/Test/TestSetupTrait.php b/core/lib/Drupal/Core/Test/TestSetupTrait.php index 31849c8..ea9137e 100644 --- a/core/lib/Drupal/Core/Test/TestSetupTrait.php +++ b/core/lib/Drupal/Core/Test/TestSetupTrait.php @@ -14,7 +14,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', @@ -23,7 +23,7 @@ 'config_schema_test.no_schema_data_types', // Used to test application of schema to filtering of configuration. 'config_test.dynamic.system', - ); + ]; /** * The dependency injection container used in the test. @@ -172,9 +172,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']); } diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index a3054e3..a0af702 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -249,7 +249,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->runtimeCache ?: $this->cache, $this->lock, array('theme_registry'), $this->moduleHandler->isLoaded()); + $this->runtimeRegistry[$this->theme->getName()] = new ThemeRegistry('theme_registry:runtime:' . $this->theme->getName(), $this->runtimeCache ?: $this->cache, $this->lock, ['theme_registry'], $this->moduleHandler->isLoaded()); } return $this->runtimeRegistry[$this->theme->getName()]; } @@ -258,7 +258,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']); } /** @@ -320,7 +320,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 @@ -334,7 +334,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']); } } @@ -428,14 +428,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()); @@ -519,8 +519,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'; @@ -578,7 +578,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. @@ -605,7 +605,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 = []; // Continue looping if the candidate hook doesn't exist or if the candidate // hook has incomplete preprocess functions, and if the candidate hook is a // suggestion (has a double underscore). @@ -767,7 +767,7 @@ public function reset() { $this->runtimeRegistry = []; $this->registry = []; - Cache::invalidateTags(array('theme_registry')); + Cache::invalidateTags(['theme_registry']); return $this; } @@ -788,7 +788,7 @@ public function destruct() { * @return array * Functions grouped by the first prefix. */ - public function getPrefixGroupedUserFunctions($prefixes = array()) { + public function getPrefixGroupedUserFunctions($prefixes = []) { $functions = get_defined_functions(); // If a list of prefixes is supplied, trim down the list to those items 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 3064eb0..c932e89 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 b1c295d..8c4f265 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 20a4a76..29723c6 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 ccc62fe..76dc46c 100644 --- a/core/lib/Drupal/Core/Url.php +++ b/core/lib/Drupal/Core/Url.php @@ -51,7 +51,7 @@ class Url { * * @var array */ - protected $routeParameters = array(); + protected $routeParameters = []; /** * The URL options. @@ -60,7 +60,7 @@ class Url { * * @var array */ - protected $options = array(); + protected $options = []; /** * Indicates whether this object contains an external URL. @@ -112,7 +112,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; @@ -138,7 +138,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); } @@ -310,7 +310,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); @@ -494,7 +494,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 1dad742..8367556 100644 --- a/core/lib/Drupal/Core/Utility/LinkGenerator.php +++ b/core/lib/Drupal/Core/Utility/LinkGenerator.php @@ -90,20 +90,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. @@ -150,7 +150,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 24043d3..4a4d0c0 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 8dbf42e..99b970c 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/phpcs.xml.dist b/core/phpcs.xml.dist index 9ad822f..e4e42be 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -101,6 +101,7 @@ + diff --git a/core/profiles/minimal/src/Tests/MinimalTest.php b/core/profiles/minimal/src/Tests/MinimalTest.php index 056565e..7a505cd 100644 --- a/core/profiles/minimal/src/Tests/MinimalTest.php +++ b/core/profiles/minimal/src/Tests/MinimalTest.php @@ -24,7 +24,7 @@ function testMinimal() { // Create a user to test tools and navigation blocks for logged in users // with appropriate permissions. - $user = $this->drupalCreateUser(array('access administration pages', 'administer content types')); + $user = $this->drupalCreateUser(['access administration pages', 'administer content types']); $this->drupalLogin($user); $this->drupalGet(''); $this->assertText(t('Tools')); diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install index 0a40ce6..2f567ab 100644 --- a/core/profiles/standard/standard.install +++ b/core/profiles/standard/standard.install @@ -25,8 +25,8 @@ function standard_install() { $user_settings->set('register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)->save(TRUE); // Enable default permissions for system roles. - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access comments')); - user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access comments', 'post comments', 'skip comment approval')); + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access comments']); + user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access comments', 'post comments', 'skip comment approval']); // Assign user 1 the "administrator" role. $user = User::load(1); @@ -40,34 +40,34 @@ function standard_install() { // Enable the Contact link in the footer menu. /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */ $menu_link_manager = \Drupal::service('plugin.manager.menu.link'); - $menu_link_manager->updateDefinition('contact.site_page', array('enabled' => TRUE)); + $menu_link_manager->updateDefinition('contact.site_page', ['enabled' => TRUE]); - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form')); - user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access site-wide contact form')); + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['access site-wide contact form']); + user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access site-wide contact form']); // Allow authenticated users to use shortcuts. - user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access shortcuts')); + user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access shortcuts']); // Populate the default shortcut set. - $shortcut = Shortcut::create(array( + $shortcut = Shortcut::create([ 'shortcut_set' => 'default', 'title' => t('Add content'), 'weight' => -20, - 'link' => array('uri' => 'internal:/node/add'), - )); + 'link' => ['uri' => 'internal:/node/add'], + ]); $shortcut->save(); - $shortcut = Shortcut::create(array( + $shortcut = Shortcut::create([ 'shortcut_set' => 'default', 'title' => t('All content'), 'weight' => -19, - 'link' => array('uri' => 'internal:/admin/content'), - )); + 'link' => ['uri' => 'internal:/admin/content'], + ]); $shortcut->save(); // Allow all users to use search. - user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('search content')); - user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('search content')); + user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['search content']); + user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['search content']); // Enable the admin theme. \Drupal::configFactory()->getEditable('node.settings')->set('use_admin_theme', TRUE)->save(TRUE); diff --git a/core/profiles/standard/tests/src/Functional/StandardTest.php b/core/profiles/standard/tests/src/Functional/StandardTest.php index 6416368..9baae37 100644 --- a/core/profiles/standard/tests/src/Functional/StandardTest.php +++ b/core/profiles/standard/tests/src/Functional/StandardTest.php @@ -38,20 +38,20 @@ function testStandard() { $this->assertResponse(200); // Test anonymous user can access 'Main navigation' block. - $this->adminUser = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser([ 'administer blocks', 'post comments', 'skip comment approval', 'create article content', 'create page content', - )); + ]); $this->drupalLogin($this->adminUser); // Configure the block. $this->drupalGet('admin/structure/block/add/system_menu_block:main/bartik'); - $this->drupalPostForm(NULL, array( + $this->drupalPostForm(NULL, [ 'region' => 'sidebar_first', 'id' => 'main_navigation', - ), t('Save block')); + ], t('Save block')); // Verify admin user can see the block. $this->drupalGet(''); $this->assertText('Main navigation'); @@ -59,18 +59,18 @@ function testStandard() { // Verify we have role = aria on system_powered_by and help_block // blocks. $this->drupalGet('admin/structure/block'); - $elements = $this->xpath('//div[@role=:role and @id=:id]', array( + $elements = $this->xpath('//div[@role=:role and @id=:id]', [ ':role' => 'complementary', ':id' => 'block-bartik-help', - )); + ]); $this->assertEqual(count($elements), 1, 'Found complementary role on help block.'); $this->drupalGet(''); - $elements = $this->xpath('//div[@role=:role and @id=:id]', array( + $elements = $this->xpath('//div[@role=:role and @id=:id]', [ ':role' => 'complementary', ':id' => 'block-bartik-powered', - )); + ]); $this->assertEqual(count($elements), 1, 'Found complementary role on powered by block.'); // Verify anonymous user can see the block. @@ -79,22 +79,22 @@ function testStandard() { // Ensure comments don't show in the front page RSS feed. // Create an article. - $this->drupalCreateNode(array( + $this->drupalCreateNode([ 'type' => 'article', 'title' => 'Foobar', 'promote' => 1, 'status' => 1, - 'body' => array(array('value' => 'Then she picked out two somebodies,
    Sally and me', 'format' => 'basic_html')), - )); + 'body' => [['value' => 'Then she picked out two somebodies,
    Sally and me', 'format' => 'basic_html']], + ]); // Add a comment. $this->drupalLogin($this->adminUser); $this->drupalGet('node/1'); $this->assertRaw('Then she picked out two somebodies,
    Sally and me', 'Found a line break.'); - $this->drupalPostForm(NULL, array( + $this->drupalPostForm(NULL, [ 'subject[0][value]' => 'Barfoo', 'comment_body[0][value]' => 'Then she picked out two somebodies, Sally and me', - ), t('Save')); + ], t('Save')); // Fetch the feed. $this->drupalGet('rss.xml'); $this->assertText('Foobar'); @@ -131,9 +131,9 @@ function testStandard() { $filter->removeFilter('editor_file_reference'); $filter->save(); } - \Drupal::service('module_installer')->uninstall(array('editor', 'ckeditor')); + \Drupal::service('module_installer')->uninstall(['editor', 'ckeditor']); $this->rebuildContainer(); - \Drupal::service('module_installer')->install(array('editor')); + \Drupal::service('module_installer')->install(['editor']); /** @var \Drupal\contact\ContactFormInterface $contact_form */ $contact_form = ContactForm::load('feedback'); $recipients = $contact_form->getRecipients(); @@ -167,7 +167,7 @@ function testStandard() { // Make sure the optional image styles are installed after enabling // the responsive_image module. - \Drupal::service('module_installer')->install(array('responsive_image')); + \Drupal::service('module_installer')->install(['responsive_image']); $this->rebuildContainer(); $this->drupalGet('admin/config/media/image-styles'); $this->assertText('Max 325x325'); diff --git a/core/profiles/testing/modules/drupal_system_listing_compatible_test/src/Tests/SystemListingCompatibleTest.php b/core/profiles/testing/modules/drupal_system_listing_compatible_test/src/Tests/SystemListingCompatibleTest.php index 332b000..ac2087b 100644 --- a/core/profiles/testing/modules/drupal_system_listing_compatible_test/src/Tests/SystemListingCompatibleTest.php +++ b/core/profiles/testing/modules/drupal_system_listing_compatible_test/src/Tests/SystemListingCompatibleTest.php @@ -20,7 +20,7 @@ class SystemListingCompatibleTest extends WebTestBase { * * @var array */ - public static $modules = array('drupal_system_listing_compatible_test'); + public static $modules = ['drupal_system_listing_compatible_test']; /** * Use the Minimal profile. diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php index 10aa88e..bf2643d 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php @@ -27,9 +27,9 @@ class MachineNameTest extends JavascriptTestBase { protected function setUp() { parent::setUp(); - $account = $this->drupalCreateUser(array( + $account = $this->drupalCreateUser([ 'access content', - )); + ]); $this->drupalLogin($account); } diff --git a/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php b/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php index a116c6f..511dee6 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/EntityReference/EntityReferenceAutocompleteWidgetTest.php @@ -52,9 +52,9 @@ public function testEntityReferenceAutocompleteWidget() { entity_get_form_display('node', 'page', 'default') ->setComponent($field_name, [ 'type' => 'entity_reference_autocomplete', - 'settings' => array( + 'settings' => [ 'match_operator' => 'CONTAINS', - ), + ], ]) ->save(); @@ -78,9 +78,9 @@ public function testEntityReferenceAutocompleteWidget() { entity_get_form_display('node', 'page', 'default') ->setComponent($field_name, [ 'type' => 'entity_reference_autocomplete', - 'settings' => array( + 'settings' => [ 'match_operator' => 'STARTS_WITH', - ), + ], ]) ->save(); diff --git a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php index 815a26b..81d379f 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php @@ -113,7 +113,7 @@ public function waitForElementVisible($selector, $locator, $timeout = 10000) { * The page element node if found, NULL if not. */ public function waitForButton($locator, $timeout = 10000) { - return $this->waitForElement('named', array('button', $locator), $timeout); + return $this->waitForElement('named', ['button', $locator], $timeout); } /** @@ -128,7 +128,7 @@ public function waitForButton($locator, $timeout = 10000) { * The page element node if found, NULL if not. */ public function waitForLink($locator, $timeout = 10000) { - return $this->waitForElement('named', array('link', $locator), $timeout); + return $this->waitForElement('named', ['link', $locator], $timeout); } /** @@ -143,7 +143,7 @@ public function waitForLink($locator, $timeout = 10000) { * The page element node if found, NULL if not. */ public function waitForField($locator, $timeout = 10000) { - return $this->waitForElement('named', array('field', $locator), $timeout); + return $this->waitForElement('named', ['field', $locator], $timeout); } /** @@ -158,7 +158,7 @@ public function waitForField($locator, $timeout = 10000) { * The page element node if found, NULL if not. */ public function waitForId($id, $timeout = 10000) { - return $this->waitForElement('named', array('id', $id), $timeout); + return $this->waitForElement('named', ['id', $id], $timeout); } /** diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php index 7930a90..36f6340 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Tests/JSWebAssertTest.php @@ -80,7 +80,7 @@ public function testJsWebAssert() { $result = $page->findButton('Added WaitForElementVisible'); $this->assertEmpty($result); $test_wait_on_element_visible->click(); - $result = $assert_session->waitForElementVisible('named', array('button', 'Added WaitForElementVisible')); + $result = $assert_session->waitForElementVisible('named', ['button', 'Added WaitForElementVisible']); $this->assertNotEmpty($result); $this->assertTrue($result instanceof NodeElement); $this->assertEquals(TRUE, $result->isVisible()); diff --git a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php index 5e9caf4..1cf46fc 100644 --- a/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php +++ b/core/tests/Drupal/FunctionalTests/AssertLegacyTrait.php @@ -711,7 +711,7 @@ protected function assertHeader($name, $value) { * @deprecated Scheduled for removal in Drupal 9.0.0. * Use $this->assertSession()->buildXPathQuery() instead. */ - protected function buildXPathQuery($xpath, array $args = array()) { + protected function buildXPathQuery($xpath, array $args = []) { return $this->assertSession()->buildXPathQuery($xpath, $args); } diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php index 25d1c70..b555fb6 100644 --- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php @@ -21,7 +21,7 @@ class BrowserTestBaseTest extends BrowserTestBase { * * @var array */ - public static $modules = array('test_page_test', 'form_test', 'system_test'); + public static $modules = ['test_page_test', 'form_test', 'system_test']; /** * Tests basic page test. @@ -58,9 +58,9 @@ public function testGoTo() { $this->assertSession()->pageTextContains('Hello Drupal'); // Test that setting headers with drupalGet() works. - $this->drupalGet('system-test/header', array(), array( + $this->drupalGet('system-test/header', [], [ 'Test-Header' => 'header value', - )); + ]); $returned_header = $this->getSession()->getResponseHeader('Test-Header'); $this->assertSame('header value', $returned_header); } diff --git a/core/tests/Drupal/FunctionalTests/Core/Config/SchemaConfigListenerTest.php b/core/tests/Drupal/FunctionalTests/Core/Config/SchemaConfigListenerTest.php index 7138c5e..698a7d1 100644 --- a/core/tests/Drupal/FunctionalTests/Core/Config/SchemaConfigListenerTest.php +++ b/core/tests/Drupal/FunctionalTests/Core/Config/SchemaConfigListenerTest.php @@ -17,6 +17,6 @@ class SchemaConfigListenerTest extends BrowserTestBase { /** * {@inheritdoc} */ - public static $modules = array('config_test'); + public static $modules = ['config_test']; } diff --git a/core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php b/core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php index c631701..ba30da9 100644 --- a/core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php +++ b/core/tests/Drupal/FunctionalTests/Entity/ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest.php @@ -84,10 +84,10 @@ public function testCorrectUserInputMappingOnComplexFields() { $this->drupalGet($this->entityTypeId . '/manage/' . $entity->id() . '/edit'); // Rearrange the field items. - $edit = array( + $edit = [ "$this->fieldName[0][_weight]" => 0, "$this->fieldName[1][_weight]" => -1, - ); + ]; // Executing an ajax call is important before saving as it will trigger // form state caching and so if for any reasons the form is rebuilt with // the entity built based on the user submitted values with already diff --git a/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php b/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php index 72e7b6f..3e05802 100644 --- a/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php +++ b/core/tests/Drupal/KernelTests/Core/Asset/AttachedAssetsTest.php @@ -39,7 +39,7 @@ class AttachedAssetsTest extends KernelTestBase { /** * {@inheritdoc} */ - public static $modules = array('language', 'simpletest', 'common_test', 'system'); + public static $modules = ['language', 'simpletest', 'common_test', 'system']; /** * {@inheritdoc} @@ -57,10 +57,10 @@ protected function setUp() { */ function testDefault() { $assets = new AttachedAssets(); - $this->assertEqual(array(), $this->assetResolver->getCssAssets($assets, FALSE), 'Default CSS is empty.'); + $this->assertEqual([], $this->assetResolver->getCssAssets($assets, FALSE), 'Default CSS is empty.'); list($js_assets_header, $js_assets_footer) = $this->assetResolver->getJsAssets($assets, FALSE); - $this->assertEqual(array(), $js_assets_header, 'Default header JavaScript is empty.'); - $this->assertEqual(array(), $js_assets_footer, 'Default footer JavaScript is empty.'); + $this->assertEqual([], $js_assets_header, 'Default header JavaScript is empty.'); + $this->assertEqual([], $js_assets_footer, 'Default footer JavaScript is empty.'); } /** @@ -187,7 +187,7 @@ function testAggregation() { * Tests JavaScript settings. */ function testSettings() { - $build = array(); + $build = []; $build['#attached']['library'][] = 'core/drupalSettings'; // Nonsensical value to verify if it's possible to override path settings. $build['#attached']['drupalSettings']['path']['pathPrefix'] = 'yarhar'; @@ -311,12 +311,12 @@ function testRenderOrder() { $js = $this->assetResolver->getJsAssets($assets, FALSE)[1]; $js_render_array = \Drupal::service('asset.js.collection_renderer')->render($js); $rendered_js = $this->renderer->renderPlain($js_render_array); - $matches = array(); + $matches = []; if (preg_match_all('/weight_([-0-9]+_[0-9]+)/', $rendered_js, $matches)) { $result = $matches[1]; } else { - $result = array(); + $result = []; } $this->assertIdentical($result, $expected_order_js, 'JavaScript is added in the expected weight order.'); @@ -353,12 +353,12 @@ function testRenderOrder() { $css = $this->assetResolver->getCssAssets($assets, FALSE); $css_render_array = \Drupal::service('asset.css.collection_renderer')->render($css); $rendered_css = $this->renderer->renderPlain($css_render_array); - $matches = array(); + $matches = []; if (preg_match_all('/([a-z]+)_weight_([-0-9]+_[0-9]+)/', $rendered_css, $matches)) { $result = $matches[0]; } else { - $result = array(); + $result = []; } $this->assertIdentical($result, $expected_order_css, 'CSS is added in the expected weight order.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php b/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php index e2108b3..9246eaa 100644 --- a/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php +++ b/core/tests/Drupal/KernelTests/Core/Bootstrap/GetFilenameTest.php @@ -39,7 +39,7 @@ function testDrupalGetFilename() { $this->assertIdentical(drupal_get_filename('module', 'system'), 'core/modules/system/system.info.yml'); // Retrieving the location of a theme. - \Drupal::service('theme_handler')->install(array('stark')); + \Drupal::service('theme_handler')->install(['stark']); $this->assertIdentical(drupal_get_filename('theme', 'stark'), 'core/themes/stark/stark.info.yml'); // Retrieving the location of a theme engine. diff --git a/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTagTest.php b/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTagTest.php index 484ee9c..0fefc39 100644 --- a/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTagTest.php +++ b/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTagTest.php @@ -19,7 +19,7 @@ class DatabaseBackendTagTest extends KernelTestBase { * * @var array */ - public static $modules = array('system'); + public static $modules = ['system']; /** * {@inheritdoc} @@ -30,21 +30,21 @@ public function register(ContainerBuilder $container) { $container ->register('cache_factory', 'Drupal\Core\Cache\CacheFactory') ->addArgument(new Reference('settings')) - ->addMethodCall('setContainer', array(new Reference('service_container'))); + ->addMethodCall('setContainer', [new Reference('service_container')]); } public function testTagInvalidations() { // Create cache entry in multiple bins. - $tags = array('test_tag:1', 'test_tag:2', 'test_tag:3'); - $bins = array('data', 'bootstrap', 'render'); + $tags = ['test_tag:1', 'test_tag:2', 'test_tag:3']; + $bins = ['data', 'bootstrap', 'render']; foreach ($bins as $bin) { $bin = \Drupal::cache($bin); $bin->set('test', 'value', Cache::PERMANENT, $tags); $this->assertTrue($bin->get('test'), 'Cache item was set in bin.'); } - $invalidations_before = intval(db_select('cachetags')->fields('cachetags', array('invalidations'))->condition('tag', 'test_tag:2')->execute()->fetchField()); - Cache::invalidateTags(array('test_tag:2')); + $invalidations_before = intval(db_select('cachetags')->fields('cachetags', ['invalidations'])->condition('tag', 'test_tag:2')->execute()->fetchField()); + Cache::invalidateTags(['test_tag:2']); // Test that cache entry has been invalidated in multiple bins. foreach ($bins as $bin) { @@ -53,7 +53,7 @@ public function testTagInvalidations() { } // Test that only one tag invalidation has occurred. - $invalidations_after = intval(db_select('cachetags')->fields('cachetags', array('invalidations'))->condition('tag', 'test_tag:2')->execute()->fetchField()); + $invalidations_after = intval(db_select('cachetags')->fields('cachetags', ['invalidations'])->condition('tag', 'test_tag:2')->execute()->fetchField()); $this->assertEqual($invalidations_after, $invalidations_before + 1, 'Only one addition cache tag invalidation has occurred after invalidating a tag used in multiple bins.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php b/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php index fd1c942..de8bbda 100644 --- a/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php +++ b/core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php @@ -16,7 +16,7 @@ class DatabaseBackendTest extends GenericCacheBackendUnitTestBase { * * @var array */ - public static $modules = array('system'); + public static $modules = ['system']; /** * Creates a new instance of DatabaseBackend. diff --git a/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php b/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php index d5f3e95..8179d7d 100644 --- a/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php @@ -102,7 +102,7 @@ protected function getCacheBackend($bin = NULL) { } protected function setUp() { - $this->cachebackends = array(); + $this->cachebackends = []; $this->defaultValue = $this->randomMachineName(10); parent::setUp(); @@ -131,7 +131,7 @@ public function testSetGet() { $backend = $this->getCacheBackend(); $this->assertIdentical(FALSE, $backend->get('test1'), "Backend does not contain data for cache id test1."); - $with_backslash = array('foo' => '\Drupal\foo\Bar'); + $with_backslash = ['foo' => '\Drupal\foo\Bar']; $backend->set('test1', $with_backslash); $cached = $backend->get('test1'); $this->assert(is_object($cached), "Backend returned an object for cache id test1."); @@ -142,10 +142,10 @@ public function testSetGet() { $this->assertEqual($cached->expire, Cache::PERMANENT, 'Expire time is correct.'); $this->assertIdentical(FALSE, $backend->get('test2'), "Backend does not contain data for cache id test2."); - $backend->set('test2', array('value' => 3), REQUEST_TIME + 3); + $backend->set('test2', ['value' => 3], REQUEST_TIME + 3); $cached = $backend->get('test2'); $this->assert(is_object($cached), "Backend returned an object for cache id test2."); - $this->assertIdentical(array('value' => 3), $cached->data); + $this->assertIdentical(['value' => 3], $cached->data); $this->assertTrue($cached->valid, 'Item is marked as valid.'); $this->assertTrue($cached->created >= REQUEST_TIME && $cached->created <= round(microtime(TRUE), 3), 'Created time is correct.'); $this->assertEqual($cached->expire, REQUEST_TIME + 3, 'Expire time is correct.'); @@ -159,7 +159,7 @@ public function testSetGet() { $this->assertEqual($cached->expire, REQUEST_TIME - 3, 'Expire time is correct.'); $this->assertIdentical(FALSE, $backend->get('test4'), "Backend does not contain data for cache id test4."); - $with_eof = array('foo' => "\nEOF\ndata"); + $with_eof = ['foo' => "\nEOF\ndata"]; $backend->set('test4', $with_eof); $cached = $backend->get('test4'); $this->assert(is_object($cached), "Backend returned an object for cache id test4."); @@ -169,7 +169,7 @@ public function testSetGet() { $this->assertEqual($cached->expire, Cache::PERMANENT, 'Expire time is correct.'); $this->assertIdentical(FALSE, $backend->get('test5'), "Backend does not contain data for cache id test5."); - $with_eof_and_semicolon = array('foo' => "\nEOF;\ndata"); + $with_eof_and_semicolon = ['foo' => "\nEOF;\ndata"]; $backend->set('test5', $with_eof_and_semicolon); $cached = $backend->get('test5'); $this->assert(is_object($cached), "Backend returned an object for cache id test5."); @@ -178,7 +178,7 @@ public function testSetGet() { $this->assertTrue($cached->created >= REQUEST_TIME && $cached->created <= round(microtime(TRUE), 3), 'Created time is correct.'); $this->assertEqual($cached->expire, Cache::PERMANENT, 'Expire time is correct.'); - $with_variable = array('foo' => '$bar'); + $with_variable = ['foo' => '$bar']; $backend->set('test6', $with_variable); $cached = $backend->get('test6'); $this->assert(is_object($cached), "Backend returned an object for cache id test6."); @@ -257,14 +257,14 @@ public function testDelete() { public function testValueTypeIsKept() { $backend = $this->getCacheBackend(); - $variables = array( + $variables = [ 'test1' => 1, 'test2' => '0', 'test3' => '', 'test4' => 12.64, 'test5' => FALSE, - 'test6' => array(1, 2, 3), - ); + 'test6' => [1, 2, 3], + ]; // Create cache entries. foreach ($variables as $cid => $data) { @@ -297,14 +297,14 @@ public function testGetMultiple() { $backend->set($long_cid, 300); // Mismatch order for harder testing. - $reference = array( + $reference = [ 'test3', 'test7', 'test21', // Cid does not exist. 'test6', 'test19', // Cid does not exist until added before second getMultiple(). 'test2', - ); + ]; $cids = $reference; $ret = $backend->getMultiple($cids); @@ -364,7 +364,7 @@ public function testGetMultiple() { $this->assertFalse(in_array('test19', $cids), "Added cache id test19 is not in cids array."); // Test with a long $cid and non-numeric array key. - $cids = array('key:key' => $long_cid); + $cids = ['key:key' => $long_cid]; $return = $backend->getMultiple($cids); $this->assertEqual(300, $return[$long_cid]->data); $this->assertTrue(empty($cids)); @@ -380,13 +380,13 @@ public function testSetMultiple() { // Set multiple testing keys. $backend->set('cid_1', 'Some other value'); - $items = array( - 'cid_1' => array('data' => 1), - 'cid_2' => array('data' => 2), - 'cid_3' => array('data' => array(1, 2)), - 'cid_4' => array('data' => 1, 'expire' => $future_expiration), - 'cid_5' => array('data' => 1, 'tags' => array('test:a', 'test:b')), - ); + $items = [ + 'cid_1' => ['data' => 1], + 'cid_2' => ['data' => 2], + 'cid_3' => ['data' => [1, 2]], + 'cid_4' => ['data' => 1, 'expire' => $future_expiration], + 'cid_5' => ['data' => 1, 'tags' => ['test:a', 'test:b']], + ]; $backend->setMultiple($items); $cids = array_keys($items); $cached = $backend->getMultiple($cids); @@ -411,9 +411,9 @@ public function testSetMultiple() { // assertion. try { $items = [ - 'exception_test_1' => array('data' => 1, 'tags' => []), - 'exception_test_2' => array('data' => 2, 'tags' => ['valid']), - 'exception_test_3' => array('data' => 3, 'tags' => ['node' => [3, 5, 7]]), + 'exception_test_1' => ['data' => 1, 'tags' => []], + 'exception_test_2' => ['data' => 2, 'tags' => ['valid']], + 'exception_test_3' => ['data' => 3, 'tags' => ['node' => [3, 5, 7]]], ]; $backend->setMultiple($items); $this->fail('::setMultiple() was called with invalid cache tags, runtime assertion did not fail.'); @@ -441,13 +441,13 @@ public function testDeleteMultiple() { $backend->delete('test1'); $backend->delete('test23'); // Nonexistent key should not cause an error. - $backend->deleteMultiple(array( + $backend->deleteMultiple([ 'test3', 'test5', 'test7', 'test19', // Nonexistent key should not cause an error. 'test21', // Nonexistent key should not cause an error. - )); + ]); // Test if expected keys have been deleted. $this->assertIdentical(FALSE, $backend->get('test1'), "Cache id test1 deleted."); @@ -465,7 +465,7 @@ public function testDeleteMultiple() { $this->assertIdentical(FALSE, $backend->get('test21'), "Cache id test21 does not exist."); // Calling deleteMultiple() with an empty array should not cause an error. - $this->assertFalse($backend->deleteMultiple(array())); + $this->assertFalse($backend->deleteMultiple([])); } /** @@ -498,14 +498,14 @@ function testInvalidate() { $backend->set('test3', 2); $backend->set('test4', 2); - $reference = array('test1', 'test2', 'test3', 'test4'); + $reference = ['test1', 'test2', 'test3', 'test4']; $cids = $reference; $ret = $backend->getMultiple($cids); $this->assertEqual(count($ret), 4, 'Four items returned.'); $backend->invalidate('test1'); - $backend->invalidateMultiple(array('test2', 'test3')); + $backend->invalidateMultiple(['test2', 'test3']); $cids = $reference; $ret = $backend->getMultiple($cids); @@ -517,7 +517,7 @@ function testInvalidate() { // Calling invalidateMultiple() with an empty array should not cause an // error. - $this->assertFalse($backend->invalidateMultiple(array())); + $this->assertFalse($backend->invalidateMultiple([])); } /** @@ -527,45 +527,45 @@ function testInvalidateTags() { $backend = $this->getCacheBackend(); // Create two cache entries with the same tag and tag value. - $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:2')); - $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:2')); + $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, ['test_tag:2']); + $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, ['test_tag:2']); $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.'); // Invalidate test_tag of value 1. This should invalidate both entries. - Cache::invalidateTags(array('test_tag:2')); + Cache::invalidateTags(['test_tag:2']); $this->assertFalse($backend->get('test_cid_invalidate1') || $backend->get('test_cid_invalidate2'), 'Two cache items invalidated after invalidating a cache tag.'); $this->assertTrue($backend->get('test_cid_invalidate1', TRUE) && $backend->get('test_cid_invalidate2', TRUE), 'Cache items not deleted after invalidating a cache tag.'); // Create two cache entries with the same tag and an array tag value. - $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:1')); - $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:1')); + $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, ['test_tag:1']); + $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, ['test_tag:1']); $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Two cache items were created.'); // Invalidate test_tag of value 1. This should invalidate both entries. - Cache::invalidateTags(array('test_tag:1')); + Cache::invalidateTags(['test_tag:1']); $this->assertFalse($backend->get('test_cid_invalidate1') || $backend->get('test_cid_invalidate2'), 'Two caches removed after invalidating a cache tag.'); $this->assertTrue($backend->get('test_cid_invalidate1', TRUE) && $backend->get('test_cid_invalidate2', TRUE), 'Cache items not deleted after invalidating a cache tag.'); // Create three cache entries with a mix of tags and tag values. - $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, array('test_tag:1')); - $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, array('test_tag:2')); - $backend->set('test_cid_invalidate3', $this->defaultValue, Cache::PERMANENT, array('test_tag_foo:3')); + $backend->set('test_cid_invalidate1', $this->defaultValue, Cache::PERMANENT, ['test_tag:1']); + $backend->set('test_cid_invalidate2', $this->defaultValue, Cache::PERMANENT, ['test_tag:2']); + $backend->set('test_cid_invalidate3', $this->defaultValue, Cache::PERMANENT, ['test_tag_foo:3']); $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2') && $backend->get('test_cid_invalidate3'), 'Three cached items were created.'); - Cache::invalidateTags(array('test_tag_foo:3')); + Cache::invalidateTags(['test_tag_foo:3']); $this->assertTrue($backend->get('test_cid_invalidate1') && $backend->get('test_cid_invalidate2'), 'Cache items not matching the tag were not invalidated.'); $this->assertFalse($backend->get('test_cid_invalidated3'), 'Cached item matching the tag was removed.'); // Create cache entry in multiple bins. Two cache entries // (test_cid_invalidate1 and test_cid_invalidate2) still exist from previous // tests. - $tags = array('test_tag:1', 'test_tag:2', 'test_tag:3'); - $bins = array('path', 'bootstrap', 'page'); + $tags = ['test_tag:1', 'test_tag:2', 'test_tag:3']; + $bins = ['path', 'bootstrap', 'page']; foreach ($bins as $bin) { $this->getCacheBackend($bin)->set('test', $this->defaultValue, Cache::PERMANENT, $tags); $this->assertTrue($this->getCacheBackend($bin)->get('test'), 'Cache item was set in bin.'); } - Cache::invalidateTags(array('test_tag:2')); + Cache::invalidateTags(['test_tag:2']); // Test that the cache entry has been invalidated in multiple bins. foreach ($bins as $bin) { diff --git a/core/tests/Drupal/KernelTests/Core/Common/SizeTest.php b/core/tests/Drupal/KernelTests/Core/Common/SizeTest.php index 2bcee75..a759bb5 100644 --- a/core/tests/Drupal/KernelTests/Core/Common/SizeTest.php +++ b/core/tests/Drupal/KernelTests/Core/Common/SizeTest.php @@ -18,7 +18,7 @@ class SizeTest extends KernelTestBase { protected function setUp() { parent::setUp(); $kb = Bytes::KILOBYTE; - $this->exactTestCases = array( + $this->exactTestCases = [ '1 byte' => 1, '1 KB' => $kb, '1 MB' => $kb * $kb, @@ -28,21 +28,21 @@ protected function setUp() { '1 EB' => $kb * $kb * $kb * $kb * $kb * $kb, '1 ZB' => $kb * $kb * $kb * $kb * $kb * $kb * $kb, '1 YB' => $kb * $kb * $kb * $kb * $kb * $kb * $kb * $kb, - ); - $this->roundedTestCases = array( + ]; + $this->roundedTestCases = [ '2 bytes' => 2, '1 MB' => ($kb * $kb) - 1, // rounded to 1 MB (not 1000 or 1024 kilobyte!) round(3623651 / ($this->exactTestCases['1 MB']), 2) . ' MB' => 3623651, // megabytes round(67234178751368124 / ($this->exactTestCases['1 PB']), 2) . ' PB' => 67234178751368124, // petabytes round(235346823821125814962843827 / ($this->exactTestCases['1 YB']), 2) . ' YB' => 235346823821125814962843827, // yottabytes - ); + ]; } /** * Checks that format_size() returns the expected string. */ function testCommonFormatSize() { - foreach (array($this->exactTestCases, $this->roundedTestCases) as $test_cases) { + foreach ([$this->exactTestCases, $this->roundedTestCases] as $test_cases) { foreach ($test_cases as $expected => $input) { $this->assertEqual( ($result = format_size($input, NULL)), diff --git a/core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php b/core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php index 7c68ed4..0a67384 100644 --- a/core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php +++ b/core/tests/Drupal/KernelTests/Core/Common/XssUnitTest.php @@ -18,11 +18,11 @@ class XssUnitTest extends KernelTestBase { * * @var array */ - public static $modules = array('filter', 'system'); + public static $modules = ['filter', 'system']; protected function setUp() { parent::setUp(); - $this->installConfig(array('system')); + $this->installConfig(['system']); } /** @@ -31,9 +31,9 @@ protected function setUp() { function testT() { $text = t('Simple text'); $this->assertEqual($text, 'Simple text', 't leaves simple text alone.'); - $text = t('Escaped text: @value', array('@value' => ' & < > " \' ', - ); + ]; // Encode and write, and reload and decode the configuration data. $filestorage = new FileStorage(config_get_config_directory(CONFIG_SYNC_DIRECTORY)); diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php index 570ca4c..0523ee8 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRecreateTest.php @@ -33,7 +33,7 @@ protected function setUp() { parent::setUp(); $this->installEntitySchema('node'); - $this->installConfig(array('field', 'node')); + $this->installConfig(['field', 'node']); $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync')); diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php index 48b9c46..e755d5f 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php @@ -40,7 +40,7 @@ protected function setUp() { $this->installEntitySchema('user'); $this->installEntitySchema('node'); - $this->installConfig(array('field')); + $this->installConfig(['field']); // Set up the ConfigImporter object for testing. $storage_comparer = new StorageComparer( @@ -67,10 +67,10 @@ protected function setUp() { public function testRenameValidation() { // Create a test entity. $test_entity_id = $this->randomMachineName(); - $test_entity = entity_create('config_test', array( + $test_entity = entity_create('config_test', [ 'id' => $test_entity_id, 'label' => $this->randomMachineName(), - )); + ]); $test_entity->save(); $uuid = $test_entity->uuid(); @@ -91,9 +91,9 @@ public function testRenameValidation() { // Confirm that the staged configuration is detected as a rename since the // UUIDs match. $this->configImporter->reset(); - $expected = array( + $expected = [ 'node.type.' . $content_type->id() . '::config_test.dynamic.' . $test_entity_id, - ); + ]; $renames = $this->configImporter->getUnprocessedConfiguration('rename'); $this->assertIdentical($expected, $renames); @@ -105,9 +105,9 @@ public function testRenameValidation() { } catch (ConfigImporterException $e) { $this->pass('Expected ConfigImporterException thrown when a renamed configuration entity does not match the existing entity type.'); - $expected = array( - SafeMarkup::format('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' => 'node_type', '@new_type' => 'config_test', '@old_name' => 'node.type.' . $content_type->id(), '@new_name' => 'config_test.dynamic.' . $test_entity_id)) - ); + $expected = [ + SafeMarkup::format('Entity type mismatch on rename. @old_type not equal to @new_type for existing configuration @old_name and staged configuration @new_name.', ['@old_type' => 'node_type', '@new_type' => 'config_test', '@old_name' => 'node.type.' . $content_type->id(), '@new_name' => 'config_test.dynamic.' . $test_entity_id]) + ]; $this->assertEqual($expected, $this->configImporter->getErrors()); } } @@ -134,9 +134,9 @@ public function testRenameSimpleConfigValidation() { // Confirm that the staged configuration is detected as a rename since the // UUIDs match. $this->configImporter->reset(); - $expected = array( + $expected = [ 'config_test.old::config_test.new' - ); + ]; $renames = $this->configImporter->getUnprocessedConfiguration('rename'); $this->assertIdentical($expected, $renames); @@ -148,9 +148,9 @@ public function testRenameSimpleConfigValidation() { } catch (ConfigImporterException $e) { $this->pass('Expected ConfigImporterException thrown when simple configuration is renamed.'); - $expected = array( - SafeMarkup::format('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', array('@old_name' => 'config_test.old', '@new_name' => 'config_test.new')) - ); + $expected = [ + SafeMarkup::format('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', ['@old_name' => 'config_test.old', '@new_name' => 'config_test.new']) + ]; $this->assertEqual($expected, $this->configImporter->getErrors()); } } diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php index 55f6481..9331195 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterMissingContentTest.php @@ -26,14 +26,14 @@ class ConfigImporterMissingContentTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'user', 'entity_test', 'config_test', 'config_import_test'); + public static $modules = ['system', 'user', 'entity_test', 'config_test', 'config_import_test']; protected function setUp() { parent::setUp(); $this->installSchema('system', 'sequences'); $this->installEntitySchema('entity_test'); $this->installEntitySchema('user'); - $this->installConfig(array('config_test')); + $this->installConfig(['config_test']); // Installing config_test's default configuration pollutes the global // variable being used for recording hook invocations by this test already, // so it has to be cleared out manually. @@ -73,9 +73,9 @@ function testMissingContent() { // on two content entities that do not exist. $storage = $this->container->get('config.storage'); $sync = $this->container->get('config.storage.sync'); - $entity_one = EntityTest::create(array('name' => 'one')); - $entity_two = EntityTest::create(array('name' => 'two')); - $entity_three = EntityTest::create(array('name' => 'three')); + $entity_one = EntityTest::create(['name' => 'one']); + $entity_two = EntityTest::create(['name' => 'two']); + $entity_three = EntityTest::create(['name' => 'three']); $dynamic_name = 'config_test.dynamic.dotted.default'; $original_dynamic_data = $storage->read($dynamic_name); // Entity one will be resolved by diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php index bde5644..53ac7d1 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php @@ -28,12 +28,12 @@ class ConfigImporterTest extends KernelTestBase { * * @var array */ - public static $modules = array('config_test', 'system', 'config_import_test'); + public static $modules = ['config_test', 'system', 'config_import_test']; protected function setUp() { parent::setUp(); - $this->installConfig(array('config_test')); + $this->installConfig(['config_test']); // Installing config_test's default configuration pollutes the global // variable being used for recording hook invocations by this test already, // so it has to be cleared out manually. @@ -106,7 +106,7 @@ function testSiteUuidValidate() { catch (ConfigImporterException $e) { $this->assertEqual($e->getMessage(), 'There were errors validating the config synchronization.'); $error_log = $this->configImporter->getErrors(); - $expected = array('Site UUID in source storage does not match the target storage.'); + $expected = ['Site UUID in source storage does not match the target storage.']; $this->assertEqual($expected, $error_log); } } @@ -160,11 +160,11 @@ function testNew() { $this->assertIdentical($storage->exists($dynamic_name), FALSE, $dynamic_name . ' not 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, @@ -172,7 +172,7 @@ function testNew() { 'size' => '', 'size_value' => '', 'protected_property' => '', - ); + ]; $sync->write($dynamic_name, $original_dynamic_data); $this->assertIdentical($sync->exists($dynamic_name), TRUE, $dynamic_name . ' found.'); @@ -211,23 +211,23 @@ function testSecondaryWritePrimaryFirst() { $sync = $this->container->get('config.storage.sync'); $uuid = $this->container->get('uuid'); - $values_primary = array( + $values_primary = [ 'id' => 'primary', 'label' => 'Primary', 'weight' => 0, 'uuid' => $uuid->generate(), - ); + ]; $sync->write($name_primary, $values_primary); - $values_secondary = array( + $values_secondary = [ 'id' => 'secondary', 'label' => 'Secondary Sync', 'weight' => 0, 'uuid' => $uuid->generate(), // Add a dependency on primary, to ensure that is synced first. - 'dependencies' => array( - 'config' => array($name_primary), - ) - ); + 'dependencies' => [ + 'config' => [$name_primary], + ] + ]; $sync->write($name_secondary, $values_secondary); // Import. @@ -245,7 +245,7 @@ function testSecondaryWritePrimaryFirst() { $logs = $this->configImporter->getErrors(); $this->assertEqual(count($logs), 1); - $this->assertEqual($logs[0], SafeMarkup::format('Deleted and replaced configuration entity "@name"', array('@name' => $name_secondary))); + $this->assertEqual($logs[0], SafeMarkup::format('Deleted and replaced configuration entity "@name"', ['@name' => $name_secondary])); } /** @@ -257,23 +257,23 @@ function testSecondaryWriteSecondaryFirst() { $sync = $this->container->get('config.storage.sync'); $uuid = $this->container->get('uuid'); - $values_primary = array( + $values_primary = [ 'id' => 'primary', 'label' => 'Primary', 'weight' => 0, 'uuid' => $uuid->generate(), // Add a dependency on secondary, so that is synced first. - 'dependencies' => array( - 'config' => array($name_secondary), - ) - ); + 'dependencies' => [ + 'config' => [$name_secondary], + ] + ]; $sync->write($name_primary, $values_primary); - $values_secondary = array( + $values_secondary = [ 'id' => 'secondary', 'label' => 'Secondary Sync', 'weight' => 0, 'uuid' => $uuid->generate(), - ); + ]; $sync->write($name_secondary, $values_secondary); // Import. @@ -305,52 +305,52 @@ function testSecondaryUpdateDeletedDeleterFirst() { $sync = $this->container->get('config.storage.sync'); $uuid = $this->container->get('uuid'); - $values_deleter = array( + $values_deleter = [ 'id' => 'deleter', 'label' => 'Deleter', 'weight' => 0, 'uuid' => $uuid->generate(), - ); + ]; $storage->write($name_deleter, $values_deleter); $values_deleter['label'] = 'Updated Deleter'; $sync->write($name_deleter, $values_deleter); - $values_deletee = array( + $values_deletee = [ 'id' => 'deletee', 'label' => 'Deletee', 'weight' => 0, 'uuid' => $uuid->generate(), // Add a dependency on deleter, to make sure that is synced first. - 'dependencies' => array( - 'config' => array($name_deleter), - ) - ); + 'dependencies' => [ + 'config' => [$name_deleter], + ] + ]; $storage->write($name_deletee, $values_deletee); $values_deletee['label'] = 'Updated Deletee'; $sync->write($name_deletee, $values_deletee); // Ensure that import will continue after the error. - $values_other = array( + $values_other = [ 'id' => 'other', 'label' => 'Other', 'weight' => 0, 'uuid' => $uuid->generate(), // Add a dependency on deleter, to make sure that is synced first. This // will also be synced after the deletee due to alphabetical ordering. - 'dependencies' => array( - 'config' => array($name_deleter), - ) - ); + 'dependencies' => [ + 'config' => [$name_deleter], + ] + ]; $storage->write($name_other, $values_other); $values_other['label'] = 'Updated other'; $sync->write($name_other, $values_other); // Check update changelist order. $updates = $this->configImporter->reset()->getStorageComparer()->getChangelist('update'); - $expected = array( + $expected = [ $name_deleter, $name_deletee, $name_other, - ); + ]; $this->assertIdentical($expected, $updates); // Import. @@ -373,7 +373,7 @@ function testSecondaryUpdateDeletedDeleterFirst() { $logs = $this->configImporter->getErrors(); $this->assertEqual(count($logs), 1); - $this->assertEqual($logs[0], SafeMarkup::format('Update target "@name" is missing.', array('@name' => $name_deletee))); + $this->assertEqual($logs[0], SafeMarkup::format('Update target "@name" is missing.', ['@name' => $name_deletee])); } /** @@ -390,25 +390,25 @@ function testSecondaryUpdateDeletedDeleteeFirst() { $sync = $this->container->get('config.storage.sync'); $uuid = $this->container->get('uuid'); - $values_deleter = array( + $values_deleter = [ 'id' => 'deleter', 'label' => 'Deleter', 'weight' => 0, 'uuid' => $uuid->generate(), // Add a dependency on deletee, to make sure that is synced first. - 'dependencies' => array( - 'config' => array($name_deletee), - ), - ); + 'dependencies' => [ + 'config' => [$name_deletee], + ], + ]; $storage->write($name_deleter, $values_deleter); $values_deleter['label'] = 'Updated Deleter'; $sync->write($name_deleter, $values_deleter); - $values_deletee = array( + $values_deletee = [ 'id' => 'deletee', 'label' => 'Deletee', 'weight' => 0, 'uuid' => $uuid->generate(), - ); + ]; $storage->write($name_deletee, $values_deletee); $values_deletee['label'] = 'Updated Deletee'; $sync->write($name_deletee, $values_deletee); @@ -436,23 +436,23 @@ function testSecondaryDeletedDeleteeSecond() { $uuid = $this->container->get('uuid'); - $values_deleter = array( + $values_deleter = [ 'id' => 'deleter', 'label' => 'Deleter', 'weight' => 0, 'uuid' => $uuid->generate(), // Add a dependency on deletee, to make sure this delete is synced first. - 'dependencies' => array( - 'config' => array($name_deletee), - ), - ); + 'dependencies' => [ + 'config' => [$name_deletee], + ], + ]; $storage->write($name_deleter, $values_deleter); - $values_deletee = array( + $values_deletee = [ 'id' => 'deletee', 'label' => 'Deletee', 'weight' => 0, 'uuid' => $uuid->generate(), - ); + ]; $storage->write($name_deletee, $values_deletee); // Import. @@ -483,9 +483,9 @@ function testUpdated() { // Replace the file content of the existing configuration objects in the // sync directory. - $original_name_data = array( + $original_name_data = [ 'foo' => 'beer', - ); + ]; $sync->write($name, $original_name_data); $original_dynamic_data = $storage->read($dynamic_name); $original_dynamic_data['label'] = 'Updated'; @@ -532,7 +532,7 @@ function testIsInstallable() { $config_name = 'config_test.dynamic.isinstallable'; $this->assertFalse($this->container->get('config.storage')->exists($config_name)); \Drupal::state()->set('config_test.isinstallable', TRUE); - $this->installConfig(array('config_test')); + $this->installConfig(['config_test']); $this->assertTrue($this->container->get('config.storage')->exists($config_name)); } diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php index dcd66a3..953ff24 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigInstallTest.php @@ -49,7 +49,7 @@ function testModuleInstallation() { $this->assertFalse(\Drupal::service('config.typed')->hasConfigSchema('config_schema_test.someschema'), 'Configuration schema for config_schema_test.someschema does not exist.'); // Install the test module. - $this->installModules(array('config_test')); + $this->installModules(['config_test']); // Verify that default module config exists. \Drupal::configFactory()->reset($default_config); @@ -69,14 +69,14 @@ function testModuleInstallation() { $this->assertFalse(isset($GLOBALS['hook_config_test']['delete'])); // Install the schema test module. - $this->enableModules(array('config_schema_test')); - $this->installConfig(array('config_schema_test')); + $this->enableModules(['config_schema_test']); + $this->installConfig(['config_schema_test']); // After module installation the new schema should exist. $this->assertTrue(\Drupal::service('config.typed')->hasConfigSchema('config_schema_test.someschema'), 'Configuration schema for config_schema_test.someschema exists.'); // Test that uninstalling configuration removes configuration schema. - $this->config('core.extension')->set('module', array())->save(); + $this->config('core.extension')->set('module', [])->save(); \Drupal::service('config.manager')->uninstall('module', 'config_test'); $this->assertFalse(\Drupal::service('config.typed')->hasConfigSchema('config_schema_test.someschema'), 'Configuration schema for config_schema_test.someschema does not exist.'); } @@ -86,28 +86,28 @@ function testModuleInstallation() { */ public function testCollectionInstallationNoCollections() { // Install the test module. - $this->enableModules(array('config_collection_install_test')); - $this->installConfig(array('config_collection_install_test')); + $this->enableModules(['config_collection_install_test']); + $this->installConfig(['config_collection_install_test']); /** @var \Drupal\Core\Config\StorageInterface $active_storage */ $active_storage = \Drupal::service('config.storage'); - $this->assertEqual(array(), $active_storage->getAllCollectionNames()); + $this->assertEqual([], $active_storage->getAllCollectionNames()); } /** * Tests config objects in collections are installed as expected. */ public function testCollectionInstallationCollections() { - $collections = array( + $collections = [ 'another_collection', 'collection.test1', 'collection.test2', - ); + ]; // Set the event listener to return three possible collections. // @see \Drupal\config_collection_install_test\EventSubscriber \Drupal::state()->set('config_collection_install_test.collection_names', $collections); // Install the test module. - $this->enableModules(array('config_collection_install_test')); - $this->installConfig(array('config_collection_install_test')); + $this->enableModules(['config_collection_install_test']); + $this->installConfig(['config_collection_install_test']); /** @var \Drupal\Core\Config\StorageInterface $active_storage */ $active_storage = \Drupal::service('config.storage'); $this->assertEqual($collections, $active_storage->getAllCollectionNames()); @@ -140,20 +140,20 @@ public function testCollectionInstallationCollections() { // is not enabled. $this->assertEqual($collections, $active_storage->getAllCollectionNames()); // Enable the 'config_test' module and try again. - $this->enableModules(array('config_test')); + $this->enableModules(['config_test']); \Drupal::service('config.installer')->installCollectionDefaultConfig('entity'); $collections[] = 'entity'; $this->assertEqual($collections, $active_storage->getAllCollectionNames()); $collection_storage = $active_storage->createCollection('entity'); $data = $collection_storage->read('config_test.dynamic.dotted.default'); - $this->assertIdentical(array('label' => 'entity'), $data); + $this->assertIdentical(['label' => 'entity'], $data); // Test that the config manager uninstalls configuration from collections // as expected. \Drupal::service('config.manager')->uninstall('module', 'config_collection_install_test'); - $this->assertEqual(array('entity'), $active_storage->getAllCollectionNames()); + $this->assertEqual(['entity'], $active_storage->getAllCollectionNames()); \Drupal::service('config.manager')->uninstall('module', 'config_test'); - $this->assertEqual(array(), $active_storage->getAllCollectionNames()); + $this->assertEqual([], $active_storage->getAllCollectionNames()); } /** @@ -165,12 +165,12 @@ public function testCollectionInstallationCollections() { * using simple configuration. */ public function testCollectionInstallationCollectionConfigEntity() { - $collections = array( + $collections = [ 'entity', - ); + ]; \Drupal::state()->set('config_collection_install_test.collection_names', $collections); // Install the test module. - $this->installModules(array('config_test', 'config_collection_install_test')); + $this->installModules(['config_test', 'config_collection_install_test']); /** @var \Drupal\Core\Config\StorageInterface $active_storage */ $active_storage = \Drupal::service('config.storage'); $this->assertEqual($collections, $active_storage->getAllCollectionNames()); @@ -185,7 +185,7 @@ public function testCollectionInstallationCollectionConfigEntity() { $data = $active_storage->read($name); $this->assertTrue(isset($data['uuid'])); $data = $collection_storage->read($name); - $this->assertIdentical(array('label' => 'entity'), $data); + $this->assertIdentical(['label' => 'entity'], $data); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigLanguageOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigLanguageOverrideTest.php index 994406c..6c6fa90 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigLanguageOverrideTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigLanguageOverrideTest.php @@ -17,14 +17,14 @@ class ConfigLanguageOverrideTest extends KernelTestBase { * * @var array */ - public static $modules = array('user', 'language', 'config_test', 'system', 'field'); + public static $modules = ['user', 'language', 'config_test', 'system', 'field']; /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); - $this->installConfig(array('config_test')); + $this->installConfig(['config_test']); } /** @@ -68,40 +68,40 @@ function testConfigLanguageOverride() { // Test how overrides react to base configuration changes. Set up some base // values. \Drupal::configFactory()->getEditable('config_test.foo') - ->set('value', array('key' => 'original')) + ->set('value', ['key' => 'original']) ->set('label', 'Original') ->save(); \Drupal::languageManager() ->getLanguageConfigOverride('de', 'config_test.foo') - ->set('value', array('key' => 'override')) + ->set('value', ['key' => 'override']) ->set('label', 'Override') ->save(); \Drupal::languageManager() ->getLanguageConfigOverride('fr', 'config_test.foo') - ->set('value', array('key' => 'override')) + ->set('value', ['key' => 'override']) ->save(); \Drupal::configFactory()->clearStaticCache(); $config = \Drupal::config('config_test.foo'); - $this->assertIdentical($config->get('value'), array('key' => 'override')); + $this->assertIdentical($config->get('value'), ['key' => 'override']); // Ensure renaming the config will rename the override. \Drupal::languageManager()->setConfigOverrideLanguage(\Drupal::languageManager()->getLanguage('en')); \Drupal::configFactory()->rename('config_test.foo', 'config_test.bar'); $config = \Drupal::config('config_test.bar'); - $this->assertEqual($config->get('value'), array('key' => 'original')); + $this->assertEqual($config->get('value'), ['key' => 'original']); $override = \Drupal::languageManager()->getLanguageConfigOverride('de', 'config_test.foo'); $this->assertTrue($override->isNew()); $this->assertEqual($override->get('value'), NULL); $override = \Drupal::languageManager()->getLanguageConfigOverride('de', 'config_test.bar'); $this->assertFalse($override->isNew()); - $this->assertEqual($override->get('value'), array('key' => 'override')); + $this->assertEqual($override->get('value'), ['key' => 'override']); $override = \Drupal::languageManager()->getLanguageConfigOverride('fr', 'config_test.bar'); $this->assertFalse($override->isNew()); - $this->assertEqual($override->get('value'), array('key' => 'override')); + $this->assertEqual($override->get('value'), ['key' => 'override']); // Ensure changing data in the config will update the overrides. $config = \Drupal::configFactory()->getEditable('config_test.bar')->clear('value.key')->save(); - $this->assertEqual($config->get('value'), array()); + $this->assertEqual($config->get('value'), []); $override = \Drupal::languageManager()->getLanguageConfigOverride('de', 'config_test.bar'); $this->assertFalse($override->isNew()); $this->assertEqual($override->get('value'), NULL); diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigModuleOverridesTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigModuleOverridesTest.php index 1310cb3..a94123d 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigModuleOverridesTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigModuleOverridesTest.php @@ -16,7 +16,7 @@ class ConfigModuleOverridesTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'config', 'config_override_test'); + public static $modules = ['system', 'config', 'config_override_test']; public function testSimpleModuleOverrides() { $GLOBALS['config_test_run_module_overrides'] = TRUE; diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigOverrideTest.php index 914adcf..157853b 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigOverrideTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigOverrideTest.php @@ -16,7 +16,7 @@ class ConfigOverrideTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'config_test'); + public static $modules = ['system', 'config_test']; protected function setUp() { parent::setUp(); @@ -27,11 +27,11 @@ protected function setUp() { * Tests configuration override. */ function testConfOverride() { - $expected_original_data = array( + $expected_original_data = [ 'foo' => 'bar', 'baz' => NULL, '404' => 'herp', - ); + ]; // Set globals before installing to prove that the installed file does not // contain these values. @@ -40,7 +40,7 @@ function testConfOverride() { $overrides['config_test.system']['404'] = 'derp'; $GLOBALS['config'] = $overrides; - $this->installConfig(array('config_test')); + $this->installConfig(['config_test']); // Verify that the original configuration data exists. Have to read storage // directly otherwise overrides will apply. @@ -90,10 +90,10 @@ function testConfOverride() { // Write file to sync. $sync = $this->container->get('config.storage.sync'); - $expected_new_data = array( + $expected_new_data = [ 'foo' => 'barbar', '404' => 'herpderp', - ); + ]; $sync->write('config_test.system', $expected_new_data); // Import changed data from sync to active. diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigOverridesPriorityTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigOverridesPriorityTest.php index f18bf3c..6c568b8 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigOverridesPriorityTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigOverridesPriorityTest.php @@ -18,7 +18,7 @@ class ConfigOverridesPriorityTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'config', 'config_override_test', 'language'); + public static $modules = ['system', 'config', 'config_override_test', 'language']; public function testOverridePriorities() { $GLOBALS['config_test_run_module_overrides'] = FALSE; @@ -50,10 +50,10 @@ public function testOverridePriorities() { $this->assertEqual(50, $config_factory->get('system.site')->get('weight_select_max')); // Override using language. - $language = new Language(array( + $language = new Language([ 'name' => 'French', 'id' => 'fr', - )); + ]); \Drupal::languageManager()->setConfigOverrideLanguage($language); \Drupal::languageManager() ->getLanguageConfigOverride($language->getId(), 'system.site') diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php index 8a39d64..5554fb2 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php @@ -25,14 +25,14 @@ class ConfigSchemaTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'language', 'field', 'image', 'config_test', 'config_schema_test'); + public static $modules = ['system', 'language', 'field', 'image', 'config_test', 'config_schema_test']; /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); - $this->installConfig(array('system', 'image', 'config_schema_test')); + $this->installConfig(['system', 'image', 'config_schema_test']); } /** @@ -42,7 +42,7 @@ function testSchemaMapping() { // Nonexistent configuration key will have Undefined as metadata. $this->assertIdentical(FALSE, \Drupal::service('config.typed')->hasConfigSchema('config_schema_test.no_such_key')); $definition = \Drupal::service('config.typed')->getDefinition('config_schema_test.no_such_key'); - $expected = array(); + $expected = []; $expected['label'] = 'Undefined'; $expected['class'] = Undefined::class; $expected['type'] = 'undefined'; @@ -57,14 +57,14 @@ function testSchemaMapping() { // Configuration file with only some schema. $this->assertIdentical(TRUE, \Drupal::service('config.typed')->hasConfigSchema('config_schema_test.someschema')); $definition = \Drupal::service('config.typed')->getDefinition('config_schema_test.someschema'); - $expected = array(); + $expected = []; $expected['label'] = 'Schema test data'; $expected['class'] = Mapping::class; $expected['mapping']['langcode']['type'] = 'string'; $expected['mapping']['langcode']['label'] = 'Language code'; $expected['mapping']['_core']['type'] = '_core_config_info'; - $expected['mapping']['testitem'] = array('label' => 'Test item'); - $expected['mapping']['testlist'] = array('label' => 'Test list'); + $expected['mapping']['testitem'] = ['label' => 'Test item']; + $expected['mapping']['testlist'] = ['label' => 'Test list']; $expected['type'] = 'config_schema_test.someschema'; $expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition'; $this->assertEqual($definition, $expected, 'Retrieved the right metadata for configuration with only some schema.'); @@ -72,21 +72,21 @@ function testSchemaMapping() { // Check type detection on elements with undefined types. $config = \Drupal::service('config.typed')->get('config_schema_test.someschema'); $definition = $config->get('testitem')->getDataDefinition()->toArray(); - $expected = array(); + $expected = []; $expected['label'] = 'Test item'; $expected['class'] = Undefined::class; $expected['type'] = 'undefined'; $expected['definition_class'] = '\Drupal\Core\TypedData\DataDefinition'; $this->assertEqual($definition, $expected, 'Automatic type detected for a scalar is undefined.'); $definition = $config->get('testlist')->getDataDefinition()->toArray(); - $expected = array(); + $expected = []; $expected['label'] = 'Test list'; $expected['class'] = Undefined::class; $expected['type'] = 'undefined'; $expected['definition_class'] = '\Drupal\Core\TypedData\DataDefinition'; $this->assertEqual($definition, $expected, 'Automatic type detected for a list is undefined.'); $definition = $config->get('testnoschema')->getDataDefinition()->toArray(); - $expected = array(); + $expected = []; $expected['label'] = 'Undefined'; $expected['class'] = Undefined::class; $expected['type'] = 'undefined'; @@ -95,17 +95,17 @@ function testSchemaMapping() { // Simple case, straight metadata. $definition = \Drupal::service('config.typed')->getDefinition('system.maintenance'); - $expected = array(); + $expected = []; $expected['label'] = 'Maintenance mode'; $expected['class'] = Mapping::class; - $expected['mapping']['message'] = array( + $expected['mapping']['message'] = [ 'label' => 'Message to display when in maintenance mode', 'type' => 'text', - ); - $expected['mapping']['langcode'] = array( + ]; + $expected['mapping']['langcode'] = [ 'label' => 'Language code', 'type' => 'string', - ); + ]; $expected['mapping']['_core']['type'] = '_core_config_info'; $expected['type'] = 'system.maintenance'; $expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition'; @@ -113,38 +113,38 @@ function testSchemaMapping() { // Mixed schema with ignore elements. $definition = \Drupal::service('config.typed')->getDefinition('config_schema_test.ignore'); - $expected = array(); + $expected = []; $expected['label'] = 'Ignore test'; $expected['class'] = Mapping::class; $expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition'; - $expected['mapping']['langcode'] = array( + $expected['mapping']['langcode'] = [ 'type' => 'string', 'label' => 'Language code', - ); + ]; $expected['mapping']['_core']['type'] = '_core_config_info'; - $expected['mapping']['label'] = array( + $expected['mapping']['label'] = [ 'label' => 'Label', 'type' => 'label', - ); - $expected['mapping']['irrelevant'] = array( + ]; + $expected['mapping']['irrelevant'] = [ 'label' => 'Irrelevant', 'type' => 'ignore', - ); - $expected['mapping']['indescribable'] = array( + ]; + $expected['mapping']['indescribable'] = [ 'label' => 'Indescribable', 'type' => 'ignore', - ); - $expected['mapping']['weight'] = array( + ]; + $expected['mapping']['weight'] = [ 'label' => 'Weight', 'type' => 'integer', - ); + ]; $expected['type'] = 'config_schema_test.ignore'; $this->assertEqual($definition, $expected); // The ignore elements themselves. $definition = \Drupal::service('config.typed')->get('config_schema_test.ignore')->get('irrelevant')->getDataDefinition()->toArray(); - $expected = array(); + $expected = []; $expected['type'] = 'ignore'; $expected['label'] = 'Irrelevant'; $expected['class'] = Ignore::class; @@ -156,7 +156,7 @@ function testSchemaMapping() { // More complex case, generic type. Metadata for image style. $definition = \Drupal::service('config.typed')->getDefinition('image.style.large'); - $expected = array(); + $expected = []; $expected['label'] = 'Image style'; $expected['class'] = Mapping::class; $expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition'; @@ -189,7 +189,7 @@ function testSchemaMapping() { // More complex, type based on a complex one. $definition = \Drupal::service('config.typed')->getDefinition('image.effect.image_scale'); // This should be the schema for image.effect.image_scale. - $expected = array(); + $expected = []; $expected['label'] = 'Image scale'; $expected['class'] = Mapping::class; $expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition'; @@ -215,7 +215,7 @@ function testSchemaMapping() { $a = \Drupal::config('config_test.dynamic.third_party'); $test = \Drupal::service('config.typed')->get('config_test.dynamic.third_party')->get('third_party_settings.config_schema_test'); $definition = $test->getDataDefinition()->toArray(); - $expected = array(); + $expected = []; $expected['type'] = 'config_test.dynamic.*.third_party.config_schema_test'; $expected['label'] = 'Mapping'; $expected['class'] = Mapping::class; @@ -229,7 +229,7 @@ function testSchemaMapping() { // More complex, several level deep test. $definition = \Drupal::service('config.typed')->getDefinition('config_schema_test.someschema.somemodule.section_one.subsection'); // This should be the schema of config_schema_test.someschema.somemodule.*.*. - $expected = array(); + $expected = []; $expected['label'] = 'Schema multiple filesystem marker test'; $expected['class'] = Mapping::class; $expected['mapping']['langcode']['type'] = 'string'; @@ -258,34 +258,34 @@ function testSchemaMappingWithParents() { // Test fetching parent one level up. $entry = $config_data->get('one_level'); $definition = $entry->get('testitem')->getDataDefinition()->toArray(); - $expected = array( + $expected = [ 'type' => 'config_schema_test.someschema.with_parents.key_1', 'label' => 'Test item nested one level', 'class' => StringData::class, 'definition_class' => '\Drupal\Core\TypedData\DataDefinition', - ); + ]; $this->assertEqual($definition, $expected); // Test fetching parent two levels up. $entry = $config_data->get('two_levels'); $definition = $entry->get('wrapper')->get('testitem')->getDataDefinition()->toArray(); - $expected = array( + $expected = [ 'type' => 'config_schema_test.someschema.with_parents.key_2', 'label' => 'Test item nested two levels', 'class' => StringData::class, 'definition_class' => '\Drupal\Core\TypedData\DataDefinition', - ); + ]; $this->assertEqual($definition, $expected); // Test fetching parent three levels up. $entry = $config_data->get('three_levels'); $definition = $entry->get('wrapper_1')->get('wrapper_2')->get('testitem')->getDataDefinition()->toArray(); - $expected = array( + $expected = [ 'type' => 'config_schema_test.someschema.with_parents.key_3', 'label' => 'Test item nested three levels', 'class' => StringData::class, 'definition_class' => '\Drupal\Core\TypedData\DataDefinition', - ); + ]; $this->assertEqual($definition, $expected); } @@ -328,7 +328,7 @@ function testSchemaData() { * Test configuration value data type enforcement using schemas. */ public function testConfigSaveWithSchema() { - $untyped_values = array( + $untyped_values = [ 'string' => 1, 'empty_string' => '', 'null_string' => NULL, @@ -337,22 +337,22 @@ public function testConfigSaveWithSchema() { 'boolean' => 1, // If the config schema doesn't have a type it shouldn't be casted. 'no_type' => 1, - 'mapping' => array( + 'mapping' => [ 'string' => 1 - ), + ], 'float' => '3.14', 'null_float' => '', - 'sequence' => array (1, 0, 1), - 'sequence_bc' => array(1, 0, 1), + 'sequence' => [1, 0, 1], + 'sequence_bc' => [1, 0, 1], // Not in schema and therefore should be left untouched. 'not_present_in_schema' => TRUE, // Test a custom type. 'config_schema_test_integer' => '1', 'config_schema_test_integer_empty_string' => '', - ); + ]; $untyped_to_typed = $untyped_values; - $typed_values = array( + $typed_values = [ 'string' => '1', 'empty_string' => '', 'null_string' => NULL, @@ -360,17 +360,17 @@ public function testConfigSaveWithSchema() { 'null_integer' => NULL, 'boolean' => TRUE, 'no_type' => 1, - 'mapping' => array( + 'mapping' => [ 'string' => '1' - ), + ], 'float' => 3.14, 'null_float' => NULL, - 'sequence' => array (TRUE, FALSE, TRUE), - 'sequence_bc' => array(TRUE, FALSE, TRUE), + 'sequence' => [TRUE, FALSE, TRUE], + 'sequence_bc' => [TRUE, FALSE, TRUE], 'not_present_in_schema' => TRUE, 'config_schema_test_integer' => 1, 'config_schema_test_integer_empty_string' => NULL, - ); + ]; // Save config which has a schema that enforces types. $this->config('config_schema_test.schema_data_types') @@ -401,7 +401,7 @@ public function testConfigSaveWithSchema() { function testSchemaFallback() { $definition = \Drupal::service('config.typed')->getDefinition('config_schema_test.wildcard_fallback.something'); // This should be the schema of config_schema_test.wildcard_fallback.*. - $expected = array(); + $expected = []; $expected['label'] = 'Schema wildcard fallback test'; $expected['class'] = Mapping::class; $expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition'; diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigSnapshotTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigSnapshotTest.php index efac2dd..2261168 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigSnapshotTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigSnapshotTest.php @@ -17,7 +17,7 @@ class ConfigSnapshotTest extends KernelTestBase { * * @var array */ - public static $modules = array('config_test', 'system'); + public static $modules = ['config_test', 'system']; /** * {@inheritdoc} @@ -50,7 +50,7 @@ function testSnapshot() { $this->assertFalse($active_snapshot_comparer->createChangelist()->hasChanges()); // Install the default config. - $this->installConfig(array('config_test')); + $this->installConfig(['config_test']); // Although we have imported config this has not affected the snapshot. $this->assertTrue($active_snapshot_comparer->reset()->hasChanges()); diff --git a/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php b/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php index 4b14805..f06806c 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/DefaultConfigTest.php @@ -23,7 +23,7 @@ class DefaultConfigTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'config_test'); + public static $modules = ['system', 'config_test']; /** * Themes which provide default configuration and need enabling. diff --git a/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php b/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php index 15aecaa..68a8962 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/SchemaCheckTraitTest.php @@ -27,14 +27,14 @@ class SchemaCheckTraitTest extends KernelTestBase { * * @var array */ - public static $modules = array('config_test', 'config_schema_test'); + public static $modules = ['config_test', 'config_schema_test']; /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); - $this->installConfig(array('config_test', 'config_schema_test')); + $this->installConfig(['config_test', 'config_schema_test']); $this->typedConfig = \Drupal::service('config.typed'); } @@ -53,14 +53,14 @@ public function testTrait() { // Add a new key, a new array and overwrite boolean with array to test the // error messages. - $config_data = array('new_key' => 'new_value', 'new_array' => array()) + $config_data; - $config_data['boolean'] = array(); + $config_data = ['new_key' => 'new_value', 'new_array' => []] + $config_data; + $config_data['boolean'] = []; $ret = $this->checkConfigSchema($this->typedConfig, 'config_test.types', $config_data); - $expected = array( + $expected = [ 'config_test.types:new_key' => 'missing schema', 'config_test.types:new_array' => 'missing schema', 'config_test.types:boolean' => 'non-scalar value but not defined as an array (such as mapping or sequence)', - ); + ]; $this->assertEqual($ret, $expected); } diff --git a/core/tests/Drupal/KernelTests/Core/Config/SchemaConfigListenerTest.php b/core/tests/Drupal/KernelTests/Core/Config/SchemaConfigListenerTest.php index f078021..2674a3c 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/SchemaConfigListenerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/SchemaConfigListenerTest.php @@ -17,7 +17,7 @@ class SchemaConfigListenerTest extends KernelTestBase { /** * {@inheritdoc} */ - public static $modules = array('config_test'); + public static $modules = ['config_test']; /** * {@inheritdoc} diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/CachedStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/CachedStorageTest.php index 163cca7..2366478 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/Storage/CachedStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/CachedStorageTest.php @@ -37,7 +37,7 @@ protected function setUp() { $this->storage = new CachedStorage($this->fileStorage, \Drupal::service('cache.config')); $this->cache = \Drupal::service('cache_factory')->get('config'); // ::listAll() verifications require other configuration data to exist. - $this->storage->write('system.performance', array()); + $this->storage->write('system.performance', []); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php index 1863dab..079ac04 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php @@ -44,7 +44,7 @@ function testCRUD() { $this->assertIdentical($data, FALSE); // Writing data returns TRUE and the data has been written. - $data = array('foo' => 'bar'); + $data = ['foo' => 'bar']; $result = $this->storage->write($name, $data); $this->assertIdentical($result, TRUE); @@ -86,11 +86,11 @@ function testCRUD() { // Deleting all names with prefix deletes the appropriate data and returns // TRUE. - $files = array( + $files = [ 'config_test.test.biff', 'config_test.test.bang', 'config_test.test.pow', - ); + ]; foreach ($files as $name) { $this->storage->write($name, $data); } @@ -98,7 +98,7 @@ function testCRUD() { $result = $this->storage->deleteAll('config_test.'); $names = $this->storage->listAll('config_test.'); $this->assertIdentical($result, TRUE); - $this->assertIdentical($names, array()); + $this->assertIdentical($names, []); // Test renaming an object that does not exist throws an exception. try { @@ -127,7 +127,7 @@ public function testInvalidStorage() { // Write something to the valid storage to prove that the storages do not // pollute one another. - $data = array('foo' => 'bar'); + $data = ['foo' => 'bar']; $result = $this->storage->write($name, $data); $this->assertIdentical($result, TRUE); @@ -150,11 +150,11 @@ public function testInvalidStorage() { // Listing on a non-existing storage bin returns an empty array. $result = $this->invalidStorage->listAll(); - $this->assertIdentical($result, array()); + $this->assertIdentical($result, []); // Writing to a non-existing storage bin creates the bin. - $this->invalidStorage->write($name, array('foo' => 'bar')); + $this->invalidStorage->write($name, ['foo' => 'bar']); $result = $this->invalidStorage->read($name); - $this->assertIdentical($result, array('foo' => 'bar')); + $this->assertIdentical($result, ['foo' => 'bar']); } /** @@ -162,8 +162,8 @@ public function testInvalidStorage() { */ function testDataTypes() { $name = 'config_test.types'; - $data = array( - 'array' => array(), + $data = [ + 'array' => [], 'boolean' => TRUE, 'exp' => 1.2e+34, 'float' => 3.14159, @@ -172,7 +172,7 @@ function testDataTypes() { 'octal' => 0775, 'string' => 'string', 'string_int' => '1', - ); + ]; $result = $this->storage->write($name, $data); $this->assertIdentical($result, TRUE); @@ -186,7 +186,7 @@ function testDataTypes() { */ public function testCollection() { $name = 'config_test.storage'; - $data = array('foo' => 'bar'); + $data = ['foo' => 'bar']; $result = $this->storage->write($name, $data); $this->assertIdentical($result, TRUE); $this->assertIdentical($data, $this->storage->read($name)); @@ -194,13 +194,13 @@ public function testCollection() { // Create configuration in a new collection. $new_storage = $this->storage->createCollection('collection.sub.new'); $this->assertFalse($new_storage->exists($name)); - $this->assertEqual(array(), $new_storage->listAll()); + $this->assertEqual([], $new_storage->listAll()); $new_storage->write($name, $data); $this->assertIdentical($result, TRUE); $this->assertIdentical($data, $new_storage->read($name)); - $this->assertEqual(array($name), $new_storage->listAll()); + $this->assertEqual([$name], $new_storage->listAll()); $this->assertTrue($new_storage->exists($name)); - $new_data = array('foo' => 'baz'); + $new_data = ['foo' => 'baz']; $new_storage->write($name, $new_data); $this->assertIdentical($result, TRUE); $this->assertIdentical($new_data, $new_storage->read($name)); @@ -208,11 +208,11 @@ public function testCollection() { // Create configuration in another collection. $another_storage = $this->storage->createCollection('collection.sub.another'); $this->assertFalse($another_storage->exists($name)); - $this->assertEqual(array(), $another_storage->listAll()); + $this->assertEqual([], $another_storage->listAll()); $another_storage->write($name, $new_data); $this->assertIdentical($result, TRUE); $this->assertIdentical($new_data, $another_storage->read($name)); - $this->assertEqual(array($name), $another_storage->listAll()); + $this->assertEqual([$name], $another_storage->listAll()); $this->assertTrue($another_storage->exists($name)); // Create configuration in yet another collection. @@ -226,33 +226,33 @@ public function testCollection() { $this->assertIdentical($data, $this->storage->read($name)); // Check that the getAllCollectionNames() method works. - $this->assertIdentical(array('alternate', 'collection.sub.another', 'collection.sub.new'), $this->storage->getAllCollectionNames()); + $this->assertIdentical(['alternate', 'collection.sub.another', 'collection.sub.new'], $this->storage->getAllCollectionNames()); // Check that the collections are removed when they are empty. $alt_storage->delete($name); - $this->assertIdentical(array('collection.sub.another', 'collection.sub.new'), $this->storage->getAllCollectionNames()); + $this->assertIdentical(['collection.sub.another', 'collection.sub.new'], $this->storage->getAllCollectionNames()); // Create configuration in collection called 'collection'. This ensures that // FileStorage's collection storage works regardless of its use of // subdirectories. $parent_storage = $this->storage->createCollection('collection'); $this->assertFalse($parent_storage->exists($name)); - $this->assertEqual(array(), $parent_storage->listAll()); + $this->assertEqual([], $parent_storage->listAll()); $parent_storage->write($name, $new_data); $this->assertIdentical($result, TRUE); $this->assertIdentical($new_data, $parent_storage->read($name)); - $this->assertEqual(array($name), $parent_storage->listAll()); + $this->assertEqual([$name], $parent_storage->listAll()); $this->assertTrue($parent_storage->exists($name)); - $this->assertIdentical(array('collection', 'collection.sub.another', 'collection.sub.new'), $this->storage->getAllCollectionNames()); + $this->assertIdentical(['collection', 'collection.sub.another', 'collection.sub.new'], $this->storage->getAllCollectionNames()); $parent_storage->deleteAll(); - $this->assertIdentical(array('collection.sub.another', 'collection.sub.new'), $this->storage->getAllCollectionNames()); + $this->assertIdentical(['collection.sub.another', 'collection.sub.new'], $this->storage->getAllCollectionNames()); // Check that the having an empty collection-less storage does not break // anything. Before deleting check that the previous delete did not affect // data in another collection. $this->assertIdentical($data, $this->storage->read($name)); $this->storage->delete($name); - $this->assertIdentical(array('collection.sub.another', 'collection.sub.new'), $this->storage->getAllCollectionNames()); + $this->assertIdentical(['collection.sub.another', 'collection.sub.new'], $this->storage->getAllCollectionNames()); } abstract protected function read($name); diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php index 6f09a82..0aecc72 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php @@ -21,20 +21,20 @@ protected function setUp() { $this->invalidStorage = new DatabaseStorage($this->container->get('database'), 'invalid'); // ::listAll() verifications require other configuration data to exist. - $this->storage->write('system.performance', array()); + $this->storage->write('system.performance', []); } protected function read($name) { - $data = db_query('SELECT data FROM {config} WHERE name = :name', array(':name' => $name))->fetchField(); + $data = db_query('SELECT data FROM {config} WHERE name = :name', [':name' => $name])->fetchField(); return unserialize($data); } protected function insert($name, $data) { - db_insert('config')->fields(array('name' => $name, 'data' => $data))->execute(); + db_insert('config')->fields(['name' => $name, 'data' => $data])->execute(); } protected function update($name, $data) { - db_update('config')->fields(array('data' => $data))->condition('name', $name)->execute(); + db_update('config')->fields(['data' => $data])->condition('name', $name)->execute(); } protected function delete($name) { diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/FileStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/FileStorageTest.php index fa10a09..23bd5ea 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/Storage/FileStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/FileStorageTest.php @@ -33,7 +33,7 @@ protected function setUp() { // FileStorage::listAll() requires other configuration data to exist. $this->storage->write('system.performance', $this->config('system.performance')->get()); - $this->storage->write('core.extension', array('module' => array())); + $this->storage->write('core.extension', ['module' => []]); } protected function read($name) { @@ -57,10 +57,10 @@ protected function delete($name) { * Tests the FileStorage::listAll method with a relative and absolute path. */ public function testlistAll() { - $expected_files = array( + $expected_files = [ 'core.extension', 'system.performance', - ); + ]; $config_files = $this->storage->listAll(); $this->assertIdentical($config_files, $expected_files, 'Relative path, two config files found.'); diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/StorageReplaceDataWrapperTest.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/StorageReplaceDataWrapperTest.php index 84b4f56..44ce495 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/Storage/StorageReplaceDataWrapperTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/StorageReplaceDataWrapperTest.php @@ -19,8 +19,8 @@ protected function setUp() { parent::setUp(); $this->storage = new StorageReplaceDataWrapper($this->container->get('config.storage')); // ::listAll() verifications require other configuration data to exist. - $this->storage->write('system.performance', array()); - $this->storage->replaceData('system.performance', array('foo' => 'bar')); + $this->storage->write('system.performance', []); + $this->storage->replaceData('system.performance', ['foo' => 'bar']); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php b/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php index eaf50e5..c595e8f 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/BasicSyntaxTest.php @@ -16,13 +16,13 @@ class BasicSyntaxTest extends DatabaseTestBase { * Tests string concatenation. */ function testConcatLiterals() { - $result = db_query('SELECT CONCAT(:a1, CONCAT(:a2, CONCAT(:a3, CONCAT(:a4, :a5))))', array( + $result = db_query('SELECT CONCAT(:a1, CONCAT(:a2, CONCAT(:a3, CONCAT(:a4, :a5))))', [ ':a1' => 'This', ':a2' => ' ', ':a3' => 'is', ':a4' => ' a ', ':a5' => 'test.', - )); + ]); $this->assertIdentical($result->fetchField(), 'This is a test.', 'Basic CONCAT works.'); } @@ -30,12 +30,12 @@ function testConcatLiterals() { * Tests string concatenation with field values. */ function testConcatFields() { - $result = db_query('SELECT CONCAT(:a1, CONCAT(name, CONCAT(:a2, CONCAT(age, :a3)))) FROM {test} WHERE age = :age', array( + $result = db_query('SELECT CONCAT(:a1, CONCAT(name, CONCAT(:a2, CONCAT(age, :a3)))) FROM {test} WHERE age = :age', [ ':a1' => 'The age of ', ':a2' => ' is ', ':a3' => '.', ':age' => 25, - )); + ]); $this->assertIdentical($result->fetchField(), 'The age of John is 25.', 'Field CONCAT works.'); } @@ -43,12 +43,12 @@ function testConcatFields() { * Tests string concatenation with separator. */ function testConcatWsLiterals() { - $result = db_query("SELECT CONCAT_WS(', ', :a1, NULL, :a2, :a3, :a4)", array( + $result = db_query("SELECT CONCAT_WS(', ', :a1, NULL, :a2, :a3, :a4)", [ ':a1' => 'Hello', ':a2' => NULL, ':a3' => '', ':a4' => 'world.', - )); + ]); $this->assertIdentical($result->fetchField(), 'Hello, , world.'); } @@ -56,11 +56,11 @@ function testConcatWsLiterals() { * Tests string concatenation with separator, with field values. */ function testConcatWsFields() { - $result = db_query("SELECT CONCAT_WS('-', :a1, name, :a2, age) FROM {test} WHERE age = :age", array( + $result = db_query("SELECT CONCAT_WS('-', :a1, name, :a2, age) FROM {test} WHERE age = :age", [ ':a1' => 'name', ':a2' => 'age', ':age' => 25, - )); + ]); $this->assertIdentical($result->fetchField(), 'name-John-age-25'); } @@ -69,9 +69,9 @@ function testConcatWsFields() { */ function testLikeEscape() { db_insert('test') - ->fields(array( + ->fields([ 'name' => 'Ring_', - )) + ]) ->execute(); // Match both "Ringo" and "Ring_". @@ -95,13 +95,13 @@ function testLikeEscape() { */ function testLikeBackslash() { db_insert('test') - ->fields(array('name')) - ->values(array( + ->fields(['name']) + ->values([ 'name' => 'abcde\f', - )) - ->values(array( + ]) + ->values([ 'name' => 'abc%\_', - )) + ]) ->execute(); // Match both rows using a LIKE expression with two wildcards and a verbatim diff --git a/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php b/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php index 35fdb4d..24a1872 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/CaseSensitivityTest.php @@ -15,16 +15,16 @@ function testCaseSensitiveInsert() { $num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField(); db_insert('test') - ->fields(array( + ->fields([ 'name' => 'john', // <- A record already exists with name 'John'. 'age' => 2, 'job' => 'Baby', - )) + ]) ->execute(); $num_records_after = db_query('SELECT COUNT(*) FROM {test}')->fetchField(); $this->assertIdentical($num_records_before + 1, (int) $num_records_after, 'Record inserts correctly.'); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'john'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'john'])->fetchField(); $this->assertIdentical($saved_age, '2', 'Can retrieve after inserting.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php index 0cc3627..5a8444a 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php @@ -168,9 +168,9 @@ public function testPostgresqlReservedWords() { $stmt->execute(); foreach ($stmt->fetchAllAssoc('word') as $word => $row) { $expected = '"' . $word . '"'; - $this->assertIdentical($db->escapeTable($word), $expected, format_string('The reserved word %word was correctly escaped when used as a table name.', array('%word' => $word))); - $this->assertIdentical($db->escapeField($word), $expected, format_string('The reserved word %word was correctly escaped when used as a column name.', array('%word' => $word))); - $this->assertIdentical($db->escapeAlias($word), $expected, format_string('The reserved word %word was correctly escaped when used as an alias.', array('%word' => $word))); + $this->assertIdentical($db->escapeTable($word), $expected, format_string('The reserved word %word was correctly escaped when used as a table name.', ['%word' => $word])); + $this->assertIdentical($db->escapeField($word), $expected, format_string('The reserved word %word was correctly escaped when used as a column name.', ['%word' => $word])); + $this->assertIdentical($db->escapeAlias($word), $expected, format_string('The reserved word %word was correctly escaped when used as an alias.', ['%word' => $word])); } } diff --git a/core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php b/core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php index e315f96..cd5dcd4 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/ConnectionUnitTest.php @@ -75,7 +75,7 @@ protected function getConnectionID() { */ protected function assertConnection($id) { $list = $this->monitor->query('SHOW PROCESSLIST')->fetchAllKeyed(0, 0); - return $this->assertTrue(isset($list[$id]), format_string('Connection ID @id found.', array('@id' => $id))); + return $this->assertTrue(isset($list[$id]), format_string('Connection ID @id found.', ['@id' => $id])); } /** @@ -86,7 +86,7 @@ protected function assertConnection($id) { */ protected function assertNoConnection($id) { $list = $this->monitor->query('SHOW PROCESSLIST')->fetchAllKeyed(0, 0); - return $this->assertFalse(isset($list[$id]), format_string('Connection ID @id not found.', array('@id' => $id))); + return $this->assertFalse(isset($list[$id]), format_string('Connection ID @id not found.', ['@id' => $id])); } /** @@ -186,18 +186,18 @@ function testOpenSelectQueryClose() { // Create a table. $name = 'foo'; - Database::getConnection($this->target, $this->key)->schema()->createTable($name, array( - 'fields' => array( - 'name' => array( + Database::getConnection($this->target, $this->key)->schema()->createTable($name, [ + 'fields' => [ + 'name' => [ 'type' => 'varchar', 'length' => 255, - ), - ), - )); + ], + ], + ]); // Execute a query. Database::getConnection($this->target, $this->key)->select('foo', 'f') - ->fields('f', array('name')) + ->fields('f', ['name']) ->execute() ->fetchAll(); diff --git a/core/tests/Drupal/KernelTests/Core/Database/DatabaseTestBase.php b/core/tests/Drupal/KernelTests/Core/Database/DatabaseTestBase.php index f8c8c3d..7781a90 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/DatabaseTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DatabaseTestBase.php @@ -12,11 +12,11 @@ */ abstract class DatabaseTestBase extends KernelTestBase { - public static $modules = array('database_test'); + public static $modules = ['database_test']; protected function setUp() { parent::setUp(); - $this->installSchema('database_test', array( + $this->installSchema('database_test', [ 'test', 'test_people', 'test_people_copy', @@ -27,7 +27,7 @@ protected function setUp() { 'test_serialized', 'test_special_columns', 'TEST_UPPERCASE', - )); + ]); self::addSampleData(); } @@ -36,19 +36,19 @@ protected function setUp() { */ function ensureSampleDataNull() { db_insert('test_null') - ->fields(array('name', 'age')) - ->values(array( + ->fields(['name', 'age']) + ->values([ 'name' => 'Kermit', 'age' => 25, - )) - ->values(array( + ]) + ->values([ 'name' => 'Fozzie', 'age' => NULL, - )) - ->values(array( + ]) + ->values([ 'name' => 'Gonzo', 'age' => 27, - )) + ]) ->execute(); } @@ -58,89 +58,89 @@ function ensureSampleDataNull() { static function addSampleData() { // We need the IDs, so we can't use a multi-insert here. $john = db_insert('test') - ->fields(array( + ->fields([ 'name' => 'John', 'age' => 25, 'job' => 'Singer', - )) + ]) ->execute(); $george = db_insert('test') - ->fields(array( + ->fields([ 'name' => 'George', 'age' => 27, 'job' => 'Singer', - )) + ]) ->execute(); db_insert('test') - ->fields(array( + ->fields([ 'name' => 'Ringo', 'age' => 28, 'job' => 'Drummer', - )) + ]) ->execute(); $paul = db_insert('test') - ->fields(array( + ->fields([ 'name' => 'Paul', 'age' => 26, 'job' => 'Songwriter', - )) + ]) ->execute(); db_insert('test_people') - ->fields(array( + ->fields([ 'name' => 'Meredith', 'age' => 30, 'job' => 'Speaker', - )) + ]) ->execute(); db_insert('test_task') - ->fields(array('pid', 'task', 'priority')) - ->values(array( + ->fields(['pid', 'task', 'priority']) + ->values([ 'pid' => $john, 'task' => 'eat', 'priority' => 3, - )) - ->values(array( + ]) + ->values([ 'pid' => $john, 'task' => 'sleep', 'priority' => 4, - )) - ->values(array( + ]) + ->values([ 'pid' => $john, 'task' => 'code', 'priority' => 1, - )) - ->values(array( + ]) + ->values([ 'pid' => $george, 'task' => 'sing', 'priority' => 2, - )) - ->values(array( + ]) + ->values([ 'pid' => $george, 'task' => 'sleep', 'priority' => 2, - )) - ->values(array( + ]) + ->values([ 'pid' => $paul, 'task' => 'found new band', 'priority' => 1, - )) - ->values(array( + ]) + ->values([ 'pid' => $paul, 'task' => 'perform at superbowl', 'priority' => 3, - )) + ]) ->execute(); db_insert('test_special_columns') - ->fields(array( + ->fields([ 'id' => 1, 'offset' => 'Offset value 1', - )) + ]) ->execute(); } diff --git a/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php b/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php index 1545dd9..37dbab1 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php @@ -25,8 +25,8 @@ function testSubselectDelete() { $pid_to_delete = db_query("SELECT * FROM {test_task} WHERE task = 'sleep'")->fetchField(); $subquery = db_select('test', 't') - ->fields('t', array('id')) - ->condition('t.id', array($pid_to_delete), 'IN'); + ->fields('t', ['id']) + ->condition('t.id', [$pid_to_delete], 'IN'); $delete = db_delete('test_task') ->condition('task', 'sleep') ->condition('pid', $subquery, 'IN'); diff --git a/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php b/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php index e4f4d67..a29811d 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php @@ -19,8 +19,8 @@ class FetchTest extends DatabaseTestBase { * Confirms that we can fetch a record properly in default object mode. */ function testQueryFetchDefault() { - $records = array(); - $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25)); + $records = []; + $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25]); $this->assertTrue($result instanceof StatementInterface, 'Result set is a Drupal statement object.'); foreach ($result as $record) { $records[] = $record; @@ -35,8 +35,8 @@ function testQueryFetchDefault() { * Confirms that we can fetch a record to an object explicitly. */ function testQueryFetchObject() { - $records = array(); - $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => \PDO::FETCH_OBJ)); + $records = []; + $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25], ['fetch' => \PDO::FETCH_OBJ]); foreach ($result as $record) { $records[] = $record; $this->assertTrue(is_object($record), 'Record is an object.'); @@ -50,8 +50,8 @@ function testQueryFetchObject() { * Confirms that we can fetch a record to an associative array explicitly. */ function testQueryFetchArray() { - $records = array(); - $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => \PDO::FETCH_ASSOC)); + $records = []; + $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25], ['fetch' => \PDO::FETCH_ASSOC]); foreach ($result as $record) { $records[] = $record; if ($this->assertTrue(is_array($record), 'Record is an array.')) { @@ -68,8 +68,8 @@ function testQueryFetchArray() { * @see \Drupal\system\Tests\Database\FakeRecord */ function testQueryFetchClass() { - $records = array(); - $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => 'Drupal\system\Tests\Database\FakeRecord')); + $records = []; + $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25], ['fetch' => 'Drupal\system\Tests\Database\FakeRecord']); foreach ($result as $record) { $records[] = $record; if ($this->assertTrue($record instanceof FakeRecord, 'Record is an object of class FakeRecord.')) { @@ -84,8 +84,8 @@ function testQueryFetchClass() { * Confirms that we can fetch a record into an indexed array explicitly. */ function testQueryFetchNum() { - $records = array(); - $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => \PDO::FETCH_NUM)); + $records = []; + $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25], ['fetch' => \PDO::FETCH_NUM]); foreach ($result as $record) { $records[] = $record; if ($this->assertTrue(is_array($record), 'Record is an array.')) { @@ -100,8 +100,8 @@ function testQueryFetchNum() { * Confirms that we can fetch a record into a doubly-keyed array explicitly. */ function testQueryFetchBoth() { - $records = array(); - $result = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 25), array('fetch' => \PDO::FETCH_BOTH)); + $records = []; + $result = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 25], ['fetch' => \PDO::FETCH_BOTH]); foreach ($result as $record) { $records[] = $record; if ($this->assertTrue(is_array($record), 'Record is an array.')) { @@ -130,11 +130,11 @@ public function testQueryFetchAllColumn() { * Confirms that we can fetch an entire column of a result set at once. */ function testQueryFetchCol() { - $result = db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25)); + $result = db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25]); $column = $result->fetchCol(); $this->assertIdentical(count($column), 3, 'fetchCol() returns the right number of records.'); - $result = db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25)); + $result = db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25]); $i = 0; foreach ($result as $record) { $this->assertIdentical($record->name, $column[$i++], 'Column matches direct access.'); diff --git a/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php b/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php index 6e0363a..0cf1eba 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php @@ -15,12 +15,12 @@ class InsertDefaultsTest extends DatabaseTestBase { * Tests that we can run a query that uses default values for everything. */ function testDefaultInsert() { - $query = db_insert('test')->useDefaults(array('job')); + $query = db_insert('test')->useDefaults(['job']); $id = $query->execute(); $schema = drupal_get_module_schema('database_test', 'test'); - $job = db_query('SELECT job FROM {test} WHERE id = :id', array(':id' => $id))->fetchField(); + $job = db_query('SELECT job FROM {test} WHERE id = :id', [':id' => $id])->fetchField(); $this->assertEqual($job, $schema['fields']['job']['default'], 'Default field value is set.'); } @@ -48,13 +48,13 @@ function testDefaultEmptyInsert() { */ function testDefaultInsertWithFields() { $query = db_insert('test') - ->fields(array('name' => 'Bob')) - ->useDefaults(array('job')); + ->fields(['name' => 'Bob']) + ->useDefaults(['job']); $id = $query->execute(); $schema = drupal_get_module_schema('database_test', 'test'); - $job = db_query('SELECT job FROM {test} WHERE id = :id', array(':id' => $id))->fetchField(); + $job = db_query('SELECT job FROM {test} WHERE id = :id', [':id' => $id])->fetchField(); $this->assertEqual($job, $schema['fields']['job']['default'], 'Default field value is set.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php b/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php index cb41dc0..ca4273e 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/InsertLobTest.php @@ -16,10 +16,10 @@ function testInsertOneBlob() { $data = "This is\000a test."; $this->assertTrue(strlen($data) === 15, 'Test data contains a NULL.'); $id = db_insert('test_one_blob') - ->fields(array('blob1' => $data)) + ->fields(['blob1' => $data]) ->execute(); - $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', array(':id' => $id))->fetchAssoc(); - $this->assertTrue($r['blob1'] === $data, format_string('Can insert a blob: id @id, @data.', array('@id' => $id, '@data' => serialize($r)))); + $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', [':id' => $id])->fetchAssoc(); + $this->assertTrue($r['blob1'] === $data, format_string('Can insert a blob: id @id, @data.', ['@id' => $id, '@data' => serialize($r)])); } /** @@ -27,12 +27,12 @@ function testInsertOneBlob() { */ function testInsertMultipleBlob() { $id = db_insert('test_two_blobs') - ->fields(array( + ->fields([ 'blob1' => 'This is', 'blob2' => 'a test', - )) + ]) ->execute(); - $r = db_query('SELECT * FROM {test_two_blobs} WHERE id = :id', array(':id' => $id))->fetchAssoc(); + $r = db_query('SELECT * FROM {test_two_blobs} WHERE id = :id', [':id' => $id])->fetchAssoc(); $this->assertTrue($r['blob1'] === 'This is' && $r['blob2'] === 'a test', 'Can insert multiple blobs per row.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php b/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php index d703f9d..0c72d2e 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/InsertTest.php @@ -16,10 +16,10 @@ function testSimpleInsert() { $num_records_before = db_query('SELECT COUNT(*) FROM {test}')->fetchField(); $query = db_insert('test'); - $query->fields(array( + $query->fields([ 'name' => 'Yoko', 'age' => '29', - )); + ]); // Check how many records are queued for insertion. $this->assertIdentical($query->count(), 1, 'One record is queued for insertion.'); @@ -27,7 +27,7 @@ function testSimpleInsert() { $num_records_after = db_query('SELECT COUNT(*) FROM {test}')->fetchField(); $this->assertIdentical($num_records_before + 1, (int) $num_records_after, 'Record inserts correctly.'); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Yoko'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Yoko'])->fetchField(); $this->assertIdentical($saved_age, '29', 'Can retrieve after inserting.'); } @@ -38,23 +38,23 @@ function testMultiInsert() { $num_records_before = (int) db_query('SELECT COUNT(*) FROM {test}')->fetchField(); $query = db_insert('test'); - $query->fields(array( + $query->fields([ 'name' => 'Larry', 'age' => '30', - )); + ]); // We should be able to specify values in any order if named. - $query->values(array( + $query->values([ 'age' => '31', 'name' => 'Curly', - )); + ]); // Check how many records are queued for insertion. $this->assertIdentical($query->count(), 2, 'Two records are queued for insertion.'); // We should be able to say "use the field order". // This is not the recommended mechanism for most cases, but it should work. - $query->values(array('Moe', '32')); + $query->values(['Moe', '32']); // Check how many records are queued for insertion. $this->assertIdentical($query->count(), 3, 'Three records are queued for insertion.'); @@ -62,11 +62,11 @@ function testMultiInsert() { $num_records_after = (int) db_query('SELECT COUNT(*) FROM {test}')->fetchField(); $this->assertIdentical($num_records_before + 3, $num_records_after, 'Record inserts correctly.'); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Larry'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Larry'])->fetchField(); $this->assertIdentical($saved_age, '30', 'Can retrieve after inserting.'); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Curly'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Curly'])->fetchField(); $this->assertIdentical($saved_age, '31', 'Can retrieve after inserting.'); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Moe'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Moe'])->fetchField(); $this->assertIdentical($saved_age, '32', 'Can retrieve after inserting.'); } @@ -78,25 +78,25 @@ function testRepeatedInsert() { $query = db_insert('test'); - $query->fields(array( + $query->fields([ 'name' => 'Larry', 'age' => '30', - )); + ]); // Check how many records are queued for insertion. $this->assertIdentical($query->count(), 1, 'One record is queued for insertion.'); $query->execute(); // This should run the insert, but leave the fields intact. // We should be able to specify values in any order if named. - $query->values(array( + $query->values([ 'age' => '31', 'name' => 'Curly', - )); + ]); // Check how many records are queued for insertion. $this->assertIdentical($query->count(), 1, 'One record is queued for insertion.'); $query->execute(); // We should be able to say "use the field order". - $query->values(array('Moe', '32')); + $query->values(['Moe', '32']); // Check how many records are queued for insertion. $this->assertIdentical($query->count(), 1, 'One record is queued for insertion.'); @@ -104,11 +104,11 @@ function testRepeatedInsert() { $num_records_after = db_query('SELECT COUNT(*) FROM {test}')->fetchField(); $this->assertIdentical((int) $num_records_before + 3, (int) $num_records_after, 'Record inserts correctly.'); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Larry'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Larry'])->fetchField(); $this->assertIdentical($saved_age, '30', 'Can retrieve after inserting.'); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Curly'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Curly'])->fetchField(); $this->assertIdentical($saved_age, '31', 'Can retrieve after inserting.'); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Moe'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Moe'])->fetchField(); $this->assertIdentical($saved_age, '32', 'Can retrieve after inserting.'); } @@ -119,16 +119,16 @@ function testInsertFieldOnlyDefinition() { // This is useful for importers, when we want to create a query and define // its fields once, then loop over a multi-insert execution. db_insert('test') - ->fields(array('name', 'age')) - ->values(array('Larry', '30')) - ->values(array('Curly', '31')) - ->values(array('Moe', '32')) + ->fields(['name', 'age']) + ->values(['Larry', '30']) + ->values(['Curly', '31']) + ->values(['Moe', '32']) ->execute(); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Larry'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Larry'])->fetchField(); $this->assertIdentical($saved_age, '30', 'Can retrieve after inserting.'); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Curly'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Curly'])->fetchField(); $this->assertIdentical($saved_age, '31', 'Can retrieve after inserting.'); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Moe'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Moe'])->fetchField(); $this->assertIdentical($saved_age, '32', 'Can retrieve after inserting.'); } @@ -137,10 +137,10 @@ function testInsertFieldOnlyDefinition() { */ function testInsertLastInsertID() { $id = db_insert('test') - ->fields(array( + ->fields([ 'name' => 'Larry', 'age' => '30', - )) + ]) ->execute(); $this->assertIdentical($id, '5', 'Auto-increment ID returned successfully.'); @@ -156,7 +156,7 @@ function testInsertSelectFields() { // re-ordered. $query->addExpression('tp.age', 'age'); $query - ->fields('tp', array('name', 'job')) + ->fields('tp', ['name', 'job']) ->condition('tp.name', 'Meredith'); // The resulting query should be equivalent to: @@ -168,7 +168,7 @@ function testInsertSelectFields() { ->from($query) ->execute(); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Meredith'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Meredith'])->fetchField(); $this->assertIdentical($saved_age, '30', 'Can retrieve after inserting.'); } @@ -189,7 +189,7 @@ function testInsertSelectAll() { ->from($query) ->execute(); - $saved_age = db_query('SELECT age FROM {test_people_copy} WHERE name = :name', array(':name' => 'Meredith'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test_people_copy} WHERE name = :name', [':name' => 'Meredith'])->fetchField(); $this->assertIdentical($saved_age, '30', 'Can retrieve after inserting.'); } @@ -198,12 +198,12 @@ function testInsertSelectAll() { */ function testSpecialColumnInsert() { $id = db_insert('test_special_columns') - ->fields(array( + ->fields([ 'id' => 2, 'offset' => 'Offset value 2', - )) + ]) ->execute(); - $saved_value = db_query('SELECT "offset" FROM {test_special_columns} WHERE id = :id', array(':id' => 2))->fetchField(); + $saved_value = db_query('SELECT "offset" FROM {test_special_columns} WHERE id = :id', [':id' => 2])->fetchField(); $this->assertIdentical($saved_value, 'Offset value 2', 'Can retrieve special column name value after inserting.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php b/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php index 774a20b..bf64bc8 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/InvalidDataTest.php @@ -18,27 +18,27 @@ function testInsertDuplicateData() { // Try to insert multiple records where at least one has bad data. try { db_insert('test') - ->fields(array('name', 'age', 'job')) - ->values(array( + ->fields(['name', 'age', 'job']) + ->values([ 'name' => 'Elvis', 'age' => 63, 'job' => 'Singer', - ))->values(array( + ])->values([ 'name' => 'John', // <-- Duplicate value on unique field. 'age' => 17, 'job' => 'Consultant', - )) - ->values(array( + ]) + ->values([ 'name' => 'Frank', 'age' => 75, 'job' => 'Singer', - )) + ]) ->execute(); $this->fail('Insert succeeded when it should not have.'); } catch (IntegrityConstraintViolationException $e) { // Check if the first record was inserted. - $name = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => 63))->fetchField(); + $name = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => 63])->fetchField(); if ($name == 'Elvis') { if (!Database::getConnection()->supportsTransactions()) { @@ -58,8 +58,8 @@ function testInsertDuplicateData() { // Ensure the other values were not inserted. $record = db_select('test') - ->fields('test', array('name', 'age')) - ->condition('age', array(17, 75), 'IN') + ->fields('test', ['name', 'age']) + ->condition('age', [17, 75], 'IN') ->execute()->fetchObject(); $this->assertFalse($record, 'The rest of the insert aborted as expected.'); diff --git a/core/tests/Drupal/KernelTests/Core/Database/LargeQueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/LargeQueryTest.php index 4b24ebe..a0aaa14 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/LargeQueryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/LargeQueryTest.php @@ -29,7 +29,7 @@ function testMaxAllowedPacketQueryTruncating() { if (Environment::checkMemoryLimit($max_allowed_packet + (16 * 1024 * 1024))) { $long_name = str_repeat('a', $max_allowed_packet + 1); try { - db_query('SELECT name FROM {test} WHERE name = :name', array(':name' => $long_name)); + db_query('SELECT name FROM {test} WHERE name = :name', [':name' => $long_name]); $this->fail("An exception should be thrown for queries larger than 'max_allowed_packet'"); } catch (DatabaseException $e) { diff --git a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php index c354c82..ac10fe8 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php @@ -17,11 +17,11 @@ class LoggingTest extends DatabaseTestBase { function testEnableLogging() { Database::startLog('testing'); - db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25))->fetchCol(); - db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetchCol(); + db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25])->fetchCol(); + db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetchCol(); // Trigger a call that does not have file in the backtrace. - call_user_func_array('db_query', array('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo')))->fetchCol(); + call_user_func_array('db_query', ['SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo']])->fetchCol(); $queries = Database::getLog('testing', 'default'); @@ -38,11 +38,11 @@ function testEnableLogging() { function testEnableMultiLogging() { Database::startLog('testing1'); - db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25))->fetchCol(); + db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25])->fetchCol(); Database::startLog('testing2'); - db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetchCol(); + db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetchCol(); $queries1 = Database::getLog('testing1'); $queries2 = Database::getLog('testing2'); @@ -62,9 +62,9 @@ function testEnableTargetLogging() { Database::startLog('testing1'); - db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25))->fetchCol(); + db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25])->fetchCol(); - db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'), array('target' => 'replica'));//->fetchCol(); + db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'], ['target' => 'replica']);//->fetchCol(); $queries1 = Database::getLog('testing1'); @@ -83,14 +83,14 @@ function testEnableTargetLogging() { function testEnableTargetLoggingNoTarget() { Database::startLog('testing1'); - db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25))->fetchCol(); + db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25])->fetchCol(); // We use "fake" here as a target because any non-existent target will do. // However, because all of the tests in this class share a single page // request there is likely to be a target of "replica" from one of the other // unit tests, so we use a target here that we know with absolute certainty // does not exist. - db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'), array('target' => 'fake'))->fetchCol(); + db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'], ['target' => 'fake'])->fetchCol(); $queries1 = Database::getLog('testing1'); @@ -111,11 +111,11 @@ function testEnableMultiConnectionLogging() { Database::startLog('testing1'); Database::startLog('testing1', 'test2'); - db_query('SELECT name FROM {test} WHERE age > :age', array(':age' => 25))->fetchCol(); + db_query('SELECT name FROM {test} WHERE age > :age', [':age' => 25])->fetchCol(); $old_key = db_set_active('test2'); - db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'), array('target' => 'replica'))->fetchCol(); + db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'], ['target' => 'replica'])->fetchCol(); db_set_active($old_key); diff --git a/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php b/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php index 34b81d0..853e5b2 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php @@ -20,10 +20,10 @@ function testMergeInsert() { $result = db_merge('test_people') ->key('job', 'Presenter') - ->fields(array( + ->fields([ 'age' => 31, 'name' => 'Tiffany', - )) + ]) ->execute(); $this->assertEqual($result, Merge::STATUS_INSERT, 'Insert status returned.'); @@ -31,7 +31,7 @@ function testMergeInsert() { $num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField(); $this->assertEqual($num_records_before + 1, $num_records_after, 'Merge inserted properly.'); - $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Presenter'))->fetch(); + $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Presenter'])->fetch(); $this->assertEqual($person->name, 'Tiffany', 'Name set correctly.'); $this->assertEqual($person->age, 31, 'Age set correctly.'); $this->assertEqual($person->job, 'Presenter', 'Job set correctly.'); @@ -45,10 +45,10 @@ function testMergeUpdate() { $result = db_merge('test_people') ->key('job', 'Speaker') - ->fields(array( + ->fields([ 'age' => 31, 'name' => 'Tiffany', - )) + ]) ->execute(); $this->assertEqual($result, Merge::STATUS_UPDATE, 'Update status returned.'); @@ -56,7 +56,7 @@ function testMergeUpdate() { $num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField(); $this->assertEqual($num_records_before, $num_records_after, 'Merge updated properly.'); - $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch(); + $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch(); $this->assertEqual($person->name, 'Tiffany', 'Name set correctly.'); $this->assertEqual($person->age, 31, 'Age set correctly.'); $this->assertEqual($person->job, 'Speaker', 'Job set correctly.'); @@ -73,14 +73,14 @@ function testMergeUpdateExcept() { db_merge('test_people') ->key('job', 'Speaker') - ->insertFields(array('age' => 31)) - ->updateFields(array('name' => 'Tiffany')) + ->insertFields(['age' => 31]) + ->updateFields(['name' => 'Tiffany']) ->execute(); $num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField(); $this->assertEqual($num_records_before, $num_records_after, 'Merge updated properly.'); - $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch(); + $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch(); $this->assertEqual($person->name, 'Tiffany', 'Name set correctly.'); $this->assertEqual($person->age, 30, 'Age skipped correctly.'); $this->assertEqual($person->job, 'Speaker', 'Job set correctly.'); @@ -94,19 +94,19 @@ function testMergeUpdateExplicit() { db_merge('test_people') ->key('job', 'Speaker') - ->insertFields(array( + ->insertFields([ 'age' => 31, 'name' => 'Tiffany', - )) - ->updateFields(array( + ]) + ->updateFields([ 'name' => 'Joe', - )) + ]) ->execute(); $num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField(); $this->assertEqual($num_records_before, $num_records_after, 'Merge updated properly.'); - $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch(); + $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch(); $this->assertEqual($person->name, 'Joe', 'Name set correctly.'); $this->assertEqual($person->age, 30, 'Age skipped correctly.'); $this->assertEqual($person->job, 'Speaker', 'Job set correctly.'); @@ -118,7 +118,7 @@ function testMergeUpdateExplicit() { function testMergeUpdateExpression() { $num_records_before = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField(); - $age_before = db_query('SELECT age FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetchField(); + $age_before = db_query('SELECT age FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetchField(); // This is a very contrived example, as I have no idea why you'd want to // change age this way, but that's beside the point. @@ -127,15 +127,15 @@ function testMergeUpdateExpression() { // which is what is supposed to happen. db_merge('test_people') ->key('job', 'Speaker') - ->fields(array('name' => 'Tiffany')) - ->insertFields(array('age' => 31)) - ->expression('age', 'age + :age', array(':age' => 4)) + ->fields(['name' => 'Tiffany']) + ->insertFields(['age' => 31]) + ->expression('age', 'age + :age', [':age' => 4]) ->execute(); $num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField(); $this->assertEqual($num_records_before, $num_records_after, 'Merge updated properly.'); - $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch(); + $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch(); $this->assertEqual($person->name, 'Tiffany', 'Name set correctly.'); $this->assertEqual($person->age, $age_before + 4, 'Age updated correctly.'); $this->assertEqual($person->job, 'Speaker', 'Job set correctly.'); @@ -154,7 +154,7 @@ function testMergeInsertWithoutUpdate() { $num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField(); $this->assertEqual($num_records_before + 1, $num_records_after, 'Merge inserted properly.'); - $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Presenter'))->fetch(); + $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Presenter'])->fetch(); $this->assertEqual($person->name, '', 'Name set correctly.'); $this->assertEqual($person->age, 0, 'Age set correctly.'); $this->assertEqual($person->job, 'Presenter', 'Job set correctly.'); @@ -173,20 +173,20 @@ function testMergeUpdateWithoutUpdate() { $num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField(); $this->assertEqual($num_records_before, $num_records_after, 'Merge skipped properly.'); - $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch(); + $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch(); $this->assertEqual($person->name, 'Meredith', 'Name skipped correctly.'); $this->assertEqual($person->age, 30, 'Age skipped correctly.'); $this->assertEqual($person->job, 'Speaker', 'Job skipped correctly.'); db_merge('test_people') ->key('job', 'Speaker') - ->insertFields(array('age' => 31)) + ->insertFields(['age' => 31]) ->execute(); $num_records_after = db_query('SELECT COUNT(*) FROM {test_people}')->fetchField(); $this->assertEqual($num_records_before, $num_records_after, 'Merge skipped properly.'); - $person = db_query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch(); + $person = db_query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch(); $this->assertEqual($person->name, 'Meredith', 'Name skipped correctly.'); $this->assertEqual($person->age, 30, 'Age skipped correctly.'); $this->assertEqual($person->job, 'Speaker', 'Job skipped correctly.'); @@ -202,10 +202,10 @@ function testInvalidMerge() { // the throw_exception option. $options['throw_exception'] = FALSE; db_merge('test_people', $options) - ->fields(array( + ->fields([ 'age' => 31, 'name' => 'Tiffany', - )) + ]) ->execute(); $this->pass('$options[\'throw_exception\'] is FALSE, no InvalidMergeQueryException thrown.'); } @@ -217,10 +217,10 @@ function testInvalidMerge() { try { // This query will fail because there is no key field specified. db_merge('test_people') - ->fields(array( + ->fields([ 'age' => 31, 'name' => 'Tiffany', - )) + ]) ->execute(); } catch (InvalidMergeQueryException $e) { diff --git a/core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php b/core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php index b0cdc85..5c0239f 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php @@ -15,7 +15,7 @@ class NextIdTest extends KernelTestBase { * The modules to enable. * @var array */ - public static $modules = array('system'); + public static $modules = ['system']; protected function setUp() { parent::setUp(); diff --git a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php index f84a9c8..966f96f 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php @@ -13,10 +13,10 @@ class QueryTest extends DatabaseTestBase { * Tests that we can pass an array of values directly in the query. */ function testArraySubstitution() { - $names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', array(':ages[]' => array(25, 26, 27)))->fetchAll(); + $names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', [':ages[]' => [25, 26, 27]])->fetchAll(); $this->assertEqual(count($names), 3, 'Correct number of names returned'); - $names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', array(':ages[]' => array(25)))->fetchAll(); + $names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', [':ages[]' => [25]])->fetchAll(); $this->assertEqual(count($names), 1, 'Correct number of names returned'); } @@ -25,7 +25,7 @@ function testArraySubstitution() { */ function testScalarSubstitution() { try { - $names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', array(':ages[]' => 25))->fetchAll(); + $names = db_query('SELECT name FROM {test} WHERE age IN ( :ages[] ) ORDER BY age', [':ages[]' => 25])->fetchAll(); $this->fail('Array placeholder with scalar argument should result in an exception.'); } catch (\InvalidArgumentException $e) { @@ -39,12 +39,12 @@ function testScalarSubstitution() { */ public function testArrayArgumentsSQLInjection() { // Attempt SQL injection and verify that it does not work. - $condition = array( + $condition = [ "1 ;INSERT INTO {test} (name) VALUES ('test12345678'); -- " => '', '1' => '', - ); + ]; try { - db_query("SELECT * FROM {test} WHERE name = :name", array(':name' => $condition))->fetchObject(); + db_query("SELECT * FROM {test} WHERE name = :name", [':name' => $condition])->fetchObject(); $this->fail('SQL injection attempt via array arguments should result in a database exception.'); } catch (\InvalidArgumentException $e) { @@ -101,7 +101,7 @@ public function testConditionOperatorArgumentsSQLInjection() { try { $result = db_select('test', 't') - ->fields('t', array('name', 'name')) + ->fields('t', ['name', 'name']) ->condition('name', 1, $injection) ->execute(); $this->fail('Should not be able to attempt SQL injection via operator.'); @@ -118,7 +118,7 @@ public function testConditionOperatorArgumentsSQLInjection() { try { $result = db_select('test', 't') - ->fields('t', array('name')) + ->fields('t', ['name']) ->condition('name', 1, $injection) ->execute(); $this->fail('Should not be able to attempt SQL injection via operator.'); @@ -139,9 +139,9 @@ public function testNumericExpressionSubstitution() { $count = db_query('SELECT COUNT(*) >= 3 FROM {test}')->fetchField(); $this->assertEqual((bool) $count, TRUE); - $count = db_query('SELECT COUNT(*) >= :count FROM {test}', array( + $count = db_query('SELECT COUNT(*) >= :count FROM {test}', [ ':count' => 3, - ))->fetchField(); + ])->fetchField(); $this->assertEqual((bool) $count, TRUE); } diff --git a/core/tests/Drupal/KernelTests/Core/Database/RangeQueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/RangeQueryTest.php index 33f315b..44c2535 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/RangeQueryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/RangeQueryTest.php @@ -14,7 +14,7 @@ class RangeQueryTest extends DatabaseTestBase { * * @var array */ - public static $modules = array('database_test'); + public static $modules = ['database_test']; /** * Confirms that range queries work and return the correct result. diff --git a/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php b/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php index e13bcfe..29a966a 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/RegressionTest.php @@ -14,7 +14,7 @@ class RegressionTest extends DatabaseTestBase { * * @var array */ - public static $modules = array('node', 'user'); + public static $modules = ['node', 'user']; /** * Ensures that non-ASCII UTF-8 data is stored in the database properly. @@ -23,13 +23,13 @@ function testRegression_310447() { // That's a 255 character UTF-8 string. $job = str_repeat("é", 255); db_insert('test') - ->fields(array( + ->fields([ 'name' => $this->randomMachineName(), 'age' => 20, 'job' => $job, - ))->execute(); + ])->execute(); - $from_database = db_query('SELECT job FROM {test} WHERE job = :job', array(':job' => $job))->fetchField(); + $from_database = db_query('SELECT job FROM {test} WHERE job = :job', [':job' => $job])->fetchField(); $this->assertIdentical($job, $from_database, 'The database handles UTF-8 characters cleanly.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php b/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php index 8641fd3..346c4ce 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/SchemaTest.php @@ -26,32 +26,32 @@ class SchemaTest extends KernelTestBase { */ function testSchema() { // Try creating a table. - $table_specification = array( + $table_specification = [ 'description' => 'Schema table description may contain "quotes" and could be long—very long indeed.', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'type' => 'int', 'default' => NULL, - ), - 'test_field' => array( + ], + 'test_field' => [ 'type' => 'int', 'not null' => TRUE, 'description' => 'Schema table description may contain "quotes" and could be long—very long indeed. There could be "multiple quoted regions".', - ), - 'test_field_string' => array( + ], + 'test_field_string' => [ 'type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => "'\"funky default'\"", 'description' => 'Schema column description for string.', - ), - 'test_field_string_ascii' => array( + ], + 'test_field_string_ascii' => [ 'type' => 'varchar_ascii', 'length' => 255, 'description' => 'Schema column description for ASCII string.', - ), - ), - ); + ], + ], + ]; db_create_table('test_table', $table_specification); // Assert that the table exists. @@ -95,7 +95,7 @@ function testSchema() { $index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field'); $this->assertIdentical($index_exists, FALSE, 'Fake index does not exists'); // Add index. - db_add_index('test_table', 'test_field', array('test_field'), $table_specification); + db_add_index('test_table', 'test_field', ['test_field'], $table_specification); // Test for created index and test for the boolean result of indexExists(). $index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field'); $this->assertIdentical($index_exists, TRUE, 'Index created.'); @@ -123,13 +123,13 @@ function testSchema() { // Recreate the table. db_create_table('test_table', $table_specification); db_field_set_default('test_table', 'test_field', 0); - db_add_field('test_table', 'test_serial', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Added column description.')); + db_add_field('test_table', 'test_serial', ['type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Added column description.']); // Assert that the column comment has been set. $this->checkSchemaComment('Added column description.', 'test_table', 'test_serial'); // Change the new field to a serial column. - db_change_field('test_table', 'test_serial', 'test_serial', array('type' => 'serial', 'not null' => TRUE, 'description' => 'Changed column description.'), array('primary key' => array('test_serial'))); + db_change_field('test_table', 'test_serial', 'test_serial', ['type' => 'serial', 'not null' => TRUE, 'description' => 'Changed column description.'], ['primary key' => ['test_serial']]); // Assert that the column comment has been set. $this->checkSchemaComment('Changed column description.', 'test_table', 'test_serial'); @@ -145,22 +145,22 @@ function testSchema() { // Test renaming of keys and constraints. db_drop_table('test_table'); - $table_specification = array( - 'fields' => array( - 'id' => array( + $table_specification = [ + 'fields' => [ + 'id' => [ 'type' => 'serial', 'not null' => TRUE, - ), - 'test_field' => array( + ], + 'test_field' => [ 'type' => 'int', 'default' => 0, - ), - ), - 'primary key' => array('id'), - 'unique keys' => array( - 'test_field' => array('test_field'), - ), - ); + ], + ], + 'primary key' => ['id'], + 'unique keys' => [ + 'test_field' => ['test_field'], + ], + ]; db_create_table('test_table', $table_specification); // Tests for indexes are Database specific. @@ -215,18 +215,18 @@ function testSchema() { } // Use database specific data type and ensure that table is created. - $table_specification = array( + $table_specification = [ 'description' => 'Schema table description.', - 'fields' => array( - 'timestamp' => array( + 'fields' => [ + 'timestamp' => [ 'mysql_type' => 'timestamp', 'pgsql_type' => 'timestamp', 'sqlite_type' => 'datetime', 'not null' => FALSE, 'default' => NULL, - ), - ), - ); + ], + ], + ]; try { db_create_table('test_timestamp', $table_specification); } @@ -244,52 +244,52 @@ function testIndexLength() { if (Database::getConnection()->databaseType() != 'mysql') { return; } - $table_specification = array( - 'fields' => array( - 'id' => array( + $table_specification = [ + 'fields' => [ + 'id' => [ 'type' => 'int', 'default' => NULL, - ), - 'test_field_text' => array( + ], + 'test_field_text' => [ 'type' => 'text', 'not null' => TRUE, - ), - 'test_field_string_long' => array( + ], + 'test_field_string_long' => [ 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, - ), - 'test_field_string_ascii_long' => array( + ], + 'test_field_string_ascii_long' => [ 'type' => 'varchar_ascii', 'length' => 255, - ), - 'test_field_string_short' => array( + ], + 'test_field_string_short' => [ 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, - ), - ), - 'indexes' => array( - 'test_regular' => array( + ], + ], + 'indexes' => [ + 'test_regular' => [ 'test_field_text', 'test_field_string_long', 'test_field_string_ascii_long', 'test_field_string_short', - ), - 'test_length' => array( - array('test_field_text', 128), - array('test_field_string_long', 128), - array('test_field_string_ascii_long', 128), - array('test_field_string_short', 128), - ), - 'test_mixed' => array( - array('test_field_text', 200), + ], + 'test_length' => [ + ['test_field_text', 128], + ['test_field_string_long', 128], + ['test_field_string_ascii_long', 128], + ['test_field_string_short', 128], + ], + 'test_mixed' => [ + ['test_field_text', 200], 'test_field_string_long', - array('test_field_string_ascii_long', 200), + ['test_field_string_ascii_long', 200], 'test_field_string_short', - ), - ), - ); + ], + ], + ]; db_create_table('test_table_index_length', $table_specification); $schema_object = Database::getConnection()->schema(); @@ -331,29 +331,29 @@ function testIndexLength() { // Get index information. $results = db_query('SHOW INDEX FROM {test_table_index_length}'); - $expected_lengths = array( - 'test_regular' => array( + $expected_lengths = [ + 'test_regular' => [ 'test_field_text' => 191, 'test_field_string_long' => 191, 'test_field_string_ascii_long' => NULL, 'test_field_string_short' => NULL, - ), - 'test_length' => array( + ], + 'test_length' => [ 'test_field_text' => 128, 'test_field_string_long' => 128, 'test_field_string_ascii_long' => 128, 'test_field_string_short' => NULL, - ), - 'test_mixed' => array( + ], + 'test_mixed' => [ 'test_field_text' => 191, 'test_field_string_long' => 191, 'test_field_string_ascii_long' => 200, 'test_field_string_short' => NULL, - ), - 'test_separate' => array( + ], + 'test_separate' => [ 'test_field_text' => 191, - ), - ); + ], + ]; // Count the number of columns defined in the indexes. $column_count = 0; @@ -382,7 +382,7 @@ function testIndexLength() { function tryInsert($table = 'test_table') { try { db_insert($table) - ->fields(array('id' => mt_rand(10, 20))) + ->fields(['id' => mt_rand(10, 20)]) ->execute(); return TRUE; } @@ -419,18 +419,18 @@ function checkSchemaComment($description, $table, $column = NULL) { function testUnsignedColumns() { // First create the table with just a serial column. $table_name = 'unsigned_table'; - $table_spec = array( - 'fields' => array('serial_column' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE)), - 'primary key' => array('serial_column'), - ); + $table_spec = [ + 'fields' => ['serial_column' => ['type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE]], + 'primary key' => ['serial_column'], + ]; db_create_table($table_name, $table_spec); // Now set up columns for the other types. - $types = array('int', 'float', 'numeric'); + $types = ['int', 'float', 'numeric']; foreach ($types as $type) { - $column_spec = array('type' => $type, 'unsigned' => TRUE); + $column_spec = ['type' => $type, 'unsigned' => TRUE]; if ($type == 'numeric') { - $column_spec += array('precision' => 10, 'scale' => 0); + $column_spec += ['precision' => 10, 'scale' => 0]; } $column_name = $type . '_column'; $table_spec['fields'][$column_name] = $column_spec; @@ -439,8 +439,8 @@ function testUnsignedColumns() { // Finally, check each column and try to insert invalid values into them. foreach ($table_spec['fields'] as $column_name => $column_spec) { - $this->assertTrue(db_field_exists($table_name, $column_name), format_string('Unsigned @type column was created.', array('@type' => $column_spec['type']))); - $this->assertFalse($this->tryUnsignedInsert($table_name, $column_name), format_string('Unsigned @type column rejected a negative value.', array('@type' => $column_spec['type']))); + $this->assertTrue(db_field_exists($table_name, $column_name), format_string('Unsigned @type column was created.', ['@type' => $column_spec['type']])); + $this->assertFalse($this->tryUnsignedInsert($table_name, $column_name), format_string('Unsigned @type column rejected a negative value.', ['@type' => $column_spec['type']])); } } @@ -458,7 +458,7 @@ function testUnsignedColumns() { function tryUnsignedInsert($table_name, $column_name) { try { db_insert($table_name) - ->fields(array($column_name => -1)) + ->fields([$column_name => -1]) ->execute(); return TRUE; } @@ -472,20 +472,20 @@ function tryUnsignedInsert($table_name, $column_name) { */ function testSchemaAddField() { // Test varchar types. - foreach (array(1, 32, 128, 256, 512) as $length) { - $base_field_spec = array( + foreach ([1, 32, 128, 256, 512] as $length) { + $base_field_spec = [ 'type' => 'varchar', 'length' => $length, - ); - $variations = array( - array('not null' => FALSE), - array('not null' => FALSE, 'default' => '7'), - array('not null' => FALSE, 'default' => substr('"thing"', 0, $length)), - array('not null' => FALSE, 'default' => substr("\"'hing", 0, $length)), - array('not null' => TRUE, 'initial' => 'd'), - array('not null' => FALSE, 'default' => NULL), - array('not null' => TRUE, 'initial' => 'd', 'default' => '7'), - ); + ]; + $variations = [ + ['not null' => FALSE], + ['not null' => FALSE, 'default' => '7'], + ['not null' => FALSE, 'default' => substr('"thing"', 0, $length)], + ['not null' => FALSE, 'default' => substr("\"'hing", 0, $length)], + ['not null' => TRUE, 'initial' => 'd'], + ['not null' => FALSE, 'default' => NULL], + ['not null' => TRUE, 'initial' => 'd', 'default' => '7'], + ]; foreach ($variations as $variation) { $field_spec = $variation + $base_field_spec; @@ -494,19 +494,19 @@ function testSchemaAddField() { } // Test int and float types. - foreach (array('int', 'float') as $type) { - foreach (array('tiny', 'small', 'medium', 'normal', 'big') as $size) { - $base_field_spec = array( + foreach (['int', 'float'] as $type) { + foreach (['tiny', 'small', 'medium', 'normal', 'big'] as $size) { + $base_field_spec = [ 'type' => $type, 'size' => $size, - ); - $variations = array( - array('not null' => FALSE), - array('not null' => FALSE, 'default' => 7), - array('not null' => TRUE, 'initial' => 1), - array('not null' => TRUE, 'initial' => 1, 'default' => 7), - array('not null' => TRUE, 'initial_from_field' => 'serial_column'), - ); + ]; + $variations = [ + ['not null' => FALSE], + ['not null' => FALSE, 'default' => 7], + ['not null' => TRUE, 'initial' => 1], + ['not null' => TRUE, 'initial' => 1, 'default' => 7], + ['not null' => TRUE, 'initial_from_field' => 'serial_column'], + ]; foreach ($variations as $variation) { $field_spec = $variation + $base_field_spec; @@ -516,25 +516,25 @@ function testSchemaAddField() { } // Test numeric types. - foreach (array(1, 5, 10, 40, 65) as $precision) { - foreach (array(0, 2, 10, 30) as $scale) { + foreach ([1, 5, 10, 40, 65] as $precision) { + foreach ([0, 2, 10, 30] as $scale) { // Skip combinations where precision is smaller than scale. if ($precision <= $scale) { continue; } - $base_field_spec = array( + $base_field_spec = [ 'type' => 'numeric', 'scale' => $scale, 'precision' => $precision, - ); - $variations = array( - array('not null' => FALSE), - array('not null' => FALSE, 'default' => 7), - array('not null' => TRUE, 'initial' => 1), - array('not null' => TRUE, 'initial' => 1, 'default' => 7), - array('not null' => TRUE, 'initial_from_field' => 'serial_column'), - ); + ]; + $variations = [ + ['not null' => FALSE], + ['not null' => FALSE, 'default' => 7], + ['not null' => TRUE, 'initial' => 1], + ['not null' => TRUE, 'initial' => 1, 'default' => 7], + ['not null' => TRUE, 'initial_from_field' => 'serial_column'], + ]; foreach ($variations as $variation) { $field_spec = $variation + $base_field_spec; @@ -556,15 +556,15 @@ function testSchemaAddField() { protected function assertFieldAdditionRemoval($field_spec) { // Try creating the field on a new table. $table_name = 'test_table_' . ($this->counter++); - $table_spec = array( - 'fields' => array( - 'serial_column' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), + $table_spec = [ + 'fields' => [ + 'serial_column' => ['type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE], 'test_field' => $field_spec, - ), - 'primary key' => array('serial_column'), - ); + ], + 'primary key' => ['serial_column'], + ]; db_create_table($table_name, $table_spec); - $this->pass(format_string('Table %table created.', array('%table' => $table_name))); + $this->pass(format_string('Table %table created.', ['%table' => $table_name])); // Check the characteristics of the field. $this->assertFieldCharacteristics($table_name, 'test_field', $field_spec); @@ -574,24 +574,24 @@ protected function assertFieldAdditionRemoval($field_spec) { // Try adding a field to an existing table. $table_name = 'test_table_' . ($this->counter++); - $table_spec = array( - 'fields' => array( - 'serial_column' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), - ), - 'primary key' => array('serial_column'), - ); + $table_spec = [ + 'fields' => [ + 'serial_column' => ['type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE], + ], + 'primary key' => ['serial_column'], + ]; db_create_table($table_name, $table_spec); - $this->pass(format_string('Table %table created.', array('%table' => $table_name))); + $this->pass(format_string('Table %table created.', ['%table' => $table_name])); // Insert some rows to the table to test the handling of initial values. for ($i = 0; $i < 3; $i++) { db_insert($table_name) - ->useDefaults(array('serial_column')) + ->useDefaults(['serial_column']) ->execute(); } db_add_field($table_name, 'test_field', $field_spec); - $this->pass(format_string('Column %column created.', array('%column' => 'test_field'))); + $this->pass(format_string('Column %column created.', ['%column' => 'test_field'])); // Check the characteristics of the field. $this->assertFieldCharacteristics($table_name, 'test_field', $field_spec); @@ -614,7 +614,7 @@ protected function assertFieldCharacteristics($table_name, $field_name, $field_s if (isset($field_spec['initial'])) { // There should be no row with a value different then $field_spec['initial']. $count = db_select($table_name) - ->fields($table_name, array('serial_column')) + ->fields($table_name, ['serial_column']) ->condition($field_name, $field_spec['initial'], '<>') ->countQuery() ->execute() @@ -627,7 +627,7 @@ protected function assertFieldCharacteristics($table_name, $field_name, $field_s // There should be no row with a value different than // $field_spec['initial_from_field']. $count = db_select($table_name) - ->fields($table_name, array('serial_column')) + ->fields($table_name, ['serial_column']) ->where($table_name . '.' . $field_spec['initial_from_field'] . ' <> ' . $table_name . '.' . $field_name) ->countQuery() ->execute() @@ -639,10 +639,10 @@ protected function assertFieldCharacteristics($table_name, $field_name, $field_s if (isset($field_spec['default'])) { // Try inserting a row, and check the resulting value of the new column. $id = db_insert($table_name) - ->useDefaults(array('serial_column')) + ->useDefaults(['serial_column']) ->execute(); $field_value = db_select($table_name) - ->fields($table_name, array($field_name)) + ->fields($table_name, [$field_name]) ->condition('serial_column', $id) ->execute() ->fetchField(); @@ -654,14 +654,14 @@ protected function assertFieldCharacteristics($table_name, $field_name, $field_s * Tests changing columns between types. */ function testSchemaChangeField() { - $field_specs = array( - array('type' => 'int', 'size' => 'normal', 'not null' => FALSE), - array('type' => 'int', 'size' => 'normal', 'not null' => TRUE, 'initial' => 1, 'default' => 17), - array('type' => 'float', 'size' => 'normal', 'not null' => FALSE), - array('type' => 'float', 'size' => 'normal', 'not null' => TRUE, 'initial' => 1, 'default' => 7.3), - array('type' => 'numeric', 'scale' => 2, 'precision' => 10, 'not null' => FALSE), - array('type' => 'numeric', 'scale' => 2, 'precision' => 10, 'not null' => TRUE, 'initial' => 1, 'default' => 7), - ); + $field_specs = [ + ['type' => 'int', 'size' => 'normal', 'not null' => FALSE], + ['type' => 'int', 'size' => 'normal', 'not null' => TRUE, 'initial' => 1, 'default' => 17], + ['type' => 'float', 'size' => 'normal', 'not null' => FALSE], + ['type' => 'float', 'size' => 'normal', 'not null' => TRUE, 'initial' => 1, 'default' => 7.3], + ['type' => 'numeric', 'scale' => 2, 'precision' => 10, 'not null' => FALSE], + ['type' => 'numeric', 'scale' => 2, 'precision' => 10, 'not null' => TRUE, 'initial' => 1, 'default' => 7], + ]; foreach ($field_specs as $i => $old_spec) { foreach ($field_specs as $j => $new_spec) { @@ -673,12 +673,12 @@ function testSchemaChangeField() { } } - $field_specs = array( - array('type' => 'varchar_ascii', 'length' => '255'), - array('type' => 'varchar', 'length' => '255'), - array('type' => 'text'), - array('type' => 'blob', 'size' => 'big'), - ); + $field_specs = [ + ['type' => 'varchar_ascii', 'length' => '255'], + ['type' => 'varchar', 'length' => '255'], + ['type' => 'text'], + ['type' => 'blob', 'size' => 'big'], + ]; foreach ($field_specs as $i => $old_spec) { foreach ($field_specs as $j => $new_spec) { @@ -705,15 +705,15 @@ function testSchemaChangeField() { */ protected function assertFieldChange($old_spec, $new_spec, $test_data = NULL) { $table_name = 'test_table_' . ($this->counter++); - $table_spec = array( - 'fields' => array( - 'serial_column' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), + $table_spec = [ + 'fields' => [ + 'serial_column' => ['type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE], 'test_field' => $old_spec, - ), - 'primary key' => array('serial_column'), - ); + ], + 'primary key' => ['serial_column'], + ]; db_create_table($table_name, $table_spec); - $this->pass(format_string('Table %table created.', array('%table' => $table_name))); + $this->pass(format_string('Table %table created.', ['%table' => $table_name])); // Check the characteristics of the field. $this->assertFieldCharacteristics($table_name, 'test_field', $old_spec); diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php index f107100..94ee755 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php @@ -19,7 +19,7 @@ class SelectComplexTest extends DatabaseTestBase { * * @var array */ - public static $modules = array('system', 'user', 'node_access_test', 'field'); + public static $modules = ['system', 'user', 'node_access_test', 'field']; /** * Tests simple JOIN statements. @@ -83,7 +83,7 @@ function testGroupBy() { $num_records = 0; $last_count = 0; - $records = array(); + $records = []; foreach ($result as $record) { $num_records++; $this->assertTrue($record->$count_field >= $last_count, 'Results returned in correct order.'); @@ -91,16 +91,16 @@ function testGroupBy() { $records[$record->$task_field] = $record->$count_field; } - $correct_results = array( + $correct_results = [ 'eat' => 1, 'sleep' => 2, 'code' => 1, 'found new band' => 1, 'perform at superbowl' => 1, - ); + ]; foreach ($correct_results as $task => $count) { - $this->assertEqual($records[$task], $count, format_string("Correct number of '@task' records found.", array('@task' => $task))); + $this->assertEqual($records[$task], $count, format_string("Correct number of '@task' records found.", ['@task' => $task])); } $this->assertEqual($num_records, 6, 'Returned the correct number of total rows.'); @@ -120,7 +120,7 @@ function testGroupByAndHaving() { $num_records = 0; $last_count = 0; - $records = array(); + $records = []; foreach ($result as $record) { $num_records++; $this->assertTrue($record->$count_field >= 2, 'Record has the minimum count.'); @@ -129,12 +129,12 @@ function testGroupByAndHaving() { $records[$record->$task_field] = $record->$count_field; } - $correct_results = array( + $correct_results = [ 'sleep' => 2, - ); + ]; foreach ($correct_results as $task => $count) { - $this->assertEqual($records[$task], $count, format_string("Correct number of '@task' records found.", array('@task' => $task))); + $this->assertEqual($records[$task], $count, format_string("Correct number of '@task' records found.", ['@task' => $task])); } $this->assertEqual($num_records, 1, 'Returned the correct number of total rows.'); @@ -256,7 +256,7 @@ function testCountQueryFieldRemovals() { // number of records, which in this case happens to be 4 (there are four // records in the {test} table). $query = db_select('test'); - $query->fields('test', array('fail')); + $query->fields('test', ['fail']); $this->assertEqual(4, $query->countQuery()->execute()->fetchField(), 'Count Query removed fields'); $query = db_select('test'); @@ -344,7 +344,7 @@ function testJoinSubquery() { 'mail' => $this->randomMachineName() . '@example.com', ]); - $query = db_select('test_task', 'tt', array('target' => 'replica')); + $query = db_select('test_task', 'tt', ['target' => 'replica']); $query->addExpression('tt.pid + 1', 'abc'); $query->condition('priority', 1, '>'); $query->condition('priority', 100, '<'); diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectOrderedTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectOrderedTest.php index c9e199b..53a311c 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/SelectOrderedTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/SelectOrderedTest.php @@ -43,12 +43,12 @@ function testSimpleSelectMultiOrdered() { $result = $query->execute(); $num_records = 0; - $expected = array( - array('Ringo', 28, 'Drummer'), - array('John', 25, 'Singer'), - array('George', 27, 'Singer'), - array('Paul', 26, 'Songwriter'), - ); + $expected = [ + ['Ringo', 28, 'Drummer'], + ['John', 25, 'Singer'], + ['George', 27, 'Singer'], + ['Paul', 26, 'Songwriter'], + ]; $results = $result->fetchAll(\PDO::FETCH_NUM); foreach ($expected as $k => $record) { $num_records++; diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php index 98849bb..d5f0237 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/SelectSubqueryTest.php @@ -210,18 +210,18 @@ function testJoinSubquerySelect() { function testExistsSubquerySelect() { // Put George into {test_people}. db_insert('test_people') - ->fields(array( + ->fields([ 'name' => 'George', 'age' => 27, 'job' => 'Singer', - )) + ]) ->execute(); // Base query to {test}. $query = db_select('test', 't') - ->fields('t', array('name')); + ->fields('t', ['name']); // Subquery to {test_people}. $subquery = db_select('test_people', 'tp') - ->fields('tp', array('name')) + ->fields('tp', ['name']) ->where('tp.name = t.name'); $query->exists($subquery); $result = $query->execute(); @@ -240,19 +240,19 @@ function testExistsSubquerySelect() { function testNotExistsSubquerySelect() { // Put George into {test_people}. db_insert('test_people') - ->fields(array( + ->fields([ 'name' => 'George', 'age' => 27, 'job' => 'Singer', - )) + ]) ->execute(); // Base query to {test}. $query = db_select('test', 't') - ->fields('t', array('name')); + ->fields('t', ['name']); // Subquery to {test_people}. $subquery = db_select('test_people', 'tp') - ->fields('tp', array('name')) + ->fields('tp', ['name']) ->where('tp.name = t.name'); $query->notExists($subquery); diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php index b3eef54..038224e 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php @@ -163,7 +163,7 @@ function testSimpleSelectExpressionMultiple() { */ function testSimpleSelectMultipleFields() { $record = db_select('test') - ->fields('test', array('id', 'name', 'age', 'job')) + ->fields('test', ['id', 'name', 'age', 'job']) ->condition('age', 27) ->execute()->fetchObject(); @@ -211,7 +211,7 @@ function testNullCondition() { $this->ensureSampleDataNull(); $names = db_select('test_null', 'tn') - ->fields('tn', array('name')) + ->fields('tn', ['name']) ->condition('age', NULL) ->execute()->fetchCol(); @@ -225,7 +225,7 @@ function testIsNullCondition() { $this->ensureSampleDataNull(); $names = db_select('test_null', 'tn') - ->fields('tn', array('name')) + ->fields('tn', ['name']) ->isNull('age') ->execute()->fetchCol(); @@ -240,7 +240,7 @@ function testIsNotNullCondition() { $this->ensureSampleDataNull(); $names = db_select('test_null', 'tn') - ->fields('tn', array('name')) + ->fields('tn', ['name']) ->isNotNull('tn.age') ->orderBy('name') ->execute()->fetchCol(); @@ -258,11 +258,11 @@ function testIsNotNullCondition() { */ function testUnion() { $query_1 = db_select('test', 't') - ->fields('t', array('name')) - ->condition('age', array(27, 28), 'IN'); + ->fields('t', ['name']) + ->condition('age', [27, 28], 'IN'); $query_2 = db_select('test', 't') - ->fields('t', array('name')) + ->fields('t', ['name']) ->condition('age', 28); $query_1->union($query_2); @@ -281,11 +281,11 @@ function testUnion() { */ function testUnionAll() { $query_1 = db_select('test', 't') - ->fields('t', array('name')) - ->condition('age', array(27, 28), 'IN'); + ->fields('t', ['name']) + ->condition('age', [27, 28], 'IN'); $query_2 = db_select('test', 't') - ->fields('t', array('name')) + ->fields('t', ['name']) ->condition('age', 28); $query_1->union($query_2, 'ALL'); @@ -305,11 +305,11 @@ function testUnionAll() { */ function testUnionCount() { $query_1 = db_select('test', 't') - ->fields('t', array('name', 'age')) - ->condition('age', array(27, 28), 'IN'); + ->fields('t', ['name', 'age']) + ->condition('age', [27, 28], 'IN'); $query_2 = db_select('test', 't') - ->fields('t', array('name', 'age')) + ->fields('t', ['name', 'age']) ->condition('age', 28); $query_1->union($query_2, 'ALL'); @@ -328,12 +328,12 @@ function testUnionCount() { function testUnionOrder() { // This gives George and Ringo. $query_1 = db_select('test', 't') - ->fields('t', array('name')) - ->condition('age', array(27, 28), 'IN'); + ->fields('t', ['name']) + ->condition('age', [27, 28], 'IN'); // This gives Paul. $query_2 = db_select('test', 't') - ->fields('t', array('name')) + ->fields('t', ['name']) ->condition('age', 26); $query_1->union($query_2); @@ -357,12 +357,12 @@ function testUnionOrder() { function testUnionOrderLimit() { // This gives George and Ringo. $query_1 = db_select('test', 't') - ->fields('t', array('name')) - ->condition('age', array(27, 28), 'IN'); + ->fields('t', ['name']) + ->condition('age', [27, 28], 'IN'); // This gives Paul. $query_2 = db_select('test', 't') - ->fields('t', array('name')) + ->fields('t', ['name']) ->condition('age', 26); $query_1->union($query_2); @@ -401,13 +401,13 @@ function testRandomOrder() { // after shuffling it (in other words, nearly impossible). $number_of_items = 52; while (db_query("SELECT MAX(id) FROM {test}")->fetchField() < $number_of_items) { - db_insert('test')->fields(array('name' => $this->randomMachineName()))->execute(); + db_insert('test')->fields(['name' => $this->randomMachineName()])->execute(); } // First select the items in order and make sure we get an ordered list. $expected_ids = range(1, $number_of_items); $ordered_ids = db_select('test', 't') - ->fields('t', array('id')) + ->fields('t', ['id']) ->range(0, $number_of_items) ->orderBy('id') ->execute() @@ -418,7 +418,7 @@ function testRandomOrder() { // expect this to contain a differently ordered version of the original // result. $randomized_ids = db_select('test', 't') - ->fields('t', array('id')) + ->fields('t', ['id']) ->range(0, $number_of_items) ->orderRandom() ->execute() @@ -431,7 +431,7 @@ function testRandomOrder() { // Now perform the exact same query again, and make sure the order is // different. $randomized_ids_second_set = db_select('test', 't') - ->fields('t', array('id')) + ->fields('t', ['id']) ->range(0, $number_of_items) ->orderRandom() ->execute() @@ -447,24 +447,24 @@ function testRandomOrder() { */ public function testRegexCondition() { - $test_groups[] = array( + $test_groups[] = [ 'regex' => 'hn$', - 'expected' => array( + 'expected' => [ 'John', - ), - ); - $test_groups[] = array( + ], + ]; + $test_groups[] = [ 'regex' => '^Pau', - 'expected' => array( + 'expected' => [ 'Paul', - ), - ); - $test_groups[] = array( + ], + ]; + $test_groups[] = [ 'regex' => 'Ringo|George', - 'expected' => array( + 'expected' => [ 'Ringo', 'George', - ), - ); + ], + ]; $database = $this->container->get('database'); @@ -480,25 +480,25 @@ public function testRegexCondition() { // Ensure that filter by "#" still works due to the quoting. $database->insert('test') - ->fields(array( + ->fields([ 'name' => 'Pete', 'age' => 26, 'job' => '#Drummer', - )) + ]) ->execute(); - $test_groups = array(); - $test_groups[] = array( + $test_groups = []; + $test_groups[] = [ 'regex' => '#Drummer', - 'expected' => array( + 'expected' => [ 'Pete', - ), - ); - $test_groups[] = array( + ], + ]; + $test_groups[] = [ 'regex' => '#Singer', - 'expected' => array( - ), - ); + 'expected' => [ + ], + ]; foreach ($test_groups as $test_group) { $query = $database->select('test', 't'); @@ -570,7 +570,7 @@ function testEmptyInCondition() { try { db_select('test', 't') ->fields('t') - ->condition('age', array(), 'IN') + ->condition('age', [], 'IN') ->execute(); $this->fail('Expected exception not thrown'); @@ -582,7 +582,7 @@ function testEmptyInCondition() { try { db_select('test', 't') ->fields('t') - ->condition('age', array(), 'NOT IN') + ->condition('age', [], 'NOT IN') ->execute(); $this->fail('Expected exception not thrown'); diff --git a/core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php b/core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php index 611b246..0f9f6d4 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/TaggingTest.php @@ -111,10 +111,10 @@ function testMetaData() { $query->addField('test', 'name'); $query->addField('test', 'age', 'age'); - $data = array( + $data = [ 'a' => 'A', 'b' => 'B', - ); + ]; $query->addMetaData('test', $data); diff --git a/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php b/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php index d060f4d..862b3e6 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/TransactionTest.php @@ -58,10 +58,10 @@ protected function transactionOuterLayer($suffix, $rollback = FALSE, $ddl_statem // Insert a single row into the testing table. db_insert('test') - ->fields(array( + ->fields([ 'name' => 'David' . $suffix, 'age' => '24', - )) + ]) ->execute(); $this->assertTrue($connection->inTransaction(), 'In transaction before calling nested transaction.'); @@ -108,25 +108,25 @@ protected function transactionInnerLayer($suffix, $rollback = FALSE, $ddl_statem // Insert a single row into the testing table. db_insert('test') - ->fields(array( + ->fields([ 'name' => 'Daniel' . $suffix, 'age' => '19', - )) + ]) ->execute(); $this->assertTrue($connection->inTransaction(), 'In transaction inside nested transaction.'); if ($ddl_statement) { - $table = array( - 'fields' => array( - 'id' => array( + $table = [ + 'fields' => [ + 'id' => [ 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, - ), - ), - 'primary key' => array('id'), - ); + ], + ], + 'primary key' => ['id'], + ]; db_create_table('database_test_1', $table); $this->assertTrue($connection->inTransaction(), 'In transaction inside nested transaction.'); @@ -157,9 +157,9 @@ function testTransactionRollBackSupported() { // Neither of the rows we inserted in the two transaction layers // should be present in the tables post-rollback. - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DavidB'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'DavidB'])->fetchField(); $this->assertNotIdentical($saved_age, '24', 'Cannot retrieve DavidB row after commit.'); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DanielB'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'DanielB'])->fetchField(); $this->assertNotIdentical($saved_age, '19', 'Cannot retrieve DanielB row after commit.'); } catch (\Exception $e) { @@ -183,9 +183,9 @@ function testTransactionRollBackNotSupported() { // Because our current database claims to not support transactions, // the inserted rows should be present despite the attempt to roll back. - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DavidB'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'DavidB'])->fetchField(); $this->assertIdentical($saved_age, '24', 'DavidB not rolled back, since transactions are not supported.'); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DanielB'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'DanielB'])->fetchField(); $this->assertIdentical($saved_age, '19', 'DanielB not rolled back, since transactions are not supported.'); } catch (\Exception $e) { @@ -205,9 +205,9 @@ function testCommittedTransaction() { $this->transactionOuterLayer('A'); // Because we committed, both of the inserted rows should be present. - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DavidA'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'DavidA'])->fetchField(); $this->assertIdentical($saved_age, '24', 'Can retrieve DavidA row after commit.'); - $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'DanielA'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'DanielA'])->fetchField(); $this->assertIdentical($saved_age, '19', 'Can retrieve DanielA row after commit.'); } catch (\Exception $e) { @@ -311,9 +311,9 @@ function testTransactionWithDdlStatement() { */ protected function insertRow($name) { db_insert('test') - ->fields(array( + ->fields([ 'name' => $name, - )) + ]) ->execute(); } @@ -322,16 +322,16 @@ protected function insertRow($name) { */ protected function executeDDLStatement() { static $count = 0; - $table = array( - 'fields' => array( - 'id' => array( + $table = [ + 'fields' => [ + 'id' => [ 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, - ), - ), - 'primary key' => array('id'), - ); + ], + ], + 'primary key' => ['id'], + ]; db_create_table('database_test_' . ++$count, $table); } @@ -353,9 +353,9 @@ protected function cleanUp() { */ function assertRowPresent($name, $message = NULL) { if (!isset($message)) { - $message = format_string('Row %name is present.', array('%name' => $name)); + $message = format_string('Row %name is present.', ['%name' => $name]); } - $present = (boolean) db_query('SELECT 1 FROM {test} WHERE name = :name', array(':name' => $name))->fetchField(); + $present = (boolean) db_query('SELECT 1 FROM {test} WHERE name = :name', [':name' => $name])->fetchField(); return $this->assertTrue($present, $message); } @@ -369,9 +369,9 @@ function assertRowPresent($name, $message = NULL) { */ function assertRowAbsent($name, $message = NULL) { if (!isset($message)) { - $message = format_string('Row %name is absent.', array('%name' => $name)); + $message = format_string('Row %name is absent.', ['%name' => $name]); } - $present = (boolean) db_query('SELECT 1 FROM {test} WHERE name = :name', array(':name' => $name))->fetchField(); + $present = (boolean) db_query('SELECT 1 FROM {test} WHERE name = :name', [':name' => $name])->fetchField(); return $this->assertFalse($present, $message); } @@ -498,7 +498,7 @@ public function testQueryFailureInTransaction() { // Test a failed query using the query() method. try { - $connection->query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'David'))->fetchField(); + $connection->query('SELECT age FROM {test} WHERE name = :name', [':name' => 'David'])->fetchField(); $this->fail('Using the query method failed.'); } catch (\Exception $e) { @@ -594,16 +594,16 @@ public function testQueryFailureInTransaction() { // Create the missing schema and insert a row. $this->installSchema('database_test', ['test']); $connection->insert('test') - ->fields(array( + ->fields([ 'name' => 'David', 'age' => '24', - )) + ]) ->execute(); // Commit the transaction. unset($transaction); - $saved_age = $connection->query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'David'))->fetchField(); + $saved_age = $connection->query('SELECT age FROM {test} WHERE name = :name', [':name' => 'David'])->fetchField(); $this->assertEqual('24', $saved_age); } diff --git a/core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php b/core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php index e4289e6..85521b1 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/UpdateComplexTest.php @@ -16,7 +16,7 @@ class UpdateComplexTest extends DatabaseTestBase { */ function testOrConditionUpdate() { $update = db_update('test') - ->fields(array('job' => 'Musician')) + ->fields(['job' => 'Musician']) ->condition((new Condition('OR')) ->condition('name', 'John') ->condition('name', 'Paul') @@ -24,7 +24,7 @@ function testOrConditionUpdate() { $num_updated = $update->execute(); $this->assertIdentical($num_updated, 2, 'Updated 2 records.'); - $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField(); $this->assertIdentical($num_matches, '2', 'Updated fields successfully.'); } @@ -33,12 +33,12 @@ function testOrConditionUpdate() { */ function testInConditionUpdate() { $num_updated = db_update('test') - ->fields(array('job' => 'Musician')) - ->condition('name', array('John', 'Paul'), 'IN') + ->fields(['job' => 'Musician']) + ->condition('name', ['John', 'Paul'], 'IN') ->execute(); $this->assertIdentical($num_updated, 2, 'Updated 2 records.'); - $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField(); $this->assertIdentical($num_matches, '2', 'Updated fields successfully.'); } @@ -49,12 +49,12 @@ function testNotInConditionUpdate() { // The o is lowercase in the 'NoT IN' operator, to make sure the operators // work in mixed case. $num_updated = db_update('test') - ->fields(array('job' => 'Musician')) - ->condition('name', array('John', 'Paul', 'George'), 'NoT IN') + ->fields(['job' => 'Musician']) + ->condition('name', ['John', 'Paul', 'George'], 'NoT IN') ->execute(); $this->assertIdentical($num_updated, 1, 'Updated 1 record.'); - $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField(); $this->assertIdentical($num_matches, '1', 'Updated fields successfully.'); } @@ -63,12 +63,12 @@ function testNotInConditionUpdate() { */ function testBetweenConditionUpdate() { $num_updated = db_update('test') - ->fields(array('job' => 'Musician')) - ->condition('age', array(25, 26), 'BETWEEN') + ->fields(['job' => 'Musician']) + ->condition('age', [25, 26], 'BETWEEN') ->execute(); $this->assertIdentical($num_updated, 2, 'Updated 2 records.'); - $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField(); $this->assertIdentical($num_matches, '2', 'Updated fields successfully.'); } @@ -77,12 +77,12 @@ function testBetweenConditionUpdate() { */ function testLikeConditionUpdate() { $num_updated = db_update('test') - ->fields(array('job' => 'Musician')) + ->fields(['job' => 'Musician']) ->condition('name', '%ge%', 'LIKE') ->execute(); $this->assertIdentical($num_updated, 1, 'Updated 1 record.'); - $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField(); $this->assertIdentical($num_matches, '1', 'Updated fields successfully.'); } @@ -90,18 +90,18 @@ function testLikeConditionUpdate() { * Tests UPDATE with expression values. */ function testUpdateExpression() { - $before_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetchField(); + $before_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetchField(); $num_updated = db_update('test') ->condition('name', 'Ringo') - ->fields(array('job' => 'Musician')) - ->expression('age', 'age + :age', array(':age' => 4)) + ->fields(['job' => 'Musician']) + ->expression('age', 'age + :age', [':age' => 4]) ->execute(); $this->assertIdentical($num_updated, 1, 'Updated 1 record.'); - $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField(); $this->assertIdentical($num_matches, '1', 'Updated fields successfully.'); - $person = db_query('SELECT * FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetch(); + $person = db_query('SELECT * FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetch(); $this->assertEqual($person->name, 'Ringo', 'Name set correctly.'); $this->assertEqual($person->age, $before_age + 4, 'Age set correctly.'); $this->assertEqual($person->job, 'Musician', 'Job set correctly.'); @@ -111,14 +111,14 @@ function testUpdateExpression() { * Tests UPDATE with only expression values. */ function testUpdateOnlyExpression() { - $before_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetchField(); + $before_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetchField(); $num_updated = db_update('test') ->condition('name', 'Ringo') - ->expression('age', 'age + :age', array(':age' => 4)) + ->expression('age', 'age + :age', [':age' => 4]) ->execute(); $this->assertIdentical($num_updated, 1, 'Updated 1 record.'); - $after_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetchField(); + $after_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetchField(); $this->assertEqual($before_age + 4, $after_age, 'Age updated correctly'); } @@ -127,7 +127,7 @@ function testUpdateOnlyExpression() { */ function testSubSelectUpdate() { $subselect = db_select('test_task', 't'); - $subselect->addExpression('MAX(priority) + :increment', 'max_priority', array(':increment' => 30)); + $subselect->addExpression('MAX(priority) + :increment', 'max_priority', [':increment' => 30]); // Clone this to make sure we are running a different query when // asserting. $select = clone $subselect; @@ -136,7 +136,7 @@ function testSubSelectUpdate() { ->condition('name', 'Ringo'); // Save the number of rows that updated for assertion later. $num_updated = $query->execute(); - $after_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'Ringo'))->fetchField(); + $after_age = db_query('SELECT age FROM {test} WHERE name = :name', [':name' => 'Ringo'])->fetchField(); $expected_age = $select->execute()->fetchField(); $this->assertEqual($after_age, $expected_age); $this->assertEqual(1, $num_updated, t('Expected 1 row to be updated in subselect update query.')); diff --git a/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php b/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php index 57a1418..cee2c95 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/UpdateLobTest.php @@ -16,17 +16,17 @@ function testUpdateOneBlob() { $data = "This is\000a test."; $this->assertTrue(strlen($data) === 15, 'Test data contains a NULL.'); $id = db_insert('test_one_blob') - ->fields(array('blob1' => $data)) + ->fields(['blob1' => $data]) ->execute(); $data .= $data; db_update('test_one_blob') ->condition('id', $id) - ->fields(array('blob1' => $data)) + ->fields(['blob1' => $data]) ->execute(); - $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', array(':id' => $id))->fetchAssoc(); - $this->assertTrue($r['blob1'] === $data, format_string('Can update a blob: id @id, @data.', array('@id' => $id, '@data' => serialize($r)))); + $r = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', [':id' => $id])->fetchAssoc(); + $this->assertTrue($r['blob1'] === $data, format_string('Can update a blob: id @id, @data.', ['@id' => $id, '@data' => serialize($r)])); } /** @@ -34,18 +34,18 @@ function testUpdateOneBlob() { */ function testUpdateMultipleBlob() { $id = db_insert('test_two_blobs') - ->fields(array( + ->fields([ 'blob1' => 'This is', 'blob2' => 'a test', - )) + ]) ->execute(); db_update('test_two_blobs') ->condition('id', $id) - ->fields(array('blob1' => 'and so', 'blob2' => 'is this')) + ->fields(['blob1' => 'and so', 'blob2' => 'is this']) ->execute(); - $r = db_query('SELECT * FROM {test_two_blobs} WHERE id = :id', array(':id' => $id))->fetchAssoc(); + $r = db_query('SELECT * FROM {test_two_blobs} WHERE id = :id', [':id' => $id])->fetchAssoc(); $this->assertTrue($r['blob1'] === 'and so' && $r['blob2'] === 'is this', 'Can update multiple blobs per row.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php b/core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php index 25ad3cb..aef6e86 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/UpdateTest.php @@ -14,12 +14,12 @@ class UpdateTest extends DatabaseTestBase { */ function testSimpleUpdate() { $num_updated = db_update('test') - ->fields(array('name' => 'Tiffany')) + ->fields(['name' => 'Tiffany']) ->condition('id', 1) ->execute(); $this->assertIdentical($num_updated, 1, 'Updated 1 record.'); - $saved_name = db_query('SELECT name FROM {test} WHERE id = :id', array(':id' => 1))->fetchField(); + $saved_name = db_query('SELECT name FROM {test} WHERE id = :id', [':id' => 1])->fetchField(); $this->assertIdentical($saved_name, 'Tiffany', 'Updated name successfully.'); } @@ -29,12 +29,12 @@ function testSimpleUpdate() { function testSimpleNullUpdate() { $this->ensureSampleDataNull(); $num_updated = db_update('test_null') - ->fields(array('age' => NULL)) + ->fields(['age' => NULL]) ->condition('name', 'Kermit') ->execute(); $this->assertIdentical($num_updated, 1, 'Updated 1 record.'); - $saved_age = db_query('SELECT age FROM {test_null} WHERE name = :name', array(':name' => 'Kermit'))->fetchField(); + $saved_age = db_query('SELECT age FROM {test_null} WHERE name = :name', [':name' => 'Kermit'])->fetchField(); $this->assertNull($saved_age, 'Updated name successfully.'); } @@ -43,12 +43,12 @@ function testSimpleNullUpdate() { */ function testMultiUpdate() { $num_updated = db_update('test') - ->fields(array('job' => 'Musician')) + ->fields(['job' => 'Musician']) ->condition('job', 'Singer') ->execute(); $this->assertIdentical($num_updated, 2, 'Updated 2 records.'); - $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField(); $this->assertIdentical($num_matches, '2', 'Updated fields successfully.'); } @@ -57,12 +57,12 @@ function testMultiUpdate() { */ function testMultiGTUpdate() { $num_updated = db_update('test') - ->fields(array('job' => 'Musician')) + ->fields(['job' => 'Musician']) ->condition('age', 26, '>') ->execute(); $this->assertIdentical($num_updated, 2, 'Updated 2 records.'); - $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField(); $this->assertIdentical($num_matches, '2', 'Updated fields successfully.'); } @@ -71,12 +71,12 @@ function testMultiGTUpdate() { */ function testWhereUpdate() { $num_updated = db_update('test') - ->fields(array('job' => 'Musician')) - ->where('age > :age', array(':age' => 26)) + ->fields(['job' => 'Musician']) + ->where('age > :age', [':age' => 26]) ->execute(); $this->assertIdentical($num_updated, 2, 'Updated 2 records.'); - $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField(); $this->assertIdentical($num_matches, '2', 'Updated fields successfully.'); } @@ -85,13 +85,13 @@ function testWhereUpdate() { */ function testWhereAndConditionUpdate() { $update = db_update('test') - ->fields(array('job' => 'Musician')) - ->where('age > :age', array(':age' => 26)) + ->fields(['job' => 'Musician']) + ->where('age > :age', [':age' => 26]) ->condition('name', 'Ringo'); $num_updated = $update->execute(); $this->assertIdentical($num_updated, 1, 'Updated 1 record.'); - $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query('SELECT COUNT(*) FROM {test} WHERE job = :job', [':job' => 'Musician'])->fetchField(); $this->assertIdentical($num_matches, '1', 'Updated fields successfully.'); } @@ -106,7 +106,7 @@ function testExpressionUpdate() { ->execute(); $this->assertIdentical($num_rows, 4, 'Updated 4 records.'); - $saved_name = db_query('SELECT name FROM {test} WHERE age = :age', array(':age' => pow(26, 2)))->fetchField(); + $saved_name = db_query('SELECT name FROM {test} WHERE age = :age', [':age' => pow(26, 2)])->fetchField(); $this->assertIdentical($saved_name, 'Paul', 'Successfully updated values using an algebraic expression.'); } @@ -122,7 +122,7 @@ function testUpdateAffectedRows() { // because that's cross-db expected behavior. $num_rows = db_update('test_task') ->condition('priority', 1, '<>') - ->fields(array('task' => 'sleep')) + ->fields(['task' => 'sleep']) ->execute(); $this->assertIdentical($num_rows, 5, 'Correctly returned 5 affected rows.'); } @@ -132,12 +132,12 @@ function testUpdateAffectedRows() { */ function testPrimaryKeyUpdate() { $num_updated = db_update('test') - ->fields(array('id' => 42, 'name' => 'John')) + ->fields(['id' => 42, 'name' => 'John']) ->condition('id', 1) ->execute(); $this->assertIdentical($num_updated, 1, 'Updated 1 record.'); - $saved_name = db_query('SELECT name FROM {test} WHERE id = :id', array(':id' => 42))->fetchField(); + $saved_name = db_query('SELECT name FROM {test} WHERE id = :id', [':id' => 42])->fetchField(); $this->assertIdentical($saved_name, 'John', 'Updated primary key successfully.'); } @@ -146,12 +146,12 @@ function testPrimaryKeyUpdate() { */ function testSpecialColumnUpdate() { $num_updated = db_update('test_special_columns') - ->fields(array('offset' => 'New offset value')) + ->fields(['offset' => 'New offset value']) ->condition('id', 1) ->execute(); $this->assertIdentical($num_updated, 1, 'Updated 1 special column record.'); - $saved_value = db_query('SELECT "offset" FROM {test_special_columns} WHERE id = :id', array(':id' => 1))->fetchField(); + $saved_value = db_query('SELECT "offset" FROM {test_special_columns} WHERE id = :id', [':id' => 1])->fetchField(); $this->assertIdentical($saved_value, 'New offset value', 'Updated special column name value successfully.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Database/UpsertTest.php b/core/tests/Drupal/KernelTests/Core/Database/UpsertTest.php index 9b8e167..5c62f87 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/UpsertTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/UpsertTest.php @@ -42,12 +42,12 @@ public function testUpsert() { $num_records_after = $connection->query('SELECT COUNT(*) FROM {test_people}')->fetchField(); $this->assertEqual($num_records_before + 1, $num_records_after, 'Rows were inserted and updated properly.'); - $person = $connection->query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Presenter'))->fetch(); + $person = $connection->query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Presenter'])->fetch(); $this->assertEqual($person->job, 'Presenter', 'Job set correctly.'); $this->assertEqual($person->age, 31, 'Age set correctly.'); $this->assertEqual($person->name, 'Tiffany', 'Name set correctly.'); - $person = $connection->query('SELECT * FROM {test_people} WHERE job = :job', array(':job' => 'Speaker'))->fetch(); + $person = $connection->query('SELECT * FROM {test_people} WHERE job = :job', [':job' => 'Speaker'])->fetch(); $this->assertEqual($person->job, 'Speaker', 'Job was not changed.'); $this->assertEqual($person->age, 32, 'Age updated correctly.'); $this->assertEqual($person->name, 'Meredith', 'Name was not changed.'); diff --git a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php index 7778a5a..7370491 100644 --- a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php +++ b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php @@ -60,10 +60,10 @@ protected function getTestKernel(Request $request, array $modules_enabled = NULL */ public function testCompileDIC() { // @todo: write a memory based storage backend for testing. - $modules_enabled = array( + $modules_enabled = [ 'system' => 'system', 'user' => 'user', - ); + ]; $request = Request::createFromGlobals(); $this->getTestKernel($request, $modules_enabled); @@ -128,11 +128,11 @@ public function testCompileDIC() { // Check that the location of the new module is registered. $modules = $container->getParameter('container.modules'); - $this->assertEqual($modules['service_provider_test'], array( + $this->assertEqual($modules['service_provider_test'], [ 'type' => 'module', 'pathname' => drupal_get_filename('module', 'service_provider_test'), 'filename' => NULL, - )); + ]); // Check that the container itself is not among the persist IDs because it // does not make sense to persist the container itself. @@ -169,10 +169,10 @@ public function testRepeatedBootWithDifferentEnvironment() { */ public function testPreventChangeOfSitePath() { // @todo: write a memory based storage backend for testing. - $modules_enabled = array( + $modules_enabled = [ 'system' => 'system', 'user' => 'user', - ); + ]; $request = Request::createFromGlobals(); $kernel = $this->getTestKernel($request, $modules_enabled); diff --git a/core/tests/Drupal/KernelTests/Core/DrupalKernel/ServiceDestructionTest.php b/core/tests/Drupal/KernelTests/Core/DrupalKernel/ServiceDestructionTest.php index f4fe094..1716280 100644 --- a/core/tests/Drupal/KernelTests/Core/DrupalKernel/ServiceDestructionTest.php +++ b/core/tests/Drupal/KernelTests/Core/DrupalKernel/ServiceDestructionTest.php @@ -17,7 +17,7 @@ class ServiceDestructionTest extends KernelTestBase { */ public function testDestructionUsed() { // Enable the test module to add it to the container. - $this->enableModules(array('service_provider_test')); + $this->enableModules(['service_provider_test']); $request = $this->container->get('request_stack')->getCurrentRequest(); $kernel = $this->container->get('kernel'); @@ -39,7 +39,7 @@ public function testDestructionUsed() { */ public function testDestructionUnused() { // Enable the test module to add it to the container. - $this->enableModules(array('service_provider_test')); + $this->enableModules(['service_provider_test']); $request = $this->container->get('request_stack')->getCurrentRequest(); $kernel = $this->container->get('kernel'); diff --git a/core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php b/core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php index ca4e501..b5b9ffd 100644 --- a/core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php +++ b/core/tests/Drupal/KernelTests/Core/Element/PathElementFormTest.php @@ -30,7 +30,7 @@ class PathElementFormTest extends KernelTestBase implements FormInterface { * * @var array */ - public static $modules = array('system', 'user'); + public static $modules = ['system', 'user']; /** * Sets up the test. @@ -41,16 +41,16 @@ protected function setUp() { $this->installEntitySchema('user'); \Drupal::service('router.builder')->rebuild(); /** @var \Drupal\user\RoleInterface $role */ - $role = Role::create(array( + $role = Role::create([ 'id' => 'admin', 'label' => 'admin', - )); + ]); $role->grantPermission('link to any page'); $role->save(); - $this->testUser = User::create(array( + $this->testUser = User::create([ 'name' => 'foobar', 'mail' => 'foobar@example.com', - )); + ]); $this->testUser->addRole($role->id()); $this->testUser->save(); \Drupal::service('current_user')->setAccount($this->testUser); @@ -68,57 +68,57 @@ public function getFormId() { */ public function buildForm(array $form, FormStateInterface $form_state) { // A required validated path. - $form['required_validate'] = array( + $form['required_validate'] = [ '#type' => 'path', '#required' => TRUE, '#title' => 'required_validate', '#convert_path' => PathElement::CONVERT_NONE, - ); + ]; // A non validated required path. - $form['required_non_validate'] = array( + $form['required_non_validate'] = [ '#type' => 'path', '#required' => TRUE, '#title' => 'required_non_validate', '#convert_path' => PathElement::CONVERT_NONE, '#validate_path' => FALSE, - ); + ]; // A non required validated path. - $form['optional_validate'] = array( + $form['optional_validate'] = [ '#type' => 'path', '#required' => FALSE, '#title' => 'optional_validate', '#convert_path' => PathElement::CONVERT_NONE, - ); + ]; // A non required converted path. - $form['optional_validate'] = array( + $form['optional_validate'] = [ '#type' => 'path', '#required' => FALSE, '#title' => 'optional_validate', '#convert_path' => PathElement::CONVERT_ROUTE, - ); + ]; // A converted required validated path. - $form['required_validate_route'] = array( + $form['required_validate_route'] = [ '#type' => 'path', '#required' => TRUE, '#title' => 'required_validate_route', - ); + ]; // A converted required validated path. - $form['required_validate_url'] = array( + $form['required_validate_url'] = [ '#type' => 'path', '#required' => TRUE, '#title' => 'required_validate_url', '#convert_path' => PathElement::CONVERT_URL, - ); + ]; - $form['submit'] = array( + $form['submit'] = [ '#type' => 'submit', '#value' => t('Submit'), - ); + ]; return $form; } @@ -154,19 +154,19 @@ public function testPathElement() { // Valid form state. $this->assertEqual(count($form_state->getErrors()), 0); - $this->assertEqual($form_state->getValue('required_validate_route'), array( + $this->assertEqual($form_state->getValue('required_validate_route'), [ 'route_name' => 'entity.user.canonical', - 'route_parameters' => array( + 'route_parameters' => [ 'user' => $this->testUser->id(), - ), - )); + ], + ]); /** @var \Drupal\Core\Url $url */ $url = $form_state->getValue('required_validate_url'); $this->assertTrue($url instanceof Url); $this->assertEqual($url->getRouteName(), 'entity.user.canonical'); - $this->assertEqual($url->getRouteParameters(), array( + $this->assertEqual($url->getRouteParameters(), [ 'user' => $this->testUser->id(), - )); + ]); // Test #required. $form_state = (new FormState()) @@ -179,7 +179,7 @@ public function testPathElement() { $errors = $form_state->getErrors(); // Should be missing 'required_validate' field. $this->assertEqual(count($errors), 1); - $this->assertEqual($errors, array('required_validate' => t('@name field is required.', array('@name' => 'required_validate')))); + $this->assertEqual($errors, ['required_validate' => t('@name field is required.', ['@name' => 'required_validate'])]); // Test invalid parameters. $form_state = (new FormState()) @@ -195,11 +195,11 @@ public function testPathElement() { // Valid form state. $errors = $form_state->getErrors(); $this->assertEqual(count($errors), 3); - $this->assertEqual($errors, array( - 'required_validate' => t('This path does not exist or you do not have permission to link to %path.', array('%path' => 'user/74')), - 'required_validate_route' => t('This path does not exist or you do not have permission to link to %path.', array('%path' => 'user/74')), - 'required_validate_url' => t('This path does not exist or you do not have permission to link to %path.', array('%path' => 'user/74')), - )); + $this->assertEqual($errors, [ + 'required_validate' => t('This path does not exist or you do not have permission to link to %path.', ['%path' => 'user/74']), + 'required_validate_route' => t('This path does not exist or you do not have permission to link to %path.', ['%path' => 'user/74']), + 'required_validate_url' => t('This path does not exist or you do not have permission to link to %path.', ['%path' => 'user/74']), + ]); } } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/BundleConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/BundleConstraintValidatorTest.php index 2219487..613ba4e 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/BundleConstraintValidatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/BundleConstraintValidatorTest.php @@ -19,7 +19,7 @@ class BundleConstraintValidatorTest extends KernelTestBase { */ protected $typedData; - public static $modules = array('node', 'field', 'text', 'user'); + public static $modules = ['node', 'field', 'text', 'user']; protected function setUp() { parent::setUp(); @@ -32,7 +32,7 @@ protected function setUp() { */ public function testValidation() { // Test with multiple values. - $this->assertValidation(array('foo', 'bar')); + $this->assertValidation(['foo', 'bar']); // Test with a single string value as well. $this->assertValidation('foo'); } @@ -49,14 +49,14 @@ protected function assertValidation($bundle) { ->addConstraint('Bundle', $bundle); // Test the validation. - $node = $this->container->get('entity.manager')->getStorage('node')->create(array('type' => 'foo')); + $node = $this->container->get('entity.manager')->getStorage('node')->create(['type' => 'foo']); $typed_data = $this->typedData->create($definition, $node); $violations = $typed_data->validate(); $this->assertEqual($violations->count(), 0, 'Validation passed for correct value.'); // Test the validation when an invalid value is passed. - $page_node = $this->container->get('entity.manager')->getStorage('node')->create(array('type' => 'baz')); + $page_node = $this->container->get('entity.manager')->getStorage('node')->create(['type' => 'baz']); $typed_data = $this->typedData->create($definition, $page_node); $violations = $typed_data->validate(); @@ -64,7 +64,7 @@ protected function assertValidation($bundle) { // Make sure the information provided by a violation is correct. $violation = $violations[0]; - $this->assertEqual($violation->getMessage(), t('The entity must be of bundle %bundle.', array('%bundle' => implode(', ', (array) $bundle))), 'The message for invalid value is correct.'); + $this->assertEqual($violation->getMessage(), t('The entity must be of bundle %bundle.', ['%bundle' => implode(', ', (array) $bundle)]), 'The message for invalid value is correct.'); $this->assertEqual($violation->getRoot(), $typed_data, 'Violation root is correct.'); $this->assertEqual($violation->getInvalidValue(), $page_node, 'The invalid value is set correctly in the violation.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php index 22cae65..87ba104 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityQueryTest.php @@ -19,7 +19,7 @@ class ConfigEntityQueryTest extends KernelTestBase { * * @var array */ - public static $modules = array('config_test'); + public static $modules = ['config_test']; /** * Stores the search results for alter comparison. @@ -45,7 +45,7 @@ class ConfigEntityQueryTest extends KernelTestBase { protected function setUp() { parent::setUp(); - $this->entities = array(); + $this->entities = []; $this->factory = $this->container->get('entity.query'); // These two are here to make sure that matchArray needs to go over several @@ -54,56 +54,56 @@ protected function setUp() { $array['level1a']['level2'] = 9; // The tests match array.level1.level2. $array['level1']['level2'] = 1; - $entity = ConfigQueryTest::create(array( + $entity = ConfigQueryTest::create([ 'label' => $this->randomMachineName(), 'id' => '1', 'number' => 31, 'array' => $array, - )); + ]); $this->entities[] = $entity; $entity->enforceIsNew(); $entity->save(); $array['level1']['level2'] = 2; - $entity = ConfigQueryTest::create(array( + $entity = ConfigQueryTest::create([ 'label' => $this->randomMachineName(), 'id' => '2', 'number' => 41, 'array' => $array, - )); + ]); $this->entities[] = $entity; $entity->enforceIsNew(); $entity->save(); $array['level1']['level2'] = 1; - $entity = ConfigQueryTest::create(array( + $entity = ConfigQueryTest::create([ 'label' => 'test_prefix_' . $this->randomMachineName(), 'id' => '3', 'number' => 59, 'array' => $array, - )); + ]); $this->entities[] = $entity; $entity->enforceIsNew(); $entity->save(); $array['level1']['level2'] = 2; - $entity = ConfigQueryTest::create(array( + $entity = ConfigQueryTest::create([ 'label' => $this->randomMachineName() . '_test_suffix', 'id' => '4', 'number' => 26, 'array' => $array, - )); + ]); $this->entities[] = $entity; $entity->enforceIsNew(); $entity->save(); $array['level1']['level2'] = 3; - $entity = ConfigQueryTest::create(array( + $entity = ConfigQueryTest::create([ 'label' => $this->randomMachineName() . '_TEST_contains_' . $this->randomMachineName(), 'id' => '5', 'number' => 53, 'array' => $array, - )); + ]); $this->entities[] = $entity; $entity->enforceIsNew(); $entity->save(); @@ -116,84 +116,84 @@ public function testConfigEntityQuery() { // Run a test without any condition. $this->queryResults = $this->factory->get('config_query_test') ->execute(); - $this->assertResults(array('1', '2', '3', '4', '5')); + $this->assertResults(['1', '2', '3', '4', '5']); // No conditions, OR. $this->queryResults = $this->factory->get('config_query_test', 'OR') ->execute(); - $this->assertResults(array('1', '2', '3', '4', '5')); + $this->assertResults(['1', '2', '3', '4', '5']); // Filter by ID with equality. $this->queryResults = $this->factory->get('config_query_test') ->condition('id', '3') ->execute(); - $this->assertResults(array('3')); + $this->assertResults(['3']); // Filter by label with a known prefix. $this->queryResults = $this->factory->get('config_query_test') ->condition('label', 'test_prefix', 'STARTS_WITH') ->execute(); - $this->assertResults(array('3')); + $this->assertResults(['3']); // Filter by label with a known suffix. $this->queryResults = $this->factory->get('config_query_test') ->condition('label', 'test_suffix', 'ENDS_WITH') ->execute(); - $this->assertResults(array('4')); + $this->assertResults(['4']); // Filter by label with a known containing word. $this->queryResults = $this->factory->get('config_query_test') ->condition('label', 'test_contains', 'CONTAINS') ->execute(); - $this->assertResults(array('5')); + $this->assertResults(['5']); // Filter by ID with the IN operator. $this->queryResults = $this->factory->get('config_query_test') - ->condition('id', array('2', '3'), 'IN') + ->condition('id', ['2', '3'], 'IN') ->execute(); - $this->assertResults(array('2', '3')); + $this->assertResults(['2', '3']); // Filter by ID with the implicit IN operator. $this->queryResults = $this->factory->get('config_query_test') - ->condition('id', array('2', '3')) + ->condition('id', ['2', '3']) ->execute(); - $this->assertResults(array('2', '3')); + $this->assertResults(['2', '3']); // Filter by ID with the > operator. $this->queryResults = $this->factory->get('config_query_test') ->condition('id', '3', '>') ->execute(); - $this->assertResults(array('4', '5')); + $this->assertResults(['4', '5']); // Filter by ID with the >= operator. $this->queryResults = $this->factory->get('config_query_test') ->condition('id', '3', '>=') ->execute(); - $this->assertResults(array('3', '4', '5')); + $this->assertResults(['3', '4', '5']); // Filter by ID with the <> operator. $this->queryResults = $this->factory->get('config_query_test') ->condition('id', '3', '<>') ->execute(); - $this->assertResults(array('1', '2', '4', '5')); + $this->assertResults(['1', '2', '4', '5']); // Filter by ID with the < operator. $this->queryResults = $this->factory->get('config_query_test') ->condition('id', '3', '<') ->execute(); - $this->assertResults(array('1', '2')); + $this->assertResults(['1', '2']); // Filter by ID with the <= operator. $this->queryResults = $this->factory->get('config_query_test') ->condition('id', '3', '<=') ->execute(); - $this->assertResults(array('1', '2', '3')); + $this->assertResults(['1', '2', '3']); // Filter by two conditions on the same field. $this->queryResults = $this->factory->get('config_query_test') ->condition('label', 'test_pref', 'STARTS_WITH') ->condition('label', 'test_prefix', 'STARTS_WITH') ->execute(); - $this->assertResults(array('3')); + $this->assertResults(['3']); // Filter by two conditions on different fields. The first query matches for // a different ID, so the result is empty. @@ -201,7 +201,7 @@ public function testConfigEntityQuery() { ->condition('label', 'test_prefix', 'STARTS_WITH') ->condition('id', '5') ->execute(); - $this->assertResults(array()); + $this->assertResults([]); // Filter by two different conditions on different fields. This time the // first condition matches on one item, but the second one does as well. @@ -209,7 +209,7 @@ public function testConfigEntityQuery() { ->condition('label', 'test_prefix', 'STARTS_WITH') ->condition('id', '3') ->execute(); - $this->assertResults(array('3')); + $this->assertResults(['3']); // Filter by two different conditions, of which the first one matches for // every entry, the second one as well, but just the third one filters so @@ -219,37 +219,37 @@ public function testConfigEntityQuery() { ->condition('number', 10, '>=') ->condition('number', 50, '>=') ->execute(); - $this->assertResults(array('3', '5')); + $this->assertResults(['3', '5']); // Filter with an OR condition group. $this->queryResults = $this->factory->get('config_query_test', 'OR') ->condition('id', 1) ->condition('id', '2') ->execute(); - $this->assertResults(array('1', '2')); + $this->assertResults(['1', '2']); // Simplify it with IN. $this->queryResults = $this->factory->get('config_query_test') - ->condition('id', array('1', '2')) + ->condition('id', ['1', '2']) ->execute(); - $this->assertResults(array('1', '2')); + $this->assertResults(['1', '2']); // Try explicit IN. $this->queryResults = $this->factory->get('config_query_test') - ->condition('id', array('1', '2'), 'IN') + ->condition('id', ['1', '2'], 'IN') ->execute(); - $this->assertResults(array('1', '2')); + $this->assertResults(['1', '2']); // Try not IN. $this->queryResults = $this->factory->get('config_query_test') - ->condition('id', array('1', '2'), 'NOT IN') + ->condition('id', ['1', '2'], 'NOT IN') ->execute(); - $this->assertResults(array('3', '4', '5')); + $this->assertResults(['3', '4', '5']); // Filter with an OR condition group on different fields. $this->queryResults = $this->factory->get('config_query_test', 'OR') ->condition('id', 1) ->condition('number', 41) ->execute(); - $this->assertResults(array('1', '2')); + $this->assertResults(['1', '2']); // Filter with an OR condition group on different fields but matching on the // same entity. @@ -257,7 +257,7 @@ public function testConfigEntityQuery() { ->condition('id', 1) ->condition('number', 31) ->execute(); - $this->assertResults(array('1')); + $this->assertResults(['1']); // NO simple conditions, YES complex conditions, 'AND'. $query = $this->factory->get('config_query_test', 'AND'); @@ -271,7 +271,7 @@ public function testConfigEntityQuery() { ->condition($and_condition_1) ->condition($and_condition_2) ->execute(); - $this->assertResults(array('1')); + $this->assertResults(['1']); // NO simple conditions, YES complex conditions, 'OR'. $query = $this->factory->get('config_query_test', 'OR'); @@ -285,7 +285,7 @@ public function testConfigEntityQuery() { ->condition($and_condition_1) ->condition($and_condition_2) ->execute(); - $this->assertResults(array('1', '2')); + $this->assertResults(['1', '2']); // YES simple conditions, YES complex conditions, 'AND'. $query = $this->factory->get('config_query_test', 'AND'); @@ -300,7 +300,7 @@ public function testConfigEntityQuery() { ->condition($and_condition_1) ->condition($and_condition_2) ->execute(); - $this->assertResults(array('1')); + $this->assertResults(['1']); // YES simple conditions, YES complex conditions, 'OR'. $query = $this->factory->get('config_query_test', 'OR'); @@ -315,28 +315,28 @@ public function testConfigEntityQuery() { ->condition($and_condition_1) ->condition($and_condition_2) ->execute(); - $this->assertResults(array('1', '2', '4', '5')); + $this->assertResults(['1', '2', '4', '5']); // Test the exists and notExists conditions. $this->queryResults = $this->factory->get('config_query_test') ->exists('id') ->execute(); - $this->assertResults(array('1', '2', '3', '4', '5')); + $this->assertResults(['1', '2', '3', '4', '5']); $this->queryResults = $this->factory->get('config_query_test') ->exists('non-existent') ->execute(); - $this->assertResults(array()); + $this->assertResults([]); $this->queryResults = $this->factory->get('config_query_test') ->notExists('id') ->execute(); - $this->assertResults(array()); + $this->assertResults([]); $this->queryResults = $this->factory->get('config_query_test') ->notExists('non-existent') ->execute(); - $this->assertResults(array('1', '2', '3', '4', '5')); + $this->assertResults(['1', '2', '3', '4', '5']); } /** @@ -344,10 +344,10 @@ public function testConfigEntityQuery() { */ public function testStringIdConditions() { // We need an entity with a non-numeric ID. - $entity = ConfigQueryTest::create(array( + $entity = ConfigQueryTest::create([ 'label' => $this->randomMachineName(), 'id' => 'foo.bar', - )); + ]); $this->entities[] = $entity; $entity->enforceIsNew(); $entity->save(); @@ -356,43 +356,43 @@ public function testStringIdConditions() { $this->queryResults = $this->factory->get('config_query_test') ->condition('id', 'foo.bar', 'STARTS_WITH') ->execute(); - $this->assertResults(array('foo.bar')); + $this->assertResults(['foo.bar']); $this->queryResults = $this->factory->get('config_query_test') ->condition('id', 'f', 'STARTS_WITH') ->execute(); - $this->assertResults(array('foo.bar')); + $this->assertResults(['foo.bar']); $this->queryResults = $this->factory->get('config_query_test') ->condition('id', 'miss', 'STARTS_WITH') ->execute(); - $this->assertResults(array()); + $this->assertResults([]); // Test 'CONTAINS' condition. $this->queryResults = $this->factory->get('config_query_test') ->condition('id', 'foo.bar', 'CONTAINS') ->execute(); - $this->assertResults(array('foo.bar')); + $this->assertResults(['foo.bar']); $this->queryResults = $this->factory->get('config_query_test') ->condition('id', 'oo.ba', 'CONTAINS') ->execute(); - $this->assertResults(array('foo.bar')); + $this->assertResults(['foo.bar']); $this->queryResults = $this->factory->get('config_query_test') ->condition('id', 'miss', 'CONTAINS') ->execute(); - $this->assertResults(array()); + $this->assertResults([]); // Test 'ENDS_WITH' condition. $this->queryResults = $this->factory->get('config_query_test') ->condition('id', 'foo.bar', 'ENDS_WITH') ->execute(); - $this->assertResults(array('foo.bar')); + $this->assertResults(['foo.bar']); $this->queryResults = $this->factory->get('config_query_test') ->condition('id', 'r', 'ENDS_WITH') ->execute(); - $this->assertResults(array('foo.bar')); + $this->assertResults(['foo.bar']); $this->queryResults = $this->factory->get('config_query_test') ->condition('id', 'miss', 'ENDS_WITH') ->execute(); - $this->assertResults(array()); + $this->assertResults([]); } /** @@ -429,62 +429,62 @@ public function testSortRange() { $this->queryResults = $this->factory->get('config_query_test') ->sort('number', 'DESC') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('3', '5', '2', '1', '4')); + $this->assertIdentical(array_values($this->queryResults), ['3', '5', '2', '1', '4']); $this->queryResults = $this->factory->get('config_query_test') ->sort('number', 'ASC') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('4', '1', '2', '5', '3')); + $this->assertIdentical(array_values($this->queryResults), ['4', '1', '2', '5', '3']); // Apply some filters and sort. $this->queryResults = $this->factory->get('config_query_test') ->condition('id', '3', '>') ->sort('number', 'DESC') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('5', '4')); + $this->assertIdentical(array_values($this->queryResults), ['5', '4']); $this->queryResults = $this->factory->get('config_query_test') ->condition('id', '3', '>') ->sort('number', 'ASC') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('4', '5')); + $this->assertIdentical(array_values($this->queryResults), ['4', '5']); // Apply a pager and sort. $this->queryResults = $this->factory->get('config_query_test') ->sort('number', 'DESC') ->range('2', '2') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('2', '1')); + $this->assertIdentical(array_values($this->queryResults), ['2', '1']); $this->queryResults = $this->factory->get('config_query_test') ->sort('number', 'ASC') ->range('2', '2') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('2', '5')); + $this->assertIdentical(array_values($this->queryResults), ['2', '5']); // Add a range to a query without a start parameter. $this->queryResults = $this->factory->get('config_query_test') ->range(0, '3') ->sort('id', 'ASC') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('1', '2', '3')); + $this->assertIdentical(array_values($this->queryResults), ['1', '2', '3']); // Apply a pager with limit 4. $this->queryResults = $this->factory->get('config_query_test') ->pager('4', 0) ->sort('id', 'ASC') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('1', '2', '3', '4')); + $this->assertIdentical(array_values($this->queryResults), ['1', '2', '3', '4']); } /** * Tests sorting with tableSort on config entity queries. */ public function testTableSort() { - $header = array( - array('data' => t('ID'), 'specifier' => 'id'), - array('data' => t('Number'), 'specifier' => 'number'), - ); + $header = [ + ['data' => t('ID'), 'specifier' => 'id'], + ['data' => t('Number'), 'specifier' => 'number'], + ]; // Sort key: id // Sorting with 'DESC' upper case @@ -492,28 +492,28 @@ public function testTableSort() { ->tableSort($header) ->sort('id', 'DESC') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('5', '4', '3', '2', '1')); + $this->assertIdentical(array_values($this->queryResults), ['5', '4', '3', '2', '1']); // Sorting with 'ASC' upper case $this->queryResults = $this->factory->get('config_query_test') ->tableSort($header) ->sort('id', 'ASC') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('1', '2', '3', '4', '5')); + $this->assertIdentical(array_values($this->queryResults), ['1', '2', '3', '4', '5']); // Sorting with 'desc' lower case $this->queryResults = $this->factory->get('config_query_test') ->tableSort($header) ->sort('id', 'desc') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('5', '4', '3', '2', '1')); + $this->assertIdentical(array_values($this->queryResults), ['5', '4', '3', '2', '1']); // Sorting with 'asc' lower case $this->queryResults = $this->factory->get('config_query_test') ->tableSort($header) ->sort('id', 'asc') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('1', '2', '3', '4', '5')); + $this->assertIdentical(array_values($this->queryResults), ['1', '2', '3', '4', '5']); // Sort key: number // Sorting with 'DeSc' mixed upper and lower case @@ -521,28 +521,28 @@ public function testTableSort() { ->tableSort($header) ->sort('number', 'DeSc') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('3', '5', '2', '1', '4')); + $this->assertIdentical(array_values($this->queryResults), ['3', '5', '2', '1', '4']); // Sorting with 'AsC' mixed upper and lower case $this->queryResults = $this->factory->get('config_query_test') ->tableSort($header) ->sort('number', 'AsC') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('4', '1', '2', '5', '3')); + $this->assertIdentical(array_values($this->queryResults), ['4', '1', '2', '5', '3']); // Sorting with 'dEsC' mixed upper and lower case $this->queryResults = $this->factory->get('config_query_test') ->tableSort($header) ->sort('number', 'dEsC') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('3', '5', '2', '1', '4')); + $this->assertIdentical(array_values($this->queryResults), ['3', '5', '2', '1', '4']); // Sorting with 'aSc' mixed upper and lower case $this->queryResults = $this->factory->get('config_query_test') ->tableSort($header) ->sort('number', 'aSc') ->execute(); - $this->assertIdentical(array_values($this->queryResults), array('4', '1', '2', '5', '3')); + $this->assertIdentical(array_values($this->queryResults), ['4', '1', '2', '5', '3']); } /** @@ -552,26 +552,26 @@ public function testDotted() { $this->queryResults = $this->factory->get('config_query_test') ->condition('array.level1.*', 1) ->execute(); - $this->assertResults(array('1', '3')); + $this->assertResults(['1', '3']); $this->queryResults = $this->factory->get('config_query_test') ->condition('*.level1.level2', 2) ->execute(); - $this->assertResults(array('2', '4')); + $this->assertResults(['2', '4']); $this->queryResults = $this->factory->get('config_query_test') ->condition('array.level1.*', 3) ->execute(); - $this->assertResults(array('5')); + $this->assertResults(['5']); $this->queryResults = $this->factory->get('config_query_test') ->condition('array.level1.level2', 3) ->execute(); - $this->assertResults(array('5')); + $this->assertResults(['5']); // Make sure that values on the wildcard level do not match if there are // sub-keys defined. This must not find anything even if entity 2 has a // top-level key number with value 41. $this->queryResults = $this->factory->get('config_query_test') ->condition('*.level1.level2', 41) ->execute(); - $this->assertResults(array()); + $this->assertResults([]); } /** @@ -582,12 +582,12 @@ public function testCaseSensitivity() { $this->queryResults = $this->factory->get('config_query_test') ->condition('label', 'TEST', 'CONTAINS') ->execute(); - $this->assertResults(array('3', '4', '5')); + $this->assertResults(['3', '4', '5']); $this->queryResults = $this->factory->get('config_query_test') ->condition('label', 'test', 'CONTAINS') ->execute(); - $this->assertResults(array('3', '4', '5')); + $this->assertResults(['3', '4', '5']); } /** @@ -599,11 +599,11 @@ public function testLookupKeys() { $key_value = $this->container->get('keyvalue')->get(QueryFactory::CONFIG_LOOKUP_PREFIX . 'config_test'); $test_entities = []; - $entity = entity_create('config_test', array( + $entity = entity_create('config_test', [ 'label' => $this->randomMachineName(), 'id' => '1', 'style' => 'test', - )); + ]); $test_entities[$entity->getConfigDependencyName()] = $entity; $entity->enforceIsNew(); $entity->save(); @@ -612,22 +612,22 @@ public function testLookupKeys() { $expected[] = $entity->getConfigDependencyName(); $this->assertEqual($expected, $key_value->get('style:test')); - $entity = entity_create('config_test', array( + $entity = entity_create('config_test', [ 'label' => $this->randomMachineName(), 'id' => '2', 'style' => 'test', - )); + ]); $test_entities[$entity->getConfigDependencyName()] = $entity; $entity->enforceIsNew(); $entity->save(); $expected[] = $entity->getConfigDependencyName(); $this->assertEqual($expected, $key_value->get('style:test')); - $entity = entity_create('config_test', array( + $entity = entity_create('config_test', [ 'label' => $this->randomMachineName(), 'id' => '3', 'style' => 'blah', - )); + ]); $entity->enforceIsNew(); $entity->save(); // Do not add this entity to the list of expected result as it has a diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php index e9e2ad1..66e1abb 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityChangedTest.php @@ -59,12 +59,12 @@ public function testChanged() { $user2 = $this->createUser(); // Create a test entity. - $entity = EntityTestMulChanged::create(array( + $entity = EntityTestMulChanged::create([ 'name' => $this->randomString(), 'not_translatable' => $this->randomString(), 'user_id' => $user1->id(), 'language' => 'en', - )); + ]); $entity->save(); $this->assertTrue( @@ -289,11 +289,11 @@ public function testRevisionChanged() { $user2 = $this->createUser(); // Create a test entity. - $entity = EntityTestMulRevChanged::create(array( + $entity = EntityTestMulRevChanged::create([ 'name' => $this->randomString(), 'user_id' => $user1->id(), 'language' => 'en', - )); + ]); $entity->save(); $this->assertTrue( diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php index 73684e9..99c99b0 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNonRevisionableFieldTest.php @@ -57,21 +57,21 @@ public function testMulNonRevisionableField() { $user2 = $this->createUser(); // Create a test entity. - $entity = EntityTestMulRev::create(array( + $entity = EntityTestMulRev::create([ 'name' => $this->randomString(), 'user_id' => $user1->id(), 'language' => 'en', 'non_rev_field' => 'Huron', - )); + ]); $entity->save(); // Create a test entity. - $entity2 = EntityTestMulRev::create(array( + $entity2 = EntityTestMulRev::create([ 'name' => $this->randomString(), 'user_id' => $user1->id(), 'language' => 'en', 'non_rev_field' => 'Michigan', - )); + ]); $entity2->save(); $this->assertEquals('Huron', $entity->get('non_rev_field')->value, 'Huron found on entity 1'); @@ -123,19 +123,19 @@ public function testNonRevisionableField() { $user2 = $this->createUser(); // Create a test entity. - $entity = EntityTestRev::create(array( + $entity = EntityTestRev::create([ 'name' => $this->randomString(), 'user_id' => $user1->id(), 'non_rev_field' => 'Superior', - )); + ]); $entity->save(); // Create a test entity. - $entity2 = EntityTestRev::create(array( + $entity2 = EntityTestRev::create([ 'name' => $this->randomString(), 'user_id' => $user1->id(), 'non_rev_field' => 'Ontario', - )); + ]); $entity2->save(); $this->assertEquals('Superior', $entity->get('non_rev_field')->value, 'Superior found on entity 1'); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php index 51162fc..697f1be 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityNullStorageTest.php @@ -22,7 +22,7 @@ class ContentEntityNullStorageTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'contact', 'user'); + public static $modules = ['system', 'contact', 'user']; /** * Tests using entity query with ContentEntityNullStorage. diff --git a/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php b/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php index c2d737b..5d7ea0e 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/Element/EntityAutocompleteElementFormTest.php @@ -50,23 +50,23 @@ protected function setUp() { $this->installEntitySchema('entity_test_string_id'); \Drupal::service('router.builder')->rebuild(); - $this->testUser = User::create(array( + $this->testUser = User::create([ 'name' => 'foobar1', 'mail' => 'foobar1@example.com', - )); + ]); $this->testUser->save(); \Drupal::service('current_user')->setAccount($this->testUser); - $this->testAutocreateUser = User::create(array( + $this->testAutocreateUser = User::create([ 'name' => 'foobar2', 'mail' => 'foobar2@example.com', - )); + ]); $this->testAutocreateUser->save(); for ($i = 1; $i < 3; $i++) { - $entity = EntityTest::create(array( + $entity = EntityTest::create([ 'name' => $this->randomMachineName() - )); + ]); $entity->save(); $this->referencedEntities[] = $entity; } @@ -94,84 +94,84 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $form['single'] = array( + $form['single'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'entity_test', - ); - $form['single_autocreate'] = array( + ]; + $form['single_autocreate'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'entity_test', - '#autocreate' => array( + '#autocreate' => [ 'bundle' => 'entity_test', - ), - ); - $form['single_autocreate_specific_uid'] = array( + ], + ]; + $form['single_autocreate_specific_uid'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'entity_test', - '#autocreate' => array( + '#autocreate' => [ 'bundle' => 'entity_test', 'uid' => $this->testAutocreateUser->id(), - ), - ); + ], + ]; - $form['tags'] = array( + $form['tags'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'entity_test', '#tags' => TRUE, - ); - $form['tags_autocreate'] = array( + ]; + $form['tags_autocreate'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'entity_test', '#tags' => TRUE, - '#autocreate' => array( + '#autocreate' => [ 'bundle' => 'entity_test', - ), - ); - $form['tags_autocreate_specific_uid'] = array( + ], + ]; + $form['tags_autocreate_specific_uid'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'entity_test', '#tags' => TRUE, - '#autocreate' => array( + '#autocreate' => [ 'bundle' => 'entity_test', 'uid' => $this->testAutocreateUser->id(), - ), - ); + ], + ]; - $form['single_no_validate'] = array( + $form['single_no_validate'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'entity_test', '#validate_reference' => FALSE, - ); - $form['single_autocreate_no_validate'] = array( + ]; + $form['single_autocreate_no_validate'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'entity_test', '#validate_reference' => FALSE, - '#autocreate' => array( + '#autocreate' => [ 'bundle' => 'entity_test', - ), - ); + ], + ]; - $form['single_access'] = array( + $form['single_access'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'entity_test', '#default_value' => $this->referencedEntities[0], - ); - $form['tags_access'] = array( + ]; + $form['tags_access'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'entity_test', '#tags' => TRUE, - '#default_value' => array($this->referencedEntities[0], $this->referencedEntities[1]), - ); + '#default_value' => [$this->referencedEntities[0], $this->referencedEntities[1]], + ]; - $form['single_string_id'] = array( + $form['single_string_id'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'entity_test_string_id', - ); - $form['tags_string_id'] = array( + ]; + $form['tags_string_id'] = [ '#type' => 'entity_autocomplete', '#target_type' => 'entity_test_string_id', '#tags' => TRUE, - ); + ]; return $form; } @@ -229,10 +229,10 @@ public function testValidEntityAutocompleteElement() { $this->assertEqual($value['entity']->getOwnerId(), $this->testAutocreateUser->id()); // Test the 'tags' element. - $expected = array( - array('target_id' => $this->referencedEntities[0]->id()), - array('target_id' => $this->referencedEntities[1]->id()), - ); + $expected = [ + ['target_id' => $this->referencedEntities[0]->id()], + ['target_id' => $this->referencedEntities[1]->id()], + ]; $this->assertEqual($form_state->getValue('tags'), $expected); // Test the 'single_autocreate' element. @@ -281,7 +281,7 @@ public function testInvalidEntityAutocompleteElement() { ]); $form_builder->submitForm($this, $form_state); $this->assertEqual(count($form_state->getErrors()), 1); - $this->assertEqual($form_state->getErrors()['single'], t('There are no entities matching "%value".', array('%value' => 'single - non-existent label'))); + $this->assertEqual($form_state->getErrors()['single'], t('There are no entities matching "%value".', ['%value' => 'single - non-existent label'])); // Test 'single' with a entity ID that doesn't exist. $form_state = (new FormState()) @@ -290,7 +290,7 @@ public function testInvalidEntityAutocompleteElement() { ]); $form_builder->submitForm($this, $form_state); $this->assertEqual(count($form_state->getErrors()), 1); - $this->assertEqual($form_state->getErrors()['single'], t('The referenced entity (%type: %id) does not exist.', array('%type' => 'entity_test', '%id' => 42))); + $this->assertEqual($form_state->getErrors()['single'], t('The referenced entity (%type: %id) does not exist.', ['%type' => 'entity_test', '%id' => 42])); // Do the same tests as above but on an element with '#validate_reference' // set to FALSE. @@ -304,7 +304,7 @@ public function testInvalidEntityAutocompleteElement() { // The element without 'autocreate' support still has to emit a warning when // the input doesn't end with an entity ID enclosed in parentheses. $this->assertEqual(count($form_state->getErrors()), 1); - $this->assertEqual($form_state->getErrors()['single_no_validate'], t('There are no entities matching "%value".', array('%value' => 'single - non-existent label'))); + $this->assertEqual($form_state->getErrors()['single_no_validate'], t('There are no entities matching "%value".', ['%value' => 'single - non-existent label'])); $form_state = (new FormState()) ->setValues([ @@ -333,7 +333,7 @@ public function testEntityAutocompleteAccess() { $this->assertEqual($form['tags_access']['#value'], $expected); // Set up a non-admin user that is *not* allowed to view test entities. - \Drupal::currentUser()->setAccount($this->createUser(array(), array())); + \Drupal::currentUser()->setAccount($this->createUser([], [])); // Rebuild the form. $form = $form_builder->getForm($this); @@ -381,7 +381,7 @@ public function testEntityAutocompleteIdInput() { * A string that can be used as a value for EntityAutocomplete elements. */ protected function getAutocompleteInput(EntityInterface $entity) { - return EntityAutocomplete::getEntityLabels(array($entity)); + return EntityAutocomplete::getEntityLabels([$entity]); } } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php index 77210d5..a0ab999 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityAccessControlHandlerTest.php @@ -25,10 +25,10 @@ class EntityAccessControlHandlerTest extends EntityLanguageTestBase { */ function assertEntityAccess($ops, AccessibleInterface $object, AccountInterface $account = NULL) { foreach ($ops as $op => $result) { - $message = format_string("Entity access returns @result with operation '@op'.", array( + $message = format_string("Entity access returns @result with operation '@op'.", [ '@result' => !isset($result) ? 'null' : ($result ? 'true' : 'false'), '@op' => $op, - )); + ]); $this->assertEqual($result, $object->access($op, $account), $message); } @@ -45,44 +45,44 @@ public function testUserLabelAccess() { $user = $this->createUser(); // The current user is allowed to view the anonymous user label. - $this->assertEntityAccess(array( + $this->assertEntityAccess([ 'create' => FALSE, 'update' => FALSE, 'delete' => FALSE, 'view' => FALSE, 'view label' => TRUE, - ), $anonymous_user); + ], $anonymous_user); // The current user is allowed to view user labels. - $this->assertEntityAccess(array( + $this->assertEntityAccess([ 'create' => FALSE, 'update' => FALSE, 'delete' => FALSE, 'view' => FALSE, 'view label' => TRUE, - ), $user); + ], $user); // Switch to a anonymous user account. $account_switcher = \Drupal::service('account_switcher'); $account_switcher->switchTo(new AnonymousUserSession()); // The anonymous user is allowed to view the anonymous user label. - $this->assertEntityAccess(array( + $this->assertEntityAccess([ 'create' => FALSE, 'update' => FALSE, 'delete' => FALSE, 'view' => FALSE, 'view label' => TRUE, - ), $anonymous_user); + ], $anonymous_user); // The anonymous user is allowed to view user labels. - $this->assertEntityAccess(array( + $this->assertEntityAccess([ 'create' => FALSE, 'update' => FALSE, 'delete' => FALSE, 'view' => FALSE, 'view label' => TRUE, - ), $user); + ], $user); // Restore user account. $account_switcher->switchBack(); @@ -93,33 +93,33 @@ public function testUserLabelAccess() { */ function testEntityAccess() { // Set up a non-admin user that is allowed to view test entities. - \Drupal::currentUser()->setAccount($this->createUser(array('uid' => 2), array('view test entity'))); + \Drupal::currentUser()->setAccount($this->createUser(['uid' => 2], ['view test entity'])); // Use the 'entity_test_label' entity type in order to test the 'view label' // access operation. - $entity = EntityTestLabel::create(array( + $entity = EntityTestLabel::create([ 'name' => 'test', - )); + ]); // The current user is allowed to view entities. - $this->assertEntityAccess(array( + $this->assertEntityAccess([ 'create' => FALSE, 'update' => FALSE, 'delete' => FALSE, 'view' => TRUE, 'view label' => TRUE, - ), $entity); + ], $entity); // The custom user is not allowed to perform any operation on test entities, // except for viewing their label. $custom_user = $this->createUser(); - $this->assertEntityAccess(array( + $this->assertEntityAccess([ 'create' => FALSE, 'update' => FALSE, 'delete' => FALSE, 'view' => FALSE, 'view label' => TRUE, - ), $entity, $custom_user); + ], $entity, $custom_user); } /** @@ -136,18 +136,18 @@ function testEntityAccess() { */ function testDefaultEntityAccess() { // Set up a non-admin user that is allowed to view test entities. - \Drupal::currentUser()->setAccount($this->createUser(array('uid' => 2), array('view test entity'))); - $entity = EntityTest::create(array( + \Drupal::currentUser()->setAccount($this->createUser(['uid' => 2], ['view test entity'])); + $entity = EntityTest::create([ 'name' => 'forbid_access', - )); + ]); // The user is denied access to the entity. - $this->assertEntityAccess(array( + $this->assertEntityAccess([ 'create' => FALSE, 'update' => FALSE, 'delete' => FALSE, 'view' => FALSE, - ), $entity); + ], $entity); } /** @@ -155,7 +155,7 @@ function testDefaultEntityAccess() { */ function testEntityAccessDefaultController() { // The implementation requires that the global user id can be loaded. - \Drupal::currentUser()->setAccount($this->createUser(array('uid' => 2))); + \Drupal::currentUser()->setAccount($this->createUser(['uid' => 2])); // Check that the default access control handler is used for entities that don't // have a specific access control handler defined. @@ -163,12 +163,12 @@ function testEntityAccessDefaultController() { $this->assertTrue($handler instanceof EntityAccessControlHandler, 'The default entity handler is used for the entity_test_default_access entity type.'); $entity = EntityTestDefaultAccess::create(); - $this->assertEntityAccess(array( + $this->assertEntityAccess([ 'create' => FALSE, 'update' => FALSE, 'delete' => FALSE, 'view' => FALSE, - ), $entity); + ], $entity); } /** @@ -177,26 +177,26 @@ function testEntityAccessDefaultController() { function testEntityTranslationAccess() { // Set up a non-admin user that is allowed to view test entity translations. - \Drupal::currentUser()->setAccount($this->createUser(array('uid' => 2), array('view test entity translations'))); + \Drupal::currentUser()->setAccount($this->createUser(['uid' => 2], ['view test entity translations'])); // Create two test languages. - foreach (array('foo', 'bar') as $langcode) { - ConfigurableLanguage::create(array( + foreach (['foo', 'bar'] as $langcode) { + ConfigurableLanguage::create([ 'id' => $langcode, 'label' => $this->randomString(), - ))->save(); + ])->save(); } - $entity = EntityTest::create(array( + $entity = EntityTest::create([ 'name' => 'test', 'langcode' => 'foo', - )); + ]); $entity->save(); $translation = $entity->addTranslation('bar'); - $this->assertEntityAccess(array( + $this->assertEntityAccess([ 'view' => TRUE, - ), $translation); + ], $translation); } /** @@ -204,9 +204,9 @@ function testEntityTranslationAccess() { */ public function testHooks() { $state = $this->container->get('state'); - $entity = EntityTest::create(array( + $entity = EntityTest::create([ 'name' => 'test', - )); + ]); // Test hook_entity_create_access() and hook_ENTITY_TYPE_create_access(). $entity->access('create'); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php index 7ce15f5..744121e 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php @@ -49,15 +49,15 @@ protected function assertCRUD($entity_type, UserInterface $user1) { // Create some test entities. $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array('name' => 'test', 'user_id' => $user1->id())); + ->create(['name' => 'test', 'user_id' => $user1->id()]); $entity->save(); $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array('name' => 'test2', 'user_id' => $user1->id())); + ->create(['name' => 'test2', 'user_id' => $user1->id()]); $entity->save(); $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array('name' => 'test', 'user_id' => NULL)); + ->create(['name' => 'test', 'user_id' => NULL]); $entity->save(); /** @var \Drupal\Core\Entity\EntityStorageInterface $storage */ @@ -65,32 +65,32 @@ protected function assertCRUD($entity_type, UserInterface $user1) { ->getStorage($entity_type); $entities = array_values($storage->loadByProperties(['name' => 'test'])); - $this->assertEqual($entities[0]->name->value, 'test', format_string('%entity_type: Created and loaded entity', array('%entity_type' => $entity_type))); - $this->assertEqual($entities[1]->name->value, 'test', format_string('%entity_type: Created and loaded entity', array('%entity_type' => $entity_type))); + $this->assertEqual($entities[0]->name->value, 'test', format_string('%entity_type: Created and loaded entity', ['%entity_type' => $entity_type])); + $this->assertEqual($entities[1]->name->value, 'test', format_string('%entity_type: Created and loaded entity', ['%entity_type' => $entity_type])); // Test loading a single entity. $loaded_entity = $storage->load($entity->id()); - $this->assertEqual($loaded_entity->id(), $entity->id(), format_string('%entity_type: Loaded a single entity by id.', array('%entity_type' => $entity_type))); + $this->assertEqual($loaded_entity->id(), $entity->id(), format_string('%entity_type: Loaded a single entity by id.', ['%entity_type' => $entity_type])); // Test deleting an entity. $entities = array_values($storage->loadByProperties(['name' => 'test2'])); $entities[0]->delete(); $entities = array_values($storage->loadByProperties(['name' => 'test2'])); - $this->assertEqual($entities, array(), format_string('%entity_type: Entity deleted.', array('%entity_type' => $entity_type))); + $this->assertEqual($entities, [], format_string('%entity_type: Entity deleted.', ['%entity_type' => $entity_type])); // Test updating an entity. $entities = array_values($storage->loadByProperties(['name' => 'test'])); $entities[0]->name->value = 'test3'; $entities[0]->save(); $entity = $storage->load($entities[0]->id()); - $this->assertEqual($entity->name->value, 'test3', format_string('%entity_type: Entity updated.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->name->value, 'test3', format_string('%entity_type: Entity updated.', ['%entity_type' => $entity_type])); // Try deleting multiple test entities by deleting all. $ids = array_keys($storage->loadMultiple()); entity_delete_multiple($entity_type, $ids); $all = $storage->loadMultiple(); - $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', array('%entity_type' => $entity_type))); + $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', ['%entity_type' => $entity_type])); // Verify that all data got deleted. $definition = \Drupal::entityManager()->getDefinition($entity_type); @@ -103,11 +103,11 @@ protected function assertCRUD($entity_type, UserInterface $user1) { } // Test deleting a list of entities not indexed by entity id. - $entities = array(); - $entity = entity_create($entity_type, array('name' => 'test', 'user_id' => $user1->id())); + $entities = []; + $entity = entity_create($entity_type, ['name' => 'test', 'user_id' => $user1->id()]); $entity->save(); $entities['test'] = $entity; - $entity = entity_create($entity_type, array('name' => 'test2', 'user_id' => $user1->id())); + $entity = entity_create($entity_type, ['name' => 'test2', 'user_id' => $user1->id()]); $entity->save(); $entities['test2'] = $entity; $controller = \Drupal::entityManager()->getStorage($entity_type); @@ -115,7 +115,7 @@ protected function assertCRUD($entity_type, UserInterface $user1) { // Verify that entities got deleted. $all = $storage->loadMultiple(); - $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', array('%entity_type' => $entity_type))); + $this->assertTrue(empty($all), format_string('%entity_type: Deleted all entities.', ['%entity_type' => $entity_type])); // Verify that all data got deleted from the tables. $definition = \Drupal::entityManager()->getDefinition($entity_type); @@ -132,7 +132,7 @@ protected function assertCRUD($entity_type, UserInterface $user1) { * Tests that exceptions are thrown when saving or deleting an entity. */ public function testEntityStorageExceptionHandling() { - $entity = EntityTest::create(array('name' => 'test')); + $entity = EntityTest::create(['name' => 'test']); try { $GLOBALS['entity_test_throw_exception'] = TRUE; $entity->save(); @@ -142,7 +142,7 @@ public function testEntityStorageExceptionHandling() { $this->assertEqual($e->getcode(), 1, 'Entity presave EntityStorageException caught.'); } - $entity = EntityTest::create(array('name' => 'test2')); + $entity = EntityTest::create(['name' => 'test2']); try { unset($GLOBALS['entity_test_throw_exception']); $entity->save(); @@ -152,7 +152,7 @@ public function testEntityStorageExceptionHandling() { $this->assertNotEqual($e->getCode(), 1, 'Entity presave EntityStorageException caught.'); } - $entity = EntityTest::create(array('name' => 'test3')); + $entity = EntityTest::create(['name' => 'test3']); $entity->save(); try { $GLOBALS['entity_test_throw_exception'] = TRUE; @@ -164,7 +164,7 @@ public function testEntityStorageExceptionHandling() { } unset($GLOBALS['entity_test_throw_exception']); - $entity = EntityTest::create(array('name' => 'test4')); + $entity = EntityTest::create(['name' => 'test4']); $entity->save(); try { $entity->delete(); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php index ae4925c..3fed33c 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityAutocompleteTest.php @@ -47,19 +47,19 @@ function testEntityReferenceAutocompletion() { // Add an entity with a slash in its name. $entity_1 = $this->container->get('entity_type.manager') ->getStorage($this->entityType) - ->create(array('name' => '10/16/2011')); + ->create(['name' => '10/16/2011']); $entity_1->save(); // Add another entity that differs after the slash character. $entity_2 = $this->container->get('entity_type.manager') ->getStorage($this->entityType) - ->create(array('name' => '10/17/2011')); + ->create(['name' => '10/17/2011']); $entity_2->save(); // Add another entity that has both a comma, a slash and markup. $entity_3 = $this->container->get('entity_type.manager') ->getStorage($this->entityType) - ->create(array('name' => 'label with, and / test')); + ->create(['name' => 'label with, and / test']); $entity_3->save(); // Try to autocomplete a entity label that matches both entities. @@ -73,10 +73,10 @@ function testEntityReferenceAutocompletion() { // We should only get the first entity in a JSON encoded string. $input = '10/16'; $data = $this->getAutocompleteResult($input); - $target = array( + $target = [ 'value' => $entity_1->name->value . ' (1)', 'label' => Html::escape($entity_1->name->value), - ); + ]; $this->assertIdentical(reset($data), $target, 'Autocomplete returns only the expected matching entity.'); // Try to autocomplete a entity label that matches the second entity, and @@ -91,10 +91,10 @@ function testEntityReferenceAutocompletion() { $n = $entity_3->name->value . ' (3)'; // Entity labels containing commas or quotes must be wrapped in quotes. $n = Tags::encode($n); - $target = array( + $target = [ 'value' => $n, 'label' => Html::escape($entity_3->name->value), - ); + ]; $this->assertIdentical(reset($data), $target, 'Autocomplete returns an entity label containing a comma and a slash.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityBundleFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityBundleFieldTest.php index ec8fd1c..ed30d4b 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityBundleFieldTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityBundleFieldTest.php @@ -14,7 +14,7 @@ class EntityBundleFieldTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('entity_schema_test'); + public static $modules = ['entity_schema_test']; /** * The module handler. @@ -35,7 +35,7 @@ class EntityBundleFieldTest extends EntityKernelTestBase { */ protected function setUp() { parent::setUp(); - $this->installSchema('user', array('users_data')); + $this->installSchema('user', ['users_data']); $this->moduleHandler = $this->container->get('module_handler'); $this->database = $this->container->get('database'); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php index 935fd7a..8178cec 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php @@ -40,17 +40,17 @@ class EntityCrudHookTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('block', 'block_test', 'entity_crud_hook_test', 'file', 'taxonomy', 'node', 'comment'); + public static $modules = ['block', 'block_test', 'entity_crud_hook_test', 'file', 'taxonomy', 'node', 'comment']; - protected $ids = array(); + protected $ids = []; protected function setUp() { parent::setUp(); - $this->installSchema('user', array('users_data')); - $this->installSchema('file', array('file_usage')); - $this->installSchema('node', array('node_access')); - $this->installSchema('comment', array('comment_entity_statistics')); + $this->installSchema('user', ['users_data']); + $this->installSchema('file', ['file_usage']); + $this->installSchema('node', ['node_access']); + $this->installSchema('comment', ['comment_entity_statistics']); $this->installConfig(['node', 'comment']); } @@ -64,7 +64,7 @@ protected function setUp() { * An array of plain-text messages in the order they should appear. */ protected function assertHookMessageOrder($messages) { - $positions = array(); + $positions = []; foreach ($messages as $message) { // Verify that each message is found and record its position. $position = array_search($message, $GLOBALS['entity_crud_hook_test']); @@ -83,55 +83,55 @@ protected function assertHookMessageOrder($messages) { * Tests hook invocations for CRUD operations on blocks. */ public function testBlockHooks() { - $entity = Block::create(array( + $entity = Block::create([ 'id' => 'stark_test_html', 'plugin' => 'test_html', 'theme' => 'stark', - )); + ]); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_block_create called', 'entity_crud_hook_test_entity_create called for type block', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $entity->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_block_presave called', 'entity_crud_hook_test_entity_presave called for type block', 'entity_crud_hook_test_block_insert called', 'entity_crud_hook_test_entity_insert called for type block', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $entity = Block::load($entity->id()); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_entity_load called for type block', 'entity_crud_hook_test_block_load called', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $entity->label = 'New label'; $entity->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_block_presave called', 'entity_crud_hook_test_entity_presave called for type block', 'entity_crud_hook_test_block_update called', 'entity_crud_hook_test_entity_update called for type block', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $entity->delete(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_block_predelete called', 'entity_crud_hook_test_entity_predelete called for type block', 'entity_crud_hook_test_block_delete called', 'entity_crud_hook_test_entity_delete called for type block', - )); + ]); } /** @@ -158,9 +158,9 @@ public function testCommentHooks() { ]); $node->save(); $nid = $node->id(); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; - $comment = Comment::create(array( + $comment = Comment::create([ 'cid' => NULL, 'pid' => 0, 'entity_id' => $nid, @@ -172,51 +172,51 @@ public function testCommentHooks() { 'changed' => REQUEST_TIME, 'status' => 1, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, - )); + ]); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_comment_create called', 'entity_crud_hook_test_entity_create called for type comment', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $comment->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_comment_presave called', 'entity_crud_hook_test_entity_presave called for type comment', 'entity_crud_hook_test_comment_insert called', 'entity_crud_hook_test_entity_insert called for type comment', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $comment = Comment::load($comment->id()); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_entity_load called for type comment', 'entity_crud_hook_test_comment_load called', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $comment->setSubject('New subject'); $comment->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_comment_presave called', 'entity_crud_hook_test_entity_presave called for type comment', 'entity_crud_hook_test_comment_update called', 'entity_crud_hook_test_entity_update called for type comment', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $comment->delete(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_comment_predelete called', 'entity_crud_hook_test_entity_predelete called for type comment', 'entity_crud_hook_test_comment_delete called', 'entity_crud_hook_test_entity_delete called for type comment', - )); + ]); } /** @@ -239,49 +239,49 @@ public function testFileHooks() { 'changed' => REQUEST_TIME, ]); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_file_create called', 'entity_crud_hook_test_entity_create called for type file', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $file->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_file_presave called', 'entity_crud_hook_test_entity_presave called for type file', 'entity_crud_hook_test_file_insert called', 'entity_crud_hook_test_entity_insert called for type file', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $file = File::load($file->id()); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_entity_load called for type file', 'entity_crud_hook_test_file_load called', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $file->setFilename('new.entity_crud_hook_test.file'); $file->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_file_presave called', 'entity_crud_hook_test_entity_presave called for type file', 'entity_crud_hook_test_file_update called', 'entity_crud_hook_test_entity_update called for type file', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $file->delete(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_file_predelete called', 'entity_crud_hook_test_entity_predelete called for type file', 'entity_crud_hook_test_file_delete called', 'entity_crud_hook_test_entity_delete called for type file', - )); + ]); } /** @@ -302,49 +302,49 @@ public function testNodeHooks() { 'changed' => REQUEST_TIME, ]); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_node_create called', 'entity_crud_hook_test_entity_create called for type node', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $node->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_node_presave called', 'entity_crud_hook_test_entity_presave called for type node', 'entity_crud_hook_test_node_insert called', 'entity_crud_hook_test_entity_insert called for type node', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $node = Node::load($node->id()); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_entity_load called for type node', 'entity_crud_hook_test_node_load called', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $node->title = 'New title'; $node->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_node_presave called', 'entity_crud_hook_test_entity_presave called for type node', 'entity_crud_hook_test_node_update called', 'entity_crud_hook_test_entity_update called for type node', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $node->delete(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_node_predelete called', 'entity_crud_hook_test_entity_predelete called for type node', 'entity_crud_hook_test_node_delete called', 'entity_crud_hook_test_entity_delete called for type node', - )); + ]); } /** @@ -361,7 +361,7 @@ public function testTaxonomyTermHooks() { 'module' => 'entity_crud_hook_test', ]); $vocabulary->save(); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $term = Term::create([ 'vid' => $vocabulary->id(), @@ -371,49 +371,49 @@ public function testTaxonomyTermHooks() { 'format' => 1, ]); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_taxonomy_term_create called', 'entity_crud_hook_test_entity_create called for type taxonomy_term', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $term->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_taxonomy_term_presave called', 'entity_crud_hook_test_entity_presave called for type taxonomy_term', 'entity_crud_hook_test_taxonomy_term_insert called', 'entity_crud_hook_test_entity_insert called for type taxonomy_term', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $term = Term::load($term->id()); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_entity_load called for type taxonomy_term', 'entity_crud_hook_test_taxonomy_term_load called', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $term->setName('New name'); $term->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_taxonomy_term_presave called', 'entity_crud_hook_test_entity_presave called for type taxonomy_term', 'entity_crud_hook_test_taxonomy_term_update called', 'entity_crud_hook_test_entity_update called for type taxonomy_term', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $term->delete(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_taxonomy_term_predelete called', 'entity_crud_hook_test_entity_predelete called for type taxonomy_term', 'entity_crud_hook_test_taxonomy_term_delete called', 'entity_crud_hook_test_entity_delete called for type taxonomy_term', - )); + ]); } /** @@ -430,49 +430,49 @@ public function testTaxonomyVocabularyHooks() { 'module' => 'entity_crud_hook_test', ]); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_taxonomy_vocabulary_create called', 'entity_crud_hook_test_entity_create called for type taxonomy_vocabulary', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $vocabulary->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_taxonomy_vocabulary_presave called', 'entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary', 'entity_crud_hook_test_taxonomy_vocabulary_insert called', 'entity_crud_hook_test_entity_insert called for type taxonomy_vocabulary', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $vocabulary = Vocabulary::load($vocabulary->id()); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_entity_load called for type taxonomy_vocabulary', 'entity_crud_hook_test_taxonomy_vocabulary_load called', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $vocabulary->set('name', 'New name'); $vocabulary->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_taxonomy_vocabulary_presave called', 'entity_crud_hook_test_entity_presave called for type taxonomy_vocabulary', 'entity_crud_hook_test_taxonomy_vocabulary_update called', 'entity_crud_hook_test_entity_update called for type taxonomy_vocabulary', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $vocabulary->delete(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_taxonomy_vocabulary_predelete called', 'entity_crud_hook_test_entity_predelete called for type taxonomy_vocabulary', 'entity_crud_hook_test_taxonomy_vocabulary_delete called', 'entity_crud_hook_test_entity_delete called for type taxonomy_vocabulary', - )); + ]); } /** @@ -487,49 +487,49 @@ public function testUserHooks() { 'language' => 'en', ]); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_user_create called', 'entity_crud_hook_test_entity_create called for type user', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $account->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_user_presave called', 'entity_crud_hook_test_entity_presave called for type user', 'entity_crud_hook_test_user_insert called', 'entity_crud_hook_test_entity_insert called for type user', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; User::load($account->id()); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_entity_load called for type user', 'entity_crud_hook_test_user_load called', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; $account->name = 'New name'; $account->save(); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_user_presave called', 'entity_crud_hook_test_entity_presave called for type user', 'entity_crud_hook_test_user_update called', 'entity_crud_hook_test_entity_update called for type user', - )); + ]); - $GLOBALS['entity_crud_hook_test'] = array(); + $GLOBALS['entity_crud_hook_test'] = []; user_delete($account->id()); - $this->assertHookMessageOrder(array( + $this->assertHookMessageOrder([ 'entity_crud_hook_test_user_predelete called', 'entity_crud_hook_test_entity_predelete called for type user', 'entity_crud_hook_test_user_delete called', 'entity_crud_hook_test_entity_delete called for type user', - )); + ]); } /** @@ -538,7 +538,7 @@ public function testUserHooks() { function testEntityRollback() { // Create a block. try { - EntityTest::create(array('name' => 'fail_insert'))->save(); + EntityTest::create(['name' => 'fail_insert'])->save(); $this->fail('Expected exception has not been thrown.'); } catch (\Exception $e) { diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php index e49ee7e..e37a4e0 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php @@ -49,7 +49,7 @@ protected function setUp() { // Install every entity type's schema that wasn't installed in the parent // method. - foreach (array_diff_key($this->entityManager->getDefinitions(), array_flip(array('user', 'entity_test'))) as $entity_type_id => $entity_type) { + foreach (array_diff_key($this->entityManager->getDefinitions(), array_flip(['user', 'entity_test'])) as $entity_type_id => $entity_type) { $this->installEntitySchema($entity_type_id); } } @@ -80,7 +80,7 @@ public function testNewEntityType() { public function testNoUpdates() { // Ensure that the definition update manager reports no updates. $this->assertFalse($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that no updates are needed.'); - $this->assertIdentical($this->entityDefinitionUpdateManager->getChangeSummary(), array(), 'EntityDefinitionUpdateManager reports an empty change summary.'); + $this->assertIdentical($this->entityDefinitionUpdateManager->getChangeSummary(), [], 'EntityDefinitionUpdateManager reports an empty change summary.'); // Ensure that applyUpdates() runs without error (it's not expected to do // anything when there aren't updates). @@ -99,14 +99,14 @@ public function testEntityTypeUpdateWithoutData() { // reports that an update is needed. $this->updateEntityTypeToRevisionable(); $this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.'); - $expected = array( - 'entity_test_update' => array( + $expected = [ + 'entity_test_update' => [ t('The %entity_type entity type needs to be updated.', ['%entity_type' => $this->entityManager->getDefinition('entity_test_update')->getLabel()]), // The revision key is now defined, so the revision field needs to be // created. t('The %field_name field needs to be installed.', ['%field_name' => 'Revision ID']), - ), - ); + ], + ]; $this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected); //, 'EntityDefinitionUpdateManager reports the expected change summary.'); // Run the update and ensure the revision table is created. @@ -141,11 +141,11 @@ public function testBaseFieldCreateUpdateDeleteWithoutData() { // creates its schema. $this->addBaseField(); $this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.'); - $expected = array( - 'entity_test_update' => array( + $expected = [ + 'entity_test_update' => [ t('The %field_name field needs to be installed.', ['%field_name' => t('A new base field')]), - ), - ); + ], + ]; $this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.'); $this->entityDefinitionUpdateManager->applyUpdates(); $this->assertTrue($this->database->schema()->fieldExists('entity_test_update', 'new_base_field'), 'Column created in shared table for new_base_field.'); @@ -154,11 +154,11 @@ public function testBaseFieldCreateUpdateDeleteWithoutData() { // and the update creates it. $this->addBaseFieldIndex(); $this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.'); - $expected = array( - 'entity_test_update' => array( + $expected = [ + 'entity_test_update' => [ t('The %field_name field needs to be updated.', ['%field_name' => t('A new base field')]), - ), - ); + ], + ]; $this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.'); $this->entityDefinitionUpdateManager->applyUpdates(); $this->assertTrue($this->database->schema()->indexExists('entity_test_update', 'entity_test_update_field__new_base_field'), 'Index created.'); @@ -167,11 +167,11 @@ public function testBaseFieldCreateUpdateDeleteWithoutData() { // update deletes it. $this->removeBaseFieldIndex(); $this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.'); - $expected = array( - 'entity_test_update' => array( + $expected = [ + 'entity_test_update' => [ t('The %field_name field needs to be updated.', ['%field_name' => t('A new base field')]), - ), - ); + ], + ]; $this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.'); $this->entityDefinitionUpdateManager->applyUpdates(); $this->assertFalse($this->database->schema()->indexExists('entity_test_update', 'entity_test_update_field__new_base_field'), 'Index deleted.'); @@ -181,11 +181,11 @@ public function testBaseFieldCreateUpdateDeleteWithoutData() { // accordingly. $this->modifyBaseField(); $this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.'); - $expected = array( - 'entity_test_update' => array( + $expected = [ + 'entity_test_update' => [ t('The %field_name field needs to be updated.', ['%field_name' => t('A new base field')]), - ), - ); + ], + ]; $this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.'); $this->entityDefinitionUpdateManager->applyUpdates(); $this->assertFalse($this->database->schema()->fieldExists('entity_test_update', 'new_base_field'), 'Original column deleted in shared table for new_base_field.'); @@ -196,11 +196,11 @@ public function testBaseFieldCreateUpdateDeleteWithoutData() { // update deletes the schema. $this->removeBaseField(); $this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.'); - $expected = array( - 'entity_test_update' => array( + $expected = [ + 'entity_test_update' => [ t('The %field_name field needs to be uninstalled.', ['%field_name' => t('A new base field')]), - ), - ); + ], + ]; $this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.'); $this->entityDefinitionUpdateManager->applyUpdates(); $this->assertFalse($this->database->schema()->fieldExists('entity_test_update', 'new_base_field_value'), 'Value column deleted from shared table for new_base_field.'); @@ -215,11 +215,11 @@ public function testBundleFieldCreateUpdateDeleteWithoutData() { // creates its schema. $this->addBundleField(); $this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.'); - $expected = array( - 'entity_test_update' => array( + $expected = [ + 'entity_test_update' => [ t('The %field_name field needs to be installed.', ['%field_name' => t('A new bundle field')]), - ), - ); + ], + ]; $this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.'); $this->entityDefinitionUpdateManager->applyUpdates(); $this->assertTrue($this->database->schema()->tableExists('entity_test_update__new_bundle_field'), 'Dedicated table created for new_bundle_field.'); @@ -229,11 +229,11 @@ public function testBundleFieldCreateUpdateDeleteWithoutData() { // accordingly. $this->modifyBundleField(); $this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.'); - $expected = array( + $expected = [ 'entity_test_update' => [ t('The %field_name field needs to be updated.', ['%field_name' => t('A new bundle field')]), ], - ); + ]; $this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.'); $this->entityDefinitionUpdateManager->applyUpdates(); $this->assertTrue($this->database->schema()->fieldExists('entity_test_update__new_bundle_field', 'new_bundle_field_format'), 'Format column created in dedicated table for new_base_field.'); @@ -242,11 +242,11 @@ public function testBundleFieldCreateUpdateDeleteWithoutData() { // update deletes the schema. $this->removeBundleField(); $this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.'); - $expected = array( - 'entity_test_update' => array( + $expected = [ + 'entity_test_update' => [ t('The %field_name field needs to be uninstalled.', ['%field_name' => t('A new bundle field')]), - ), - ); + ], + ]; $this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.'); $this->entityDefinitionUpdateManager->applyUpdates(); $this->assertFalse($this->database->schema()->tableExists('entity_test_update__new_bundle_field'), 'Dedicated table deleted for new_bundle_field.'); @@ -264,7 +264,7 @@ public function testBaseFieldCreateDeleteWithExistingEntities() { // Save an entity. $name = $this->randomString(); $storage = $this->entityManager->getStorage('entity_test_update'); - $entity = $storage->create(array('name' => $name)); + $entity = $storage->create(['name' => $name]); $entity->save(); // Add a base field and run the update. Ensure the base field's column is @@ -304,7 +304,7 @@ public function testBaseFieldCreateDeleteWithExistingEntities() { $this->entityDefinitionUpdateManager->applyUpdates(); $assert = $schema_handler->fieldExists('entity_test_update', 'new_base_field__shape') && $schema_handler->fieldExists('entity_test_update', 'new_base_field__color'); $this->assertTrue($assert, 'Columns created again in shared table for new_base_field.'); - $entity = $storage->create(array('name' => $name)); + $entity = $storage->create(['name' => $name]); $entity->save(); $this->pass('The new_base_field columns are still nullable'); } @@ -321,7 +321,7 @@ public function testBundleFieldCreateDeleteWithExistingEntities() { // Save an entity. $name = $this->randomString(); $storage = $this->entityManager->getStorage('entity_test_update'); - $entity = $storage->create(array('name' => $name)); + $entity = $storage->create(['name' => $name]); $entity->save(); // Add a bundle field and run the update. Ensure the bundle field's table @@ -345,7 +345,7 @@ public function testBundleFieldCreateDeleteWithExistingEntities() { $this->addBundleField('shape_required'); $this->entityDefinitionUpdateManager->applyUpdates(); $message = 'The new_bundle_field_shape column is not nullable.'; - $values = array( + $values = [ 'bundle' => $entity->bundle(), 'deleted' => 0, 'entity_id' => $entity->id(), @@ -353,7 +353,7 @@ public function testBundleFieldCreateDeleteWithExistingEntities() { 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'delta' => 0, 'new_bundle_field_color' => $this->randomString(), - ); + ]; try { // Try to insert a record without providing a value for the 'not null' // column. This should fail. @@ -388,7 +388,7 @@ public function testBaseFieldDeleteWithExistingData() { $this->entityDefinitionUpdateManager->applyUpdates(); // Save an entity with the base field populated. - $this->entityManager->getStorage('entity_test_update')->create(array('new_base_field' => 'foo'))->save(); + $this->entityManager->getStorage('entity_test_update')->create(['new_base_field' => 'foo'])->save(); // Remove the base field and apply updates. It's expected to throw an // exception. @@ -414,7 +414,7 @@ public function testBundleFieldDeleteWithExistingData() { // Save an entity with the bundle field populated. entity_test_create_bundle('custom'); - $this->entityManager->getStorage('entity_test_update')->create(array('type' => 'test_bundle', 'new_bundle_field' => 'foo'))->save(); + $this->entityManager->getStorage('entity_test_update')->create(['type' => 'test_bundle', 'new_bundle_field' => 'foo'])->save(); // Remove the bundle field and apply updates. It's expected to throw an // exception. @@ -439,7 +439,7 @@ public function testBaseFieldUpdateWithExistingData() { $this->entityDefinitionUpdateManager->applyUpdates(); // Save an entity with the base field populated. - $this->entityManager->getStorage('entity_test_update')->create(array('new_base_field' => 'foo'))->save(); + $this->entityManager->getStorage('entity_test_update')->create(['new_base_field' => 'foo'])->save(); // Change the field's field type and apply updates. It's expected to // throw an exception. @@ -463,7 +463,7 @@ public function testBundleFieldUpdateWithExistingData() { // Save an entity with the bundle field populated. entity_test_create_bundle('custom'); - $this->entityManager->getStorage('entity_test_update')->create(array('type' => 'test_bundle', 'new_bundle_field' => 'foo'))->save(); + $this->entityManager->getStorage('entity_test_update')->create(['type' => 'test_bundle', 'new_bundle_field' => 'foo'])->save(); // Change the field's field type and apply updates. It's expected to // throw an exception. @@ -485,11 +485,11 @@ public function testEntityIndexCreateDeleteWithoutData() { // update to the entity type. $this->addEntityIndex(); $this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.'); - $expected = array( - 'entity_test_update' => array( + $expected = [ + 'entity_test_update' => [ t('The %entity_type entity type needs to be updated.', ['%entity_type' => $this->entityManager->getDefinition('entity_test_update')->getLabel()]), - ), - ); + ], + ]; $this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.'); // Run the update and ensure the new index is created. @@ -500,11 +500,11 @@ public function testEntityIndexCreateDeleteWithoutData() { // update to the entity type. $this->removeEntityIndex(); $this->assertTrue($this->entityDefinitionUpdateManager->needsUpdates(), 'EntityDefinitionUpdateManager reports that updates are needed.'); - $expected = array( - 'entity_test_update' => array( + $expected = [ + 'entity_test_update' => [ t('The %entity_type entity type needs to be updated.', ['%entity_type' => $this->entityManager->getDefinition('entity_test_update')->getLabel()]), - ), - ); + ], + ]; $this->assertEqual($this->entityDefinitionUpdateManager->getChangeSummary(), $expected, 'EntityDefinitionUpdateManager reports the expected change summary.'); // Run the update and ensure the index is deleted. @@ -530,7 +530,7 @@ public function testEntityIndexCreateDeleteWithoutData() { public function testEntityIndexCreateWithData() { // Save an entity. $name = $this->randomString(); - $entity = $this->entityManager->getStorage('entity_test_update')->create(array('name' => $name)); + $entity = $this->entityManager->getStorage('entity_test_update')->create(['name' => $name]); $entity->save(); // Add an entity index, run the update. Ensure that the index is created @@ -732,13 +732,13 @@ public function testCreateIndexUsingEntityStorageSchemaWithData() { // Save an entity. $name = $this->randomString(); $storage = $this->entityManager->getStorage('entity_test_update'); - $entity = $storage->create(array('name' => $name)); + $entity = $storage->create(['name' => $name]); $entity->save(); // Create an index. - $indexes = array( - 'entity_test_update__type_index' => array('type'), - ); + $indexes = [ + 'entity_test_update__type_index' => ['type'], + ]; $this->state->set('entity_test_update.additional_entity_indexes', $indexes); $this->entityDefinitionUpdateManager->applyUpdates(); $this->assertTrue($this->database->schema()->indexExists('entity_test_update', 'entity_test_update__type_index'), "New index 'entity_test_update__type_index' has been created on the 'entity_test_update' table."); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php index c806409..c300b48 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldDefaultValueTest.php @@ -47,9 +47,9 @@ protected function assertDefaultValues($entity_type_id) { ->create(); $definition = $this->entityManager->getDefinition($entity_type_id); $langcode_key = $definition->getKey('langcode'); - $this->assertEqual($entity->{$langcode_key}->value, 'en', SafeMarkup::format('%entity_type: Default language', array('%entity_type' => $entity_type_id))); - $this->assertTrue(Uuid::isValid($entity->uuid->value), SafeMarkup::format('%entity_type: Default UUID', array('%entity_type' => $entity_type_id))); - $this->assertEqual($entity->name->getValue(), array(), 'Field has one empty value by default.'); + $this->assertEqual($entity->{$langcode_key}->value, 'en', SafeMarkup::format('%entity_type: Default language', ['%entity_type' => $entity_type_id])); + $this->assertTrue(Uuid::isValid($entity->uuid->value), SafeMarkup::format('%entity_type: Default UUID', ['%entity_type' => $entity_type_id])); + $this->assertEqual($entity->name->getValue(), [], 'Field has one empty value by default.'); } /** @@ -60,16 +60,16 @@ public function testDefaultValueCallback() { // The description field has a default value callback for testing, see // entity_test_field_default_value(). $string = 'description_' . $entity->language()->getId(); - $expected = array( - array( + $expected = [ + [ 'shape' => "shape:0:$string", 'color' => "color:0:$string", - ), - array( + ], + [ 'shape' => "shape:1:$string", 'color' => "color:1:$string", - ), - ); + ], + ]; $this->assertEqual($entity->description->getValue(), $expected); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php index 5dc1a94..e0bf655 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php @@ -31,7 +31,7 @@ class EntityFieldTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('filter', 'text', 'node', 'user', 'field_test'); + public static $modules = ['filter', 'text', 'node', 'user', 'field_test']; /** * @var string @@ -63,7 +63,7 @@ protected function setUp() { entity_test_install(); // Install required default configuration for filter module. - $this->installConfig(array('system', 'filter')); + $this->installConfig(['system', 'filter']); } /** @@ -112,108 +112,108 @@ protected function doTestReadWrite($entity_type) { $langcode = 'en'; // Access the name field. - $this->assertTrue($entity->name instanceof FieldItemListInterface, format_string('%entity_type: Field implements interface', array('%entity_type' => $entity_type))); - $this->assertTrue($entity->name[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', array('%entity_type' => $entity_type))); + $this->assertTrue($entity->name instanceof FieldItemListInterface, format_string('%entity_type: Field implements interface', ['%entity_type' => $entity_type])); + $this->assertTrue($entity->name[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', ['%entity_type' => $entity_type])); - $this->assertEqual($this->entityName, $entity->name->value, format_string('%entity_type: Name value can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entityName, $entity->name[0]->value, format_string('%entity_type: Name value can be read through list access.', array('%entity_type' => $entity_type))); - $this->assertEqual($entity->name->getValue(), array(0 => array('value' => $this->entityName)), format_string('%entity_type: Plain field value returned.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entityName, $entity->name->value, format_string('%entity_type: Name value can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual($this->entityName, $entity->name[0]->value, format_string('%entity_type: Name value can be read through list access.', ['%entity_type' => $entity_type])); + $this->assertEqual($entity->name->getValue(), [0 => ['value' => $this->entityName]], format_string('%entity_type: Plain field value returned.', ['%entity_type' => $entity_type])); // Change the name. $new_name = $this->randomMachineName(); $entity->name->value = $new_name; - $this->assertEqual($new_name, $entity->name->value, format_string('%entity_type: Name can be updated and read.', array('%entity_type' => $entity_type))); - $this->assertEqual($entity->name->getValue(), array(0 => array('value' => $new_name)), format_string('%entity_type: Plain field value reflects the update.', array('%entity_type' => $entity_type))); + $this->assertEqual($new_name, $entity->name->value, format_string('%entity_type: Name can be updated and read.', ['%entity_type' => $entity_type])); + $this->assertEqual($entity->name->getValue(), [0 => ['value' => $new_name]], format_string('%entity_type: Plain field value reflects the update.', ['%entity_type' => $entity_type])); $new_name = $this->randomMachineName(); $entity->name[0]->value = $new_name; - $this->assertEqual($new_name, $entity->name->value, format_string('%entity_type: Name can be updated and read through list access.', array('%entity_type' => $entity_type))); + $this->assertEqual($new_name, $entity->name->value, format_string('%entity_type: Name can be updated and read through list access.', ['%entity_type' => $entity_type])); // Access the user field. - $this->assertTrue($entity->user_id instanceof FieldItemListInterface, format_string('%entity_type: Field implements interface', array('%entity_type' => $entity_type))); - $this->assertTrue($entity->user_id[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', array('%entity_type' => $entity_type))); + $this->assertTrue($entity->user_id instanceof FieldItemListInterface, format_string('%entity_type: Field implements interface', ['%entity_type' => $entity_type])); + $this->assertTrue($entity->user_id[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', ['%entity_type' => $entity_type])); - $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', ['%entity_type' => $entity_type])); // Change the assigned user by entity. $new_user1 = $this->createUser(); $entity->user_id->entity = $new_user1; - $this->assertEqual($new_user1->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($new_user1->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated username value can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($new_user1->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual($new_user1->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated username value can be read.', ['%entity_type' => $entity_type])); // Change the assigned user by id. $new_user2 = $this->createUser(); $entity->user_id->target_id = $new_user2->id(); - $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated username value can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated username value can be read.', ['%entity_type' => $entity_type])); // Try unsetting a field property. $entity->name->value = NULL; $entity->user_id->target_id = NULL; - $this->assertNull($entity->name->value, format_string('%entity_type: Name field is not set.', array('%entity_type' => $entity_type))); - $this->assertNull($entity->user_id->target_id, format_string('%entity_type: User ID field is not set.', array('%entity_type' => $entity_type))); - $this->assertNull($entity->user_id->entity, format_string('%entity_type: User entity field is not set.', array('%entity_type' => $entity_type))); + $this->assertNull($entity->name->value, format_string('%entity_type: Name field is not set.', ['%entity_type' => $entity_type])); + $this->assertNull($entity->user_id->target_id, format_string('%entity_type: User ID field is not set.', ['%entity_type' => $entity_type])); + $this->assertNull($entity->user_id->entity, format_string('%entity_type: User entity field is not set.', ['%entity_type' => $entity_type])); // Test setting the values via the typed data API works as well. // Change the assigned user by entity. $entity->user_id->first()->get('entity')->setValue($new_user2); - $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', ['%entity_type' => $entity_type])); // Change the assigned user by id. $entity->user_id->first()->get('target_id')->setValue($new_user2->id()); - $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($new_user2->id(), $entity->user_id->target_id, format_string('%entity_type: Updated user id can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual($new_user2->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', ['%entity_type' => $entity_type])); // Try unsetting a field. $entity->name->first()->get('value')->setValue(NULL); $entity->user_id->first()->get('target_id')->setValue(NULL); - $this->assertNull($entity->name->value, format_string('%entity_type: Name field is not set.', array('%entity_type' => $entity_type))); - $this->assertNull($entity->user_id->target_id, format_string('%entity_type: User ID field is not set.', array('%entity_type' => $entity_type))); - $this->assertNull($entity->user_id->entity, format_string('%entity_type: User entity field is not set.', array('%entity_type' => $entity_type))); + $this->assertNull($entity->name->value, format_string('%entity_type: Name field is not set.', ['%entity_type' => $entity_type])); + $this->assertNull($entity->user_id->target_id, format_string('%entity_type: User ID field is not set.', ['%entity_type' => $entity_type])); + $this->assertNull($entity->user_id->entity, format_string('%entity_type: User entity field is not set.', ['%entity_type' => $entity_type])); // Create a fresh entity so target_id does not get its property object // instantiated, then verify setting a new value via typed data API works. $entity2 = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array( - 'user_id' => array('target_id' => $new_user1->id()), - )); + ->create([ + 'user_id' => ['target_id' => $new_user1->id()], + ]); // Access the property object, and set a value. $entity2->user_id->first()->get('target_id')->setValue($new_user2->id()); - $this->assertEqual($new_user2->id(), $entity2->user_id->target_id, format_string('%entity_type: Updated user id can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($new_user2->name->value, $entity2->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($new_user2->id(), $entity2->user_id->target_id, format_string('%entity_type: Updated user id can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual($new_user2->name->value, $entity2->user_id->entity->name->value, format_string('%entity_type: Updated user name value can be read.', ['%entity_type' => $entity_type])); // Test using isset(), empty() and unset(). $entity->name->value = 'test unset'; unset($entity->name->value); - $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type))); - $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type))); - $this->assertTrue(empty($entity->name->value), format_string('%entity_type: Name is empty.', array('%entity_type' => $entity_type))); - $this->assertTrue(empty($entity->name[0]->value), format_string('%entity_type: Name is empty.', array('%entity_type' => $entity_type))); + $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name is not set.', ['%entity_type' => $entity_type])); + $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: Name is not set.', ['%entity_type' => $entity_type])); + $this->assertTrue(empty($entity->name->value), format_string('%entity_type: Name is empty.', ['%entity_type' => $entity_type])); + $this->assertTrue(empty($entity->name[0]->value), format_string('%entity_type: Name is empty.', ['%entity_type' => $entity_type])); $entity->name->value = 'a value'; - $this->assertTrue(isset($entity->name->value), format_string('%entity_type: Name is set.', array('%entity_type' => $entity_type))); - $this->assertTrue(isset($entity->name[0]->value), format_string('%entity_type: Name is set.', array('%entity_type' => $entity_type))); - $this->assertFalse(empty($entity->name->value), format_string('%entity_type: Name is not empty.', array('%entity_type' => $entity_type))); - $this->assertFalse(empty($entity->name[0]->value), format_string('%entity_type: Name is not empty.', array('%entity_type' => $entity_type))); - $this->assertTrue(isset($entity->name[0]), format_string('%entity_type: Name string item is set.', array('%entity_type' => $entity_type))); - $this->assertFalse(isset($entity->name[1]), format_string('%entity_type: Second name string item is not set as it does not exist', array('%entity_type' => $entity_type))); - $this->assertTrue(isset($entity->name), format_string('%entity_type: Name field is set.', array('%entity_type' => $entity_type))); - $this->assertFalse(isset($entity->nameInvalid), format_string('%entity_type: Not existing field is not set.', array('%entity_type' => $entity_type))); + $this->assertTrue(isset($entity->name->value), format_string('%entity_type: Name is set.', ['%entity_type' => $entity_type])); + $this->assertTrue(isset($entity->name[0]->value), format_string('%entity_type: Name is set.', ['%entity_type' => $entity_type])); + $this->assertFalse(empty($entity->name->value), format_string('%entity_type: Name is not empty.', ['%entity_type' => $entity_type])); + $this->assertFalse(empty($entity->name[0]->value), format_string('%entity_type: Name is not empty.', ['%entity_type' => $entity_type])); + $this->assertTrue(isset($entity->name[0]), format_string('%entity_type: Name string item is set.', ['%entity_type' => $entity_type])); + $this->assertFalse(isset($entity->name[1]), format_string('%entity_type: Second name string item is not set as it does not exist', ['%entity_type' => $entity_type])); + $this->assertTrue(isset($entity->name), format_string('%entity_type: Name field is set.', ['%entity_type' => $entity_type])); + $this->assertFalse(isset($entity->nameInvalid), format_string('%entity_type: Not existing field is not set.', ['%entity_type' => $entity_type])); unset($entity->name[0]); - $this->assertFalse(isset($entity->name[0]), format_string('%entity_type: Name field item is not set.', array('%entity_type' => $entity_type))); - $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type))); - $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name is not set.', array('%entity_type' => $entity_type))); + $this->assertFalse(isset($entity->name[0]), format_string('%entity_type: Name field item is not set.', ['%entity_type' => $entity_type])); + $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: Name is not set.', ['%entity_type' => $entity_type])); + $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name is not set.', ['%entity_type' => $entity_type])); // Test emptying a field by assigning an empty value. NULL and array() // behave the same. - foreach ([NULL, array(), 'unset'] as $empty) { + foreach ([NULL, [], 'unset'] as $empty) { // Make sure a value is present $entity->name->value = 'a value'; - $this->assertTrue(isset($entity->name->value), format_string('%entity_type: Name is set.', array('%entity_type' => $entity_type))); + $this->assertTrue(isset($entity->name->value), format_string('%entity_type: Name is set.', ['%entity_type' => $entity_type])); // Now, empty the field. if ($empty === 'unset') { unset($entity->name); @@ -221,36 +221,36 @@ protected function doTestReadWrite($entity_type) { else { $entity->name = $empty; } - $this->assertTrue(isset($entity->name), format_string('%entity_type: Name field is set.', array('%entity_type' => $entity_type))); - $this->assertTrue($entity->name->isEmpty(), format_string('%entity_type: Name field is set.', array('%entity_type' => $entity_type))); - $this->assertIdentical(count($entity->name), 0, format_string('%entity_type: Name field contains no items.', array('%entity_type' => $entity_type))); - $this->assertIdentical($entity->name->getValue(), array(), format_string('%entity_type: Name field value is an empty array.', array('%entity_type' => $entity_type))); - $this->assertFalse(isset($entity->name[0]), format_string('%entity_type: Name field item is not set.', array('%entity_type' => $entity_type))); - $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: First name item value is not set.', array('%entity_type' => $entity_type))); - $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name value is not set.', array('%entity_type' => $entity_type))); + $this->assertTrue(isset($entity->name), format_string('%entity_type: Name field is set.', ['%entity_type' => $entity_type])); + $this->assertTrue($entity->name->isEmpty(), format_string('%entity_type: Name field is set.', ['%entity_type' => $entity_type])); + $this->assertIdentical(count($entity->name), 0, format_string('%entity_type: Name field contains no items.', ['%entity_type' => $entity_type])); + $this->assertIdentical($entity->name->getValue(), [], format_string('%entity_type: Name field value is an empty array.', ['%entity_type' => $entity_type])); + $this->assertFalse(isset($entity->name[0]), format_string('%entity_type: Name field item is not set.', ['%entity_type' => $entity_type])); + $this->assertFalse(isset($entity->name[0]->value), format_string('%entity_type: First name item value is not set.', ['%entity_type' => $entity_type])); + $this->assertFalse(isset($entity->name->value), format_string('%entity_type: Name value is not set.', ['%entity_type' => $entity_type])); } // Access the language field. $langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode'); - $this->assertEqual($langcode, $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(\Drupal::languageManager()->getLanguage($langcode), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($langcode, $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual(\Drupal::languageManager()->getLanguage($langcode), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', ['%entity_type' => $entity_type])); // Change the language by code. $entity->{$langcode_key}->value = \Drupal::languageManager()->getDefaultLanguage()->getId(); - $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', ['%entity_type' => $entity_type])); // Revert language by code then try setting it by language object. $entity->{$langcode_key}->value = $langcode; $entity->{$langcode_key}->language = \Drupal::languageManager()->getDefaultLanguage(); - $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage()->getId(), $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', ['%entity_type' => $entity_type])); // Access the text field and test updating. - $this->assertEqual($entity->field_test_text->value, $this->entityFieldText, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->field_test_text->value, $this->entityFieldText, format_string('%entity_type: Text field can be read.', ['%entity_type' => $entity_type])); $new_text = $this->randomMachineName(); $entity->field_test_text->value = $new_text; - $this->assertEqual($entity->field_test_text->value, $new_text, format_string('%entity_type: Updated text field can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->field_test_text->value, $new_text, format_string('%entity_type: Updated text field can be read.', ['%entity_type' => $entity_type])); // Test creating the entity by passing in plain values. $this->entityName = $this->randomMachineName(); @@ -262,98 +262,98 @@ protected function doTestReadWrite($entity_type) { $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array( + ->create([ 'name' => $name_item, 'user_id' => $user_item, 'field_test_text' => $text_item, - )); - $this->assertEqual($this->entityName, $entity->name->value, format_string('%entity_type: Name value can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entityFieldText, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); + ]); + $this->assertEqual($this->entityName, $entity->name->value, format_string('%entity_type: Name value can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual($this->entityFieldText, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', ['%entity_type' => $entity_type])); // Tests copying field values by assigning the TypedData objects. $entity2 = $this->createTestEntity($entity_type); $entity2->name = $entity->name; $entity2->user_id = $entity->user_id; $entity2->field_test_text = $entity->field_test_text; - $this->assertFalse($entity->name === $entity2->name, format_string('%entity_type: Copying properties results in a different field object.', array('%entity_type' => $entity_type))); - $this->assertEqual($entity->name->value, $entity2->name->value, format_string('%entity_type: Name field copied.', array('%entity_type' => $entity_type))); - $this->assertEqual($entity->user_id->target_id, $entity2->user_id->target_id, format_string('%entity_type: User id field copied.', array('%entity_type' => $entity_type))); - $this->assertEqual($entity->field_test_text->value, $entity2->field_test_text->value, format_string('%entity_type: Text field copied.', array('%entity_type' => $entity_type))); + $this->assertFalse($entity->name === $entity2->name, format_string('%entity_type: Copying properties results in a different field object.', ['%entity_type' => $entity_type])); + $this->assertEqual($entity->name->value, $entity2->name->value, format_string('%entity_type: Name field copied.', ['%entity_type' => $entity_type])); + $this->assertEqual($entity->user_id->target_id, $entity2->user_id->target_id, format_string('%entity_type: User id field copied.', ['%entity_type' => $entity_type])); + $this->assertEqual($entity->field_test_text->value, $entity2->field_test_text->value, format_string('%entity_type: Text field copied.', ['%entity_type' => $entity_type])); // Tests that assigning TypedData objects to non-field properties keeps the // assigned value as is. $entity2 = $this->createTestEntity($entity_type); $entity2->_not_a_field = $entity->name; - $this->assertTrue($entity2->_not_a_field === $entity->name, format_string('%entity_type: Typed data objects can be copied to non-field properties as is.', array('%entity_type' => $entity_type))); + $this->assertTrue($entity2->_not_a_field === $entity->name, format_string('%entity_type: Typed data objects can be copied to non-field properties as is.', ['%entity_type' => $entity_type])); // Tests adding a value to a field item list. $entity->name[] = 'Another name'; - $this->assertEqual($entity->name[1]->value, 'Another name', format_string('%entity_type: List item added via [] and the first property.', array('%entity_type' => $entity_type))); - $entity->name[] = array('value' => 'Third name'); - $this->assertEqual($entity->name[2]->value, 'Third name', format_string('%entity_type: List item added via [] and an array of properties.', array('%entity_type' => $entity_type))); - $entity->name[3] = array('value' => 'Fourth name'); - $this->assertEqual($entity->name[3]->value, 'Fourth name', format_string('%entity_type: List item added via offset and an array of properties.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->name[1]->value, 'Another name', format_string('%entity_type: List item added via [] and the first property.', ['%entity_type' => $entity_type])); + $entity->name[] = ['value' => 'Third name']; + $this->assertEqual($entity->name[2]->value, 'Third name', format_string('%entity_type: List item added via [] and an array of properties.', ['%entity_type' => $entity_type])); + $entity->name[3] = ['value' => 'Fourth name']; + $this->assertEqual($entity->name[3]->value, 'Fourth name', format_string('%entity_type: List item added via offset and an array of properties.', ['%entity_type' => $entity_type])); unset($entity->name[3]); // Test removing and empty-ing list items. - $this->assertEqual(count($entity->name), 3, format_string('%entity_type: List has 3 items.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($entity->name), 3, format_string('%entity_type: List has 3 items.', ['%entity_type' => $entity_type])); unset($entity->name[1]); - $this->assertEqual(count($entity->name), 2, format_string('%entity_type: Second list item has been removed.', array('%entity_type' => $entity_type))); - $this->assertEqual($entity->name[1]->value, 'Third name', format_string('%entity_type: The subsequent items have been shifted up.', array('%entity_type' => $entity_type))); - $this->assertEqual($entity->name[1]->getName(), 1, format_string('%entity_type: The items names have been updated to their new delta.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($entity->name), 2, format_string('%entity_type: Second list item has been removed.', ['%entity_type' => $entity_type])); + $this->assertEqual($entity->name[1]->value, 'Third name', format_string('%entity_type: The subsequent items have been shifted up.', ['%entity_type' => $entity_type])); + $this->assertEqual($entity->name[1]->getName(), 1, format_string('%entity_type: The items names have been updated to their new delta.', ['%entity_type' => $entity_type])); $entity->name[1] = NULL; - $this->assertEqual(count($entity->name), 2, format_string('%entity_type: Assigning NULL does not reduce array count.', array('%entity_type' => $entity_type))); - $this->assertTrue($entity->name[1]->isEmpty(), format_string('%entity_type: Assigning NULL empties the item.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($entity->name), 2, format_string('%entity_type: Assigning NULL does not reduce array count.', ['%entity_type' => $entity_type])); + $this->assertTrue($entity->name[1]->isEmpty(), format_string('%entity_type: Assigning NULL empties the item.', ['%entity_type' => $entity_type])); // Test using isEmpty(). unset($entity->name[1]); - $this->assertFalse($entity->name[0]->isEmpty(), format_string('%entity_type: Name item is not empty.', array('%entity_type' => $entity_type))); + $this->assertFalse($entity->name[0]->isEmpty(), format_string('%entity_type: Name item is not empty.', ['%entity_type' => $entity_type])); $entity->name->value = NULL; - $this->assertTrue($entity->name[0]->isEmpty(), format_string('%entity_type: Name item is empty.', array('%entity_type' => $entity_type))); - $this->assertTrue($entity->name->isEmpty(), format_string('%entity_type: Name field is empty.', array('%entity_type' => $entity_type))); - $this->assertEqual(count($entity->name), 1, format_string('%entity_type: Empty item is considered when counting.', array('%entity_type' => $entity_type))); - $this->assertEqual(count(iterator_to_array($entity->name->getIterator())), count($entity->name), format_string('%entity_type: Count matches iterator count.', array('%entity_type' => $entity_type))); - $this->assertTrue($entity->name->getValue() === array(0 => array('value' => NULL)), format_string('%entity_type: Name field value contains a NULL value.', array('%entity_type' => $entity_type))); + $this->assertTrue($entity->name[0]->isEmpty(), format_string('%entity_type: Name item is empty.', ['%entity_type' => $entity_type])); + $this->assertTrue($entity->name->isEmpty(), format_string('%entity_type: Name field is empty.', ['%entity_type' => $entity_type])); + $this->assertEqual(count($entity->name), 1, format_string('%entity_type: Empty item is considered when counting.', ['%entity_type' => $entity_type])); + $this->assertEqual(count(iterator_to_array($entity->name->getIterator())), count($entity->name), format_string('%entity_type: Count matches iterator count.', ['%entity_type' => $entity_type])); + $this->assertTrue($entity->name->getValue() === [0 => ['value' => NULL]], format_string('%entity_type: Name field value contains a NULL value.', ['%entity_type' => $entity_type])); // Test using filterEmptyItems(). - $entity->name = array(NULL, 'foo'); - $this->assertEqual(count($entity->name), 2, format_string('%entity_type: List has 2 items.', array('%entity_type' => $entity_type))); + $entity->name = [NULL, 'foo']; + $this->assertEqual(count($entity->name), 2, format_string('%entity_type: List has 2 items.', ['%entity_type' => $entity_type])); $entity->name->filterEmptyItems(); - $this->assertEqual(count($entity->name), 1, format_string('%entity_type: The empty item was removed.', array('%entity_type' => $entity_type))); - $this->assertEqual($entity->name[0]->value, 'foo', format_string('%entity_type: The items were renumbered.', array('%entity_type' => $entity_type))); - $this->assertEqual($entity->name[0]->getName(), 0, format_string('%entity_type: The deltas were updated in the items.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($entity->name), 1, format_string('%entity_type: The empty item was removed.', ['%entity_type' => $entity_type])); + $this->assertEqual($entity->name[0]->value, 'foo', format_string('%entity_type: The items were renumbered.', ['%entity_type' => $entity_type])); + $this->assertEqual($entity->name[0]->getName(), 0, format_string('%entity_type: The deltas were updated in the items.', ['%entity_type' => $entity_type])); // Test get and set field values. $entity->name = 'foo'; - $this->assertEqual($entity->name[0]->toArray(), array('value' => 'foo'), format_string('%entity_type: Field value has been retrieved via toArray()', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->name[0]->toArray(), ['value' => 'foo'], format_string('%entity_type: Field value has been retrieved via toArray()', ['%entity_type' => $entity_type])); $values = $entity->toArray(); - $this->assertEqual($values['name'], array(0 => array('value' => 'foo')), format_string('%entity_type: Field value has been retrieved via toArray() from an entity.', array('%entity_type' => $entity_type))); + $this->assertEqual($values['name'], [0 => ['value' => 'foo']], format_string('%entity_type: Field value has been retrieved via toArray() from an entity.', ['%entity_type' => $entity_type])); // Make sure the user id can be set to zero. $user_item[0]['target_id'] = 0; $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array( + ->create([ 'name' => $name_item, 'user_id' => $user_item, 'field_test_text' => $text_item, - )); - $this->assertNotNull($entity->user_id->target_id, format_string('%entity_type: User id is not NULL', array('%entity_type' => $entity_type))); - $this->assertIdentical($entity->user_id->target_id, 0, format_string('%entity_type: User id has been set to 0', array('%entity_type' => $entity_type))); + ]); + $this->assertNotNull($entity->user_id->target_id, format_string('%entity_type: User id is not NULL', ['%entity_type' => $entity_type])); + $this->assertIdentical($entity->user_id->target_id, 0, format_string('%entity_type: User id has been set to 0', ['%entity_type' => $entity_type])); // Test setting the ID with the value only. $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array( + ->create([ 'name' => $name_item, 'user_id' => 0, 'field_test_text' => $text_item, - )); - $this->assertNotNull($entity->user_id->target_id, format_string('%entity_type: User id is not NULL', array('%entity_type' => $entity_type))); - $this->assertIdentical($entity->user_id->target_id, 0, format_string('%entity_type: User id has been set to 0', array('%entity_type' => $entity_type))); + ]); + $this->assertNotNull($entity->user_id->target_id, format_string('%entity_type: User id is not NULL', ['%entity_type' => $entity_type])); + $this->assertIdentical($entity->user_id->target_id, 0, format_string('%entity_type: User id has been set to 0', ['%entity_type' => $entity_type])); } /** @@ -376,21 +376,21 @@ protected function doTestSave($entity_type) { $langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode'); $entity = $this->createTestEntity($entity_type); $entity->save(); - $this->assertTrue((bool) $entity->id(), format_string('%entity_type: Entity has received an id.', array('%entity_type' => $entity_type))); + $this->assertTrue((bool) $entity->id(), format_string('%entity_type: Entity has received an id.', ['%entity_type' => $entity_type])); $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) ->load($entity->id()); - $this->assertTrue((bool) $entity->id(), format_string('%entity_type: Entity loaded.', array('%entity_type' => $entity_type))); + $this->assertTrue((bool) $entity->id(), format_string('%entity_type: Entity loaded.', ['%entity_type' => $entity_type])); // Access the name field. - $this->assertEqual(1, $entity->id->value, format_string('%entity_type: ID value can be read.', array('%entity_type' => $entity_type))); - $this->assertTrue(is_string($entity->uuid->value), format_string('%entity_type: UUID value can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual('en', $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual(\Drupal::languageManager()->getLanguage('en'), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entityFieldText, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual(1, $entity->id->value, format_string('%entity_type: ID value can be read.', ['%entity_type' => $entity_type])); + $this->assertTrue(is_string($entity->uuid->value), format_string('%entity_type: UUID value can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual('en', $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual(\Drupal::languageManager()->getLanguage('en'), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', ['%entity_type' => $entity_type])); + $this->assertEqual($this->entityFieldText, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', ['%entity_type' => $entity_type])); } /** @@ -532,8 +532,8 @@ protected function doTestIterator($entity_type) { } $fields = $entity->getFields(); - $this->assertEqual(array_keys($fields), array_keys($entity->getTypedData()->getDataDefinition()->getPropertyDefinitions()), format_string('%entity_type: All fields returned.', array('%entity_type' => $entity_type))); - $this->assertEqual($fields, iterator_to_array($entity->getIterator()), format_string('%entity_type: Entity iterator iterates over all fields.', array('%entity_type' => $entity_type))); + $this->assertEqual(array_keys($fields), array_keys($entity->getTypedData()->getDataDefinition()->getPropertyDefinitions()), format_string('%entity_type: All fields returned.', ['%entity_type' => $entity_type])); + $this->assertEqual($fields, iterator_to_array($entity->getIterator()), format_string('%entity_type: Entity iterator iterates over all fields.', ['%entity_type' => $entity_type])); } /** @@ -558,12 +558,12 @@ protected function doTestDataStructureInterfaces($entity_type) { // Test using the whole tree of typed data by navigating through the tree of // contained properties and getting all contained strings, limited by a // certain depth. - $strings = array(); + $strings = []; $this->getContainedStrings($entity->getTypedData(), 0, $strings); // @todo: Once the user entity has defined properties this should contain // the user name and other user entity strings as well. - $target_strings = array( + $target_strings = [ $entity->uuid->value, 'en', $this->entityName, @@ -572,7 +572,7 @@ protected function doTestDataStructureInterfaces($entity_type) { $this->entityFieldText, // Field format. NULL, - ); + ]; if ($entity instanceof RevisionLogInterface) { // Adding empty string for revision message. @@ -581,7 +581,7 @@ protected function doTestDataStructureInterfaces($entity_type) { asort($strings); asort($target_strings); - $this->assertEqual(array_values($strings), array_values($target_strings), format_string('%entity_type: All contained strings found.', array('%entity_type' => $entity_type))); + $this->assertEqual(array_values($strings), array_values($target_strings), format_string('%entity_type: All contained strings found.', ['%entity_type' => $entity_type])); } /** @@ -629,10 +629,10 @@ public function testDataTypes() { * @see entity_test_entity_base_field_info_alter() */ public function testBaseFieldNonExistingBaseField() { - $this->entityManager->getStorage('node_type')->create(array( + $this->entityManager->getStorage('node_type')->create([ 'type' => 'page', 'name' => 'page', - ))->save(); + ])->save(); $this->entityManager->clearCachedFieldDefinitions(); $fields = $this->entityManager->getFieldDefinitions('node', 'page'); $override = $fields['status']->getConfig('page'); @@ -686,7 +686,7 @@ public function testEntityConstraintValidation() { ->setLabel('Test entity') ->setSetting('target_type', 'entity_test'); $reference_field = \Drupal::typedDataManager()->create($definition); - $reference = $reference_field->appendItem(array('entity' => $entity))->get('entity'); + $reference = $reference_field->appendItem(['entity' => $entity])->get('entity'); // Test validation the typed data object. $violations = $reference->validate(); @@ -705,14 +705,14 @@ public function testEntityConstraintValidation() { $this->assertEqual($violations->count(), 1); // Test bundle validation. - NodeType::create(array('type' => 'article')) + NodeType::create(['type' => 'article']) ->save(); $definition = BaseFieldDefinition::create('entity_reference') ->setLabel('Test entity') ->setSetting('target_type', 'node') ->setSetting('handler_settings', ['target_bundles' => ['article' => 'article']]); $reference_field = \Drupal::TypedDataManager()->create($definition); - $reference_field->appendItem(array('entity' => $node)); + $reference_field->appendItem(['entity' => $node]); $violations = $reference_field->validate(); $this->assertEqual($violations->count(), 1); @@ -749,14 +749,14 @@ protected function doTestComputedProperties($entity_type) { $entity->field_test_text->format = filter_default_format(); $target = "

    The <strong>text</strong> text to filter.

    \n"; - $this->assertEqual($entity->field_test_text->processed, $target, format_string('%entity_type: Text is processed with the default filter.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->field_test_text->processed, $target, format_string('%entity_type: Text is processed with the default filter.', ['%entity_type' => $entity_type])); // Save and load entity and make sure it still works. $entity->save(); $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) ->load($entity->id()); - $this->assertEqual($entity->field_test_text->processed, $target, format_string('%entity_type: Text is processed with the default filter.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->field_test_text->processed, $target, format_string('%entity_type: Text is processed with the default filter.', ['%entity_type' => $entity_type])); } } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php index 4b08a56..f7108d5 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php @@ -31,7 +31,7 @@ * * @var array */ - protected $generatedIds = array(); + protected $generatedIds = []; /** * The state service. @@ -62,7 +62,7 @@ protected function setUp() { // Only check the modules, if the $modules property was not inherited. $rp = new \ReflectionProperty($class, 'modules'); if ($rp->class == $class) { - foreach (array_intersect(array('node', 'comment'), $class::$modules) as $module) { + foreach (array_intersect(['node', 'comment'], $class::$modules) as $module) { $this->installEntitySchema($module); } if (in_array('forum', $class::$modules, TRUE)) { @@ -79,7 +79,7 @@ protected function setUp() { $class = get_parent_class($class); } - $this->installConfig(array('field')); + $this->installConfig(['field']); } /** @@ -93,22 +93,22 @@ protected function setUp() { * @return \Drupal\user\Entity\User * The created user entity. */ - protected function createUser($values = array(), $permissions = array()) { + protected function createUser($values = [], $permissions = []) { if ($permissions) { // Create a new role and apply permissions to it. - $role = Role::create(array( + $role = Role::create([ 'id' => strtolower($this->randomMachineName(8)), 'label' => $this->randomMachineName(8), - )); + ]); $role->save(); user_role_grant_permissions($role->id(), $permissions); $values['roles'][] = $role->id(); } - $account = User::create($values + array( + $account = User::create($values + [ 'name' => $this->randomMachineName(), 'status' => 1, - )); + ]); $account->enforceIsNew(); $account->save(); return $account; @@ -125,7 +125,7 @@ protected function createUser($values = array(), $permissions = array()) { */ protected function reloadEntity(EntityInterface $entity) { $controller = $this->entityManager->getStorage($entity->getEntityTypeId()); - $controller->resetCache(array($entity->id())); + $controller->resetCache([$entity->id()]); return $controller->load($entity->id()); } @@ -138,7 +138,7 @@ protected function reloadEntity(EntityInterface $entity) { protected function getHooksInfo() { $key = 'entity_test.hooks'; $hooks = $this->state->get($key); - $this->state->set($key, array()); + $this->state->set($key, []); return $hooks; } @@ -149,7 +149,7 @@ protected function getHooksInfo() { * The module to install. */ protected function installModule($module) { - $this->enableModules(array($module)); + $this->enableModules([$module]); $this->refreshServices(); } @@ -160,7 +160,7 @@ protected function installModule($module) { * The module to uninstall. */ protected function uninstallModule($module) { - $this->disableModules(array($module)); + $this->disableModules([$module]); $this->refreshServices(); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php index 59510ba..570aa98 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityLanguageTestBase.php @@ -40,7 +40,7 @@ */ protected $untranslatableFieldName; - public static $modules = array('language', 'entity_test'); + public static $modules = ['language', 'entity_test']; protected function setUp() { parent::setUp(); @@ -54,7 +54,7 @@ protected function setUp() { } } - $this->installConfig(array('language')); + $this->installConfig(['language']); // Create the test field. module_load_install('entity_test'); @@ -71,12 +71,12 @@ protected function setUp() { // Create field fields in all entity variations. foreach (entity_test_entity_types() as $entity_type) { - FieldStorageConfig::create(array( + FieldStorageConfig::create([ 'field_name' => $this->fieldName, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4, - ))->save(); + ])->save(); FieldConfig::create([ 'field_name' => $this->fieldName, 'entity_type' => $entity_type, @@ -84,12 +84,12 @@ protected function setUp() { 'translatable' => TRUE, ])->save(); - FieldStorageConfig::create(array( + FieldStorageConfig::create([ 'field_name' => $this->untranslatableFieldName, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4, - ))->save(); + ])->save(); FieldConfig::create([ 'field_name' => $this->untranslatableFieldName, 'entity_type' => $entity_type, @@ -99,16 +99,16 @@ protected function setUp() { } // Create the default languages. - $this->installConfig(array('language')); + $this->installConfig(['language']); // Create test languages. - $this->langcodes = array(); + $this->langcodes = []; for ($i = 0; $i < 3; ++$i) { - $language = ConfigurableLanguage::create(array( + $language = ConfigurableLanguage::create([ 'id' => 'l' . $i, 'label' => $this->randomString(), 'weight' => $i, - )); + ]); $this->langcodes[$i] = $language->getId(); $language->save(); } @@ -121,7 +121,7 @@ protected function setUp() { * The type of the entity fields are attached to. */ protected function toggleFieldTranslatability($entity_type, $bundle) { - $fields = array($this->fieldName, $this->untranslatableFieldName); + $fields = [$this->fieldName, $this->untranslatableFieldName]; foreach ($fields as $field_name) { $field = FieldConfig::loadByName($entity_type, $bundle, $field_name); $translatable = !$field->isTranslatable(); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityNonRevisionableTranslatableFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityNonRevisionableTranslatableFieldTest.php index da6ec66..bab52b0 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityNonRevisionableTranslatableFieldTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityNonRevisionableTranslatableFieldTest.php @@ -14,7 +14,7 @@ class EntityNonRevisionableTranslatableFieldTest extends EntityKernelTestBase { /** * {@inheritdoc} */ - public static $modules = array('entity_test', 'language', 'content_translation'); + public static $modules = ['entity_test', 'language', 'content_translation']; protected function setUp() { parent::setUp(); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php index 819445d..b6362fb 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryAggregateTest.php @@ -18,7 +18,7 @@ class EntityQueryAggregateTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array(); + public static $modules = []; /** * The entity_test storage to create the test entities. @@ -50,12 +50,12 @@ protected function setUp() { // Add some fieldapi fields to be used in the test. for ($i = 1; $i <= 2; $i++) { $field_name = 'field_test_' . $i; - FieldStorageConfig::create(array( + FieldStorageConfig::create([ 'field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'integer', 'cardinality' => 2, - ))->save(); + ])->save(); FieldConfig::create([ 'field_name' => $field_name, 'entity_type' => 'entity_test', @@ -63,53 +63,53 @@ protected function setUp() { ])->save(); } - $entity = $this->entityStorage->create(array( + $entity = $this->entityStorage->create([ 'id' => 1, 'user_id' => 1, 'field_test_1' => 1, 'field_test_2' => 2, - )); + ]); $entity->enforceIsNew(); $entity->save(); - $entity = $this->entityStorage->create(array( + $entity = $this->entityStorage->create([ 'id' => 2, 'user_id' => 2, 'field_test_1' => 1, 'field_test_2' => 7, - )); + ]); $entity->enforceIsNew(); $entity->save(); - $entity = $this->entityStorage->create(array( + $entity = $this->entityStorage->create([ 'id' => 3, 'user_id' => 2, 'field_test_1' => 2, 'field_test_2' => 1, - )); + ]); $entity->enforceIsNew(); $entity->save(); - $entity = $this->entityStorage->create(array( + $entity = $this->entityStorage->create([ 'id' => 4, 'user_id' => 2, 'field_test_1' => 2, 'field_test_2' => 8, - )); + ]); $entity->enforceIsNew(); $entity->save(); - $entity = $this->entityStorage->create(array( + $entity = $this->entityStorage->create([ 'id' => 5, 'user_id' => 3, 'field_test_1' => 2, 'field_test_2' => 2, - )); + ]); $entity->enforceIsNew(); $entity->save(); - $entity = $this->entityStorage->create(array( + $entity = $this->entityStorage->create([ 'id' => 6, 'user_id' => 3, 'field_test_1' => 3, 'field_test_2' => 8, - )); + ]); $entity->enforceIsNew(); $entity->save(); @@ -124,18 +124,18 @@ public function testAggregation() { ->groupBy('user_id') ->execute(); - $this->assertResults(array( - array('user_id' => 1), - array('user_id' => 2), - array('user_id' => 3), - )); + $this->assertResults([ + ['user_id' => 1], + ['user_id' => 2], + ['user_id' => 3], + ]); - $function_expected = array(); - $function_expected['count'] = array(array('id_count' => 6)); - $function_expected['min'] = array(array('id_min' => 1)); - $function_expected['max'] = array(array('id_max' => 6)); - $function_expected['sum'] = array(array('id_sum' => 21)); - $function_expected['avg'] = array(array('id_avg' => (21.0 / 6.0))); + $function_expected = []; + $function_expected['count'] = [['id_count' => 6]]; + $function_expected['min'] = [['id_min' => 1]]; + $function_expected['max'] = [['id_max' => 6]]; + $function_expected['sum'] = [['id_sum' => 21]]; + $function_expected['avg'] = [['id_avg' => (21.0 / 6.0)]]; // Apply a simple aggregation for different aggregation functions. foreach ($function_expected as $aggregation_function => $expected) { @@ -150,11 +150,11 @@ public function testAggregation() { ->aggregate('id', 'COUNT') ->groupBy('user_id') ->execute(); - $this->assertResults(array( - array('user_id' => 1, 'id_count' => 1), - array('user_id' => 2, 'id_count' => 3), - array('user_id' => 3, 'id_count' => 2), - )); + $this->assertResults([ + ['user_id' => 1, 'id_count' => 1], + ['user_id' => 2, 'id_count' => 3], + ['user_id' => 3, 'id_count' => 2], + ]); // Apply aggregation and a condition which matches. $this->queryResult = $this->factory->getAggregate('entity_test') @@ -162,14 +162,14 @@ public function testAggregation() { ->groupBy('id') ->conditionAggregate('id', 'COUNT', 8) ->execute(); - $this->assertResults(array()); + $this->assertResults([]); // Don't call aggregate to test the implicit aggregate call. $this->queryResult = $this->factory->getAggregate('entity_test') ->groupBy('id') ->conditionAggregate('id', 'COUNT', 8) ->execute(); - $this->assertResults(array()); + $this->assertResults([]); // Apply aggregation and a condition which matches. $this->queryResult = $this->factory->getAggregate('entity_test') @@ -177,7 +177,7 @@ public function testAggregation() { ->groupBy('id') ->conditionAggregate('id', 'COUNT', 6) ->execute(); - $this->assertResults(array(array('id_count' => 6))); + $this->assertResults([['id_count' => 6]]); // Apply aggregation, a groupby and a condition which matches partially via // the operator '='. @@ -186,7 +186,7 @@ public function testAggregation() { ->conditionAggregate('id', 'count', 2) ->groupBy('user_id') ->execute(); - $this->assertResults(array(array('id_count' => 2, 'user_id' => 3))); + $this->assertResults([['id_count' => 2, 'user_id' => 3]]); // Apply aggregation, a groupby and a condition which matches partially via // the operator '>'. @@ -195,10 +195,10 @@ public function testAggregation() { ->conditionAggregate('id', 'COUNT', 1, '>') ->groupBy('user_id') ->execute(); - $this->assertResults(array( - array('id_count' => 2, 'user_id' => 3), - array('id_count' => 3, 'user_id' => 2), - )); + $this->assertResults([ + ['id_count' => 2, 'user_id' => 3], + ['id_count' => 3, 'user_id' => 2], + ]); // Apply aggregation and a sort. This might not be useful, but have a proper // test coverage. @@ -206,13 +206,13 @@ public function testAggregation() { ->aggregate('id', 'COUNT') ->sortAggregate('id', 'COUNT') ->execute(); - $this->assertSortedResults(array(array('id_count' => 6))); + $this->assertSortedResults([['id_count' => 6]]); // Don't call aggregate to test the implicit aggregate call. $this->queryResult = $this->factory->getAggregate('entity_test') ->sortAggregate('id', 'COUNT') ->execute(); - $this->assertSortedResults(array(array('id_count' => 6))); + $this->assertSortedResults([['id_count' => 6]]); // Apply aggregation, groupby and a sort descending. $this->queryResult = $this->factory->getAggregate('entity_test') @@ -220,11 +220,11 @@ public function testAggregation() { ->groupBy('user_id') ->sortAggregate('id', 'COUNT', 'DESC') ->execute(); - $this->assertSortedResults(array( - array('user_id' => 2, 'id_count' => 3), - array('user_id' => 3, 'id_count' => 2), - array('user_id' => 1, 'id_count' => 1), - )); + $this->assertSortedResults([ + ['user_id' => 2, 'id_count' => 3], + ['user_id' => 3, 'id_count' => 2], + ['user_id' => 1, 'id_count' => 1], + ]); // Apply aggregation, groupby and a sort ascending. $this->queryResult = $this->factory->getAggregate('entity_test') @@ -232,11 +232,11 @@ public function testAggregation() { ->groupBy('user_id') ->sortAggregate('id', 'COUNT', 'ASC') ->execute(); - $this->assertSortedResults(array( - array('user_id' => 1, 'id_count' => 1), - array('user_id' => 3, 'id_count' => 2), - array('user_id' => 2, 'id_count' => 3), - )); + $this->assertSortedResults([ + ['user_id' => 1, 'id_count' => 1], + ['user_id' => 3, 'id_count' => 2], + ['user_id' => 2, 'id_count' => 3], + ]); // Apply aggregation, groupby, an aggregation condition and a sort with the // operator '='. @@ -246,7 +246,7 @@ public function testAggregation() { ->sortAggregate('id', 'COUNT') ->conditionAggregate('id', 'COUNT', 2) ->execute(); - $this->assertSortedResults(array(array('id_count' => 2, 'user_id' => 3))); + $this->assertSortedResults([['id_count' => 2, 'user_id' => 3]]); // Apply aggregation, groupby, an aggregation condition and a sort with the // operator '<' and order ASC. @@ -256,10 +256,10 @@ public function testAggregation() { ->sortAggregate('id', 'COUNT', 'ASC') ->conditionAggregate('id', 'COUNT', 3, '<') ->execute(); - $this->assertSortedResults(array( - array('id_count' => 1, 'user_id' => 1), - array('id_count' => 2, 'user_id' => 3), - )); + $this->assertSortedResults([ + ['id_count' => 1, 'user_id' => 1], + ['id_count' => 2, 'user_id' => 3], + ]); // Apply aggregation, groupby, an aggregation condition and a sort with the // operator '<' and order DESC. @@ -269,10 +269,10 @@ public function testAggregation() { ->sortAggregate('id', 'COUNT', 'DESC') ->conditionAggregate('id', 'COUNT', 3, '<') ->execute(); - $this->assertSortedResults(array( - array('id_count' => 2, 'user_id' => 3), - array('id_count' => 1, 'user_id' => 1), - )); + $this->assertSortedResults([ + ['id_count' => 2, 'user_id' => 3], + ['id_count' => 1, 'user_id' => 1], + ]); // Test aggregation/groupby support for fieldapi fields. @@ -280,11 +280,11 @@ public function testAggregation() { $this->queryResult = $this->factory->getAggregate('entity_test') ->groupBy('field_test_1') ->execute(); - $this->assertResults(array( - array('field_test_1' => 1), - array('field_test_1' => 2), - array('field_test_1' => 3), - )); + $this->assertResults([ + ['field_test_1' => 1], + ['field_test_1' => 2], + ['field_test_1' => 3], + ]); // Group by a fieldapi field and aggregate a normal property. $this->queryResult = $this->factory->getAggregate('entity_test') @@ -292,11 +292,11 @@ public function testAggregation() { ->groupBy('field_test_1') ->execute(); - $this->assertResults(array( - array('field_test_1' => 1, 'user_id_count' => 2), - array('field_test_1' => 2, 'user_id_count' => 3), - array('field_test_1' => 3, 'user_id_count' => 1), - )); + $this->assertResults([ + ['field_test_1' => 1, 'user_id_count' => 2], + ['field_test_1' => 2, 'user_id_count' => 3], + ['field_test_1' => 3, 'user_id_count' => 1], + ]); // Group by a normal property and aggregate a fieldapi field. $this->queryResult = $this->factory->getAggregate('entity_test') @@ -304,21 +304,21 @@ public function testAggregation() { ->groupBy('user_id') ->execute(); - $this->assertResults(array( - array('user_id' => 1, 'field_test_1_count' => 1), - array('user_id' => 2, 'field_test_1_count' => 3), - array('user_id' => 3, 'field_test_1_count' => 2), - )); + $this->assertResults([ + ['user_id' => 1, 'field_test_1_count' => 1], + ['user_id' => 2, 'field_test_1_count' => 3], + ['user_id' => 3, 'field_test_1_count' => 2], + ]); $this->queryResult = $this->factory->getAggregate('entity_test') ->aggregate('field_test_1', 'SUM') ->groupBy('user_id') ->execute(); - $this->assertResults(array( - array('user_id' => 1, 'field_test_1_sum' => 1), - array('user_id' => 2, 'field_test_1_sum' => 5), - array('user_id' => 3, 'field_test_1_sum' => 5), - )); + $this->assertResults([ + ['user_id' => 1, 'field_test_1_sum' => 1], + ['user_id' => 2, 'field_test_1_sum' => 5], + ['user_id' => 3, 'field_test_1_sum' => 5], + ]); // Aggregate by two different fieldapi fields. $this->queryResult = $this->factory->getAggregate('entity_test') @@ -326,11 +326,11 @@ public function testAggregation() { ->aggregate('field_test_2', 'SUM') ->groupBy('user_id') ->execute(); - $this->assertResults(array( - array('user_id' => 1, 'field_test_1_sum' => 1, 'field_test_2_sum' => 2), - array('user_id' => 2, 'field_test_1_sum' => 5, 'field_test_2_sum' => 16), - array('user_id' => 3, 'field_test_1_sum' => 5, 'field_test_2_sum' => 10), - )); + $this->assertResults([ + ['user_id' => 1, 'field_test_1_sum' => 1, 'field_test_2_sum' => 2], + ['user_id' => 2, 'field_test_1_sum' => 5, 'field_test_2_sum' => 16], + ['user_id' => 3, 'field_test_1_sum' => 5, 'field_test_2_sum' => 10], + ]); // This time aggregate the same field twice. $this->queryResult = $this->factory->getAggregate('entity_test') @@ -338,22 +338,22 @@ public function testAggregation() { ->aggregate('field_test_1', 'COUNT') ->groupBy('user_id') ->execute(); - $this->assertResults(array( - array('user_id' => 1, 'field_test_1_sum' => 1, 'field_test_1_count' => 1), - array('user_id' => 2, 'field_test_1_sum' => 5, 'field_test_1_count' => 3), - array('user_id' => 3, 'field_test_1_sum' => 5, 'field_test_1_count' => 2), - )); + $this->assertResults([ + ['user_id' => 1, 'field_test_1_sum' => 1, 'field_test_1_count' => 1], + ['user_id' => 2, 'field_test_1_sum' => 5, 'field_test_1_count' => 3], + ['user_id' => 3, 'field_test_1_sum' => 5, 'field_test_1_count' => 2], + ]); // Group by and aggregate by a fieldapi field. $this->queryResult = $this->factory->getAggregate('entity_test') ->groupBy('field_test_1') ->aggregate('field_test_2', 'COUNT') ->execute(); - $this->assertResults(array( - array('field_test_1' => 1, 'field_test_2_count' => 2), - array('field_test_1' => 2, 'field_test_2_count' => 3), - array('field_test_1' => 3, 'field_test_2_count' => 1), - )); + $this->assertResults([ + ['field_test_1' => 1, 'field_test_2_count' => 2], + ['field_test_1' => 2, 'field_test_2_count' => 3], + ['field_test_1' => 3, 'field_test_2_count' => 1], + ]); // Group by and aggregate by a fieldapi field and use multiple aggregate // functions. @@ -362,11 +362,11 @@ public function testAggregation() { ->aggregate('field_test_2', 'COUNT') ->aggregate('field_test_2', 'SUM') ->execute(); - $this->assertResults(array( - array('field_test_1' => 1, 'field_test_2_count' => 2, 'field_test_2_sum' => 9), - array('field_test_1' => 2, 'field_test_2_count' => 3, 'field_test_2_sum' => 11), - array('field_test_1' => 3, 'field_test_2_count' => 1, 'field_test_2_sum' => 8), - )); + $this->assertResults([ + ['field_test_1' => 1, 'field_test_2_count' => 2, 'field_test_2_sum' => 9], + ['field_test_1' => 2, 'field_test_2_count' => 3, 'field_test_2_sum' => 11], + ['field_test_1' => 3, 'field_test_2_count' => 1, 'field_test_2_sum' => 8], + ]); // Apply an aggregate condition for a fieldapi field and group by a simple // property. @@ -374,20 +374,20 @@ public function testAggregation() { ->conditionAggregate('field_test_1', 'COUNT', 3) ->groupBy('user_id') ->execute(); - $this->assertResults(array( - array('user_id' => 2, 'field_test_1_count' => 3), - array('user_id' => 3, 'field_test_1_count' => 2), - )); + $this->assertResults([ + ['user_id' => 2, 'field_test_1_count' => 3], + ['user_id' => 3, 'field_test_1_count' => 2], + ]); $this->queryResult = $this->factory->getAggregate('entity_test') ->aggregate('field_test_1', 'SUM') ->conditionAggregate('field_test_1', 'COUNT', 2, '>') ->groupBy('user_id') ->execute(); - $this->assertResults(array( - array('user_id' => 2, 'field_test_1_sum' => 5, 'field_test_1_count' => 3), - array('user_id' => 3, 'field_test_1_sum' => 5, 'field_test_1_count' => 2), - )); + $this->assertResults([ + ['user_id' => 2, 'field_test_1_sum' => 5, 'field_test_1_count' => 3], + ['user_id' => 3, 'field_test_1_sum' => 5, 'field_test_1_count' => 2], + ]); // Apply an aggregate condition for a simple property and a group by a // fieldapi field. @@ -395,35 +395,35 @@ public function testAggregation() { ->conditionAggregate('user_id', 'COUNT', 2) ->groupBy('field_test_1') ->execute(); - $this->assertResults(array( - array('field_test_1' => 1, 'user_id_count' => 2), - )); + $this->assertResults([ + ['field_test_1' => 1, 'user_id_count' => 2], + ]); $this->queryResult = $this->factory->getAggregate('entity_test') ->conditionAggregate('user_id', 'COUNT', 2, '>') ->groupBy('field_test_1') ->execute(); - $this->assertResults(array( - array('field_test_1' => 1, 'user_id_count' => 2), - array('field_test_1' => 2, 'user_id_count' => 3), - )); + $this->assertResults([ + ['field_test_1' => 1, 'user_id_count' => 2], + ['field_test_1' => 2, 'user_id_count' => 3], + ]); // Apply an aggregate condition and a group by fieldapi fields. $this->queryResult = $this->factory->getAggregate('entity_test') ->groupBy('field_test_1') ->conditionAggregate('field_test_2', 'COUNT', 2) ->execute(); - $this->assertResults(array( - array('field_test_1' => 1, 'field_test_2_count' => 2), - )); + $this->assertResults([ + ['field_test_1' => 1, 'field_test_2_count' => 2], + ]); $this->queryResult = $this->factory->getAggregate('entity_test') ->groupBy('field_test_1') ->conditionAggregate('field_test_2', 'COUNT', 2, '>') ->execute(); - $this->assertResults(array( - array('field_test_1' => 1, 'field_test_2_count' => 2), - array('field_test_1' => 2, 'field_test_2_count' => 3), - )); + $this->assertResults([ + ['field_test_1' => 1, 'field_test_2_count' => 2], + ['field_test_1' => 2, 'field_test_2_count' => 3], + ]); // Apply an aggregate condition and a group by fieldapi fields with multiple // conditions via AND. @@ -432,7 +432,7 @@ public function testAggregation() { ->conditionAggregate('field_test_2', 'COUNT', 2) ->conditionAggregate('field_test_2', 'SUM', 8) ->execute(); - $this->assertResults(array()); + $this->assertResults([]); // Apply an aggregate condition and a group by fieldapi fields with multiple // conditions via OR. @@ -441,10 +441,10 @@ public function testAggregation() { ->conditionAggregate('field_test_2', 'COUNT', 2) ->conditionAggregate('field_test_2', 'SUM', 8) ->execute(); - $this->assertResults(array( - array('field_test_1' => 1, 'field_test_2_count' => 2, 'field_test_2_sum' => 9), - array('field_test_1' => 3, 'field_test_2_count' => 1, 'field_test_2_sum' => 8), - )); + $this->assertResults([ + ['field_test_1' => 1, 'field_test_2_count' => 2, 'field_test_2_sum' => 9], + ['field_test_1' => 3, 'field_test_2_count' => 1, 'field_test_2_sum' => 8], + ]); // Group by a normal property and aggregate a fieldapi field and sort by the // groupby field. @@ -453,32 +453,32 @@ public function testAggregation() { ->groupBy('user_id') ->sort('user_id', 'DESC') ->execute(); - $this->assertSortedResults(array( - array('user_id' => 3, 'field_test_1_count' => 2), - array('user_id' => 2, 'field_test_1_count' => 3), - array('user_id' => 1, 'field_test_1_count' => 1), - )); + $this->assertSortedResults([ + ['user_id' => 3, 'field_test_1_count' => 2], + ['user_id' => 2, 'field_test_1_count' => 3], + ['user_id' => 1, 'field_test_1_count' => 1], + ]); $this->queryResult = $this->factory->getAggregate('entity_test') ->aggregate('field_test_1', 'COUNT') ->groupBy('user_id') ->sort('user_id', 'ASC') ->execute(); - $this->assertSortedResults(array( - array('user_id' => 1, 'field_test_1_count' => 1), - array('user_id' => 2, 'field_test_1_count' => 3), - array('user_id' => 3, 'field_test_1_count' => 2), - )); + $this->assertSortedResults([ + ['user_id' => 1, 'field_test_1_count' => 1], + ['user_id' => 2, 'field_test_1_count' => 3], + ['user_id' => 3, 'field_test_1_count' => 2], + ]); $this->queryResult = $this->factory->getAggregate('entity_test') ->conditionAggregate('field_test_1', 'COUNT', 2, '>') ->groupBy('user_id') ->sort('user_id', 'ASC') ->execute(); - $this->assertSortedResults(array( - array('user_id' => 2, 'field_test_1_count' => 3), - array('user_id' => 3, 'field_test_1_count' => 2), - )); + $this->assertSortedResults([ + ['user_id' => 2, 'field_test_1_count' => 3], + ['user_id' => 3, 'field_test_1_count' => 2], + ]); // Group by a normal property, aggregate a fieldapi field, and sort by the // aggregated field. @@ -486,21 +486,21 @@ public function testAggregation() { ->sortAggregate('field_test_1', 'COUNT', 'DESC') ->groupBy('user_id') ->execute(); - $this->assertSortedResults(array( - array('user_id' => 2, 'field_test_1_count' => 3), - array('user_id' => 3, 'field_test_1_count' => 2), - array('user_id' => 1, 'field_test_1_count' => 1), - )); + $this->assertSortedResults([ + ['user_id' => 2, 'field_test_1_count' => 3], + ['user_id' => 3, 'field_test_1_count' => 2], + ['user_id' => 1, 'field_test_1_count' => 1], + ]); $this->queryResult = $this->factory->getAggregate('entity_test') ->sortAggregate('field_test_1', 'COUNT', 'ASC') ->groupBy('user_id') ->execute(); - $this->assertSortedResults(array( - array('user_id' => 1, 'field_test_1_count' => 1), - array('user_id' => 3, 'field_test_1_count' => 2), - array('user_id' => 2, 'field_test_1_count' => 3), - )); + $this->assertSortedResults([ + ['user_id' => 1, 'field_test_1_count' => 1], + ['user_id' => 3, 'field_test_1_count' => 2], + ['user_id' => 2, 'field_test_1_count' => 3], + ]); // Group by and aggregate by fieldapi field, and sort by the groupby field. $this->queryResult = $this->factory->getAggregate('entity_test') @@ -508,22 +508,22 @@ public function testAggregation() { ->aggregate('field_test_2', 'COUNT') ->sort('field_test_1', 'ASC') ->execute(); - $this->assertSortedResults(array( - array('field_test_1' => 1, 'field_test_2_count' => 2), - array('field_test_1' => 2, 'field_test_2_count' => 3), - array('field_test_1' => 3, 'field_test_2_count' => 1), - )); + $this->assertSortedResults([ + ['field_test_1' => 1, 'field_test_2_count' => 2], + ['field_test_1' => 2, 'field_test_2_count' => 3], + ['field_test_1' => 3, 'field_test_2_count' => 1], + ]); $this->queryResult = $this->factory->getAggregate('entity_test') ->groupBy('field_test_1') ->aggregate('field_test_2', 'COUNT') ->sort('field_test_1', 'DESC') ->execute(); - $this->assertSortedResults(array( - array('field_test_1' => 3, 'field_test_2_count' => 1), - array('field_test_1' => 2, 'field_test_2_count' => 3), - array('field_test_1' => 1, 'field_test_2_count' => 2), - )); + $this->assertSortedResults([ + ['field_test_1' => 3, 'field_test_2_count' => 1], + ['field_test_1' => 2, 'field_test_2_count' => 3], + ['field_test_1' => 1, 'field_test_2_count' => 2], + ]); // Groupby and aggregate by fieldapi field, and sort by the aggregated // field. @@ -531,21 +531,21 @@ public function testAggregation() { ->groupBy('field_test_1') ->sortAggregate('field_test_2', 'COUNT', 'DESC') ->execute(); - $this->assertSortedResults(array( - array('field_test_1' => 2, 'field_test_2_count' => 3), - array('field_test_1' => 1, 'field_test_2_count' => 2), - array('field_test_1' => 3, 'field_test_2_count' => 1), - )); + $this->assertSortedResults([ + ['field_test_1' => 2, 'field_test_2_count' => 3], + ['field_test_1' => 1, 'field_test_2_count' => 2], + ['field_test_1' => 3, 'field_test_2_count' => 1], + ]); $this->queryResult = $this->factory->getAggregate('entity_test') ->groupBy('field_test_1') ->sortAggregate('field_test_2', 'COUNT', 'ASC') ->execute(); - $this->assertSortedResults(array( - array('field_test_1' => 3, 'field_test_2_count' => 1), - array('field_test_1' => 1, 'field_test_2_count' => 2), - array('field_test_1' => 2, 'field_test_2_count' => 3), - )); + $this->assertSortedResults([ + ['field_test_1' => 3, 'field_test_2_count' => 1], + ['field_test_1' => 1, 'field_test_2_count' => 2], + ['field_test_1' => 2, 'field_test_2_count' => 3], + ]); } @@ -559,7 +559,7 @@ protected function assertResults($expected, $sorted = FALSE) { $found = TRUE; $expected_keys = array_keys($expected); foreach ($this->queryResult as $key => $row) { - $keys = $sorted ? array($key) : $expected_keys; + $keys = $sorted ? [$key] : $expected_keys; foreach ($keys as $key) { $expected_row = $expected[$key]; if (!array_diff_assoc($row, $expected_row) && !array_diff_assoc($expected_row, $row)) { @@ -569,7 +569,7 @@ protected function assertResults($expected, $sorted = FALSE) { $found = FALSE; break; } - return $this->assertTrue($found, strtr('!expected expected, !found found', array('!expected' => print_r($expected, TRUE), '!found' => print_r($this->queryResult, TRUE)))); + return $this->assertTrue($found, strtr('!expected expected, !found found', ['!expected' => print_r($expected, TRUE), '!found' => print_r($this->queryResult, TRUE)])); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php index 60dc13c..0bb5b16 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryRelationshipTest.php @@ -23,7 +23,7 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('taxonomy'); + public static $modules = ['taxonomy']; /** * @var \Drupal\Core\Entity\Query\QueryFactory @@ -80,12 +80,12 @@ protected function setUp() { // Second, create the field. entity_test_create_bundle('test_bundle'); $this->fieldName = strtolower($this->randomMachineName()); - $handler_settings = array( - 'target_bundles' => array( + $handler_settings = [ + 'target_bundles' => [ $vocabulary->id() => $vocabulary->id(), - ), + ], 'auto_create' => TRUE, - ); + ]; $this->createEntityReferenceField('entity_test', 'test_bundle', $this->fieldName, NULL, 'taxonomy_term', 'default', $handler_settings); // Create two terms and also two accounts. @@ -102,7 +102,7 @@ protected function setUp() { // 0th account and 0th term, the 1st and 2nd entity will point to the // 1st account and 1st term. for ($i = 0; $i <= 2; $i++) { - $entity = EntityTest::create(array('type' => 'test_bundle')); + $entity = EntityTest::create(['type' => 'test_bundle']); $entity->name->value = $this->randomMachineName(); $index = $i ? 1 : 0; $entity->user_id->target_id = $this->accounts[$index]->id(); @@ -122,18 +122,18 @@ public function testQuery() { $this->queryResults = $this->factory->get('entity_test') ->condition("user_id.entity.name", $this->accounts[0]->getUsername()) ->execute(); - $this->assertResults(array(0)); + $this->assertResults([0]); // This returns the 1st and 2nd entity as those point to the 1st account. $this->queryResults = $this->factory->get('entity_test') ->condition("user_id.entity.name", $this->accounts[0]->getUsername(), '<>') ->execute(); - $this->assertResults(array(1, 2)); + $this->assertResults([1, 2]); // This returns all three entities because all of them point to an // account. $this->queryResults = $this->factory->get('entity_test') ->exists("user_id.entity.name") ->execute(); - $this->assertResults(array(0, 1, 2)); + $this->assertResults([0, 1, 2]); // This returns no entities because all of them point to an account. $this->queryResults = $this->factory->get('entity_test') ->notExists("user_id.entity.name") @@ -144,35 +144,35 @@ public function testQuery() { $this->queryResults = $this->factory->get('entity_test') ->condition("$this->fieldName.entity.name", $this->terms[0]->name->value) ->execute(); - $this->assertResults(array(0)); + $this->assertResults([0]); // This returns the 0th entity as that's only one pointing to the 0th // term (test with specifying the column name). $this->queryResults = $this->factory->get('entity_test') ->condition("$this->fieldName.target_id.entity.name", $this->terms[0]->name->value) ->execute(); - $this->assertResults(array(0)); + $this->assertResults([0]); // This returns the 1st and 2nd entity as those point to the 1st term. $this->queryResults = $this->factory->get('entity_test') ->condition("$this->fieldName.entity.name", $this->terms[0]->name->value, '<>') ->execute(); - $this->assertResults(array(1, 2)); + $this->assertResults([1, 2]); // This returns the 0th entity as that's only one pointing to the 0th // account. $this->queryResults = $this->factory->get('entity_test') ->condition("user_id.entity:user.name", $this->accounts[0]->getUsername()) ->execute(); - $this->assertResults(array(0)); + $this->assertResults([0]); // This returns the 1st and 2nd entity as those point to the 1st account. $this->queryResults = $this->factory->get('entity_test') ->condition("user_id.entity:user.name", $this->accounts[0]->getUsername(), '<>') ->execute(); - $this->assertResults(array(1, 2)); + $this->assertResults([1, 2]); // This returns all three entities because all of them point to an // account. $this->queryResults = $this->factory->get('entity_test') ->exists("user_id.entity:user.name") ->execute(); - $this->assertResults(array(0, 1, 2)); + $this->assertResults([0, 1, 2]); // This returns no entities because all of them point to an account. $this->queryResults = $this->factory->get('entity_test') ->notExists("user_id.entity:user.name") @@ -183,18 +183,18 @@ public function testQuery() { $this->queryResults = $this->factory->get('entity_test') ->condition("$this->fieldName.entity:taxonomy_term.name", $this->terms[0]->name->value) ->execute(); - $this->assertResults(array(0)); + $this->assertResults([0]); // This returns the 0th entity as that's only one pointing to the 0th // term (test with specifying the column name). $this->queryResults = $this->factory->get('entity_test') ->condition("$this->fieldName.target_id.entity:taxonomy_term.name", $this->terms[0]->name->value) ->execute(); - $this->assertResults(array(0)); + $this->assertResults([0]); // This returns the 1st and 2nd entity as those point to the 1st term. $this->queryResults = $this->factory->get('entity_test') ->condition("$this->fieldName.entity:taxonomy_term.name", $this->terms[0]->name->value, '<>') ->execute(); - $this->assertResults(array(1, 2)); + $this->assertResults([1, 2]); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php index 8c79c5c..1ad2f31 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php @@ -24,7 +24,7 @@ class EntityQueryTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('field_test', 'language'); + public static $modules = ['field_test', 'language']; /** * @var array @@ -62,21 +62,21 @@ protected function setUp() { $this->installEntitySchema('entity_test_mulrev'); - $this->installConfig(array('language')); + $this->installConfig(['language']); $figures = Unicode::strtolower($this->randomMachineName()); $greetings = Unicode::strtolower($this->randomMachineName()); - foreach (array($figures => 'shape', $greetings => 'text') as $field_name => $field_type) { - $field_storage = FieldStorageConfig::create(array( + foreach ([$figures => 'shape', $greetings => 'text'] as $field_name => $field_type) { + $field_storage = FieldStorageConfig::create([ 'field_name' => $field_name, 'entity_type' => 'entity_test_mulrev', 'type' => $field_type, 'cardinality' => 2, - )); + ]); $field_storage->save(); $field_storages[] = $field_storage; } - $bundles = array(); + $bundles = []; for ($i = 0; $i < 2; $i++) { // For the sake of tablesort, make sure the second bundle is higher than // the first one. Beware: MySQL is not case sensitive. @@ -93,24 +93,24 @@ protected function setUp() { $bundles[] = $bundle; } // Each unit is a list of field name, langcode and a column-value array. - $units[] = array($figures, 'en', array( + $units[] = [$figures, 'en', [ 'color' => 'red', 'shape' => 'triangle', - )); - $units[] = array($figures, 'en', array( + ]]; + $units[] = [$figures, 'en', [ 'color' => 'blue', 'shape' => 'circle', - )); + ]]; // To make it easier to test sorting, the greetings get formats according // to their langcode. - $units[] = array($greetings, 'tr', array( + $units[] = [$greetings, 'tr', [ 'value' => 'merhaba', 'format' => 'format-tr' - )); - $units[] = array($greetings, 'pl', array( + ]]; + $units[] = [$greetings, 'pl', [ 'value' => 'siema', 'format' => 'format-pl' - )); + ]]; // Make these languages available to the greetings field. ConfigurableLanguage::createFromLangcode('tr')->save(); ConfigurableLanguage::createFromLangcode('pl')->save(); @@ -119,13 +119,13 @@ protected function setUp() { // decimal 13 is binary 1101 so unit 3,2 and 0 will be added to the // entity. for ($i = 1; $i <= 15; $i++) { - $entity = EntityTestMulRev::create(array( + $entity = EntityTestMulRev::create([ 'type' => $bundles[$i & 1], 'name' => $this->randomMachineName(), 'langcode' => 'en', - )); + ]); // Make sure the name is set for every language that we might create. - foreach (array('tr', 'pl') as $langcode) { + foreach (['tr', 'pl'] as $langcode) { $entity->addTranslation($langcode)->name = $this->randomMachineName(); } foreach (array_reverse(str_split(decbin($i))) as $key => $bit) { @@ -216,8 +216,8 @@ function testEntityQuery() { // Do the same test but with IN operator. $query = $this->factory->get('entity_test_mulrev'); - $group_blue = $query->andConditionGroup()->condition("$figures.color", array('blue'), 'IN'); - $group_red = $query->andConditionGroup()->condition("$figures.color", array('red'), 'IN'); + $group_blue = $query->andConditionGroup()->condition("$figures.color", ['blue'], 'IN'); + $group_red = $query->andConditionGroup()->condition("$figures.color", ['red'], 'IN'); $this->queryResults = $query ->condition($group_blue) ->condition($group_red) @@ -228,7 +228,7 @@ function testEntityQuery() { // An entity might have either red or blue figure. $this->queryResults = $this->factory->get('entity_test_mulrev') - ->condition("$figures.color", array('blue', 'red'), 'IN') + ->condition("$figures.color", ['blue', 'red'], 'IN') ->sort('id') ->execute(); // Bit 0 or 1 is on. @@ -267,7 +267,7 @@ function testEntityQuery() { ->allRevisions() ->sort('revision_id') ->execute(); - $this->assertRevisionResult(array($first_entity->id()), array($first_entity->id())); + $this->assertRevisionResult([$first_entity->id()], [$first_entity->id()]); // When querying current revisions, this string is no longer found. $this->queryResults = $this->factory->get('entity_test_mulrev') ->condition("$greetings.value", 'merhaba') @@ -279,14 +279,14 @@ function testEntityQuery() { ->sort('revision_id') ->execute(); // The query only matches the original revisions. - $this->assertRevisionResult(array(4, 5, 6, 7, 12, 13, 14, 15), array(4, 5, 6, 7, 12, 13, 14, 15)); + $this->assertRevisionResult([4, 5, 6, 7, 12, 13, 14, 15], [4, 5, 6, 7, 12, 13, 14, 15]); $results = $this->factory->get('entity_test_mulrev') ->condition("$greetings.value", 'siema', 'CONTAINS') ->sort('id') ->execute(); // This matches both the original and new current revisions, multiple // revisions are returned for some entities. - $assert = array(16 => '4', 17 => '5', 18 => '6', 19 => '7', 8 => '8', 9 => '9', 10 => '10', 11 => '11', 20 => '12', 21 => '13', 22 => '14', 23 => '15'); + $assert = [16 => '4', 17 => '5', 18 => '6', 19 => '7', 8 => '8', 9 => '9', 10 => '10', 11 => '11', 20 => '12', 21 => '13', 22 => '14', 23 => '15']; $this->assertIdentical($results, $assert); $results = $this->factory->get('entity_test_mulrev') ->condition("$greetings.value", 'siema', 'STARTS_WITH') @@ -309,7 +309,7 @@ function testEntityQuery() { ->sort('revision_id') ->execute(); // Now we get everything. - $assert = array(4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9', 10 => '10', 11 => '11', 12 => '12', 20 => '12', 13 => '13', 21 => '13', 14 => '14', 22 => '14', 15 => '15', 23 => '15'); + $assert = [4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9', 10 => '10', 11 => '11', 12 => '12', 20 => '12', 13 => '13', 21 => '13', 14 => '14', 22 => '14', 15 => '15', 23 => '15']; $this->assertIdentical($results, $assert); } @@ -376,9 +376,9 @@ function testSort() { // Test the pager by setting element #1 to page 2 with a page size of 4. // Results will be #8-12 from above. $request = Request::createFromGlobals(); - $request->query->replace(array( + $request->query->replace([ 'page' => '0,2', - )); + ]); \Drupal::getContainer()->get('request_stack')->push($request); $this->queryResults = $this->factory->get('entity_test_mulrev') ->sort("$figures.color") @@ -407,40 +407,40 @@ public function testTableSort() { // assert that all entities from one bundle are after the other as the // order dictates. $request = Request::createFromGlobals(); - $request->query->replace(array( + $request->query->replace([ 'sort' => 'asc', 'order' => 'Type', - )); + ]); \Drupal::getContainer()->get('request_stack')->push($request); - $header = array( - 'id' => array('data' => 'Id', 'specifier' => 'id'), - 'type' => array('data' => 'Type', 'specifier' => 'type'), - ); + $header = [ + 'id' => ['data' => 'Id', 'specifier' => 'id'], + 'type' => ['data' => 'Type', 'specifier' => 'type'], + ]; $this->queryResults = array_values($this->factory->get('entity_test_mulrev') ->tableSort($header) ->execute()); $this->assertBundleOrder('asc'); - $request->query->add(array( + $request->query->add([ 'sort' => 'desc', - )); + ]); \Drupal::getContainer()->get('request_stack')->push($request); - $header = array( - 'id' => array('data' => 'Id', 'specifier' => 'id'), - 'type' => array('data' => 'Type', 'specifier' => 'type'), - ); + $header = [ + 'id' => ['data' => 'Id', 'specifier' => 'id'], + 'type' => ['data' => 'Type', 'specifier' => 'type'], + ]; $this->queryResults = array_values($this->factory->get('entity_test_mulrev') ->tableSort($header) ->execute()); $this->assertBundleOrder('desc'); // Ordering on ID is definite, however. - $request->query->add(array( + $request->query->add([ 'order' => 'Id', - )); + ]); \Drupal::getContainer()->get('request_stack')->push($request); $this->queryResults = $this->factory->get('entity_test_mulrev') ->tableSort($header) @@ -454,13 +454,13 @@ public function testTableSort() { public function testCount() { // Create a field with the same name in a different entity type. $field_name = $this->figures; - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'shape', 'cardinality' => 2, 'translatable' => TRUE, - )); + ]); $field_storage->save(); $bundle = $this->randomMachineName(); FieldConfig::create([ @@ -468,10 +468,10 @@ public function testCount() { 'bundle' => $bundle, ])->save(); - $entity = EntityTest::create(array( + $entity = EntityTest::create([ 'id' => 1, 'type' => $bundle, - )); + ]); $entity->enforceIsNew(); $entity->save(); @@ -545,8 +545,8 @@ public function testDelta() { // Test the delta range condition. $this->queryResults = $this->factory->get('entity_test_mulrev') - ->condition("$figures.%delta.color", array('blue', 'red'), 'IN') - ->condition("$figures.%delta", array(0, 1), 'IN') + ->condition("$figures.%delta.color", ['blue', 'red'], 'IN') + ->condition("$figures.%delta", [0, 1], 'IN') ->sort('id') ->execute(); // Figure delta 0 or 1 can be blue or red, this matches a lot of entities. @@ -563,12 +563,12 @@ public function testDelta() { // Numeric delta on single value base field should return results only if // the first item is being targeted. $this->queryResults = $this->factory->get('entity_test_mulrev') - ->condition("id.0.value", array(1, 3, 5), 'IN') + ->condition("id.0.value", [1, 3, 5], 'IN') ->sort('id') ->execute(); $this->assertResult(1, 3, 5); $this->queryResults = $this->factory->get('entity_test_mulrev') - ->condition("id.1.value", array(1, 3, 5), 'IN') + ->condition("id.1.value", [1, 3, 5], 'IN') ->sort('id') ->execute(); $this->assertResult(); @@ -576,18 +576,18 @@ public function testDelta() { // Delta range condition on single value base field should return results // only if just the field value is targeted. $this->queryResults = $this->factory->get('entity_test_mulrev') - ->condition("id.%delta.value", array(1, 3, 5), 'IN') + ->condition("id.%delta.value", [1, 3, 5], 'IN') ->sort('id') ->execute(); $this->assertResult(1, 3, 5); $this->queryResults = $this->factory->get('entity_test_mulrev') - ->condition("id.%delta.value", array(1, 3, 5), 'IN') + ->condition("id.%delta.value", [1, 3, 5], 'IN') ->condition("id.%delta", 0, '=') ->sort('id') ->execute(); $this->assertResult(1, 3, 5); $this->queryResults = $this->factory->get('entity_test_mulrev') - ->condition("id.%delta.value", array(1, 3, 5), 'IN') + ->condition("id.%delta.value", [1, 3, 5], 'IN') ->condition("id.%delta", 1, '=') ->sort('id') ->execute(); @@ -596,7 +596,7 @@ public function testDelta() { } protected function assertResult() { - $assert = array(); + $assert = []; $expected = func_get_args(); if ($expected && is_array($expected[0])) { $expected = $expected[0]; @@ -608,7 +608,7 @@ protected function assertResult() { } protected function assertRevisionResult($keys, $expected) { - $assert = array(); + $assert = []; foreach ($expected as $key => $binary) { $assert[$keys[$key]] = strval($binary); } @@ -659,41 +659,41 @@ public function testMetaData() { public function testCaseSensitivity() { $bundle = $this->randomMachineName(); - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'field_name' => 'field_ci', 'entity_type' => 'entity_test_mulrev', 'type' => 'string', 'cardinality' => 1, 'translatable' => FALSE, - 'settings' => array( + 'settings' => [ 'case_sensitive' => FALSE, - ) - )); + ] + ]); $field_storage->save(); - FieldConfig::create(array( + FieldConfig::create([ 'field_storage' => $field_storage, 'bundle' => $bundle, - ))->save(); + ])->save(); - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'field_name' => 'field_cs', 'entity_type' => 'entity_test_mulrev', 'type' => 'string', 'cardinality' => 1, 'translatable' => FALSE, - 'settings' => array( + 'settings' => [ 'case_sensitive' => TRUE, - ), - )); + ], + ]); $field_storage->save(); - FieldConfig::create(array( + FieldConfig::create([ 'field_storage' => $field_storage, 'bundle' => $bundle, - ))->save(); + ])->save(); - $fixtures = array(); + $fixtures = []; for ($i = 0; $i < 2; $i++) { // If the last 4 of the string are all numbers, then there is no @@ -701,20 +701,20 @@ public function testCaseSensitivity() { // test will fail. Ensure that can not happen by appending a non-numeric // character. See https://www.drupal.org/node/2397297. $string = $this->randomMachineName(7) . 'a'; - $fixtures[] = array( + $fixtures[] = [ 'original' => $string, 'uppercase' => Unicode::strtoupper($string), 'lowercase' => Unicode::strtolower($string), - ); + ]; } - EntityTestMulRev::create(array( + EntityTestMulRev::create([ 'type' => $bundle, 'name' => $this->randomMachineName(), 'langcode' => 'en', 'field_ci' => $fixtures[0]['uppercase'] . $fixtures[1]['lowercase'], 'field_cs' => $fixtures[0]['uppercase'] . $fixtures[1]['lowercase'] - ))->save(); + ])->save(); // Check the case insensitive field, = operator. $result = \Drupal::entityQuery('entity_test_mulrev')->condition( @@ -750,33 +750,33 @@ public function testCaseSensitivity() { // Check the case insensitive field, IN operator. $result = \Drupal::entityQuery('entity_test_mulrev')->condition( - 'field_ci', array($fixtures[0]['lowercase'] . $fixtures[1]['lowercase']), 'IN' + 'field_ci', [$fixtures[0]['lowercase'] . $fixtures[1]['lowercase']], 'IN' )->execute(); $this->assertIdentical(count($result), 1, 'Case insensitive, lowercase'); $result = \Drupal::entityQuery('entity_test_mulrev')->condition( - 'field_ci', array($fixtures[0]['uppercase'] . $fixtures[1]['uppercase']), 'IN' + 'field_ci', [$fixtures[0]['uppercase'] . $fixtures[1]['uppercase']], 'IN' )->execute(); $this->assertIdentical(count($result), 1, 'Case insensitive, uppercase'); $result = \Drupal::entityQuery('entity_test_mulrev')->condition( - 'field_ci', array($fixtures[0]['uppercase'] . $fixtures[1]['lowercase']), 'IN' + 'field_ci', [$fixtures[0]['uppercase'] . $fixtures[1]['lowercase']], 'IN' )->execute(); $this->assertIdentical(count($result), 1, 'Case insensitive, mixed'); // Check the case sensitive field, IN operator. $result = \Drupal::entityQuery('entity_test_mulrev')->condition( - 'field_cs', array($fixtures[0]['lowercase'] . $fixtures[1]['lowercase']), 'IN' + 'field_cs', [$fixtures[0]['lowercase'] . $fixtures[1]['lowercase']], 'IN' )->execute(); $this->assertIdentical(count($result), 0, 'Case sensitive, lowercase'); $result = \Drupal::entityQuery('entity_test_mulrev')->condition( - 'field_cs', array($fixtures[0]['uppercase'] . $fixtures[1]['uppercase']), 'IN' + 'field_cs', [$fixtures[0]['uppercase'] . $fixtures[1]['uppercase']], 'IN' )->execute(); $this->assertIdentical(count($result), 0, 'Case sensitive, uppercase'); $result = \Drupal::entityQuery('entity_test_mulrev')->condition( - 'field_cs', array($fixtures[0]['uppercase'] . $fixtures[1]['lowercase']), 'IN' + 'field_cs', [$fixtures[0]['uppercase'] . $fixtures[1]['lowercase']], 'IN' )->execute(); $this->assertIdentical(count($result), 1, 'Case sensitive, mixed'); @@ -863,19 +863,19 @@ public function testBaseFieldMultipleColumns() { $term1 = Term::create([ 'name' => $this->randomMachineName(), 'vid' => 'tags', - 'description' => array( + 'description' => [ 'value' => $this->randomString(), 'format' => 'format1', - )]); + ]]); $term1->save(); $term2 = Term::create([ 'name' => $this->randomMachineName(), 'vid' => 'tags', - 'description' => array( + 'description' => [ 'value' => $this->randomString(), 'format' => 'format2', - )]); + ]]); $term2->save(); $ids = \Drupal::entityQuery('taxonomy_term') @@ -936,7 +936,7 @@ public function testForwardRevisions() { public function testInjectionInCondition() { try { $this->queryResults = $this->factory->get('entity_test_mulrev') - ->condition('1 ; -- ', array(0, 1), 'IN') + ->condition('1 ; -- ', [0, 1], 'IN') ->sort('id') ->execute(); $this->fail('SQL Injection attempt in Entity Query condition in operator should result in an exception.'); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php index cb82742..e9b1857 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php @@ -59,7 +59,7 @@ class EntityReferenceFieldTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('entity_reference_test'); + public static $modules = ['entity_reference_test']; /** * {@inheritdoc} @@ -77,7 +77,7 @@ protected function setUp() { 'Field test', $this->referencedEntityType, 'default', - array('target_bundles' => array($this->bundle)), + ['target_bundles' => [$this->bundle]], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED ); @@ -90,12 +90,12 @@ public function testEntityReferenceFieldValidation() { // Test a valid reference. $referenced_entity = $this->container->get('entity_type.manager') ->getStorage($this->referencedEntityType) - ->create(array('type' => $this->bundle)); + ->create(['type' => $this->bundle]); $referenced_entity->save(); $entity = $this->container->get('entity_type.manager') ->getStorage($this->entityType) - ->create(array('type' => $this->bundle)); + ->create(['type' => $this->bundle]); $entity->{$this->fieldName}->target_id = $referenced_entity->id(); $violations = $entity->{$this->fieldName}->validate(); $this->assertEqual($violations->count(), 0, 'Validation passes.'); @@ -104,16 +104,16 @@ public function testEntityReferenceFieldValidation() { $entity->{$this->fieldName}->target_id = 9999; $violations = $entity->{$this->fieldName}->validate(); $this->assertEqual($violations->count(), 1, 'Validation throws a violation.'); - $this->assertEqual($violations[0]->getMessage(), t('The referenced entity (%type: %id) does not exist.', array('%type' => $this->referencedEntityType, '%id' => 9999))); + $this->assertEqual($violations[0]->getMessage(), t('The referenced entity (%type: %id) does not exist.', ['%type' => $this->referencedEntityType, '%id' => 9999])); // Test a non-referenceable bundle. entity_test_create_bundle('non_referenceable', NULL, $this->referencedEntityType); - $referenced_entity = entity_create($this->referencedEntityType, array('type' => 'non_referenceable')); + $referenced_entity = entity_create($this->referencedEntityType, ['type' => 'non_referenceable']); $referenced_entity->save(); $entity->{$this->fieldName}->target_id = $referenced_entity->id(); $violations = $entity->{$this->fieldName}->validate(); $this->assertEqual($violations->count(), 1, 'Validation throws a violation.'); - $this->assertEqual($violations[0]->getMessage(), t('This entity (%type: %id) cannot be referenced.', array('%type' => $this->referencedEntityType, '%id' => $referenced_entity->id()))); + $this->assertEqual($violations[0]->getMessage(), t('This entity (%type: %id) cannot be referenced.', ['%type' => $this->referencedEntityType, '%id' => $referenced_entity->id()])); } /** @@ -123,15 +123,15 @@ public function testReferencedEntitiesMultipleLoad() { // Create the parent entity. $entity = $this->container->get('entity_type.manager') ->getStorage($this->entityType) - ->create(array('type' => $this->bundle)); + ->create(['type' => $this->bundle]); // Create three target entities and attach them to parent field. - $target_entities = array(); - $reference_field = array(); + $target_entities = []; + $reference_field = []; for ($i = 0; $i < 3; $i++) { $target_entity = $this->container->get('entity_type.manager') ->getStorage($this->referencedEntityType) - ->create(array('type' => $this->bundle)); + ->create(['type' => $this->bundle]); $target_entity->save(); $target_entities[] = $target_entity; $reference_field[]['target_id'] = $target_entity->id(); @@ -154,7 +154,7 @@ public function testReferencedEntitiesMultipleLoad() { // "autocreate" feature. $target_entity_unsaved = $this->container->get('entity_type.manager') ->getStorage($this->referencedEntityType) - ->create(array('type' => $this->bundle, 'name' => $this->randomString())); + ->create(['type' => $this->bundle, 'name' => $this->randomString()]); $reference_field[6]['entity'] = $target_entity_unsaved; $target_entities[6] = $target_entity_unsaved; @@ -201,13 +201,13 @@ public function testReferencedEntitiesStringId() { 'Field test', 'entity_test_string_id', 'default', - array('target_bundles' => array($this->bundle)), + ['target_bundles' => [$this->bundle]], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED ); // Create the parent entity. $entity = $this->container->get('entity_type.manager') ->getStorage($this->entityType) - ->create(array('type' => $this->bundle)); + ->create(['type' => $this->bundle]); // Create the default target entity. $target_entity = EntityTestStringId::create([ @@ -217,7 +217,7 @@ public function testReferencedEntitiesStringId() { $target_entity->save(); // Set the field value. - $entity->{$field_name}->setValue(array(array('target_id' => $target_entity->id()))); + $entity->{$field_name}->setValue([['target_id' => $target_entity->id()]]); // Load the target entities using EntityReferenceField::referencedEntities(). $entities = $entity->{$field_name}->referencedEntities(); @@ -233,7 +233,7 @@ public function testReferencedEntitiesStringId() { // Test that the default value works. $entity = $this->container->get('entity_type.manager') ->getStorage($this->entityType) - ->create(array('type' => $this->bundle)); + ->create(['type' => $this->bundle]); $entities = $entity->{$field_name}->referencedEntities(); $this->assertEqual($entities[0]->id(), $target_entity->id()); } @@ -244,7 +244,7 @@ public function testReferencedEntitiesStringId() { function testAutocreateApi() { $entity = $this->entityManager ->getStorage($this->entityType) - ->create(array('name' => $this->randomString())); + ->create(['name' => $this->randomString()]); // Test content entity autocreation. $this->assertUserAutocreate($entity, function(EntityInterface $entity, UserInterface $user) { @@ -260,13 +260,13 @@ function testAutocreateApi() { $entity->user_id[0]->get('entity')->setValue($user); }); $this->assertUserAutocreate($entity, function(EntityInterface $entity, UserInterface $user) { - $entity->user_id->setValue(array('entity' => $user, 'target_id' => NULL)); + $entity->user_id->setValue(['entity' => $user, 'target_id' => NULL]); }); try { $message = 'Setting both the entity and an invalid target_id property fails.'; $this->assertUserAutocreate($entity, function(EntityInterface $entity, UserInterface $user) { $user->save(); - $entity->user_id->setValue(array('entity' => $user, 'target_id' => $this->generateRandomEntityId())); + $entity->user_id->setValue(['entity' => $user, 'target_id' => $this->generateRandomEntityId()]); }); $this->fail($message); } @@ -294,13 +294,13 @@ function testAutocreateApi() { $entity->user_role[0]->get('entity')->setValue($role); }); $this->assertUserRoleAutocreate($entity, function(EntityInterface $entity, RoleInterface $role) { - $entity->user_role->setValue(array('entity' => $role, 'target_id' => NULL)); + $entity->user_role->setValue(['entity' => $role, 'target_id' => NULL]); }); try { $message = 'Setting both the entity and an invalid target_id property fails.'; $this->assertUserRoleAutocreate($entity, function(EntityInterface $entity, RoleInterface $role) { $role->save(); - $entity->user_role->setValue(array('entity' => $role, 'target_id' => $this->generateRandomEntityId(TRUE))); + $entity->user_role->setValue(['entity' => $role, 'target_id' => $this->generateRandomEntityId(TRUE)]); }); $this->fail($message); } @@ -317,7 +317,7 @@ function testAutocreateApi() { // Test target entity saving after setting it as new. $storage = $this->entityManager->getStorage('user'); $user_id = $this->generateRandomEntityId(); - $user = $storage->create(array('uid' => $user_id, 'name' => $this->randomString())); + $user = $storage->create(['uid' => $user_id, 'name' => $this->randomString()]); $entity->user_id = $user; $user->save(); $entity->save(); @@ -338,7 +338,7 @@ function testAutocreateApi() { protected function assertUserAutocreate(EntityInterface $entity, $setter_callback) { $storage = $this->entityManager->getStorage('user'); $user_id = $this->generateRandomEntityId(); - $user = $storage->create(array('uid' => $user_id, 'name' => $this->randomString())); + $user = $storage->create(['uid' => $user_id, 'name' => $this->randomString()]); $setter_callback($entity, $user); $entity->save(); $storage->resetCache(); @@ -360,7 +360,7 @@ protected function assertUserAutocreate(EntityInterface $entity, $setter_callbac protected function assertUserRoleAutocreate(EntityInterface $entity, $setter_callback) { $storage = $this->entityManager->getStorage('user_role'); $role_id = $this->generateRandomEntityId(TRUE); - $role = $storage->create(array('id' => $role_id, 'label' => $this->randomString())); + $role = $storage->create(['id' => $role_id, 'label' => $this->randomString()]); $setter_callback($entity, $role); $entity->save(); $storage->resetCache(); @@ -378,11 +378,11 @@ public function testTargetEntityNoLoad() { $entity_type = clone $this->entityManager->getDefinition('entity_test_update'); $entity_type->setHandlerClass('storage', '\Drupal\entity_test\EntityTestNoLoadStorage'); $this->state->set('entity_test_update.entity_type', $entity_type); - $definitions = array( + $definitions = [ 'target_reference' => BaseFieldDefinition::create('entity_reference') ->setSetting('target_type', $entity_type->id()) ->setSetting('handler', 'default') - ); + ]; $this->state->set('entity_test_update.additional_base_field_definitions', $definitions); $this->entityManager->clearCachedDefinitions(); $this->installEntitySchema($entity_type->id()); @@ -390,7 +390,7 @@ public function testTargetEntityNoLoad() { // Create the target entity. $storage = $this->entityManager->getStorage($entity_type->id()); $target_id = $this->generateRandomEntityId(); - $target = $storage->create(array('id' => $target_id, 'name' => $this->randomString())); + $target = $storage->create(['id' => $target_id, 'name' => $this->randomString()]); $target->save(); $this->assertEqual($target_id, $target->id(), 'The target entity has a random identifier.'); @@ -400,7 +400,7 @@ public function testTargetEntityNoLoad() { try { $entity = $this->entityManager ->getStorage($entity_type->id()) - ->create(array('name' => $this->randomString())); + ->create(['name' => $this->randomString()]); $entity->target_reference = $target_id; $this->pass($message); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php index f51c8ea..eb13d0e 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceSelection/EntityReferenceSelectionSortTest.php @@ -21,19 +21,19 @@ class EntityReferenceSelectionSortTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('node'); + public static $modules = ['node']; protected function setUp() { parent::setUp(); // Create an Article node type. - $article = NodeType::create(array( + $article = NodeType::create([ 'type' => 'article', - )); + ]); $article->save(); // Test as a non-admin. - $normal_user = $this->createUser(array(), array('access content')); + $normal_user = $this->createUser([], ['access content']); \Drupal::currentUser()->setAccount($normal_user); } @@ -42,50 +42,50 @@ protected function setUp() { */ public function testSort() { // Add text field to entity, to sort by. - FieldStorageConfig::create(array( + FieldStorageConfig::create([ 'field_name' => 'field_text', 'entity_type' => 'node', 'type' => 'text', - 'entity_types' => array('node'), - ))->save(); + 'entity_types' => ['node'], + ])->save(); FieldConfig::create([ 'label' => 'Text Field', 'field_name' => 'field_text', 'entity_type' => 'node', 'bundle' => 'article', - 'settings' => array(), + 'settings' => [], 'required' => FALSE, ])->save(); // Build a set of test data. - $node_values = array( - 'published1' => array( + $node_values = [ + 'published1' => [ 'type' => 'article', 'status' => 1, 'title' => 'Node published1 (<&>)', 'uid' => 1, - 'field_text' => array( - array( + 'field_text' => [ + [ 'value' => 1, - ), - ), - ), - 'published2' => array( + ], + ], + ], + 'published2' => [ 'type' => 'article', 'status' => 1, 'title' => 'Node published2 (<&>)', 'uid' => 1, - 'field_text' => array( - array( + 'field_text' => [ + [ 'value' => 2, - ), - ), - ), - ); + ], + ], + ], + ]; - $nodes = array(); - $node_labels = array(); + $nodes = []; + $node_labels = []; foreach ($node_values as $key => $values) { $node = Node::create($values); $node->save(); @@ -93,40 +93,40 @@ public function testSort() { $node_labels[$key] = Html::escape($node->label()); } - $selection_options = array( + $selection_options = [ 'target_type' => 'node', 'handler' => 'default', - 'handler_settings' => array( + 'handler_settings' => [ 'target_bundles' => NULL, // Add sorting. - 'sort' => array( + 'sort' => [ 'field' => 'field_text.value', 'direction' => 'DESC', - ), - ), - ); + ], + ], + ]; $handler = $this->container->get('plugin.manager.entity_reference_selection')->getInstance($selection_options); // Not only assert the result, but make sure the keys are sorted as // expected. $result = $handler->getReferenceableEntities(); - $expected_result = array( + $expected_result = [ $nodes['published2']->id() => $node_labels['published2'], $nodes['published1']->id() => $node_labels['published1'], - ); + ]; $this->assertIdentical($result['article'], $expected_result, 'Query sorted by field returned expected values.'); // Assert sort by base field. - $selection_options['handler_settings']['sort'] = array( + $selection_options['handler_settings']['sort'] = [ 'field' => 'nid', 'direction' => 'ASC', - ); + ]; $handler = $this->container->get('plugin.manager.entity_reference_selection')->getInstance($selection_options); $result = $handler->getReferenceableEntities(); - $expected_result = array( + $expected_result = [ $nodes['published1']->id() => $node_labels['published1'], $nodes['published2']->id() => $node_labels['published2'], - ); + ]; $this->assertIdentical($result['article'], $expected_result, 'Query sorted by property returned expected values.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php index fdf72df..3e285ff 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntitySchemaTest.php @@ -23,7 +23,7 @@ class EntitySchemaTest extends EntityKernelTestBase { */ protected function setUp() { parent::setUp(); - $this->installSchema('user', array('users_data')); + $this->installSchema('user', ['users_data']); $this->database = $this->container->get('database'); } @@ -80,33 +80,33 @@ public function testEntitySchemaUpdate() { $this->entityManager->onFieldStorageDefinitionCreate($storage_definitions['custom_base_field']); $this->entityManager->onFieldStorageDefinitionCreate($storage_definitions['custom_bundle_field']); $schema_handler = $this->database->schema(); - $tables = array('entity_test', 'entity_test_revision', 'entity_test_field_data', 'entity_test_field_revision'); - $dedicated_tables = array('entity_test__custom_bundle_field', 'entity_test_revision__custom_bundle_field'); + $tables = ['entity_test', 'entity_test_revision', 'entity_test_field_data', 'entity_test_field_revision']; + $dedicated_tables = ['entity_test__custom_bundle_field', 'entity_test_revision__custom_bundle_field']; // Initially only the base table and the dedicated field data table should // exist. foreach ($tables as $index => $table) { - $this->assertEqual($schema_handler->tableExists($table), !$index, SafeMarkup::format('Entity schema correct for the @table table.', array('@table' => $table))); + $this->assertEqual($schema_handler->tableExists($table), !$index, SafeMarkup::format('Entity schema correct for the @table table.', ['@table' => $table])); } - $this->assertTrue($schema_handler->tableExists($dedicated_tables[0]), SafeMarkup::format('Field schema correct for the @table table.', array('@table' => $table))); + $this->assertTrue($schema_handler->tableExists($dedicated_tables[0]), SafeMarkup::format('Field schema correct for the @table table.', ['@table' => $table])); // Update the entity type definition and check that the entity schema now // supports translations and revisions. $this->updateEntityType(TRUE); foreach ($tables as $table) { - $this->assertTrue($schema_handler->tableExists($table), SafeMarkup::format('Entity schema correct for the @table table.', array('@table' => $table))); + $this->assertTrue($schema_handler->tableExists($table), SafeMarkup::format('Entity schema correct for the @table table.', ['@table' => $table])); } foreach ($dedicated_tables as $table) { - $this->assertTrue($schema_handler->tableExists($table), SafeMarkup::format('Field schema correct for the @table table.', array('@table' => $table))); + $this->assertTrue($schema_handler->tableExists($table), SafeMarkup::format('Field schema correct for the @table table.', ['@table' => $table])); } // Revert changes and check that the entity schema now does not support // neither translations nor revisions. $this->updateEntityType(FALSE); foreach ($tables as $index => $table) { - $this->assertEqual($schema_handler->tableExists($table), !$index, SafeMarkup::format('Entity schema correct for the @table table.', array('@table' => $table))); + $this->assertEqual($schema_handler->tableExists($table), !$index, SafeMarkup::format('Entity schema correct for the @table table.', ['@table' => $table])); } - $this->assertTrue($schema_handler->tableExists($dedicated_tables[0]), SafeMarkup::format('Field schema correct for the @table table.', array('@table' => $table))); + $this->assertTrue($schema_handler->tableExists($dedicated_tables[0]), SafeMarkup::format('Field schema correct for the @table table.', ['@table' => $table])); } /** @@ -167,7 +167,7 @@ public function testCleanUpStorageDefinition() { $this->assertNotEqual($entity_type_id_count, 0, 'There are storage definitions provided by the entity_test module in the schema.'); // Uninstall the entity_test module. - $this->container->get('module_installer')->uninstall(array('entity_test')); + $this->container->get('module_installer')->uninstall(['entity_test']); // Get a list of all the entities in the schema. $key_value_store = \Drupal::keyValue('entity.storage_schema.sql'); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php index ed6140d..fad3899 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php @@ -37,28 +37,28 @@ protected function doTestEntityLanguageMethods($entity_type) { $langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode'); $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array( + ->create([ 'name' => 'test', 'user_id' => $this->container->get('current_user')->id(), - )); - $this->assertEqual($entity->language()->getId(), $this->languageManager->getDefaultLanguage()->getId(), format_string('%entity_type: Entity created with API has default language.', array('%entity_type' => $entity_type))); + ]); + $this->assertEqual($entity->language()->getId(), $this->languageManager->getDefaultLanguage()->getId(), format_string('%entity_type: Entity created with API has default language.', ['%entity_type' => $entity_type])); $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array( + ->create([ 'name' => 'test', 'user_id' => \Drupal::currentUser()->id(), $langcode_key => LanguageInterface::LANGCODE_NOT_SPECIFIED, - )); + ]); - $this->assertEqual($entity->language()->getId(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', array('%entity_type' => $entity_type))); - $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->language()->getId(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity language not specified.', ['%entity_type' => $entity_type])); + $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', ['%entity_type' => $entity_type])); // Set the value in default language. - $entity->set($this->fieldName, array(0 => array('value' => 'default value'))); + $entity->set($this->fieldName, [0 => ['value' => 'default value']]); // Get the value. $field = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get($this->fieldName); - $this->assertEqual($field->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type))); - $this->assertEqual($field->getLangcode(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type))); + $this->assertEqual($field->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', ['%entity_type' => $entity_type])); + $this->assertEqual($field->getLangcode(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Field object has the expected langcode.', ['%entity_type' => $entity_type])); // Try to get add a translation to language neutral entity. $message = 'Adding a translation to a language-neutral entity results in an error.'; @@ -74,22 +74,22 @@ protected function doTestEntityLanguageMethods($entity_type) { // translating it. $default_langcode = $this->langcodes[0]; $entity->{$langcode_key}->value = $default_langcode; - $entity->{$this->fieldName} = array(); - $this->assertEqual($entity->language(), \Drupal::languageManager()->getLanguage($this->langcodes[0]), format_string('%entity_type: Entity language retrieved.', array('%entity_type' => $entity_type))); - $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type))); + $entity->{$this->fieldName} = []; + $this->assertEqual($entity->language(), \Drupal::languageManager()->getLanguage($this->langcodes[0]), format_string('%entity_type: Entity language retrieved.', ['%entity_type' => $entity_type])); + $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', ['%entity_type' => $entity_type])); // Set the value in default language. - $entity->set($this->fieldName, array(0 => array('value' => 'default value'))); + $entity->set($this->fieldName, [0 => ['value' => 'default value']]); // Get the value. $field = $entity->get($this->fieldName); - $this->assertEqual($field->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type))); - $this->assertEqual($field->getLangcode(), $default_langcode, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type))); + $this->assertEqual($field->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', ['%entity_type' => $entity_type])); + $this->assertEqual($field->getLangcode(), $default_langcode, format_string('%entity_type: Field object has the expected langcode.', ['%entity_type' => $entity_type])); // Set a translation. - $entity->addTranslation($this->langcodes[1])->set($this->fieldName, array(0 => array('value' => 'translation 1'))); + $entity->addTranslation($this->langcodes[1])->set($this->fieldName, [0 => ['value' => 'translation 1']]); $field = $entity->getTranslation($this->langcodes[1])->{$this->fieldName}; - $this->assertEqual($field->value, 'translation 1', format_string('%entity_type: Translated value set.', array('%entity_type' => $entity_type))); - $this->assertEqual($field->getLangcode(), $this->langcodes[1], format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type))); + $this->assertEqual($field->value, 'translation 1', format_string('%entity_type: Translated value set.', ['%entity_type' => $entity_type])); + $this->assertEqual($field->getLangcode(), $this->langcodes[1], format_string('%entity_type: Field object has the expected langcode.', ['%entity_type' => $entity_type])); // Make sure the untranslated value stays. $field = $entity->get($this->fieldName); @@ -110,7 +110,7 @@ protected function doTestEntityLanguageMethods($entity_type) { } // Try to get a not available translation. - $this->assertNull($entity->addTranslation($this->langcodes[2])->get($this->fieldName)->value, format_string('%entity_type: A translation that is not available is NULL.', array('%entity_type' => $entity_type))); + $this->assertNull($entity->addTranslation($this->langcodes[2])->get($this->fieldName)->value, format_string('%entity_type: A translation that is not available is NULL.', ['%entity_type' => $entity_type])); // Try to get a value using an invalid language code. $message = 'Getting an invalid translation results in an error.'; @@ -125,19 +125,19 @@ protected function doTestEntityLanguageMethods($entity_type) { // Try to set a value using an invalid language code. try { $entity->getTranslation('invalid')->set($this->fieldName, NULL); - $this->fail(format_string('%entity_type: Setting a translation for an invalid language throws an exception.', array('%entity_type' => $entity_type))); + $this->fail(format_string('%entity_type: Setting a translation for an invalid language throws an exception.', ['%entity_type' => $entity_type])); } catch (\InvalidArgumentException $e) { - $this->pass(format_string('%entity_type: Setting a translation for an invalid language throws an exception.', array('%entity_type' => $entity_type))); + $this->pass(format_string('%entity_type: Setting a translation for an invalid language throws an exception.', ['%entity_type' => $entity_type])); } // Set the value in default language. $field_name = 'field_test_text'; - $entity->getTranslation($this->langcodes[1])->set($field_name, array(0 => array('value' => 'default value2'))); + $entity->getTranslation($this->langcodes[1])->set($field_name, [0 => ['value' => 'default value2']]); // Get the value. $field = $entity->get($field_name); - $this->assertEqual($field->value, 'default value2', format_string('%entity_type: Untranslated value set into a translation in non-strict mode.', array('%entity_type' => $entity_type))); - $this->assertEqual($field->getLangcode(), $default_langcode, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type))); + $this->assertEqual($field->value, 'default value2', format_string('%entity_type: Untranslated value set into a translation in non-strict mode.', ['%entity_type' => $entity_type])); + $this->assertEqual($field->getLangcode(), $default_langcode, format_string('%entity_type: Field object has the expected langcode.', ['%entity_type' => $entity_type])); } /** @@ -171,51 +171,51 @@ protected function doTestMultilingualProperties($entity_type) { $entity->save(); $entity = $storage->load($entity->id()); $default_langcode = $entity->language()->getId(); - $this->assertEqual($default_langcode, LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', array('%entity_type' => $entity_type))); + $this->assertEqual($default_langcode, LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Entity created as language neutral.', ['%entity_type' => $entity_type])); $field = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get('name'); - $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as language neutral.', array('%entity_type' => $entity_type))); - $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type))); - $this->assertEqual($uid, $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as language neutral.', array('%entity_type' => $entity_type))); + $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as language neutral.', ['%entity_type' => $entity_type])); + $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', ['%entity_type' => $entity_type])); + $this->assertEqual($uid, $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as language neutral.', ['%entity_type' => $entity_type])); $translation = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT); $field = $translation->get('name'); - $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name defaults to neutral language.', array('%entity_type' => $entity_type))); - $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type))); - $this->assertEqual($uid, $translation->get('user_id')->target_id, format_string('%entity_type: The entity author defaults to neutral language.', array('%entity_type' => $entity_type))); + $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name defaults to neutral language.', ['%entity_type' => $entity_type])); + $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', ['%entity_type' => $entity_type])); + $this->assertEqual($uid, $translation->get('user_id')->target_id, format_string('%entity_type: The entity author defaults to neutral language.', ['%entity_type' => $entity_type])); $field = $entity->get('name'); - $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name can be retrieved without specifying a language.', array('%entity_type' => $entity_type))); - $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type))); - $this->assertEqual($uid, $entity->get('user_id')->target_id, format_string('%entity_type: The entity author can be retrieved without specifying a language.', array('%entity_type' => $entity_type))); + $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name can be retrieved without specifying a language.', ['%entity_type' => $entity_type])); + $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', ['%entity_type' => $entity_type])); + $this->assertEqual($uid, $entity->get('user_id')->target_id, format_string('%entity_type: The entity author can be retrieved without specifying a language.', ['%entity_type' => $entity_type])); // Create a language-aware entity and check that properties are stored // as language-aware. $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array('name' => $name, 'user_id' => $uid, $langcode_key => $langcode)); + ->create(['name' => $name, 'user_id' => $uid, $langcode_key => $langcode]); $entity->save(); $entity = $storage->load($entity->id()); $default_langcode = $entity->language()->getId(); - $this->assertEqual($default_langcode, $langcode, format_string('%entity_type: Entity created as language specific.', array('%entity_type' => $entity_type))); + $this->assertEqual($default_langcode, $langcode, format_string('%entity_type: Entity created as language specific.', ['%entity_type' => $entity_type])); $field = $entity->getTranslation($langcode)->get('name'); - $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type))); - $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', array('%entity_type' => $entity_type))); - $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as a language-aware property.', array('%entity_type' => $entity_type))); + $this->assertEqual($name, $field->value, format_string('%entity_type: The entity name has been correctly stored as a language-aware property.', ['%entity_type' => $entity_type])); + $this->assertEqual($default_langcode, $field->getLangcode(), format_string('%entity_type: The field object has the expect langcode.', ['%entity_type' => $entity_type])); + $this->assertEqual($uid, $entity->getTranslation($langcode)->get('user_id')->target_id, format_string('%entity_type: The entity author has been correctly stored as a language-aware property.', ['%entity_type' => $entity_type])); // Create property translations. - $properties = array(); + $properties = []; $default_langcode = $langcode; foreach ($this->langcodes as $langcode) { if ($langcode != $default_langcode) { - $properties[$langcode] = array( - 'name' => array(0 => $this->randomMachineName()), - 'user_id' => array(0 => mt_rand(128, 256)), - ); + $properties[$langcode] = [ + 'name' => [0 => $this->randomMachineName()], + 'user_id' => [0 => mt_rand(128, 256)], + ]; } else { - $properties[$langcode] = array( - 'name' => array(0 => $name), - 'user_id' => array(0 => $uid), - ); + $properties[$langcode] = [ + 'name' => [0 => $name], + 'user_id' => [0 => $uid], + ]; } $translation = $entity->hasTranslation($langcode) ? $entity->getTranslation($langcode) : $entity->addTranslation($langcode); foreach ($properties[$langcode] as $field_name => $values) { @@ -227,10 +227,10 @@ protected function doTestMultilingualProperties($entity_type) { // Check that property translation were correctly stored. $entity = $storage->load($entity->id()); foreach ($this->langcodes as $langcode) { - $args = array( + $args = [ '%entity_type' => $entity_type, '%langcode' => $langcode, - ); + ]; $field = $entity->getTranslation($langcode)->get('name'); $this->assertEqual($properties[$langcode]['name'][0], $field->value, format_string('%entity_type: The entity name has been correctly stored for language %langcode.', $args)); $field_langcode = ($langcode == $entity->language()->getId()) ? $default_langcode : $langcode; @@ -254,24 +254,24 @@ protected function doTestMultilingualProperties($entity_type) { ->save(); $entities = $storage->loadMultiple(); - $this->assertEqual(count($entities), 3, format_string('%entity_type: Three entities were created.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($entities), 3, format_string('%entity_type: Three entities were created.', ['%entity_type' => $entity_type])); $entities = $storage->loadMultiple([$translated_id]); - $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by id.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by id.', ['%entity_type' => $entity_type])); $entities = $storage->loadByProperties(['name' => $name]); - $this->assertEqual(count($entities), 2, format_string('%entity_type: Two entities correctly loaded by name.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($entities), 2, format_string('%entity_type: Two entities correctly loaded by name.', ['%entity_type' => $entity_type])); // @todo The default language condition should go away in favor of an // explicit parameter. $entities = $storage->loadByProperties(['name' => $properties[$langcode]['name'][0], $default_langcode_key => 0]); - $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by name translation.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by name translation.', ['%entity_type' => $entity_type])); $entities = $storage->loadByProperties([$langcode_key => $default_langcode, 'name' => $name]); - $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by name and language.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity correctly loaded by name and language.', ['%entity_type' => $entity_type])); $entities = $storage->loadByProperties([$langcode_key => $langcode, 'name' => $properties[$langcode]['name'][0]]); - $this->assertEqual(count($entities), 0, format_string('%entity_type: No entity loaded by name translation specifying the translation language.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($entities), 0, format_string('%entity_type: No entity loaded by name translation specifying the translation language.', ['%entity_type' => $entity_type])); $entities = $storage->loadByProperties([$langcode_key => $langcode, 'name' => $properties[$langcode]['name'][0], $default_langcode_key => 0]); - $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity loaded by name translation and language specifying to look for translations.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($entities), 1, format_string('%entity_type: One entity loaded by name translation and language specifying to look for translations.', ['%entity_type' => $entity_type])); $entities = $storage->loadByProperties(['user_id' => $properties[$langcode]['user_id'][0], $default_langcode_key => NULL]); - $this->assertEqual(count($entities), 2, format_string('%entity_type: Two entities loaded by uid without caring about property translatability.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($entities), 2, format_string('%entity_type: Two entities loaded by uid without caring about property translatability.', ['%entity_type' => $entity_type])); // Test property conditions and orders with multiple languages in the same // query. @@ -283,13 +283,13 @@ protected function doTestMultilingualProperties($entity_type) { ->condition($group) ->condition('name', $properties[$langcode]['name'][0], '=', $langcode) ->execute(); - $this->assertEqual(count($result), 1, format_string('%entity_type: One entity loaded by name and uid using different language meta conditions.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($result), 1, format_string('%entity_type: One entity loaded by name and uid using different language meta conditions.', ['%entity_type' => $entity_type])); // Test mixed property and field conditions. $storage->resetCache($result); $entity = $storage->load(reset($result)); $field_value = $this->randomString(); - $entity->getTranslation($langcode)->set($this->fieldName, array(array('value' => $field_value))); + $entity->getTranslation($langcode)->set($this->fieldName, [['value' => $field_value]]); $entity->save(); $query = \Drupal::entityQuery($entity_type); $default_langcode_group = $query->andConditionGroup() @@ -303,7 +303,7 @@ protected function doTestMultilingualProperties($entity_type) { ->condition($default_langcode_group) ->condition($langcode_group) ->execute(); - $this->assertEqual(count($result), 1, format_string('%entity_type: One entity loaded by name, uid and field value using different language meta conditions.', array('%entity_type' => $entity_type))); + $this->assertEqual(count($result), 1, format_string('%entity_type: One entity loaded by name, uid and field value using different language meta conditions.', ['%entity_type' => $entity_type])); } /** @@ -331,7 +331,7 @@ protected function doTestEntityTranslationAPI($entity_type) { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $this->entityManager ->getStorage($entity_type) - ->create(array('name' => $this->randomMachineName(), $langcode_key => LanguageInterface::LANGCODE_NOT_SPECIFIED)); + ->create(['name' => $this->randomMachineName(), $langcode_key => LanguageInterface::LANGCODE_NOT_SPECIFIED]); $entity->save(); $hooks = $this->getHooksInfo(); @@ -462,8 +462,8 @@ protected function doTestEntityTranslationAPI($entity_type) { $entity = $this->reloadEntity($entity); $translation = $entity->getTranslation($langcode2); $entity->removeTranslation($langcode2); - foreach (array('get', 'set', '__get', '__set', 'createDuplicate') as $method) { - $message = format_string('The @method method raises an exception when trying to manipulate a removed translation.', array('@method' => $method)); + foreach (['get', 'set', '__get', '__set', 'createDuplicate'] as $method) { + $message = format_string('The @method method raises an exception when trying to manipulate a removed translation.', ['@method' => $method]); try { $translation->{$method}('name', $this->randomMachineName()); $this->fail($message); @@ -484,8 +484,8 @@ protected function doTestEntityTranslationAPI($entity_type) { // Check that removing an invalid translation causes an exception to be // thrown. - foreach (array($default_langcode, LanguageInterface::LANGCODE_DEFAULT, $this->randomMachineName()) as $invalid_langcode) { - $message = format_string('Removing an invalid translation (@langcode) causes an exception to be thrown.', array('@langcode' => $invalid_langcode)); + foreach ([$default_langcode, LanguageInterface::LANGCODE_DEFAULT, $this->randomMachineName()] as $invalid_langcode) { + $message = format_string('Removing an invalid translation (@langcode) causes an exception to be thrown.', ['@langcode' => $invalid_langcode]); try { $entity->removeTranslation($invalid_langcode); $this->fail($message); @@ -566,16 +566,16 @@ protected function doTestEntityTranslationAPI($entity_type) { ->getStorage('entity_test_mul_default_value') ->create(['name' => $this->randomMachineName(), 'langcode' => $langcode]); $translation = $entity->addTranslation($langcode2); - $expected = array( - array( + $expected = [ + [ 'shape' => "shape:0:description_$langcode2", 'color' => "color:0:description_$langcode2", - ), - array( + ], + [ 'shape' => "shape:1:description_$langcode2", 'color' => "color:1:description_$langcode2", - ), - ); + ], + ]; $this->assertEqual($translation->description->getValue(), $expected, 'Language-aware default values correctly populated.'); $this->assertEqual($translation->description->getLangcode(), $langcode2, 'Field object has the expected langcode.'); @@ -606,7 +606,7 @@ protected function doTestLanguageFallback($entity_type) { $current_langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); $this->langcodes[] = $current_langcode; - $values = array(); + $values = []; foreach ($this->langcodes as $langcode) { $values[$langcode]['name'] = $this->randomMachineName(); $values[$langcode]['user_id'] = mt_rand(0, 127); @@ -623,7 +623,7 @@ protected function doTestLanguageFallback($entity_type) { $this->languageManager->reset(); $controller = $this->entityManager->getStorage($entity_type); - $entity = $controller->create(array($langcode_key => $default_langcode) + $values[$default_langcode]); + $entity = $controller->create([$langcode_key => $default_langcode] + $values[$default_langcode]); $entity->save(); $entity->addTranslation($langcode, $values[$langcode]); @@ -649,7 +649,7 @@ protected function doTestLanguageFallback($entity_type) { $this->assertEqual($current_langcode, $translation->language()->getId(), 'The current translation language matches the current language.'); // Check that if the entity has no translation no fallback is applied. - $entity2 = $controller->create(array($langcode_key => $default_langcode)); + $entity2 = $controller->create([$langcode_key => $default_langcode]); // Get an view builder. $controller = $this->entityManager->getViewBuilder($entity_type); $entity2_build = $controller->view($entity2); @@ -686,12 +686,12 @@ function testFieldDefinitions() { // Check that field translatability can be altered to be enabled or disabled // in field definitions. $entity_type = 'entity_test_mulrev'; - $this->state->set('entity_test.field_definitions.translatable', array('name' => FALSE)); + $this->state->set('entity_test.field_definitions.translatable', ['name' => FALSE]); $this->entityManager->clearCachedFieldDefinitions(); $definitions = $this->entityManager->getBaseFieldDefinitions($entity_type); $this->assertFalse($definitions['name']->isTranslatable(), 'Field translatability can be disabled programmatically.'); - $this->state->set('entity_test.field_definitions.translatable', array('name' => TRUE)); + $this->state->set('entity_test.field_definitions.translatable', ['name' => TRUE]); $this->entityManager->clearCachedFieldDefinitions(); $definitions = $this->entityManager->getBaseFieldDefinitions($entity_type); $this->assertTrue($definitions['name']->isTranslatable(), 'Field translatability can be enabled programmatically.'); @@ -702,17 +702,17 @@ function testFieldDefinitions() { $this->assertFalse($definitions['id']->isTranslatable(), 'Field translatability is disabled by default.'); // Check that entity id keys have the expect translatability. - $translatable_fields = array( + $translatable_fields = [ 'id' => TRUE, 'uuid' => TRUE, 'revision_id' => TRUE, 'type' => TRUE, 'langcode' => FALSE, - ); + ]; foreach ($translatable_fields as $name => $translatable) { - $this->state->set('entity_test.field_definitions.translatable', array($name => $translatable)); + $this->state->set('entity_test.field_definitions.translatable', [$name => $translatable]); $this->entityManager->clearCachedFieldDefinitions(); - $message = format_string('Field %field cannot be translatable.', array('%field' => $name)); + $message = format_string('Field %field cannot be translatable.', ['%field' => $name]); try { $this->entityManager->getBaseFieldDefinitions($entity_type); @@ -747,13 +747,13 @@ protected function doTestLanguageChange($entity_type) { // check that field languages match entity language regardless of field // translatability. - $values = array( + $values = [ $langcode_key => $langcode, $this->fieldName => $this->randomMachineName(), $this->untranslatableFieldName => $this->randomMachineName(), - ); + ]; $entity = $controller->create($values); - foreach (array($this->fieldName, $this->untranslatableFieldName) as $field_name) { + foreach ([$this->fieldName, $this->untranslatableFieldName] as $field_name) { $this->assertEqual($entity->get($field_name)->getLangcode(), $langcode, 'Field language works as expected.'); } @@ -761,16 +761,16 @@ protected function doTestLanguageChange($entity_type) { // changing it. $langcode = $this->langcodes[1]; $entity->{$langcode_key}->value = $langcode; - foreach (array($this->fieldName, $this->untranslatableFieldName) as $field_name) { + foreach ([$this->fieldName, $this->untranslatableFieldName] as $field_name) { $this->assertEqual($entity->get($field_name)->getLangcode(), $langcode, 'Field language works as expected after changing entity language.'); } // Check that entity translation does not affect the language of original // field values and untranslatable ones. $langcode = $this->langcodes[0]; - $entity->addTranslation($this->langcodes[2], array($this->fieldName => $this->randomMachineName())); + $entity->addTranslation($this->langcodes[2], [$this->fieldName => $this->randomMachineName()]); $entity->{$langcode_key}->value = $langcode; - foreach (array($this->fieldName, $this->untranslatableFieldName) as $field_name) { + foreach ([$this->fieldName, $this->untranslatableFieldName] as $field_name) { $this->assertEqual($entity->get($field_name)->getLangcode(), $langcode, 'Field language works as expected after translating the entity and changing language.'); } @@ -792,21 +792,21 @@ protected function doTestLanguageChange($entity_type) { function testEntityAdapter() { $entity_type = 'entity_test'; $default_langcode = 'en'; - $values[$default_langcode] = array('name' => $this->randomString()); + $values[$default_langcode] = ['name' => $this->randomString()]; $controller = $this->entityManager->getStorage($entity_type); /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $controller->create($values[$default_langcode]); foreach ($this->langcodes as $langcode) { - $values[$langcode] = array('name' => $this->randomString()); + $values[$langcode] = ['name' => $this->randomString()]; $entity->addTranslation($langcode, $values[$langcode]); } - $langcodes = array_merge(array($default_langcode), $this->langcodes); + $langcodes = array_merge([$default_langcode], $this->langcodes); foreach ($langcodes as $langcode) { $adapter = $entity->getTranslation($langcode)->getTypedData(); $name = $adapter->get('name')->value; - $this->assertEqual($name, $values[$langcode]['name'], SafeMarkup::format('Name correctly retrieved from "@langcode" adapter', array('@langcode' => $langcode))); + $this->assertEqual($name, $values[$langcode]['name'], SafeMarkup::format('Name correctly retrieved from "@langcode" adapter', ['@langcode' => $langcode])); } } @@ -879,11 +879,11 @@ public function testDeleteEntityTranslation() { $field->save(); // Create an entity with both translatable and untranslatable test fields. - $values = array( + $values = [ 'name' => $this->randomString(), 'translatable_test_field' => $this->randomString(), 'untranslatable_test_field' => $this->randomString(), - ); + ]; /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ $entity = $controller->create($values); @@ -940,11 +940,11 @@ public function testTranslationStatus() { $storage = $this->entityManager->getStorage($entity_type); // Create an entity with both translatable and untranslatable test fields. - $values = array( + $values = [ 'name' => $this->randomString(), 'translatable_test_field' => $this->randomString(), 'untranslatable_test_field' => $this->randomString(), - ); + ]; /** @var \Drupal\Core\Entity\ContentEntityInterface|\Drupal\Core\TypedData\TranslationStatusInterface $entity */ // Test that newly created entity has the translation status diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTypeConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTypeConstraintValidatorTest.php index 87d76b4..3671d6d 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTypeConstraintValidatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTypeConstraintValidatorTest.php @@ -18,7 +18,7 @@ class EntityTypeConstraintValidatorTest extends EntityKernelTestBase { */ protected $typedData; - public static $modules = array('node', 'field', 'user'); + public static $modules = ['node', 'field', 'user']; protected function setUp() { parent::setUp(); @@ -32,13 +32,13 @@ public function testValidation() { // Create a typed data definition with an EntityType constraint. $entity_type = 'node'; $definition = DataDefinition::create('entity_reference') - ->setConstraints(array( + ->setConstraints([ 'EntityType' => $entity_type, - ) + ] ); // Test the validation. - $node = $this->container->get('entity.manager')->getStorage('node')->create(array('type' => 'page')); + $node = $this->container->get('entity.manager')->getStorage('node')->create(['type' => 'page']); $typed_data = $this->typedData->create($definition, $node); $violations = $typed_data->validate(); $this->assertEqual($violations->count(), 0, 'Validation passed for correct value.'); @@ -53,7 +53,7 @@ public function testValidation() { // Make sure the information provided by a violation is correct. $violation = $violations[0]; - $this->assertEqual($violation->getMessage(), t('The entity must be of type %type.', array('%type' => $entity_type)), 'The message for invalid value is correct.'); + $this->assertEqual($violation->getMessage(), t('The entity must be of type %type.', ['%type' => $entity_type]), 'The message for invalid value is correct.'); $this->assertEqual($violation->getRoot(), $typed_data, 'Violation root is correct.'); $this->assertEqual($violation->getInvalidValue(), $account, 'The invalid value is set correctly in the violation.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php index b61a6dd..9d5095d 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php @@ -31,7 +31,7 @@ class EntityTypedDataDefinitionTest extends KernelTestBase { * * @var array */ - public static $modules = array('filter', 'text', 'node', 'user'); + public static $modules = ['filter', 'text', 'node', 'user']; protected function setUp() { parent::setup(); @@ -51,14 +51,14 @@ public function testFields() { $this->assertTrue($field_item_definition instanceof ComplexDataDefinitionInterface); // Derive metadata about field item properties. - $this->assertEqual(array_keys($field_item_definition->getPropertyDefinitions()), array('value')); + $this->assertEqual(array_keys($field_item_definition->getPropertyDefinitions()), ['value']); $this->assertEqual($field_item_definition->getPropertyDefinition('value')->getDataType(), 'integer'); $this->assertEqual($field_item_definition->getMainPropertyName(), 'value'); $this->assertNull($field_item_definition->getPropertyDefinition('invalid')); // Test accessing field item property metadata via the field definition. $this->assertTrue($field_definition instanceof FieldDefinitionInterface); - $this->assertEqual(array_keys($field_definition->getPropertyDefinitions()), array('value')); + $this->assertEqual(array_keys($field_definition->getPropertyDefinitions()), ['value']); $this->assertEqual($field_definition->getPropertyDefinition('value')->getDataType(), 'integer'); $this->assertEqual($field_definition->getMainPropertyName(), 'value'); $this->assertNull($field_definition->getPropertyDefinition('invalid')); @@ -106,7 +106,7 @@ public function testEntities() { // Config entities don't support typed data. $entity_definition = EntityDataDefinition::create('node_type'); - $this->assertEqual(array(), $entity_definition->getPropertyDefinitions()); + $this->assertEqual([], $entity_definition->getPropertyDefinitions()); } /** diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php index ae26ec5..c76ea6a 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityUUIDTest.php @@ -42,10 +42,10 @@ protected function assertCRUD($entity_type) { $uuid = $uuid_service->generate(); $custom_entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array( + ->create([ 'name' => $this->randomMachineName(), 'uuid' => $uuid, - )); + ]); $this->assertIdentical($custom_entity->uuid(), $uuid); // Save this entity, so we have more than one later. $custom_entity->save(); @@ -53,7 +53,7 @@ protected function assertCRUD($entity_type) { // Verify that a new UUID is generated upon creating an entity. $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array('name' => $this->randomMachineName())); + ->create(['name' => $this->randomMachineName()]); $uuid = $entity->uuid(); $this->assertTrue($uuid); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php index dc7d94f..bf2a147 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityValidationTest.php @@ -16,7 +16,7 @@ class EntityValidationTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('filter', 'text'); + public static $modules = ['filter', 'text']; /** * @var string @@ -44,7 +44,7 @@ protected function setUp() { entity_test_install(); // Install required default configuration for filter module. - $this->installConfig(array('system', 'filter')); + $this->installConfig(['system', 'filter']); } /** @@ -123,13 +123,13 @@ protected function checkValidation($entity_type) { $test_entity->id->value = -1; $violations = $test_entity->validate(); $this->assertEqual($violations->count(), 1, 'Validation failed.'); - $this->assertEqual($violations[0]->getMessage(), t('%name: The integer must be larger or equal to %min.', array('%name' => 'ID', '%min' => 0))); + $this->assertEqual($violations[0]->getMessage(), t('%name: The integer must be larger or equal to %min.', ['%name' => 'ID', '%min' => 0])); $test_entity = clone $entity; $test_entity->uuid->value = $this->randomString(129); $violations = $test_entity->validate(); $this->assertEqual($violations->count(), 1, 'Validation failed.'); - $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', array('%name' => 'UUID', '@max' => 128))); + $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', ['%name' => 'UUID', '@max' => 128])); $test_entity = clone $entity; $langcode_key = $this->entityManager->getDefinition($entity_type)->getKey('langcode'); @@ -137,7 +137,7 @@ protected function checkValidation($entity_type) { $violations = $test_entity->validate(); // This should fail on AllowedValues and Length constraints. $this->assertEqual($violations->count(), 2, 'Validation failed.'); - $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', array('%limit' => '12'))); + $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', ['%limit' => '12'])); $this->assertEqual($violations[1]->getMessage(), t('The value you selected is not a valid choice.')); $test_entity = clone $entity; @@ -150,7 +150,7 @@ protected function checkValidation($entity_type) { $test_entity->name->value = $this->randomString(33); $violations = $test_entity->validate(); $this->assertEqual($violations->count(), 1, 'Validation failed.'); - $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', array('%name' => 'Name', '@max' => 32))); + $this->assertEqual($violations[0]->getMessage(), t('%name: may not be longer than @max characters.', ['%name' => 'Name', '@max' => 32])); // Make sure the information provided by a violation is correct. $violation = $violations[0]; @@ -162,7 +162,7 @@ protected function checkValidation($entity_type) { $test_entity->set('user_id', 9999); $violations = $test_entity->validate(); $this->assertEqual($violations->count(), 1, 'Validation failed.'); - $this->assertEqual($violations[0]->getMessage(), t('The referenced entity (%type: %id) does not exist.', array('%type' => 'user', '%id' => 9999))); + $this->assertEqual($violations[0]->getMessage(), t('The referenced entity (%type: %id) does not exist.', ['%type' => 'user', '%id' => 9999])); $test_entity = clone $entity; $test_entity->field_test_text->format = $this->randomString(33); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php index 0143128..e1537bc 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityViewBuilderTest.php @@ -23,7 +23,7 @@ class EntityViewBuilderTest extends EntityKernelTestBase { */ protected function setUp() { parent::setUp(); - $this->installConfig(array('user', 'entity_test')); + $this->installConfig(['user', 'entity_test']); // Give anonymous users permission to view test entities. Role::load(RoleInterface::ANONYMOUS_ID) @@ -182,7 +182,7 @@ public function testEntityViewBuilderWeight() { // Set a weight for the label component. entity_get_display('entity_test', 'entity_test', 'full') - ->setComponent('label', array('weight' => 20)) + ->setComponent('label', ['weight' => 20]) ->save(); // Create and build a test entity. @@ -204,10 +204,10 @@ public function testEntityViewBuilderWeight() { * The created entity. */ protected function createTestEntity($entity_type) { - $data = array( + $data = [ 'bundle' => $entity_type, 'name' => $this->randomMachineName(), - ); + ]; return $this->container->get('entity.manager')->getStorage($entity_type)->create($data); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php index 449f3f2..30e817d 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php @@ -23,7 +23,7 @@ class FieldSqlStorageTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('field', 'field_test', 'text', 'entity_test'); + public static $modules = ['field', 'field_test', 'text', 'entity_test']; /** * The name of the created field. @@ -80,12 +80,12 @@ protected function setUp() { $this->fieldName = strtolower($this->randomMachineName()); $this->fieldCardinality = 4; - $this->fieldStorage = FieldStorageConfig::create(array( + $this->fieldStorage = FieldStorageConfig::create([ 'field_name' => $this->fieldName, 'entity_type' => $entity_type, 'type' => 'test_field', 'cardinality' => $this->fieldCardinality, - )); + ]); $this->fieldStorage->save(); $this->field = FieldConfig::create([ 'field_storage' => $this->fieldStorage, @@ -107,10 +107,10 @@ function testFieldLoad() { $entity_type = $bundle = 'entity_test_rev'; $storage = $this->container->get('entity.manager')->getStorage($entity_type); - $columns = array('bundle', 'deleted', 'entity_id', 'revision_id', 'delta', 'langcode', $this->tableMapping->getFieldColumnName($this->fieldStorage, 'value')); + $columns = ['bundle', 'deleted', 'entity_id', 'revision_id', 'delta', 'langcode', $this->tableMapping->getFieldColumnName($this->fieldStorage, 'value')]; // Create an entity with four revisions. - $revision_ids = array(); + $revision_ids = []; $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) ->create(); @@ -123,20 +123,20 @@ function testFieldLoad() { } // Generate values and insert them directly in the storage tables. - $values = array(); + $values = []; $query = db_insert($this->revisionTable)->fields($columns); foreach ($revision_ids as $revision_id) { // Put one value too many. for ($delta = 0; $delta <= $this->fieldCardinality; $delta++) { $value = mt_rand(1, 127); $values[$revision_id][] = $value; - $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value)); + $query->values([$bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value]); } $query->execute(); } $query = db_insert($this->table)->fields($columns); foreach ($values[$revision_id] as $delta => $value) { - $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value)); + $query->values([$bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value]); } $query->execute(); @@ -167,7 +167,7 @@ function testFieldLoad() { // Add a translation in an unavailable language code and verify it is not // loaded. $unavailable_langcode = 'xx'; - $values = array($bundle, 0, $entity->id(), $entity->getRevisionId(), 0, $unavailable_langcode, mt_rand(1, 127)); + $values = [$bundle, 0, $entity->id(), $entity->getRevisionId(), 0, $unavailable_langcode, mt_rand(1, 127)]; db_insert($this->table)->fields($columns)->values($values)->execute(); db_insert($this->revisionTable)->fields($columns)->values($values)->execute(); $entity = $storage->load($entity->id()); @@ -183,10 +183,10 @@ function testFieldWrite() { ->getStorage($entity_type) ->create(); - $revision_values = array(); + $revision_values = []; // Check insert. Add one value too many. - $values = array(); + $values = []; for ($delta = 0; $delta <= $this->fieldCardinality; $delta++) { $values[$delta]['value'] = mt_rand(1, 127); } @@ -197,7 +197,7 @@ function testFieldWrite() { $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); $this->assertEqual(count($rows), $this->fieldCardinality); foreach ($rows as $delta => $row) { - $expected = array( + $expected = [ 'bundle' => $bundle, 'deleted' => 0, 'entity_id' => $entity->id(), @@ -205,13 +205,13 @@ function testFieldWrite() { 'langcode' => $entity->language()->getId(), 'delta' => $delta, $this->fieldName . '_value' => $values[$delta]['value'], - ); + ]; $this->assertEqual($row, $expected, "Row $delta was stored as expected."); } // Test update. Add less values and check that the previous values did not // persist. - $values = array(); + $values = []; for ($delta = 0; $delta <= $this->fieldCardinality - 2; $delta++) { $values[$delta]['value'] = mt_rand(1, 127); } @@ -220,7 +220,7 @@ function testFieldWrite() { $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); $this->assertEqual(count($rows), count($values)); foreach ($rows as $delta => $row) { - $expected = array( + $expected = [ 'bundle' => $bundle, 'deleted' => 0, 'entity_id' => $entity->id(), @@ -228,13 +228,13 @@ function testFieldWrite() { 'langcode' => $entity->language()->getId(), 'delta' => $delta, $this->fieldName . '_value' => $values[$delta]['value'], - ); + ]; $this->assertEqual($row, $expected, "Row $delta was stored as expected."); } // Create a new revision. $revision_values[$entity->getRevisionId()] = $values; - $values = array(); + $values = []; for ($delta = 0; $delta < $this->fieldCardinality; $delta++) { $values[$delta]['value'] = mt_rand(1, 127); } @@ -248,7 +248,7 @@ function testFieldWrite() { $rows = db_select($this->revisionTable, 't')->fields('t')->condition('revision_id', $revision_id)->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); $this->assertEqual(count($rows), min(count($values), $this->fieldCardinality)); foreach ($rows as $delta => $row) { - $expected = array( + $expected = [ 'bundle' => $bundle, 'deleted' => 0, 'entity_id' => $entity->id(), @@ -256,7 +256,7 @@ function testFieldWrite() { 'langcode' => $entity->language()->getId(), 'delta' => $delta, $this->fieldName . '_value' => $values[$delta]['value'], - ); + ]; $this->assertEqual($row, $expected, "Row $delta was stored as expected."); } } @@ -279,15 +279,15 @@ function testLongNames() { // Create two fields and generate random values. $name_base = Unicode::strtolower($this->randomMachineName(FieldStorageConfig::NAME_MAX_LENGTH - 1)); - $field_names = array(); - $values = array(); + $field_names = []; + $values = []; for ($i = 0; $i < 2; $i++) { $field_names[$i] = $name_base . $i; - FieldStorageConfig::create(array( + FieldStorageConfig::create([ 'field_name' => $field_names[$i], 'entity_type' => $entity_type, 'type' => 'test_field', - ))->save(); + ])->save(); FieldConfig::create([ 'field_name' => $field_names[$i], 'entity_type' => $entity_type, @@ -315,12 +315,12 @@ function testLongNames() { function testUpdateFieldSchemaWithData() { $entity_type = 'entity_test_rev'; // Create a decimal 5.2 field and add some data. - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'field_name' => 'decimal52', 'entity_type' => $entity_type, 'type' => 'decimal', - 'settings' => array('precision' => 5, 'scale' => 2), - )); + 'settings' => ['precision' => 5, 'scale' => 2], + ]); $field_storage->save(); $field = FieldConfig::create([ 'field_storage' => $field_storage, @@ -329,10 +329,10 @@ function testUpdateFieldSchemaWithData() { $field->save(); $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array( + ->create([ 'id' => 0, 'revision_id' => 0, - )); + ]); $entity->decimal52->value = '1.235'; $entity->save(); @@ -352,12 +352,12 @@ function testUpdateFieldSchemaWithData() { */ function testFieldUpdateFailure() { // Create a text field. - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'field_name' => 'test_text', 'entity_type' => 'entity_test_rev', 'type' => 'text', - 'settings' => array('max_length' => 255), - )); + 'settings' => ['max_length' => 255], + ]); $field_storage->save(); // Attempt to update the field in a way that would break the storage. The @@ -376,12 +376,12 @@ function testFieldUpdateFailure() { } // Ensure that the field tables are still there. - $tables = array( + $tables = [ $this->tableMapping->getDedicatedDataTableName($prior_field_storage), $this->tableMapping->getDedicatedRevisionTableName($prior_field_storage), - ); + ]; foreach ($tables as $table_name) { - $this->assertTrue(db_table_exists($table_name), t('Table %table exists.', array('%table' => $table_name))); + $this->assertTrue(db_table_exists($table_name), t('Table %table exists.', ['%table' => $table_name])); } } @@ -392,32 +392,32 @@ function testFieldUpdateIndexesWithData() { // Create a decimal field. $field_name = 'testfield'; $entity_type = 'entity_test_rev'; - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'field_name' => $field_name, 'entity_type' => $entity_type, 'type' => 'text', - )); + ]); $field_storage->save(); $field = FieldConfig::create([ 'field_storage' => $field_storage, 'bundle' => $entity_type, ]); $field->save(); - $tables = array($this->tableMapping->getDedicatedDataTableName($field_storage), $this->tableMapping->getDedicatedRevisionTableName($field_storage)); + $tables = [$this->tableMapping->getDedicatedDataTableName($field_storage), $this->tableMapping->getDedicatedRevisionTableName($field_storage)]; // Verify the indexes we will create do not exist yet. foreach ($tables as $table) { - $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), t("No index named value exists in @table", array('@table' => $table))); - $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), t("No index named value_format exists in @table", array('@table' => $table))); + $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value'), t("No index named value exists in @table", ['@table' => $table])); + $this->assertFalse(Database::getConnection()->schema()->indexExists($table, 'value_format'), t("No index named value_format exists in @table", ['@table' => $table])); } // Add data so the table cannot be dropped. $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array( + ->create([ 'id' => 1, 'revision_id' => 1, - )); + ]); $entity->$field_name->value = 'field data'; $entity->enforceIsNew(); $entity->save(); @@ -426,15 +426,15 @@ function testFieldUpdateIndexesWithData() { $field_storage->setIndexes(['value' => [['value', 255]]]); $field_storage->save(); foreach ($tables as $table) { - $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in @table", array('@table' => $table))); + $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value created in @table", ['@table' => $table])); } // Add a different index, removing the existing custom one. $field_storage->setIndexes(['value_format' => [['value', 127], ['format', 127]]]); $field_storage->save(); foreach ($tables as $table) { - $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), t("Index on value_format created in @table", array('@table' => $table))); - $this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value removed in @table", array('@table' => $table))); + $this->assertTrue(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value_format"), t("Index on value_format created in @table", ['@table' => $table])); + $this->assertFalse(Database::getConnection()->schema()->indexExists($table, "{$field_name}_value"), t("Index on value removed in @table", ['@table' => $table])); } // Verify that the tables were not dropped in the process. @@ -450,12 +450,12 @@ function testFieldSqlStorageForeignKeys() { // field_test_field_schema()). $field_name = 'testfield'; $foreign_key_name = 'shape'; - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'shape', - 'settings' => array('foreign_key_name' => $foreign_key_name), - )); + 'settings' => ['foreign_key_name' => $foreign_key_name], + ]); $field_storage->save(); // Get the field schema. $schema = $field_storage->getSchema(); @@ -487,11 +487,11 @@ public function testTableNames() { // Short entity type and field name. $entity_type = 'short_entity_type'; $field_name = 'short_field_name'; - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'entity_type' => $entity_type, 'field_name' => $field_name, 'type' => 'test_field', - )); + ]); $expected = 'short_entity_type__short_field_name'; $this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $expected); $expected = 'short_entity_type_revision__short_field_name'; @@ -500,11 +500,11 @@ public function testTableNames() { // Short entity type, long field name $entity_type = 'short_entity_type'; $field_name = 'long_field_name_abcdefghijklmnopqrstuvwxyz'; - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'entity_type' => $entity_type, 'field_name' => $field_name, 'type' => 'test_field', - )); + ]); $expected = 'short_entity_type__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); $this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $expected); $expected = 'short_entity_type_r__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); @@ -513,11 +513,11 @@ public function testTableNames() { // Long entity type, short field name $entity_type = 'long_entity_type_abcdefghijklmnopqrstuvwxyz'; $field_name = 'short_field_name'; - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'entity_type' => $entity_type, 'field_name' => $field_name, 'type' => 'test_field', - )); + ]); $expected = 'long_entity_type_abcdefghijklmnopq__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); $this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $expected); $expected = 'long_entity_type_abcdefghijklmnopq_r__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); @@ -526,31 +526,31 @@ public function testTableNames() { // Long entity type and field name. $entity_type = 'long_entity_type_abcdefghijklmnopqrstuvwxyz'; $field_name = 'long_field_name_abcdefghijklmnopqrstuvwxyz'; - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'entity_type' => $entity_type, 'field_name' => $field_name, 'type' => 'test_field', - )); + ]); $expected = 'long_entity_type_abcdefghijklmnopq__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); $this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $expected); $expected = 'long_entity_type_abcdefghijklmnopq_r__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); $this->assertEqual($this->tableMapping->getDedicatedRevisionTableName($field_storage), $expected); // Try creating a second field and check there are no clashes. - $field_storage2 = FieldStorageConfig::create(array( + $field_storage2 = FieldStorageConfig::create([ 'entity_type' => $entity_type, 'field_name' => $field_name . '2', 'type' => 'test_field', - )); + ]); $this->assertNotEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $this->tableMapping->getDedicatedDataTableName($field_storage2)); $this->assertNotEqual($this->tableMapping->getDedicatedRevisionTableName($field_storage), $this->tableMapping->getDedicatedRevisionTableName($field_storage2)); // Deleted field. - $field_storage = FieldStorageConfig::create(array( + $field_storage = FieldStorageConfig::create([ 'entity_type' => 'some_entity_type', 'field_name' => 'some_field_name', 'type' => 'test_field', 'deleted' => TRUE, - )); + ]); $expected = 'field_deleted_data_' . substr(hash('sha256', $field_storage->uuid()), 0, 10); $this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage, TRUE), $expected); $expected = 'field_deleted_revision_' . substr(hash('sha256', $field_storage->uuid()), 0, 10); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php index b301c64..c398732 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldTranslationSqlStorageTest.php @@ -20,10 +20,10 @@ public function testFieldSqlStorage() { $entity_type = 'entity_test_mul'; $controller = $this->entityManager->getStorage($entity_type); - $values = array( + $values = [ $this->fieldName => $this->randomMachineName(), $this->untranslatableFieldName => $this->randomMachineName(), - ); + ]; $entity = $controller->create($values); $entity->save(); @@ -45,7 +45,7 @@ public function testFieldSqlStorage() { // before. $this->toggleFieldTranslatability($entity_type, $entity_type); $entity = $this->reloadEntity($entity); - foreach (array($this->fieldName, $this->untranslatableFieldName) as $field_name) { + foreach ([$this->fieldName, $this->untranslatableFieldName] as $field_name) { $this->assertEqual($entity->get($field_name)->value, $values[$field_name], 'Field language works as expected after switching translatability.'); } @@ -76,7 +76,7 @@ protected function assertFieldStorageLangcode(FieldableEntityInterface $entity, $entity_type = $entity->getEntityTypeId(); $id = $entity->id(); $langcode = $entity->getUntranslated()->language()->getId(); - $fields = array($this->fieldName, $this->untranslatableFieldName); + $fields = [$this->fieldName, $this->untranslatableFieldName]; /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ $table_mapping = \Drupal::entityManager()->getStorage($entity_type)->getTableMapping(); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php index 50d173b..5ae824b 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php @@ -15,7 +15,7 @@ */ class FieldWidgetConstraintValidatorTest extends KernelTestBase { - public static $modules = array('entity_test', 'field', 'user', 'system'); + public static $modules = ['entity_test', 'field', 'user', 'system']; /** * {@inheritdoc} @@ -37,9 +37,9 @@ public function testValidation() { $entity_type = 'entity_test_constraint_violation'; $entity = $this->container->get('entity_type.manager') ->getStorage($entity_type) - ->create(array('id' => 1, 'revision_id' => 1)); + ->create(['id' => 1, 'revision_id' => 1]); $display = entity_get_form_display($entity_type, $entity_type, 'default'); - $form = array(); + $form = []; $form_state = new FormState(); $display->buildForm($entity, $form, $form_state); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ValidReferenceConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ValidReferenceConstraintValidatorTest.php index 64bb933..a365ea5 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/ValidReferenceConstraintValidatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/ValidReferenceConstraintValidatorTest.php @@ -21,14 +21,14 @@ class ValidReferenceConstraintValidatorTest extends EntityKernelTestBase { /** * {@inheritdoc} */ - public static $modules = array('field', 'user'); + public static $modules = ['field', 'user']; /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); - $this->installSchema('user', array('users_data')); + $this->installSchema('user', ['users_data']); $this->typedData = $this->container->get('typed_data_manager'); } @@ -40,18 +40,18 @@ public function testValidation() { $entity = $this->createUser(); // By default entity references already have the ValidReference constraint. $definition = BaseFieldDefinition::create('entity_reference') - ->setSettings(array('target_type' => 'user')); + ->setSettings(['target_type' => 'user']); - $typed_data = $this->typedData->create($definition, array('target_id' => $entity->id())); + $typed_data = $this->typedData->create($definition, ['target_id' => $entity->id()]); $violations = $typed_data->validate(); $this->assertFalse($violations->count(), 'Validation passed for correct value.'); // NULL is also considered a valid reference. - $typed_data = $this->typedData->create($definition, array('target_id' => NULL)); + $typed_data = $this->typedData->create($definition, ['target_id' => NULL]); $violations = $typed_data->validate(); $this->assertFalse($violations->count(), 'Validation passed for correct value.'); - $typed_data = $this->typedData->create($definition, array('target_id' => $entity->id())); + $typed_data = $this->typedData->create($definition, ['target_id' => $entity->id()]); // Delete the referenced entity. $entity->delete(); $violations = $typed_data->validate(); @@ -59,10 +59,10 @@ public function testValidation() { // Make sure the information provided by a violation is correct. $violation = $violations[0]; - $this->assertEqual($violation->getMessage(), t('The referenced entity (%type: %id) does not exist.', array( + $this->assertEqual($violation->getMessage(), t('The referenced entity (%type: %id) does not exist.', [ '%type' => 'user', '%id' => $entity->id(), - )), 'The message for invalid value is correct.'); + ]), 'The message for invalid value is correct.'); $this->assertEqual($violation->getRoot(), $typed_data, 'Violation root is correct.'); } diff --git a/core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php b/core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php index f55d744..c0ec629 100644 --- a/core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php +++ b/core/tests/Drupal/KernelTests/Core/Extension/ModuleImplementsAlterTest.php @@ -32,7 +32,7 @@ function testModuleImplementsAlter() { 'Module handler instance is still the same.'); // Install the module_test module. - \Drupal::service('module_installer')->install(array('module_test')); + \Drupal::service('module_installer')->install(['module_test']); // Assert that the \Drupal::moduleHandler() instance has been replaced. $this->assertFalse($module_handler === \Drupal::moduleHandler(), @@ -76,7 +76,7 @@ function testModuleImplementsAlter() { function testModuleImplementsAlterNonExistingImplementation() { // Install the module_test module. - \Drupal::service('module_installer')->install(array('module_test')); + \Drupal::service('module_installer')->install(['module_test']); try { // Trigger hook discovery. diff --git a/core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php b/core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php index 5a59a23..f019ff2 100644 --- a/core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php +++ b/core/tests/Drupal/KernelTests/Core/Field/FieldAccessTest.php @@ -34,7 +34,7 @@ class FieldAccessTest extends KernelTestBase { protected function setUp() { parent::setUp(); // Install field configuration. - $this->installConfig(array('field')); + $this->installConfig(['field']); // The users table is needed for creating dummy user accounts. $this->installEntitySchema('user'); // Register entity_test text field. @@ -49,18 +49,18 @@ protected function setUp() { * @see entity_test_entity_field_access_alter() */ function testFieldAccess() { - $values = array( + $values = [ 'name' => $this->randomMachineName(), 'user_id' => 1, - 'field_test_text' => array( + 'field_test_text' => [ 'value' => 'no access value', 'format' => 'full_html', - ), - ); + ], + ]; $entity = EntityTest::create($values); // Create a dummy user account for testing access with. - $values = array('name' => 'test'); + $values = ['name' => 'test']; $account = User::create($values); $this->assertFalse($entity->field_test_text->access('view', $account), 'Access to the field was denied.'); diff --git a/core/tests/Drupal/KernelTests/Core/Field/FieldModuleUninstallValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Field/FieldModuleUninstallValidatorTest.php index af2fb07..b9d545e 100644 --- a/core/tests/Drupal/KernelTests/Core/Field/FieldModuleUninstallValidatorTest.php +++ b/core/tests/Drupal/KernelTests/Core/Field/FieldModuleUninstallValidatorTest.php @@ -73,7 +73,7 @@ public function testUninstallingModule() { try { $message = 'Module uninstallation fails as the module provides a base field which has content.'; - $this->getModuleInstaller()->uninstall(array('entity_test_extra')); + $this->getModuleInstaller()->uninstall(['entity_test_extra']); $this->fail($message); } catch (ModuleUninstallValidatorException $e) { @@ -93,7 +93,7 @@ public function testUninstallingModule() { ]); $entity->save(); try { - $this->getModuleInstaller()->uninstall(array('entity_test_extra')); + $this->getModuleInstaller()->uninstall(['entity_test_extra']); $this->fail('Module uninstallation fails as the module provides a bundle field which has content.'); } catch (ModuleUninstallValidatorException $e) { diff --git a/core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php b/core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php index a55888f..583e55b 100644 --- a/core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php +++ b/core/tests/Drupal/KernelTests/Core/Field/FieldSettingsTest.php @@ -19,7 +19,7 @@ class FieldSettingsTest extends EntityKernelTestBase { * * @var array */ - public static $modules = array('field', 'field_test'); + public static $modules = ['field', 'field_test']; /** * @covers \Drupal\Core\Field\BaseFieldDefinition::getSettings diff --git a/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php b/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php index d7e7c38..c8aa14e 100644 --- a/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/DirectoryTest.php @@ -106,14 +106,14 @@ function testFileCreateNewFilepath() { $directory = 'core/misc'; $original = $directory . '/' . $basename; $path = file_create_filename($basename, $directory); - $this->assertEqual($path, $original, format_string('New filepath %new equals %original.', array('%new' => $path, '%original' => $original)), 'File'); + $this->assertEqual($path, $original, format_string('New filepath %new equals %original.', ['%new' => $path, '%original' => $original]), 'File'); // Then we test against a file that already exists within that directory. $basename = 'druplicon.png'; $original = $directory . '/' . $basename; $expected = $directory . '/druplicon_0.png'; $path = file_create_filename($basename, $directory); - $this->assertEqual($path, $expected, format_string('Creating a new filepath from %original equals %new (expected %expected).', array('%new' => $path, '%original' => $original, '%expected' => $expected)), 'File'); + $this->assertEqual($path, $expected, format_string('Creating a new filepath from %original equals %new (expected %expected).', ['%new' => $path, '%original' => $original, '%expected' => $expected]), 'File'); // @TODO: Finally we copy a file into a directory several times, to ensure a properly iterating filename suffix. } diff --git a/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php b/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php index 548d1bc..0b10d92 100644 --- a/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/File/FileTestBase.php @@ -16,7 +16,7 @@ * * @var array */ - public static $modules = array('system'); + public static $modules = ['system']; /** * A stream wrapper scheme to register for the test. @@ -70,9 +70,9 @@ protected function setUpFilesystem() { $this->setSetting('file_public_path', $public_file_directory); - $GLOBALS['config_directories'] = array( + $GLOBALS['config_directories'] = [ CONFIG_SYNC_DIRECTORY => $this->siteDirectory . '/files/config/sync', - ); + ]; } /** @@ -105,7 +105,7 @@ function assertFilePermissions($filepath, $expected_mode, $message = NULL) { } if (!isset($message)) { - $message = t('Expected file permission to be %expected, actually were %actual.', array('%actual' => decoct($actual_mode), '%expected' => decoct($expected_mode))); + $message = t('Expected file permission to be %expected, actually were %actual.', ['%actual' => decoct($actual_mode), '%expected' => decoct($expected_mode)]); } $this->assertEqual($actual_mode, $expected_mode, $message); } @@ -141,7 +141,7 @@ function assertDirectoryPermissions($directory, $expected_mode, $message = NULL) } if (!isset($message)) { - $message = t('Expected directory permission to be %expected, actually were %actual.', array('%actual' => decoct($actual_mode), '%expected' => decoct($expected_mode))); + $message = t('Expected directory permission to be %expected, actually were %actual.', ['%actual' => decoct($actual_mode), '%expected' => decoct($expected_mode)]); } $this->assertEqual($actual_mode, $expected_mode, $message); } diff --git a/core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php b/core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php index 0ef5078..8966276 100644 --- a/core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/HtaccessTest.php @@ -82,11 +82,11 @@ function testHtaccessSave() { */ protected function assertFilePermissions($uri, $expected) { $actual = fileperms($uri) & 0777; - return $this->assertIdentical($actual, $expected, SafeMarkup::format('@uri file permissions @actual are identical to @expected.', array( + return $this->assertIdentical($actual, $expected, SafeMarkup::format('@uri file permissions @actual are identical to @expected.', [ '@uri' => $uri, '@actual' => 0 . decoct($actual), '@expected' => 0 . decoct($expected), - ))); + ])); } } diff --git a/core/tests/Drupal/KernelTests/Core/File/MimeTypeTest.php b/core/tests/Drupal/KernelTests/Core/File/MimeTypeTest.php index 9bfe681..05ac7c2 100644 --- a/core/tests/Drupal/KernelTests/Core/File/MimeTypeTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/MimeTypeTest.php @@ -14,7 +14,7 @@ class MimeTypeTest extends FileTestBase { * * @var array */ - public static $modules = array('file_test'); + public static $modules = ['file_test']; /** * Test mapping of mimetypes from filenames. @@ -22,7 +22,7 @@ class MimeTypeTest extends FileTestBase { public function testFileMimeTypeDetection() { $prefixes = ['public://', 'private://', 'temporary://', 'dummy-remote://']; - $test_case = array( + $test_case = [ 'test.jar' => 'application/java-archive', 'test.jpeg' => 'image/jpeg', 'test.JPEG' => 'image/jpeg', @@ -37,7 +37,7 @@ public function testFileMimeTypeDetection() { 'foo.file_test_2' => 'madeup/file_test_2', 'foo.doc' => 'madeup/doc', 'test.ogg' => 'audio/ogg', - ); + ]; $guesser = $this->container->get('file.mime_type.guesser'); // Test using default mappings. @@ -45,27 +45,27 @@ public function testFileMimeTypeDetection() { // Test stream [URI]. foreach ($prefixes as $prefix) { $output = $guesser->guess($prefix . $input); - $this->assertIdentical($output, $expected, format_string('Mimetype for %input is %output (expected: %expected).', array('%input' => $prefix . $input, '%output' => $output, '%expected' => $expected))); + $this->assertIdentical($output, $expected, format_string('Mimetype for %input is %output (expected: %expected).', ['%input' => $prefix . $input, '%output' => $output, '%expected' => $expected])); } // Test normal path equivalent $output = $guesser->guess($input); - $this->assertIdentical($output, $expected, format_string('Mimetype (using default mappings) for %input is %output (expected: %expected).', array('%input' => $input, '%output' => $output, '%expected' => $expected))); + $this->assertIdentical($output, $expected, format_string('Mimetype (using default mappings) for %input is %output (expected: %expected).', ['%input' => $input, '%output' => $output, '%expected' => $expected])); } // Now test the extension gusser by passing in a custom mapping. - $mapping = array( - 'mimetypes' => array( + $mapping = [ + 'mimetypes' => [ 0 => 'application/java-archive', 1 => 'image/jpeg', - ), - 'extensions' => array( + ], + 'extensions' => [ 'jar' => 0, 'jpg' => 1, - ) - ); + ] + ]; - $test_case = array( + $test_case = [ 'test.jar' => 'application/java-archive', 'test.jpeg' => 'application/octet-stream', 'test.jpg' => 'image/jpeg', @@ -79,13 +79,13 @@ public function testFileMimeTypeDetection() { 'foo.file_test_2' => 'application/octet-stream', 'foo.doc' => 'application/octet-stream', 'test.ogg' => 'application/octet-stream', - ); + ]; $extension_guesser = $this->container->get('file.mime_type.guesser.extension'); $extension_guesser->setMapping($mapping); foreach ($test_case as $input => $expected) { $output = $extension_guesser->guess($input); - $this->assertIdentical($output, $expected, format_string('Mimetype (using passed-in mappings) for %input is %output (expected: %expected).', array('%input' => $input, '%output' => $output, '%expected' => $expected))); + $this->assertIdentical($output, $expected, format_string('Mimetype (using passed-in mappings) for %input is %output (expected: %expected).', ['%input' => $input, '%output' => $output, '%expected' => $expected])); } } diff --git a/core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php b/core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php index 1fff41e..8e1506d 100644 --- a/core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/NameMungingTest.php @@ -39,8 +39,8 @@ function testMunging() { $this->config('system.file')->set('allow_insecure_uploads', 0)->save(); $munged_name = file_munge_filename($this->name, '', TRUE); $messages = drupal_get_messages(); - $this->assertTrue(in_array(strtr('For security reasons, your upload has been renamed to %filename.', array('%filename' => $munged_name)), $messages['status']), 'Alert properly set when a file is renamed.'); - $this->assertNotEqual($munged_name, $this->name, format_string('The new filename (%munged) has been modified from the original (%original)', array('%munged' => $munged_name, '%original' => $this->name))); + $this->assertTrue(in_array(strtr('For security reasons, your upload has been renamed to %filename.', ['%filename' => $munged_name]), $messages['status']), 'Alert properly set when a file is renamed.'); + $this->assertNotEqual($munged_name, $this->name, format_string('The new filename (%munged) has been modified from the original (%original)', ['%munged' => $munged_name, '%original' => $this->name])); } /** @@ -59,7 +59,7 @@ function testMungeNullByte() { function testMungeIgnoreInsecure() { $this->config('system.file')->set('allow_insecure_uploads', 1)->save(); $munged_name = file_munge_filename($this->name, ''); - $this->assertIdentical($munged_name, $this->name, format_string('The original filename (%original) matches the munged filename (%munged) when insecure uploads are enabled.', array('%munged' => $munged_name, '%original' => $this->name))); + $this->assertIdentical($munged_name, $this->name, format_string('The original filename (%original) matches the munged filename (%munged) when insecure uploads are enabled.', ['%munged' => $munged_name, '%original' => $this->name])); } /** @@ -69,10 +69,10 @@ function testMungeIgnoreWhitelisted() { // Declare our extension as whitelisted. The declared extensions should // be case insensitive so test using one with a different case. $munged_name = file_munge_filename($this->nameWithUcExt, $this->badExtension); - $this->assertIdentical($munged_name, $this->nameWithUcExt, format_string('The new filename (%munged) matches the original (%original) once the extension has been whitelisted.', array('%munged' => $munged_name, '%original' => $this->nameWithUcExt))); + $this->assertIdentical($munged_name, $this->nameWithUcExt, format_string('The new filename (%munged) matches the original (%original) once the extension has been whitelisted.', ['%munged' => $munged_name, '%original' => $this->nameWithUcExt])); // The allowed extensions should also be normalized. $munged_name = file_munge_filename($this->name, strtoupper($this->badExtension)); - $this->assertIdentical($munged_name, $this->name, format_string('The new filename (%munged) matches the original (%original) also when the whitelisted extension is in uppercase.', array('%munged' => $munged_name, '%original' => $this->name))); + $this->assertIdentical($munged_name, $this->name, format_string('The new filename (%munged) matches the original (%original) also when the whitelisted extension is in uppercase.', ['%munged' => $munged_name, '%original' => $this->name])); } /** @@ -81,7 +81,7 @@ function testMungeIgnoreWhitelisted() { function testUnMunge() { $munged_name = file_munge_filename($this->name, '', FALSE); $unmunged_name = file_unmunge_filename($munged_name); - $this->assertIdentical($unmunged_name, $this->name, format_string('The unmunged (%unmunged) filename matches the original (%original)', array('%unmunged' => $unmunged_name, '%original' => $this->name))); + $this->assertIdentical($unmunged_name, $this->name, format_string('The unmunged (%unmunged) filename matches the original (%original)', ['%unmunged' => $unmunged_name, '%original' => $this->name])); } } diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileDirectoryTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileDirectoryTest.php index 3265562..e41fb74 100644 --- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileDirectoryTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileDirectoryTest.php @@ -14,7 +14,7 @@ class RemoteFileDirectoryTest extends DirectoryTest { * * @var array */ - public static $modules = array('file_test'); + public static $modules = ['file_test']; /** * A stream wrapper scheme to register for the test. diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileScanDirectoryTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileScanDirectoryTest.php index 3d872bc..e3c68a7 100644 --- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileScanDirectoryTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileScanDirectoryTest.php @@ -14,7 +14,7 @@ class RemoteFileScanDirectoryTest extends ScanDirectoryTest { * * @var array */ - public static $modules = array('file_test'); + public static $modules = ['file_test']; /** * A stream wrapper scheme to register for the test. diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedCopyTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedCopyTest.php index 8be6726..b13b92c 100644 --- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedCopyTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedCopyTest.php @@ -14,7 +14,7 @@ class RemoteFileUnmanagedCopyTest extends UnmanagedCopyTest { * * @var array */ - public static $modules = array('file_test'); + public static $modules = ['file_test']; /** * A stream wrapper scheme to register for the test. diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteRecursiveTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteRecursiveTest.php index 06f0e1a..6be98df 100644 --- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteRecursiveTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteRecursiveTest.php @@ -14,7 +14,7 @@ class RemoteFileUnmanagedDeleteRecursiveTest extends UnmanagedDeleteRecursiveTes * * @var array */ - public static $modules = array('file_test'); + public static $modules = ['file_test']; /** * A stream wrapper scheme to register for the test. diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteTest.php index fe0ad6e..f826d4d 100644 --- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedDeleteTest.php @@ -14,7 +14,7 @@ class RemoteFileUnmanagedDeleteTest extends UnmanagedDeleteTest { * * @var array */ - public static $modules = array('file_test'); + public static $modules = ['file_test']; /** * A stream wrapper scheme to register for the test. diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedMoveTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedMoveTest.php index 47b66f2..e41f87e 100644 --- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedMoveTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedMoveTest.php @@ -14,7 +14,7 @@ class RemoteFileUnmanagedMoveTest extends UnmanagedMoveTest { * * @var array */ - public static $modules = array('file_test'); + public static $modules = ['file_test']; /** * A stream wrapper scheme to register for the test. diff --git a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedSaveDataTest.php b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedSaveDataTest.php index 15b5929..817da28 100644 --- a/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedSaveDataTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/RemoteFileUnmanagedSaveDataTest.php @@ -14,7 +14,7 @@ class RemoteFileUnmanagedSaveDataTest extends UnmanagedSaveDataTest { * * @var array */ - public static $modules = array('file_test'); + public static $modules = ['file_test']; /** * A stream wrapper scheme to register for the test. diff --git a/core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php b/core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php index 8362c04..471c1aa 100644 --- a/core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/ScanDirectoryTest.php @@ -14,7 +14,7 @@ class ScanDirectoryTest extends FileTestBase { * * @var array */ - public static $modules = array('file_test'); + public static $modules = ['file_test']; /** * @var string @@ -61,7 +61,7 @@ function testReturn() { function testOptionCallback() { // When nothing is matched nothing should be passed to the callback. - $all_files = file_scan_directory($this->path, '/^NONEXISTINGFILENAME/', array('callback' => 'file_test_file_scan_callback')); + $all_files = file_scan_directory($this->path, '/^NONEXISTINGFILENAME/', ['callback' => 'file_test_file_scan_callback']); $this->assertEqual(0, count($all_files), 'No files were found.'); $results = file_test_file_scan_callback(); file_test_file_scan_callback_reset(); @@ -69,7 +69,7 @@ function testOptionCallback() { // Grab a listing of all the JavaScript files and check that they're // passed to the callback. - $all_files = file_scan_directory($this->path, '/^javascript-/', array('callback' => 'file_test_file_scan_callback')); + $all_files = file_scan_directory($this->path, '/^javascript-/', ['callback' => 'file_test_file_scan_callback']); $this->assertEqual(2, count($all_files), 'Found two, expected javascript files.'); $results = file_test_file_scan_callback(); file_test_file_scan_callback_reset(); @@ -85,7 +85,7 @@ function testOptionNoMask() { $this->assertEqual(2, count($all_files), 'Found two, expected javascript files.'); // Now use the nomask parameter to filter out the .script file. - $filtered_files = file_scan_directory($this->path, '/^javascript-/', array('nomask' => '/.script$/')); + $filtered_files = file_scan_directory($this->path, '/^javascript-/', ['nomask' => '/.script$/']); $this->assertEqual(1, count($filtered_files), 'Filtered correctly.'); } @@ -94,26 +94,26 @@ function testOptionNoMask() { */ function testOptionKey() { // "filename", for the path starting with $dir. - $expected = array($this->path . '/javascript-1.txt', $this->path . '/javascript-2.script'); - $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'filepath'))); + $expected = [$this->path . '/javascript-1.txt', $this->path . '/javascript-2.script']; + $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', ['key' => 'filepath'])); sort($actual); $this->assertEqual($expected, $actual, 'Returned the correct values for the filename key.'); // "basename", for the basename of the file. - $expected = array('javascript-1.txt', 'javascript-2.script'); - $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'filename'))); + $expected = ['javascript-1.txt', 'javascript-2.script']; + $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', ['key' => 'filename'])); sort($actual); $this->assertEqual($expected, $actual, 'Returned the correct values for the basename key.'); // "name" for the name of the file without an extension. - $expected = array('javascript-1', 'javascript-2'); - $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'name'))); + $expected = ['javascript-1', 'javascript-2']; + $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', ['key' => 'name'])); sort($actual); $this->assertEqual($expected, $actual, 'Returned the correct values for the name key.'); // Invalid option that should default back to "filename". - $expected = array($this->path . '/javascript-1.txt', $this->path . '/javascript-2.script'); - $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', array('key' => 'INVALID'))); + $expected = [$this->path . '/javascript-1.txt', $this->path . '/javascript-2.script']; + $actual = array_keys(file_scan_directory($this->path, '/^javascript-/', ['key' => 'INVALID'])); sort($actual); $this->assertEqual($expected, $actual, 'An invalid key defaulted back to the default.'); } @@ -122,10 +122,10 @@ function testOptionKey() { * Check that the recurse option descends into subdirectories. */ function testOptionRecurse() { - $files = file_scan_directory($this->path . '/..', '/^javascript-/', array('recurse' => FALSE)); + $files = file_scan_directory($this->path . '/..', '/^javascript-/', ['recurse' => FALSE]); $this->assertTrue(empty($files), "Without recursion couldn't find javascript files."); - $files = file_scan_directory($this->path . '/..', '/^javascript-/', array('recurse' => TRUE)); + $files = file_scan_directory($this->path . '/..', '/^javascript-/', ['recurse' => TRUE]); $this->assertEqual(2, count($files), 'With recursion we found the expected javascript files.'); } @@ -135,10 +135,10 @@ function testOptionRecurse() { * directory. */ function testOptionMinDepth() { - $files = file_scan_directory($this->path, '/^javascript-/', array('min_depth' => 0)); + $files = file_scan_directory($this->path, '/^javascript-/', ['min_depth' => 0]); $this->assertEqual(2, count($files), 'No minimum-depth gets files in current directory.'); - $files = file_scan_directory($this->path, '/^javascript-/', array('min_depth' => 1)); + $files = file_scan_directory($this->path, '/^javascript-/', ['min_depth' => 1]); $this->assertTrue(empty($files), 'Minimum-depth of 1 successfully excludes files from current directory.'); } diff --git a/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php b/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php index e9c8642..3db171d 100644 --- a/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php @@ -19,7 +19,7 @@ class StreamWrapperTest extends FileTestBase { * * @var array */ - public static $modules = array('file_test'); + public static $modules = ['file_test']; /** * A stream wrapper scheme to register for the test. @@ -119,7 +119,7 @@ function testFileFunctions() { $this->assertEqual(-1 /*EOF*/, @stream_set_write_buffer($handle, 512), 'Unable to set write buffer using a local stream wrapper.'); // This will test stream_cast(). - $read = array($handle); + $read = [$handle]; $write = NULL; $except = NULL; $this->assertEqual(1, stream_select($read, $write, $except, 0), 'Able to cast a stream via stream_select.'); diff --git a/core/tests/Drupal/KernelTests/Core/File/UrlRewritingTest.php b/core/tests/Drupal/KernelTests/Core/File/UrlRewritingTest.php index 5494975..e2294cb 100644 --- a/core/tests/Drupal/KernelTests/Core/File/UrlRewritingTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/UrlRewritingTest.php @@ -16,7 +16,7 @@ class UrlRewritingTest extends FileTestBase { * * @var array */ - public static $modules = array('file_test'); + public static $modules = ['file_test']; /** * Tests the rewriting of shipped file URLs by hook_file_url_alter(). diff --git a/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php b/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php index fa86bee..7cc1ff8 100644 --- a/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php +++ b/core/tests/Drupal/KernelTests/Core/Form/FormCacheTest.php @@ -20,7 +20,7 @@ class FormCacheTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'user'); + public static $modules = ['system', 'user']; /** * @var string @@ -39,12 +39,12 @@ class FormCacheTest extends KernelTestBase { protected function setUp() { parent::setUp(); - $this->installSchema('system', array('key_value_expire')); + $this->installSchema('system', ['key_value_expire']); $this->formBuildId = $this->randomMachineName(); - $this->form = array( + $this->form = [ '#property' => $this->randomMachineName(), - ); + ]; $this->formState = new FormState(); $this->formState->set('example', $this->randomMachineName()); } @@ -53,7 +53,7 @@ protected function setUp() { * Tests the form cache with a logged-in user. */ function testCacheToken() { - \Drupal::currentUser()->setAccount(new UserSession(array('uid' => 1))); + \Drupal::currentUser()->setAccount(new UserSession(['uid' => 1])); \Drupal::formBuilder()->setCache($this->formBuildId, $this->form, $this->formState); $cached_form_state = new FormState(); diff --git a/core/tests/Drupal/KernelTests/Core/Form/FormDefaultHandlersTest.php b/core/tests/Drupal/KernelTests/Core/Form/FormDefaultHandlersTest.php index 7f046e9..021c65f 100644 --- a/core/tests/Drupal/KernelTests/Core/Form/FormDefaultHandlersTest.php +++ b/core/tests/Drupal/KernelTests/Core/Form/FormDefaultHandlersTest.php @@ -19,7 +19,7 @@ class FormDefaultHandlersTest extends KernelTestBase implements FormInterface { * * @var array */ - public static $modules = array('system'); + public static $modules = ['system']; /** * {@inheritdoc} @@ -42,7 +42,7 @@ public function getFormId() { public function buildForm(array $form, FormStateInterface $form_state) { $form['#validate'][] = '::customValidateForm'; $form['#submit'][] = '::customSubmitForm'; - $form['submit'] = array('#type' => 'submit', '#value' => 'Save'); + $form['submit'] = ['#type' => 'submit', '#value' => 'Save']; return $form; } diff --git a/core/tests/Drupal/KernelTests/Core/Form/TriggeringElementProgrammedTest.php b/core/tests/Drupal/KernelTests/Core/Form/TriggeringElementProgrammedTest.php index c24d47e..a51bc5d 100644 --- a/core/tests/Drupal/KernelTests/Core/Form/TriggeringElementProgrammedTest.php +++ b/core/tests/Drupal/KernelTests/Core/Form/TriggeringElementProgrammedTest.php @@ -25,27 +25,27 @@ public function getFormId() { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $form['one'] = array( + $form['one'] = [ '#type' => 'textfield', '#title' => 'One', '#required' => TRUE, - ); - $form['two'] = array( + ]; + $form['two'] = [ '#type' => 'textfield', '#title' => 'Two', '#required' => TRUE, - ); - $form['actions'] = array('#type' => 'actions'); + ]; + $form['actions'] = ['#type' => 'actions']; $user_input = $form_state->getUserInput(); - $form['actions']['submit'] = array( + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => 'Save', - '#limit_validation_errors' => array( - array($user_input['section']), - ), + '#limit_validation_errors' => [ + [$user_input['section']], + ], // Required for #limit_validation_errors. - '#submit' => array(array($this, 'submitForm')), - ); + '#submit' => [[$this, 'submitForm']], + ]; return $form; } diff --git a/core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php b/core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php index 166ec24..29bbcff 100644 --- a/core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php +++ b/core/tests/Drupal/KernelTests/Core/HttpKernel/StackKernelIntegrationTest.php @@ -19,7 +19,7 @@ class StackKernelIntegrationTest extends KernelTestBase { * * @var array */ - public static $modules = array('httpkernel_test', 'system'); + public static $modules = ['httpkernel_test', 'system']; /** * {@inheritdoc} diff --git a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php index fe36c3d..a3a5775 100644 --- a/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php +++ b/core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php @@ -23,16 +23,16 @@ class ToolkitGdTest extends KernelTestBase { protected $imageFactory; // Colors that are used in testing. - protected $black = array(0, 0, 0, 0); - protected $red = array(255, 0, 0, 0); - protected $green = array(0, 255, 0, 0); - protected $blue = array(0, 0, 255, 0); - protected $yellow = array(255, 255, 0, 0); - protected $white = array(255, 255, 255, 0); - protected $transparent = array(0, 0, 0, 127); + protected $black = [0, 0, 0, 0]; + protected $red = [255, 0, 0, 0]; + protected $green = [0, 255, 0, 0]; + protected $blue = [0, 0, 255, 0]; + protected $yellow = [255, 255, 0, 0]; + protected $white = [255, 255, 255, 0]; + protected $transparent = [0, 0, 0, 127]; // Used as rotate background colors. - protected $fuchsia = array(255, 0, 255, 0); - protected $rotateTransparent = array(255, 255, 255, 127); + protected $fuchsia = [255, 0, 255, 0]; + protected $rotateTransparent = [255, 255, 255, 127]; protected $width = 40; protected $height = 20; @@ -42,7 +42,7 @@ class ToolkitGdTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'simpletest'); + public static $modules = ['system', 'simpletest']; /** * {@inheritdoc} @@ -57,9 +57,9 @@ protected function setUp() { protected function checkRequirements() { // GD2 support is available. if (!function_exists('imagegd2')) { - return array( + return [ 'Image manipulations for the GD toolkit cannot run because the GD toolkit is not available.', - ); + ]; } return parent::checkRequirements(); } @@ -91,7 +91,7 @@ function getPixelColor(ImageInterface $image, $x, $y) { $transparent_index = imagecolortransparent($toolkit->getResource()); if ($color_index == $transparent_index) { - return array(0, 0, 0, 127); + return [0, 0, 0, 127]; } return array_values(imagecolorsforindex($toolkit->getResource(), $color_index)); @@ -129,143 +129,143 @@ function testManipulations() { // Typically the corner colors will be unchanged. These colors are in the // order of top-left, top-right, bottom-right, bottom-left. - $default_corners = array($this->red, $this->green, $this->blue, $this->transparent); + $default_corners = [$this->red, $this->green, $this->blue, $this->transparent]; // A list of files that will be tested. - $files = array( + $files = [ 'image-test.png', 'image-test.gif', 'image-test-no-transparency.gif', 'image-test.jpg', - ); + ]; // Setup a list of tests to perform on each type. - $operations = array( - 'resize' => array( + $operations = [ + 'resize' => [ 'function' => 'resize', - 'arguments' => array('width' => 20, 'height' => 10), + 'arguments' => ['width' => 20, 'height' => 10], 'width' => 20, 'height' => 10, 'corners' => $default_corners, - ), - 'scale_x' => array( + ], + 'scale_x' => [ 'function' => 'scale', - 'arguments' => array('width' => 20), + 'arguments' => ['width' => 20], 'width' => 20, 'height' => 10, 'corners' => $default_corners, - ), - 'scale_y' => array( + ], + 'scale_y' => [ 'function' => 'scale', - 'arguments' => array('height' => 10), + 'arguments' => ['height' => 10], 'width' => 20, 'height' => 10, 'corners' => $default_corners, - ), - 'upscale_x' => array( + ], + 'upscale_x' => [ 'function' => 'scale', - 'arguments' => array('width' => 80, 'upscale' => TRUE), + 'arguments' => ['width' => 80, 'upscale' => TRUE], 'width' => 80, 'height' => 40, 'corners' => $default_corners, - ), - 'upscale_y' => array( + ], + 'upscale_y' => [ 'function' => 'scale', - 'arguments' => array('height' => 40, 'upscale' => TRUE), + 'arguments' => ['height' => 40, 'upscale' => TRUE], 'width' => 80, 'height' => 40, 'corners' => $default_corners, - ), - 'crop' => array( + ], + 'crop' => [ 'function' => 'crop', - 'arguments' => array('x' => 12, 'y' => 4, 'width' => 16, 'height' => 12), + 'arguments' => ['x' => 12, 'y' => 4, 'width' => 16, 'height' => 12], 'width' => 16, 'height' => 12, 'corners' => array_fill(0, 4, $this->white), - ), - 'scale_and_crop' => array( + ], + 'scale_and_crop' => [ 'function' => 'scale_and_crop', - 'arguments' => array('width' => 10, 'height' => 8), + 'arguments' => ['width' => 10, 'height' => 8], 'width' => 10, 'height' => 8, 'corners' => array_fill(0, 4, $this->black), - ), - 'convert_jpg' => array( + ], + 'convert_jpg' => [ 'function' => 'convert', 'width' => 40, 'height' => 20, - 'arguments' => array('extension' => 'jpeg'), + 'arguments' => ['extension' => 'jpeg'], 'corners' => $default_corners, - ), - 'convert_gif' => array( + ], + 'convert_gif' => [ 'function' => 'convert', 'width' => 40, 'height' => 20, - 'arguments' => array('extension' => 'gif'), + 'arguments' => ['extension' => 'gif'], 'corners' => $default_corners, - ), - 'convert_png' => array( + ], + 'convert_png' => [ 'function' => 'convert', 'width' => 40, 'height' => 20, - 'arguments' => array('extension' => 'png'), + 'arguments' => ['extension' => 'png'], 'corners' => $default_corners, - ), - ); + ], + ]; // Systems using non-bundled GD2 don't have imagerotate. Test if available. if (function_exists('imagerotate')) { - $operations += array( - 'rotate_5' => array( + $operations += [ + 'rotate_5' => [ 'function' => 'rotate', - 'arguments' => array('degrees' => 5, 'background' => '#FF00FF'), // Fuchsia background. + 'arguments' => ['degrees' => 5, 'background' => '#FF00FF'], // Fuchsia background. 'width' => 41, 'height' => 23, 'corners' => array_fill(0, 4, $this->fuchsia), - ), - 'rotate_90' => array( + ], + 'rotate_90' => [ 'function' => 'rotate', - 'arguments' => array('degrees' => 90, 'background' => '#FF00FF'), // Fuchsia background. + 'arguments' => ['degrees' => 90, 'background' => '#FF00FF'], // Fuchsia background. 'width' => 20, 'height' => 40, - 'corners' => array($this->transparent, $this->red, $this->green, $this->blue), - ), - 'rotate_transparent_5' => array( + 'corners' => [$this->transparent, $this->red, $this->green, $this->blue], + ], + 'rotate_transparent_5' => [ 'function' => 'rotate', - 'arguments' => array('degrees' => 5), + 'arguments' => ['degrees' => 5], 'width' => 41, 'height' => 23, 'corners' => array_fill(0, 4, $this->rotateTransparent), - ), - 'rotate_transparent_90' => array( + ], + 'rotate_transparent_90' => [ 'function' => 'rotate', - 'arguments' => array('degrees' => 90), + 'arguments' => ['degrees' => 90], 'width' => 20, 'height' => 40, - 'corners' => array($this->transparent, $this->red, $this->green, $this->blue), - ), - ); + 'corners' => [$this->transparent, $this->red, $this->green, $this->blue], + ], + ]; } // Systems using non-bundled GD2 don't have imagefilter. Test if available. if (function_exists('imagefilter')) { - $operations += array( - 'desaturate' => array( + $operations += [ + 'desaturate' => [ 'function' => 'desaturate', - 'arguments' => array(), + 'arguments' => [], 'height' => 20, 'width' => 40, // Grayscale corners are a bit funky. Each of the corners are a shade of // gray. The values of these were determined simply by looking at the // final image to see what desaturated colors end up being. - 'corners' => array( - array_fill(0, 3, 76) + array(3 => 0), - array_fill(0, 3, 149) + array(3 => 0), - array_fill(0, 3, 29) + array(3 => 0), - array_fill(0, 3, 225) + array(3 => 127) - ), - ), - ); + 'corners' => [ + array_fill(0, 3, 76) + [3 => 0], + array_fill(0, 3, 149) + [3 => 0], + array_fill(0, 3, 29) + [3 => 0], + array_fill(0, 3, 225) + [3 => 127] + ], + ], + ]; } // Prepare a directory for test file results. @@ -278,14 +278,14 @@ function testManipulations() { $image = $this->imageFactory->get(drupal_get_path('module', 'simpletest') . '/files/' . $file); $toolkit = $image->getToolkit(); if (!$image->isValid()) { - $this->fail(SafeMarkup::format('Could not load image %file.', array('%file' => $file))); + $this->fail(SafeMarkup::format('Could not load image %file.', ['%file' => $file])); continue 2; } $image_original_type = $image->getToolkit()->getType(); // All images should be converted to truecolor when loaded. $image_truecolor = imageistruecolor($toolkit->getResource()); - $this->assertTrue($image_truecolor, SafeMarkup::format('Image %file after load is a truecolor image.', array('%file' => $file))); + $this->assertTrue($image_truecolor, SafeMarkup::format('Image %file after load is a truecolor image.', ['%file' => $file])); // Store the original GD resource. $old_res = $toolkit->getResource(); @@ -317,8 +317,8 @@ function testManipulations() { $file_path = $directory . '/' . $op . image_type_to_extension($image->getToolkit()->getType()); $image->save($file_path); - $this->assertTrue($correct_dimensions_real, SafeMarkup::format('Image %file after %action action has proper dimensions.', array('%file' => $file, '%action' => $op))); - $this->assertTrue($correct_dimensions_object, SafeMarkup::format('Image %file object after %action action is reporting the proper height and width values.', array('%file' => $file, '%action' => $op))); + $this->assertTrue($correct_dimensions_real, SafeMarkup::format('Image %file after %action action has proper dimensions.', ['%file' => $file, '%action' => $op])); + $this->assertTrue($correct_dimensions_object, SafeMarkup::format('Image %file object after %action action is reporting the proper height and width values.', ['%file' => $file, '%action' => $op])); // JPEG colors will always be messed up due to compression. So we skip // these tests if the original or the result is in jpeg format. @@ -365,7 +365,7 @@ function testManipulations() { if ($image->getToolkit()->getType() == $image_original_type || $corner != $this->transparent) { $correct_colors = $this->colorsAreEqual($color, $corner); $this->assertTrue($correct_colors, SafeMarkup::format('Image %file object after %action action has the correct color placement at corner %corner.', - array('%file' => $file, '%action' => $op, '%corner' => $key))); + ['%file' => $file, '%action' => $op, '%corner' => $key])); } } } @@ -377,30 +377,30 @@ function testManipulations() { } // Test creation of image from scratch, and saving to storage. - foreach (array(IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_JPEG) as $type) { + foreach ([IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_JPEG] as $type) { $image = $this->imageFactory->get(); $image->createNew(50, 20, image_type_to_extension($type, FALSE), '#ffff00'); $file = 'from_null' . image_type_to_extension($type); $file_path = $directory . '/' . $file ; - $this->assertEqual(50, $image->getWidth(), SafeMarkup::format('Image file %file has the correct width.', array('%file' => $file))); - $this->assertEqual(20, $image->getHeight(), SafeMarkup::format('Image file %file has the correct height.', array('%file' => $file))); - $this->assertEqual(image_type_to_mime_type($type), $image->getMimeType(), SafeMarkup::format('Image file %file has the correct MIME type.', array('%file' => $file))); - $this->assertTrue($image->save($file_path), SafeMarkup::format('Image %file created anew from a null image was saved.', array('%file' => $file))); + $this->assertEqual(50, $image->getWidth(), SafeMarkup::format('Image file %file has the correct width.', ['%file' => $file])); + $this->assertEqual(20, $image->getHeight(), SafeMarkup::format('Image file %file has the correct height.', ['%file' => $file])); + $this->assertEqual(image_type_to_mime_type($type), $image->getMimeType(), SafeMarkup::format('Image file %file has the correct MIME type.', ['%file' => $file])); + $this->assertTrue($image->save($file_path), SafeMarkup::format('Image %file created anew from a null image was saved.', ['%file' => $file])); // Reload saved image. $image_reloaded = $this->imageFactory->get($file_path); if (!$image_reloaded->isValid()) { - $this->fail(SafeMarkup::format('Could not load image %file.', array('%file' => $file))); + $this->fail(SafeMarkup::format('Could not load image %file.', ['%file' => $file])); continue; } - $this->assertEqual(50, $image_reloaded->getWidth(), SafeMarkup::format('Image file %file has the correct width.', array('%file' => $file))); - $this->assertEqual(20, $image_reloaded->getHeight(), SafeMarkup::format('Image file %file has the correct height.', array('%file' => $file))); - $this->assertEqual(image_type_to_mime_type($type), $image_reloaded->getMimeType(), SafeMarkup::format('Image file %file has the correct MIME type.', array('%file' => $file))); + $this->assertEqual(50, $image_reloaded->getWidth(), SafeMarkup::format('Image file %file has the correct width.', ['%file' => $file])); + $this->assertEqual(20, $image_reloaded->getHeight(), SafeMarkup::format('Image file %file has the correct height.', ['%file' => $file])); + $this->assertEqual(image_type_to_mime_type($type), $image_reloaded->getMimeType(), SafeMarkup::format('Image file %file has the correct MIME type.', ['%file' => $file])); if ($image_reloaded->getToolkit()->getType() == IMAGETYPE_GIF) { - $this->assertEqual('#ffff00', $image_reloaded->getToolkit()->getTransparentColor(), SafeMarkup::format('Image file %file has the correct transparent color channel set.', array('%file' => $file))); + $this->assertEqual('#ffff00', $image_reloaded->getToolkit()->getTransparentColor(), SafeMarkup::format('Image file %file has the correct transparent color channel set.', ['%file' => $file])); } else { - $this->assertEqual(NULL, $image_reloaded->getToolkit()->getTransparentColor(), SafeMarkup::format('Image file %file has no color channel set.', array('%file' => $file))); + $this->assertEqual(NULL, $image_reloaded->getToolkit()->getTransparentColor(), SafeMarkup::format('Image file %file has no color channel set.', ['%file' => $file])); } } @@ -496,12 +496,12 @@ function testGifTransparentImages() { $toolkit = $image->getToolkit(); if (!$image->isValid()) { - $this->fail(SafeMarkup::format('Could not load image %file.', array('%file' => $file))); + $this->fail(SafeMarkup::format('Could not load image %file.', ['%file' => $file])); } else { // All images should be converted to truecolor when loaded. $image_truecolor = imageistruecolor($toolkit->getResource()); - $this->assertTrue($image_truecolor, SafeMarkup::format('Image %file after load is a truecolor image.', array('%file' => $file))); + $this->assertTrue($image_truecolor, SafeMarkup::format('Image %file after load is a truecolor image.', ['%file' => $file])); } } @@ -519,11 +519,11 @@ function testMissingOperation() { // Load up a fresh image. $image = $this->imageFactory->get(drupal_get_path('module', 'simpletest') . '/files/' . $file); if (!$image->isValid()) { - $this->fail(SafeMarkup::format('Could not load image %file.', array('%file' => $file))); + $this->fail(SafeMarkup::format('Could not load image %file.', ['%file' => $file])); } // Try perform a missing toolkit operation. - $this->assertFalse($image->apply('missing_op', array()), 'Calling a missing image toolkit operation plugin fails.'); + $this->assertFalse($image->apply('missing_op', []), 'Calling a missing image toolkit operation plugin fails.'); } } diff --git a/core/tests/Drupal/KernelTests/Core/Installer/InstallerLanguageTest.php b/core/tests/Drupal/KernelTests/Core/Installer/InstallerLanguageTest.php index 060ee46..d619d38 100644 --- a/core/tests/Drupal/KernelTests/Core/Installer/InstallerLanguageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Installer/InstallerLanguageTest.php @@ -18,21 +18,21 @@ class InstallerLanguageTest extends KernelTestBase { function testInstallerTranslationFiles() { // Different translation files would be found depending on which language // we are looking for. - $expected_translation_files = array( - NULL => array('drupal-8.0.0-beta2.hu.po', 'drupal-8.0.0.de.po'), - 'de' => array('drupal-8.0.0.de.po'), - 'hu' => array('drupal-8.0.0-beta2.hu.po'), - 'it' => array(), - ); + $expected_translation_files = [ + NULL => ['drupal-8.0.0-beta2.hu.po', 'drupal-8.0.0.de.po'], + 'de' => ['drupal-8.0.0.de.po'], + 'hu' => ['drupal-8.0.0-beta2.hu.po'], + 'it' => [], + ]; // Hardcode the simpletest module location as we don't yet know where it is. // @todo Remove as part of https://www.drupal.org/node/2186491 $file_translation = new FileTranslation('core/modules/simpletest/files/translations'); foreach ($expected_translation_files as $langcode => $files_expected) { $files_found = $file_translation->findTranslationFiles($langcode); - $this->assertTrue(count($files_found) == count($files_expected), format_string('@count installer languages found.', array('@count' => count($files_expected)))); + $this->assertTrue(count($files_found) == count($files_expected), format_string('@count installer languages found.', ['@count' => count($files_expected)])); foreach ($files_found as $file) { - $this->assertTrue(in_array($file->filename, $files_expected), format_string('@file found.', array('@file' => $file->filename))); + $this->assertTrue(in_array($file->filename, $files_expected), format_string('@file found.', ['@file' => $file->filename])); } } } diff --git a/core/tests/Drupal/KernelTests/Core/Installer/InstallerRedirectTraitTest.php b/core/tests/Drupal/KernelTests/Core/Installer/InstallerRedirectTraitTest.php index fea8609..0aca302 100644 --- a/core/tests/Drupal/KernelTests/Core/Installer/InstallerRedirectTraitTest.php +++ b/core/tests/Drupal/KernelTests/Core/Installer/InstallerRedirectTraitTest.php @@ -29,7 +29,7 @@ class InstallerRedirectTraitTest extends KernelTestBase { * - Whether or not there exists a sessions table in the database. */ public function providerShouldRedirectToInstaller() { - return array( + return [ [TRUE, DatabaseNotFoundException::class, FALSE, FALSE], [TRUE, DatabaseNotFoundException::class, TRUE, FALSE], [TRUE, DatabaseNotFoundException::class, FALSE, TRUE], @@ -59,7 +59,7 @@ public function providerShouldRedirectToInstaller() { [FALSE, \Exception::class, FALSE, TRUE], [FALSE, \Exception::class, TRUE, TRUE], [FALSE, \Exception::class, TRUE, TRUE, FALSE], - ); + ]; } /** @@ -73,7 +73,7 @@ function testShouldRedirectToInstaller($expected, $exception, $connection, $conn catch (\Exception $e) { // Mock the trait. $trait = $this->getMockBuilder(InstallerRedirectTrait::class) - ->setMethods(array('isCli')) + ->setMethods(['isCli']) ->getMockForTrait(); // Make sure that the method thinks we are not using the cli. @@ -95,14 +95,14 @@ function testShouldRedirectToInstaller($expected, $exception, $connection, $conn // Mock the database connection. $connection = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() - ->setMethods(array('schema')) + ->setMethods(['schema']) ->getMockForAbstractClass(); if ($connection_info) { // Mock the database schema class. $schema = $this->getMockBuilder(Schema::class) ->disableOriginalConstructor() - ->setMethods(array('tableExists')) + ->setMethods(['tableExists']) ->getMockForAbstractClass(); $schema->expects($this->any()) diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php index 1631501..2d543cb 100644 --- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php +++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageExpirableTest.php @@ -17,12 +17,12 @@ class DatabaseStorageExpirableTest extends StorageTestBase { * * @var array */ - public static $modules = array('system'); + public static $modules = ['system']; protected function setUp() { parent::setUp(); $this->factory = 'keyvalue.expirable'; - $this->installSchema('system', array('key_value_expire')); + $this->installSchema('system', ['key_value_expire']); } /** @@ -60,12 +60,12 @@ public function testCRUDWithExpiration() { $this->assertIdenticalObject($this->objects[2], $stores[1]->get('foo')); // Verify that multiple items can be stored with setMultipleWithExpire(). - $values = array( + $values = [ 'foo' => $this->objects[3], 'bar' => $this->objects[4], - ); + ]; $stores[0]->setMultipleWithExpire($values, rand(500, 100000)); - $result = $stores[0]->getMultiple(array('foo', 'bar')); + $result = $stores[0]->getMultiple(['foo', 'bar']); foreach ($values as $j => $value) { $this->assertIdenticalObject($value, $result[$j]); } @@ -85,13 +85,13 @@ public function testCRUDWithExpiration() { } // Verify that all items in the other collection are different. $result = $stores[1]->getAll(); - $this->assertEqual($result, array('foo' => $this->objects[5])); + $this->assertEqual($result, ['foo' => $this->objects[5]]); // Verify that multiple items can be deleted. $stores[0]->deleteMultiple(array_keys($values)); $this->assertFalse($stores[0]->get('foo')); $this->assertFalse($stores[0]->get('bar')); - $this->assertFalse($stores[0]->getMultiple(array('foo', 'bar'))); + $this->assertFalse($stores[0]->getMultiple(['foo', 'bar'])); // Verify that the item in the other collection still exists. $this->assertIdenticalObject($this->objects[5], $stores[1]->get('foo')); @@ -132,16 +132,16 @@ public function testExpiration() { $this->assertFalse($stores[0]->get('yesterday')); $this->assertTrue($stores[0]->has('troubles')); $this->assertIdentical($stores[0]->get('troubles'), 'here to stay'); - $this->assertIdentical(count($stores[0]->getMultiple(array('yesterday', 'troubles'))), 1); + $this->assertIdentical(count($stores[0]->getMultiple(['yesterday', 'troubles'])), 1); // Store items set to expire in the past in various ways. $stores[0]->setWithExpire($this->randomMachineName(), $this->objects[0], -7 * $day); $stores[0]->setWithExpireIfNotExists($this->randomMachineName(), $this->objects[1], -5 * $day); $stores[0]->setMultipleWithExpire( - array( + [ $this->randomMachineName() => $this->objects[2], $this->randomMachineName() => $this->objects[3], - ), + ], -3 * $day ); $stores[0]->setWithExpireIfNotExists('yesterday', "you'd forgiven me", -1 * $day); @@ -150,7 +150,7 @@ public function testExpiration() { // Ensure only non-expired items are retrieved. $all = $stores[0]->getAll(); $this->assertIdentical(count($all), 2); - foreach (array('troubles', 'still') as $key) { + foreach (['troubles', 'still'] as $key) { $this->assertTrue(!empty($all[$key])); } } diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php index 676ab10..5852da1 100644 --- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/DatabaseStorageTest.php @@ -17,11 +17,11 @@ class DatabaseStorageTest extends StorageTestBase { * * @var array */ - public static $modules = array('system'); + public static $modules = ['system']; protected function setUp() { parent::setUp(); - $this->installSchema('system', array('key_value')); + $this->installSchema('system', ['key_value']); } /** diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/GarbageCollectionTest.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/GarbageCollectionTest.php index 4dc9b47..e0badd8 100644 --- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/GarbageCollectionTest.php +++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/GarbageCollectionTest.php @@ -19,13 +19,13 @@ class GarbageCollectionTest extends KernelTestBase { * * @var array */ - public static $modules = array('system'); + public static $modules = ['system']; protected function setUp() { parent::setUp(); // These additional tables are necessary due to the call to system_cron(). - $this->installSchema('system', array('key_value_expire')); + $this->installSchema('system', ['key_value_expire']); } /** @@ -44,13 +44,13 @@ public function testGarbageCollection() { // Manually expire the data. for ($i = 0; $i <= 3; $i++) { db_merge('key_value_expire') - ->keys(array( + ->keys([ 'name' => 'key_' . $i, 'collection' => $collection, - )) - ->fields(array( + ]) + ->fields([ 'expire' => REQUEST_TIME - 1, - )) + ]) ->execute(); } @@ -62,9 +62,9 @@ public function testGarbageCollection() { // Query the database and confirm that the stale records were deleted. $result = db_query( 'SELECT name, value FROM {key_value_expire} WHERE collection = :collection', - array( + [ ':collection' => $collection, - ))->fetchAll(); + ])->fetchAll(); $this->assertIdentical(count($result), 1, 'Only one item remains after garbage collection'); } diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php index 068216b..4fc9c7a 100644 --- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php @@ -19,7 +19,7 @@ class KeyValueContentEntityStorageTest extends KernelTestBase { * * @var array */ - public static $modules = array('user', 'entity_test', 'keyvalue_test'); + public static $modules = ['user', 'entity_test', 'keyvalue_test']; /** * {@inheritdoc} @@ -69,9 +69,9 @@ function testCRUD() { } // Verify that an entity with an empty ID string is considered empty, too. - $empty_id = EntityTestLabel::create(array( + $empty_id = EntityTestLabel::create([ 'id' => '', - )); + ]); $this->assertIdentical($empty_id->isNew(), TRUE); try { $empty_id->save(); @@ -82,10 +82,10 @@ function testCRUD() { } // Verify properties on a newly created entity. - $entity_test = EntityTestLabel::create($expected = array( + $entity_test = EntityTestLabel::create($expected = [ 'id' => $this->randomMachineName(), 'name' => $this->randomString(), - )); + ]); $this->assertIdentical($entity_test->id->value, $expected['id']); $this->assertTrue($entity_test->uuid->value); $this->assertNotEqual($entity_test->uuid->value, $empty->uuid->value); @@ -125,9 +125,9 @@ function testCRUD() { // Ensure that creating an entity with the same id as an existing one is not // possible. - $same_id = EntityTestLabel::create(array( + $same_id = EntityTestLabel::create([ 'id' => $entity_test->id(), - )); + ]); $this->assertIdentical($same_id->isNew(), TRUE); try { $same_id->save(); @@ -138,7 +138,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]; diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php index 48e047d..7651234 100644 --- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/StorageTestBase.php @@ -14,14 +14,14 @@ * * @var array */ - protected $objects = array(); + protected $objects = []; /** * An array of data collection labels. * * @var array */ - protected $collections = array(); + protected $collections = []; /** * Whether we are using an expirable key/value store. @@ -34,7 +34,7 @@ protected function setUp() { parent::setUp(); // Define two data collections, - $this->collections = array(0 => 'zero', 1 => 'one'); + $this->collections = [0 => 'zero', 1 => 'one']; // Create several objects for testing. for ($i = 0; $i <= 5; $i++) { @@ -82,14 +82,14 @@ public function testCRUD() { $this->assertFalse($stores[1]->get('foo')); // Verify that multiple items can be stored. - $values = array( + $values = [ 'foo' => $this->objects[3], 'bar' => $this->objects[4], - ); + ]; $stores[0]->setMultiple($values); // Verify that multiple items can be retrieved. - $result = $stores[0]->getMultiple(array('foo', 'bar')); + $result = $stores[0]->getMultiple(['foo', 'bar']); foreach ($values as $j => $value) { $this->assertIdenticalObject($value, $result[$j]); } @@ -109,15 +109,15 @@ public function testCRUD() { } // Verify that all items in the other collection are different. $result = $stores[1]->getAll(); - $this->assertEqual($result, array('foo' => $this->objects[5])); + $this->assertEqual($result, ['foo' => $this->objects[5]]); // Verify that multiple items can be deleted. $stores[0]->deleteMultiple(array_keys($values)); $this->assertFalse($stores[0]->get('foo')); $this->assertFalse($stores[0]->get('bar')); - $this->assertFalse($stores[0]->getMultiple(array('foo', 'bar'))); + $this->assertFalse($stores[0]->getMultiple(['foo', 'bar'])); // Verify that deleting no items does not cause an error. - $stores[0]->deleteMultiple(array()); + $stores[0]->deleteMultiple([]); // Verify that the item in the other collection still exists. $this->assertIdenticalObject($this->objects[5], $stores[1]->get('foo')); @@ -146,7 +146,7 @@ public function testNonExistingKeys() { // Verify that a non-existing key is not returned when getting multiple keys. $stores[0]->set('bar', 'baz'); - $values = $stores[0]->getMultiple(array('foo', 'bar')); + $values = $stores[0]->getMultiple(['foo', 'bar']); $this->assertFalse(isset($values['foo']), "Key 'foo' not found."); $this->assertIdentical($values['bar'], 'baz'); } @@ -204,7 +204,7 @@ public function testRename() { * @see \Drupal\Core\KeyValueStore\DatabaseStorageExpirable::garbageCollection() */ protected function createStorage() { - $stores = array(); + $stores = []; foreach ($this->collections as $i => $collection) { $stores[$i] = $this->container->get($this->factory)->get($collection); } diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkDefaultIntegrationTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkDefaultIntegrationTest.php index b999887..d0da913 100644 --- a/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkDefaultIntegrationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkDefaultIntegrationTest.php @@ -17,9 +17,9 @@ class MenuLinkDefaultIntegrationTest extends KernelTestBase { * * @var array */ - public static $modules = array( + public static $modules = [ 'menu_test', - ); + ]; /** * Tests moving a static menu link without a specified menu to the root. @@ -39,7 +39,7 @@ public function testMoveToRoot() { $this->assertEqual($tree['menu_test.parent']->subtree['menu_test.child']->link->getPluginId(), 'menu_test.child'); // Ensure that the menu name is not forgotten. - $menu_link_manager->updateDefinition('menu_test.child', array('parent' => '')); + $menu_link_manager->updateDefinition('menu_test.child', ['parent' => '']); $menu_link = $menu_link_manager->getDefinition('menu_test.child'); $this->assertEqual($menu_link['parent'], ''); diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php index 1efb14b..033451ac 100644 --- a/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php +++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuLinkTreeTest.php @@ -35,13 +35,13 @@ class MenuLinkTreeTest extends KernelTestBase { * * @var array */ - public static $modules = array( + public static $modules = [ 'system', 'menu_test', 'menu_link_content', 'field', 'link', - ); + ]; /** * {@inheritdoc} @@ -59,12 +59,12 @@ protected function setUp() { * Tests deleting all the links in a menu. */ public function testDeleteLinksInMenu() { - \Drupal::entityManager()->getStorage('menu')->create(array('id' => 'menu1'))->save(); - \Drupal::entityManager()->getStorage('menu')->create(array('id' => 'menu2'))->save(); + \Drupal::entityManager()->getStorage('menu')->create(['id' => 'menu1'])->save(); + \Drupal::entityManager()->getStorage('menu')->create(['id' => 'menu2'])->save(); - \Drupal::entityManager()->getStorage('menu_link_content')->create(array('link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content'))->save(); - \Drupal::entityManager()->getStorage('menu_link_content')->create(array('link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content'))->save(); - \Drupal::entityManager()->getStorage('menu_link_content')->create(array('link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu2', 'bundle' => 'menu_link_content'))->save(); + \Drupal::entityManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content'])->save(); + \Drupal::entityManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu1', 'bundle' => 'menu_link_content'])->save(); + \Drupal::entityManager()->getStorage('menu_link_content')->create(['link' => ['uri' => 'internal:/menu_name_test'], 'menu_name' => 'menu2', 'bundle' => 'menu_link_content'])->save(); $output = $this->linkTree->load('menu1', new MenuTreeParameters()); $this->assertEqual(count($output), 2); @@ -95,16 +95,16 @@ public function testCreateLinksInMenu() { // - 8 // With link 6 being the only external link. - $links = array( - 1 => MenuLinkMock::create(array('id' => 'test.example1', 'route_name' => 'example1', 'title' => 'foo', 'parent' => '')), - 2 => MenuLinkMock::create(array('id' => 'test.example2', 'route_name' => 'example2', 'title' => 'bar', 'parent' => 'test.example1', 'route_parameters' => array('foo' => 'bar'))), - 3 => MenuLinkMock::create(array('id' => 'test.example3', 'route_name' => 'example3', 'title' => 'baz', 'parent' => 'test.example2', 'route_parameters' => array('baz' => 'qux'))), - 4 => MenuLinkMock::create(array('id' => 'test.example4', 'route_name' => 'example4', 'title' => 'qux', 'parent' => 'test.example3')), - 5 => MenuLinkMock::create(array('id' => 'test.example5', 'route_name' => 'example5', 'title' => 'foofoo', 'parent' => '')), - 6 => MenuLinkMock::create(array('id' => 'test.example6', 'route_name' => '', 'url' => 'https://www.drupal.org/', 'title' => 'barbar', 'parent' => '')), - 7 => MenuLinkMock::create(array('id' => 'test.example7', 'route_name' => 'example7', 'title' => 'bazbaz', 'parent' => '')), - 8 => MenuLinkMock::create(array('id' => 'test.example8', 'route_name' => 'example8', 'title' => 'quxqux', 'parent' => '')), - ); + $links = [ + 1 => MenuLinkMock::create(['id' => 'test.example1', 'route_name' => 'example1', 'title' => 'foo', 'parent' => '']), + 2 => MenuLinkMock::create(['id' => 'test.example2', 'route_name' => 'example2', 'title' => 'bar', 'parent' => 'test.example1', 'route_parameters' => ['foo' => 'bar']]), + 3 => MenuLinkMock::create(['id' => 'test.example3', 'route_name' => 'example3', 'title' => 'baz', 'parent' => 'test.example2', 'route_parameters' => ['baz' => 'qux']]), + 4 => MenuLinkMock::create(['id' => 'test.example4', 'route_name' => 'example4', 'title' => 'qux', 'parent' => 'test.example3']), + 5 => MenuLinkMock::create(['id' => 'test.example5', 'route_name' => 'example5', 'title' => 'foofoo', 'parent' => '']), + 6 => MenuLinkMock::create(['id' => 'test.example6', 'route_name' => '', 'url' => 'https://www.drupal.org/', 'title' => 'barbar', 'parent' => '']), + 7 => MenuLinkMock::create(['id' => 'test.example7', 'route_name' => 'example7', 'title' => 'bazbaz', 'parent' => '']), + 8 => MenuLinkMock::create(['id' => 'test.example8', 'route_name' => 'example8', 'title' => 'quxqux', 'parent' => '']), + ]; foreach ($links as $instance) { $this->menuLinkManager->addDefinition($instance->getPluginId(), $instance->getPluginDefinition()); } diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php index cb1d74d..ad3f04d 100644 --- a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php @@ -77,16 +77,16 @@ public function testSimpleHierarchy() { // -- test2 // --- test3 $this->addMenuLink('test1', ''); - $this->assertMenuLink('test1', array('has_children' => 0, 'depth' => 1)); + $this->assertMenuLink('test1', ['has_children' => 0, 'depth' => 1]); $this->addMenuLink('test2', 'test1'); - $this->assertMenuLink('test1', array('has_children' => 1, 'depth' => 1), array(), array('test2')); - $this->assertMenuLink('test2', array('has_children' => 0, 'depth' => 2), array('test1')); + $this->assertMenuLink('test1', ['has_children' => 1, 'depth' => 1], [], ['test2']); + $this->assertMenuLink('test2', ['has_children' => 0, 'depth' => 2], ['test1']); $this->addMenuLink('test3', 'test2'); - $this->assertMenuLink('test1', array('has_children' => 1, 'depth' => 1), array(), array('test2', 'test3')); - $this->assertMenuLink('test2', array('has_children' => 1, 'depth' => 2), array('test1'), array('test3')); - $this->assertMenuLink('test3', array('has_children' => 0, 'depth' => 3), array('test2', 'test1')); + $this->assertMenuLink('test1', ['has_children' => 1, 'depth' => 1], [], ['test2', 'test3']); + $this->assertMenuLink('test2', ['has_children' => 1, 'depth' => 2], ['test1'], ['test3']); + $this->assertMenuLink('test3', ['has_children' => 0, 'depth' => 3], ['test2', 'test1']); } /** @@ -109,11 +109,11 @@ public function testMenuLinkMoving() { $this->addMenuLink('test5', 'test4'); $this->addMenuLink('test6', 'test5'); - $this->assertMenuLink('test1', array('has_children' => 1, 'depth' => 1), array(), array('test2', 'test3')); - $this->assertMenuLink('test2', array('has_children' => 1, 'depth' => 2), array('test1'), array('test3')); - $this->assertMenuLink('test4', array('has_children' => 1, 'depth' => 1), array(), array('test5', 'test6')); - $this->assertMenuLink('test5', array('has_children' => 1, 'depth' => 2), array('test4'), array('test6')); - $this->assertMenuLink('test6', array('has_children' => 0, 'depth' => 3), array('test5', 'test4')); + $this->assertMenuLink('test1', ['has_children' => 1, 'depth' => 1], [], ['test2', 'test3']); + $this->assertMenuLink('test2', ['has_children' => 1, 'depth' => 2], ['test1'], ['test3']); + $this->assertMenuLink('test4', ['has_children' => 1, 'depth' => 1], [], ['test5', 'test6']); + $this->assertMenuLink('test5', ['has_children' => 1, 'depth' => 2], ['test4'], ['test6']); + $this->assertMenuLink('test6', ['has_children' => 0, 'depth' => 3], ['test5', 'test4']); $this->moveMenuLink('test2', 'test5'); // After the 1st move. @@ -125,12 +125,12 @@ public function testMenuLinkMoving() { // ---- test3 // --- test6 - $this->assertMenuLink('test1', array('has_children' => 0, 'depth' => 1)); - $this->assertMenuLink('test2', array('has_children' => 1, 'depth' => 3), array('test5', 'test4'), array('test3')); - $this->assertMenuLink('test3', array('has_children' => 0, 'depth' => 4), array('test2', 'test5', 'test4')); - $this->assertMenuLink('test4', array('has_children' => 1, 'depth' => 1), array(), array('test5', 'test2', 'test3', 'test6')); - $this->assertMenuLink('test5', array('has_children' => 1, 'depth' => 2), array('test4'), array('test2', 'test3', 'test6')); - $this->assertMenuLink('test6', array('has_children' => 0, 'depth' => 3), array('test5', 'test4')); + $this->assertMenuLink('test1', ['has_children' => 0, 'depth' => 1]); + $this->assertMenuLink('test2', ['has_children' => 1, 'depth' => 3], ['test5', 'test4'], ['test3']); + $this->assertMenuLink('test3', ['has_children' => 0, 'depth' => 4], ['test2', 'test5', 'test4']); + $this->assertMenuLink('test4', ['has_children' => 1, 'depth' => 1], [], ['test5', 'test2', 'test3', 'test6']); + $this->assertMenuLink('test5', ['has_children' => 1, 'depth' => 2], ['test4'], ['test2', 'test3', 'test6']); + $this->assertMenuLink('test6', ['has_children' => 0, 'depth' => 3], ['test5', 'test4']); $this->moveMenuLink('test4', 'test1'); $this->moveMenuLink('test3', 'test1'); @@ -143,12 +143,12 @@ public function testMenuLinkMoving() { // ---- test2 // ---- test6 - $this->assertMenuLink('test1', array('has_children' => 1, 'depth' => 1), array(), array('test4', 'test5', 'test2', 'test3', 'test6')); - $this->assertMenuLink('test2', array('has_children' => 0, 'depth' => 4), array('test5', 'test4', 'test1')); - $this->assertMenuLink('test3', array('has_children' => 0, 'depth' => 2), array('test1')); - $this->assertMenuLink('test4', array('has_children' => 1, 'depth' => 2), array('test1'), array('test2', 'test5', 'test6')); - $this->assertMenuLink('test5', array('has_children' => 1, 'depth' => 3), array('test4', 'test1'), array('test2', 'test6')); - $this->assertMenuLink('test6', array('has_children' => 0, 'depth' => 4), array('test5', 'test4', 'test1')); + $this->assertMenuLink('test1', ['has_children' => 1, 'depth' => 1], [], ['test4', 'test5', 'test2', 'test3', 'test6']); + $this->assertMenuLink('test2', ['has_children' => 0, 'depth' => 4], ['test5', 'test4', 'test1']); + $this->assertMenuLink('test3', ['has_children' => 0, 'depth' => 2], ['test1']); + $this->assertMenuLink('test4', ['has_children' => 1, 'depth' => 2], ['test1'], ['test2', 'test5', 'test6']); + $this->assertMenuLink('test5', ['has_children' => 1, 'depth' => 3], ['test4', 'test1'], ['test2', 'test6']); + $this->assertMenuLink('test6', ['has_children' => 0, 'depth' => 4], ['test5', 'test4', 'test1']); // Deleting a link in the middle should re-attach child links to the parent. $this->treeStorage->delete('test4'); @@ -159,12 +159,12 @@ public function testMenuLinkMoving() { // -- test5 // --- test2 // --- test6 - $this->assertMenuLink('test1', array('has_children' => 1, 'depth' => 1), array(), array('test5', 'test2', 'test3', 'test6')); - $this->assertMenuLink('test2', array('has_children' => 0, 'depth' => 3), array('test5', 'test1')); - $this->assertMenuLink('test3', array('has_children' => 0, 'depth' => 2), array('test1')); + $this->assertMenuLink('test1', ['has_children' => 1, 'depth' => 1], [], ['test5', 'test2', 'test3', 'test6']); + $this->assertMenuLink('test2', ['has_children' => 0, 'depth' => 3], ['test5', 'test1']); + $this->assertMenuLink('test3', ['has_children' => 0, 'depth' => 2], ['test1']); $this->assertFalse($this->treeStorage->load('test4')); - $this->assertMenuLink('test5', array('has_children' => 1, 'depth' => 2), array('test1'), array('test2', 'test6')); - $this->assertMenuLink('test6', array('has_children' => 0, 'depth' => 3), array('test5', 'test1')); + $this->assertMenuLink('test5', ['has_children' => 1, 'depth' => 2], ['test1'], ['test2', 'test6']); + $this->assertMenuLink('test6', ['has_children' => 0, 'depth' => 3], ['test5', 'test1']); } /** @@ -177,12 +177,12 @@ public function testMenuDisabledChildLinks() { // -- test2 (disabled) $this->addMenuLink('test1', ''); - $this->assertMenuLink('test1', array('has_children' => 0, 'depth' => 1)); + $this->assertMenuLink('test1', ['has_children' => 0, 'depth' => 1]); - $this->addMenuLink('test2', 'test1', '', array(), 'tools', array('enabled' => 0)); + $this->addMenuLink('test2', 'test1', '', [], 'tools', ['enabled' => 0]); // The 1st link does not have any visible children, so has_children is 0. - $this->assertMenuLink('test1', array('has_children' => 0, 'depth' => 1)); - $this->assertMenuLink('test2', array('has_children' => 0, 'depth' => 2, 'enabled' => 0), array('test1')); + $this->assertMenuLink('test1', ['has_children' => 0, 'depth' => 1]); + $this->assertMenuLink('test2', ['has_children' => 0, 'depth' => 2, 'enabled' => 0], ['test1']); // Add more links with parent on the previous one. //