diff --git a/core/core.api.php b/core/core.api.php index d8ec625f7b974a94b51ca2ac22554dabba46766b..34e699b36bd8c055e32784b01a533d7b26c89ae5 100644 --- a/core/core.api.php +++ b/core/core.api.php @@ -537,16 +537,16 @@ * Example: * @code * // A cache item with nodes, users, and some custom module data. - * $tags = array( + * $tags = [ * 'my_custom_tag', * 'node:1', * 'node:3', * 'user:7', - * ); + * ]; * \Drupal::cache()->set($cid, $data, CacheBackendInterface::CACHE_PERMANENT, $tags); * * // Invalidate all cache items with certain tags. - * \Drupal\Core\Cache\Cache::invalidateTags(array('user:1')); + * \Drupal\Core\Cache\Cache::invalidateTags(['user:1']); * @endcode * * Drupal is a content management system, so naturally you want changes to your @@ -1712,14 +1712,14 @@ * * public function buildForm(array $form, FormStateInterface $form_state) { * // Create a $form API array. - * $form['phone_number'] = array( + * $form['phone_number'] = [ * '#type' => 'tel', * '#title' => $this->t('Your phone number'), - * ); - * $form['save'] = array( + * ]; + * $form['save'] = [ * '#type' => 'submit', * '#value' => $this->t('Save'), - * ); + * ]; * return $form; * } * @@ -1753,11 +1753,11 @@ * $form = \Drupal::formBuilder()->getForm('Drupal\my_module\Form\ExampleForm', $extra); * ... * public function buildForm(array $form, FormStateInterface $form_state, $extra = NULL) - * $form['phone_number'] = array( + * $form['phone_number'] = [ * '#type' => 'tel', * '#title' => $this->t('Your phone number'), * '#value' => $extra, - * ); + * ]; * return $form; * } * @endcode @@ -2340,14 +2340,14 @@ function hook_validation_constraint_alter(array &$definitions) { * Ajax response. This is done in the text field form array element * in \Drupal\config_translation\FormElement\DateFormat::getFormElement(): * @code - * '#ajax' => array( + * '#ajax' => [ * 'callback' => 'Drupal\config_translation\FormElement\DateFormat::ajaxSample', * 'event' => 'keyup', - * 'progress' => array( + * 'progress' => [ * 'type' => 'throbber', * 'message' => NULL, - * ), - * ), + * ], + * ], * @endcode * * As you can see from this example, the #ajax property for a form element is @@ -2435,7 +2435,7 @@ function hook_validation_constraint_alter(array &$definitions) { * 'wrapper' method and return HTML markup. This is not the case if you return * commands, but if you would like to show status messages, you can add * @code - * array('#type' => 'status_messages') + * ['#type' => 'status_messages'] * @endcode * to a render array, use \Drupal::service('renderer')->render() to render it, * and add a command to place the messages in an appropriate location. @@ -2596,9 +2596,9 @@ function hook_validation_constraint_alter(array &$definitions) { * @code * public static function getSubscribedEvents(): array { * // Subscribe to kernel terminate with priority 100. - * $events[KernelEvents::TERMINATE][] = array('onTerminate', 100); + * $events[KernelEvents::TERMINATE][] = ['onTerminate', 100]; * // Subscribe to kernel request with default priority of 0. - * $events[KernelEvents::REQUEST][] = array('onRequest'); + * $events[KernelEvents::REQUEST][] = ['onRequest']; * return $events; * } * @endcode diff --git a/core/includes/common.inc b/core/includes/common.inc index cf9a8b1ad13188dd876cffc5ee945c7334a68034..fcd9df954beb4ccbace93e66febbdaf412d029ed 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -139,14 +139,14 @@ function base_path() { * into a table. The table must have an ID attribute set and it * may be set as follows: * @code - * $table = array( + * $table = [ * '#type' => 'table', * '#header' => $header, * '#rows' => $rows, - * '#attributes' => array( + * '#attributes' => [ * 'id' => 'my-module-table', - * ), - * ); + * ], + * ]; * return \Drupal::service('renderer')->render($table); * @endcode * @@ -156,17 +156,17 @@ function base_path() { * In a situation where a single weight column is being sorted in the table, the * classes could be added like this (in the theme function): * @code - * $form['my_elements'][$delta]['weight']['#attributes']['class'] = array('my-elements-weight'); + * $form['my_elements'][$delta]['weight']['#attributes']['class'] = ['my-elements-weight']; * @endcode * * Each row of the table must also have a class of "draggable" in order to * enable the drag handles: * @code - * $row = array(...); - * $rows[] = array( + * $row = [...]; + * $rows[] = [ * 'data' => $row, - * 'class' => array('draggable'), - * ); + * 'class' => ['draggable'], + * ]; * @endcode * * When tree relationships are present, the two additional classes @@ -176,18 +176,18 @@ function base_path() { * * Calling drupal_attach_tabledrag() would then be written as such: * @code - * drupal_attach_tabledrag('my-module-table', array( + * drupal_attach_tabledrag('my-module-table', [ * 'action' => 'order', * 'relationship' => 'sibling', * 'group' => 'my-elements-weight', - * ); + * ]; * @endcode * * In a more complex case where there are several groups in one column (such as * the block regions on the admin/structure/block page), a separate subgroup * class must also be added to differentiate the groups. * @code - * $form['my_elements'][$region][$delta]['weight']['#attributes']['class'] = array('my-elements-weight', 'my-elements-weight-' . $region); + * $form['my_elements'][$region][$delta]['weight']['#attributes']['class'] = ['my-elements-weight', 'my-elements-weight-' . $region]; * @endcode * * The 'group' option is still 'my-element-weight', and the additional @@ -197,12 +197,12 @@ function base_path() { * * @code * foreach ($regions as $region) { - * drupal_attach_tabledrag('my-module-table', array( + * drupal_attach_tabledrag('my-module-table', [ * 'action' => 'order', * 'relationship' => 'sibling', * 'group' => 'my-elements-weight', * 'subgroup' => 'my-elements-weight-' . $region, - * )); + * ]); * } * @endcode * diff --git a/core/includes/form.inc b/core/includes/form.inc index a976902351e1dc3f6b50654523f390a1e855073a..d6a2eb1c4c201f121dfd510ffef1f64e1e809812 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -150,7 +150,7 @@ function form_select_options($element, $choices = NULL) { * index is not sufficient, and supporting this would make the * "helper" too complicated and cumbersome to be of any help. * - * As usual with functions that can return array() or FALSE, do not + * As usual with functions that can return [] or FALSE, do not * forget to use === and !== if needed. * * @param $element @@ -576,15 +576,15 @@ function template_preprocess_form_element_label(&$variables) { * * Example: * @code - * $batch = array( + * $batch = [ * 'title' => t('Exporting'), - * 'operations' => array( - * array('my_function_1', array($account->id(), 'story')), - * array('my_function_2', array()), - * ), + * 'operations' => [ + * ['my_function_1', [$account->id(), 'story']], + * ['my_function_2', []], + * ], * 'finished' => 'my_finished_callback', * 'file' => 'path_to_file_containing_my_functions', - * ); + * ]; * batch_set($batch); * // Only needed if not inside a form _submit handler. * // Setting redirect in batch_process. @@ -638,7 +638,7 @@ function template_preprocess_form_element_label(&$variables) { * } * $limit = 5; * $result = \Drupal::database()->select('example') - * ->fields('example', array('id')) + * ->fields('example', ['id']) * ->condition('id', $context['sandbox']['current_id'], '>') * ->orderBy('id') * ->range(0, $limit) @@ -671,7 +671,7 @@ function template_preprocess_form_element_label(&$variables) { * \Drupal::messenger()->addMessage($message); * // Providing data for the redirected page is done through the session. * foreach ($results as $result) { - * $items[] = t('Loaded node %title.', array('%title' => $result)); + * $items[] = t('Loaded node %title.', ['%title' => $result)]; * } * $session = \Drupal::getRequest()->getSession(); * $session->set('my_batch_results', $items); @@ -702,10 +702,10 @@ function template_preprocess_form_element_label(&$variables) { * callback_batch_operation() and an array of parameter. * Example: * @code - * array( - * array('callback_batch_operation_1', array($arg1)), - * array('callback_batch_operation_2', array($arg2_1, $arg2_2)), - * ) + * [ + * ['callback_batch_operation_1', [$arg1)], + * ['callback_batch_operation_2', [$arg2_1, $arg2_2]], + * ] * @endcode * - title: A safe, translated string to use as the title for the progress * page. Defaults to t('Processing'). diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 56667523e88df3baca7a56c7e2358f639d1cdd37..1603c5c65de7661e9bcd544f6b72b84a2954fef4 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -727,16 +727,16 @@ function template_preprocess_image(&$variables) { * - Any HTML attributes, such as "colspan", to apply to the table cell. * Here's an example for $rows: * @code - * $rows = array( + * $rows = [ * // Simple row - * array( + * [ * 'Cell 1', 'Cell 2', 'Cell 3' - * ), + * ], * // Row with attributes on the row and some of its cells. - * array( - * 'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => array('funky') - * ), - * ); + * [ + * 'data' => ['Cell 1', ['data' => 'Cell 2', 'colspan' => 2]], 'class' => ['funky'] + * ], + * ]; * @endcode * - footer: An array of table rows which will be printed within a <tfoot> * tag, in the same format as the rows element (see above). @@ -752,23 +752,23 @@ function template_preprocess_image(&$variables) { * associative array of HTML attributes. * Here's an example for $colgroup: * @code - * $colgroup = array( + * $colgroup = [ * // <colgroup> with one <col> element. - * array( - * array( - * 'class' => array('funky'), // Attribute for the <col> element. - * ), - * ), + * [ + * [ + * 'class' => ['funky'], // Attribute for the <col> element. + * ], + * ], * // <colgroup> with attributes and inner <col> elements. - * array( - * 'data' => array( - * array( - * 'class' => array('funky'), // Attribute for the <col> element. - * ), - * ), - * 'class' => array('jazzy'), // Attribute for the <colgroup> element. - * ), - * ); + * [ + * 'data' => [ + * [ + * 'class' => ['funky'], // Attribute for the <col> element. + * ], + * ], + * 'class' => ['jazzy'], // Attribute for the <colgroup> element. + * ], + * ]; * @endcode * These optional tags are used to group and set properties on columns * within a table. For example, one may easily group three columns and diff --git a/core/lib/Drupal/Component/Plugin/DependentPluginInterface.php b/core/lib/Drupal/Component/Plugin/DependentPluginInterface.php index 0c6fc7b20adff55594d775bfbbac0ea5e6b84eb4..397e3dbd292f1cb5e3cb52ed036b1cf3ced0c534 100644 --- a/core/lib/Drupal/Component/Plugin/DependentPluginInterface.php +++ b/core/lib/Drupal/Component/Plugin/DependentPluginInterface.php @@ -21,12 +21,12 @@ interface DependentPluginInterface { * An array of dependencies grouped by type (config, content, module, * theme). For example: * @code - * array( - * 'config' => array('user.role.anonymous', 'user.role.authenticated'), - * 'content' => array('node:article:f0a189e6-55fb-47fb-8005-5bef81c44d6d'), - * 'module' => array('node', 'user'), - * 'theme' => array('claro'), - * ); + * [ + * 'config' => ['user.role.anonymous', 'user.role.authenticated'], + * 'content' => ['node:article:f0a189e6-55fb-47fb-8005-5bef81c44d6d'], + * 'module' => ['node', 'user'], + * 'theme' => ['claro'], + * ]; * @endcode * * @see \Drupal\Core\Config\Entity\ConfigDependencyManager diff --git a/core/lib/Drupal/Component/Utility/NestedArray.php b/core/lib/Drupal/Component/Utility/NestedArray.php index 6d6d8b9ef58a46a5ebd329662c57560b1d933453..ba74210b7aafb08c528ef2eebb1970c0e42ddda5 100644 --- a/core/lib/Drupal/Component/Utility/NestedArray.php +++ b/core/lib/Drupal/Component/Utility/NestedArray.php @@ -92,22 +92,22 @@ public static function &getValue(array &$array, array $parents, &$key_exists = N * Example: * @code * // Assume you have a 'signature' element somewhere in a form. It might be: - * $form['signature_settings']['signature'] = array( + * $form['signature_settings']['signature'] = [ * '#type' => 'text_format', * '#title' => t('Signature'), - * ); + * ]; * // Or, it might be further nested: - * $form['signature_settings']['user']['signature'] = array( + * $form['signature_settings']['user']['signature'] = [ * '#type' => 'text_format', * '#title' => t('Signature'), - * ); + * ]; * @endcode * * To deal with the situation, the code needs to figure out the route to the * element, given an array of parents that is either - * @code array('signature_settings', 'signature') @endcode + * @code ['signature_settings', 'signature'] @endcode * in the first case or - * @code array('signature_settings', 'user', 'signature') @endcode + * @code ['signature_settings', 'user', 'signature'] @endcode * in the second case. * * Without this helper function the only way to set the signature element in @@ -170,22 +170,22 @@ public static function setValue(array &$array, array $parents, $value, $force = * Example: * @code * // Assume you have a 'signature' element somewhere in a form. It might be: - * $form['signature_settings']['signature'] = array( + * $form['signature_settings']['signature'] = [ * '#type' => 'text_format', * '#title' => t('Signature'), - * ); + * ]; * // Or, it might be further nested: - * $form['signature_settings']['user']['signature'] = array( + * $form['signature_settings']['user']['signature'] = [ * '#type' => 'text_format', * '#title' => t('Signature'), - * ); + * ]; * @endcode * * To deal with the situation, the code needs to figure out the route to the * element, given an array of parents that is either - * @code array('signature_settings', 'signature') @endcode + * @code ['signature_settings', 'signature'] @endcode * in the first case or - * @code array('signature_settings', 'user', 'signature') @endcode + * @code ['signature_settings', 'user', 'signature'] @endcode * in the second case. * * Without this helper function the only way to unset the signature element in @@ -276,13 +276,13 @@ public static function keyExists(array $array, array $parents) { * * Example: * @code - * $link_options_1 = array('fragment' => 'x', 'attributes' => array('title' => t('X'), 'class' => array('a', 'b'))); - * $link_options_2 = array('fragment' => 'y', 'attributes' => array('title' => t('Y'), 'class' => array('c', 'd'))); + * $link_options_1 = ['fragment' => 'x', 'attributes' => ['title' => t('X'), 'class' => ['a', 'b']]]; + * $link_options_2 = ['fragment' => 'y', 'attributes' => ['title' => t('Y'), 'class' => ['c', 'd']]]; * - * // This results in array('fragment' => array('x', 'y'), 'attributes' => array('title' => array(t('X'), t('Y')), 'class' => array('a', 'b', 'c', 'd'))). + * // This results in ['fragment' => ['x', 'y'], 'attributes' => ['title' => [t('X'), t('Y')], 'class' => ['a', 'b', 'c', 'd']]]. * $incorrect = array_merge_recursive($link_options_1, $link_options_2); * - * // This results in array('fragment' => 'y', 'attributes' => array('title' => t('Y'), 'class' => array('a', 'b', 'c', 'd'))). + * // This results in ['fragment' => 'y', 'attributes' => ['title' => t('Y'), 'class' => ['a', 'b', 'c', 'd']]]. * $correct = NestedArray::mergeDeep($link_options_1, $link_options_2); * @endcode * @@ -307,7 +307,7 @@ public static function mergeDeep() { * * The following are equivalent: * - NestedArray::mergeDeep($a, $b); - * - NestedArray::mergeDeepArray(array($a, $b)); + * - NestedArray::mergeDeepArray([$a, $b]); * * The following are also equivalent: * - call_user_func_array('NestedArray::mergeDeep', $arrays_to_merge); diff --git a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php index bf2ed7c48eee773f903ab5dbb760ee889e6a6c1c..20bdc8ab04f26a338e6e6e22b6341977cb5d4525 100644 --- a/core/lib/Drupal/Core/Cache/CacheBackendInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheBackendInterface.php @@ -104,16 +104,16 @@ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []); * @param array $items * An array of cache items, keyed by cid. In the form: * @code - * $items = array( - * $cid => array( + * $items = [ + * $cid => [ * // Required, will be automatically serialized if not a string. * 'data' => $data, * // Optional, defaults to CacheBackendInterface::CACHE_PERMANENT. * 'expire' => CacheBackendInterface::CACHE_PERMANENT, * // (optional) The cache tags for this item, see CacheBackendInterface::set(). - * 'tags' => array(), - * ), - * ); + * 'tags' => [], + * ], + * ]; * @endcode */ public function setMultiple(array $items); diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index 9048403a2fd9f25a5aa466b93f13fcb64f0e0b12..447bed82fb807da32c013efdacc836fd3ebb1ec8 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -301,14 +301,14 @@ public function getOriginal($key = '', $apply_overrides = TRUE) { * (optional) A string that maps to a key within the configuration data. * For instance in the following configuration array: * @code - * array( - * 'foo' => array( + * [ + * 'foo' => [ * 'bar' => 'baz', - * ), - * ); + * ], + * ]; * @endcode * A key of 'foo.bar' would map to the string 'baz'. However, a key of 'foo' - * would map to the array('bar' => 'baz'). + * would map to the ['bar' => 'baz']. * If not supplied TRUE will be returned if there are any overrides at all * for this configuration object. * diff --git a/core/lib/Drupal/Core/Config/ConfigBase.php b/core/lib/Drupal/Core/Config/ConfigBase.php index 744af363b157b633f7063004207b4f5aa14c499d..6c8148612ed5230a3aa0f31bcdb4ef28611b9f62 100644 --- a/core/lib/Drupal/Core/Config/ConfigBase.php +++ b/core/lib/Drupal/Core/Config/ConfigBase.php @@ -115,14 +115,14 @@ public static function validateName($name) { * A string that maps to a key within the configuration data. * For instance in the following configuration array: * @code - * array( - * 'foo' => array( + * [ + * 'foo' => [ * 'bar' => 'baz', - * ), - * ); + * ], + * ]; * @endcode * A key of 'foo.bar' would return the string 'baz'. However, a key of 'foo' - * would return array('bar' => 'baz'). + * would return ['bar' => 'baz']. * If no key is specified, then the entire data array is returned. * * @return mixed diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php index ed0b821eda7be337511eca6663fe737d4a7b03dc..d1286cee924625028a35f2bd9349057a7cda7e6c 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigDependencyManager.php @@ -15,30 +15,30 @@ * * The configuration dependency value is structured like this: * @code - * array( - * 'config' => array( + * [ + * 'config' => [ * // An array of configuration entity object names. Recalculated on save. - * ), - * 'content' => array( + * ], + * 'content' => [ * // An array of content entity configuration dependency names. The default * // format is "ENTITY_TYPE_ID:BUNDLE:UUID". Recalculated on save. - * ), - * 'module' => array( + * ], + * 'module' => [ * // An array of module names. Recalculated on save. - * ), - * 'theme' => array( + * ], + * 'theme' => [ * // An array of theme names. Recalculated on save. - * ), - * 'enforced' => array( + * ], + * 'enforced' => [ * // An array of configuration dependencies that the config entity is * // ensured to have regardless of the details of the configuration. These * // dependencies are not recalculated on save. - * 'config' => array(), - * 'content' => array(), - * 'module' => array(), - * 'theme' => array(), + * 'config' => [], + * 'content' => [], + * 'module' => [], + * 'theme' => [], * ), - * ); + * ]; * @endcode * * Configuration entity dependencies are recalculated on save based on the @@ -305,21 +305,21 @@ public function setData(array $data) { * @param array $dependencies * The configuration dependencies. The array is structured like this: * @code - * array( - * 'config' => array( + * [ + * 'config' => [ * // An array of configuration entity object names. - * ), - * 'content' => array( + * ], + * 'content' => [ * // An array of content entity configuration dependency names. The default * // format is "ENTITY_TYPE_ID:BUNDLE:UUID". - * ), - * 'module' => array( + * ], + * 'module' => [ * // An array of module names. - * ), - * 'theme' => array( + * ], + * 'theme' => [ * // An array of theme names. - * ), - * ); + * ], + * ]; * @endcode * * @return $this diff --git a/core/lib/Drupal/Core/Config/FileStorage.php b/core/lib/Drupal/Core/Config/FileStorage.php index fe202a3e0ed6dd60826bd4753abcd1a3242f10b4..79153c6d9ba7debc04cbb30ebfe69b28ad67747c 100644 --- a/core/lib/Drupal/Core/Config/FileStorage.php +++ b/core/lib/Drupal/Core/Config/FileStorage.php @@ -291,12 +291,12 @@ public function getAllCollectionNames() { * ./collection/sub/two * this function will return: * @code - * array( + * [ * 'another_collection.one', * 'another_collection.two', * 'collection.sub.one', * 'collection.sub.two', - * ); + * ]; * @endcode * * @param string $directory diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index 5da12f964f6889191ade2db99253b245e95a7679..ae5bb80f0c8853468c386f4403b9cd450bf116a8 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -593,7 +593,7 @@ public function makeComment($comments) { * @code * \Drupal::database()->update('example') * ->condition('id', $id) - * ->fields(array('field2' => 10)) + * ->fields(['field2' => 10]) * ->comment('Exploit * / DROP TABLE node; --') * ->execute() * @endcode @@ -1064,7 +1064,7 @@ public function escapeAlias($field) { * @code * $result = $injected_connection->query( * 'SELECT * FROM person WHERE name LIKE :pattern', - * array(':pattern' => $injected_connection->escapeLike($prefix) . '%') + * [':pattern' => $injected_connection->escapeLike($prefix) . '%'] * ); * @endcode * diff --git a/core/lib/Drupal/Core/Database/Query/ConditionInterface.php b/core/lib/Drupal/Core/Database/Query/ConditionInterface.php index 72f54e0d1d31db332d65fcfa7c18ce53dcee3b89..01815f2c45a830658c1f74926f1229c53a3f1e66 100644 --- a/core/lib/Drupal/Core/Database/Query/ConditionInterface.php +++ b/core/lib/Drupal/Core/Database/Query/ConditionInterface.php @@ -148,11 +148,11 @@ public function alwaysFalse(); * The data structure that is returned is an indexed array of entries, where * each entry looks like the following: * @code - * array( + * [ * 'field' => $field, * 'value' => $value, * 'operator' => $operator, - * ); + * ]; * @endcode * * In the special case that $operator is NULL, the $field is taken as a raw diff --git a/core/lib/Drupal/Core/Database/Query/Merge.php b/core/lib/Drupal/Core/Database/Query/Merge.php index c5685741e9fa48cf148f1b84c5cd21a63780dc32..ab388e2e41f754059c5f5b3eab8be0d2d946abd8 100644 --- a/core/lib/Drupal/Core/Database/Query/Merge.php +++ b/core/lib/Drupal/Core/Database/Query/Merge.php @@ -105,10 +105,10 @@ class Merge extends Query implements ConditionInterface { * * This variable is a nested array in the following format: * @code - * <some field> => array( + * <some field> => [ * 'condition' => <condition to execute, as a string>, * 'arguments' => <array of arguments for condition, or NULL for none>, - * ); + * ]; * @endcode * * @var array diff --git a/core/lib/Drupal/Core/Database/Query/Update.php b/core/lib/Drupal/Core/Database/Query/Update.php index f9add858545aff1a9a4f3da15003f0c6081727c5..67cfdbc337800d53c2f2de98b90a10cae16a67b6 100644 --- a/core/lib/Drupal/Core/Database/Query/Update.php +++ b/core/lib/Drupal/Core/Database/Query/Update.php @@ -39,10 +39,10 @@ class Update extends Query implements ConditionInterface { * * This variable is a nested array in the following format: * @code - * <some field> => array( + * <some field> => [ * 'condition' => <condition to execute, as a string>, * 'arguments' => <array of arguments for condition, or NULL for none>, - * ); + * ]; * @endcode * * @var array diff --git a/core/lib/Drupal/Core/Database/Schema.php b/core/lib/Drupal/Core/Database/Schema.php index 9530c8fbf86b0a523a268916550aa303958a69ec..9c5aac0968115d749ed93e53cfa778c67747a8b7 100644 --- a/core/lib/Drupal/Core/Database/Schema.php +++ b/core/lib/Drupal/Core/Database/Schema.php @@ -543,20 +543,20 @@ protected function introspectIndexSchema($table) { * * For example, suppose you have: * @code - * $schema['foo'] = array( - * 'fields' => array( - * 'bar' => array('type' => 'int', 'not null' => TRUE) - * ), - * 'primary key' => array('bar') - * ); + * $schema['foo'] = [ + * 'fields' => [ + * 'bar' => ['type' => 'int', 'not null' => TRUE] + * ], + * 'primary key' => ['bar'] + * ]; * @endcode * and you want to change foo.bar to be type serial, leaving it as the * primary key. The correct sequence is: * @code * $injected_database->schema()->dropPrimaryKey('foo'); * $injected_database->schema()->changeField('foo', 'bar', 'bar', - * array('type' => 'serial', 'not null' => TRUE), - * array('primary key' => array('bar'))); + * ['type' => 'serial', 'not null' => TRUE], + * ['primary key' => ['bar'])]; * @endcode * * The reasons for this are due to the different database engines: diff --git a/core/lib/Drupal/Core/Database/database.api.php b/core/lib/Drupal/Core/Database/database.api.php index c713d1a62374d39562849bca04a95646575d8fb6..83faf2d21c5aeec5b4de087c37b17ff55dc30863 100644 --- a/core/lib/Drupal/Core/Database/database.api.php +++ b/core/lib/Drupal/Core/Database/database.api.php @@ -77,7 +77,7 @@ * FROM {example} e * WHERE e.uid = :uid * ORDER BY e.created DESC', - * 0, 10, array(':uid' => $uid)); + * 0, 10, [':uid' => $uid)]; * foreach ($result as $record) { * // Perform operations on $record->title, etc. here. * } @@ -90,7 +90,7 @@ * when you convert it to placeholders, omit the quotes: * @code * WHERE e.my_field = :my_field - * ... array(':my_field' => 'foo') ... + * ... [':my_field' => 'foo'] ... * @endcode * * @section sec_dynamic Dynamic SELECT queries @@ -110,7 +110,7 @@ * would be: * @code * $result = \Drupal::database()->select('example', 'e') - * ->fields('e', array('id', 'title', 'created')) + * ->fields('e', ['id', 'title', 'created']) * ->condition('e.uid', $uid) * ->orderBy('e.created', 'DESC') * ->range(0, 10) @@ -152,7 +152,7 @@ * @endcode * You can execute it via: * @code - * $fields = array('id' => 1, 'uid' => 2, 'path' => 'path', 'name' => 'Name'); + * $fields = ['id' => 1, 'uid' => 2, 'path' => 'path', 'name' => 'Name']; * \Drupal::database()->insert('example') * ->fields($fields) * ->execute(); @@ -182,10 +182,10 @@ * $transaction = $connection->startTransaction(); * * $id = $connection->insert('example') - * ->fields(array( + * ->fields([ * 'field1' => 'string', * 'field2' => 5, - * )) + * ]) * ->execute(); * * my_other_function($id); @@ -216,7 +216,7 @@ * if ($id % 2 == 0) { * $connection->update('example') * ->condition('id', $id) - * ->fields(array('field2' => 10)) + * ->fields(['field2' => 10]) * ->execute(); * } * } diff --git a/core/lib/Drupal/Core/Datetime/Element/Datelist.php b/core/lib/Drupal/Core/Datetime/Element/Datelist.php index e9e805dd38ec835c405b2b76b0a0b15d2dedbd7f..7d8c50dd02fca7539f768bc82de5e01fea6cd935 100644 --- a/core/lib/Drupal/Core/Datetime/Element/Datelist.php +++ b/core/lib/Drupal/Core/Datetime/Element/Datelist.php @@ -139,7 +139,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form * Optional properties include: * - #date_part_order: Array of date parts indicating the parts and order * that should be used in the selector, optionally including 'ampm' for - * 12 hour time. Default is array('year', 'month', 'day', 'hour', 'minute'). + * 12 hour time. Default is ['year', 'month', 'day', 'hour', 'minute']. * - #date_text_parts: Array of date parts that should be presented as * text fields instead of drop-down selectors. Default is an empty array. * - #date_date_callbacks: Array of optional callbacks for the date element. @@ -158,15 +158,15 @@ public static function valueCallback(&$element, $input, FormStateInterface $form * * Example usage: * @code - * $form = array( + * $form = [ * '#type' => 'datelist', * '#default_value' => new DrupalDateTime('2000-01-01 00:00:00'), - * '#date_part_order' => array('month', 'day', 'year', 'hour', 'minute', 'ampm'), - * '#date_text_parts' => array('year'), + * '#date_part_order' => ['month', 'day', 'year', 'hour', 'minute', 'ampm'], + * '#date_text_parts' => ['year'], * '#date_year_range' => '2010:2020', * '#date_increment' => 15, * '#date_timezone' => 'Asia/Kolkata' - * ); + * ]; * @endcode * * @param array $element diff --git a/core/lib/Drupal/Core/Datetime/Element/Datetime.php b/core/lib/Drupal/Core/Datetime/Element/Datetime.php index c979d77ee966b7c5d01c5a1edc0906dfa354a95a..60da4a4b55c1640c1d78cb7ef5a3b82cfa44a4ee 100644 --- a/core/lib/Drupal/Core/Datetime/Element/Datetime.php +++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php @@ -201,14 +201,14 @@ public static function valueCallback(&$element, $input, FormStateInterface $form * * Example usage: * @code - * $form = array( + * $form = [ * '#type' => 'datetime', * '#default_value' => new DrupalDateTime('2000-01-01 00:00:00'), * '#date_date_element' => 'date', * '#date_time_element' => 'none', * '#date_year_range' => '2010:+3', * '#date_timezone' => 'Asia/Kolkata', - * ); + * ]; * @endcode * * @param array $element diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index c0bdf11cb7a72dc24c3b7e6c89839c0ab33f1c67..191f6d1291144b703af7f1b1bc3941306d44681a 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -360,9 +360,9 @@ protected static function guessApplicationRoot() { * directory alias for https://www.drupal.org:8080/my-site/test whose * configuration file is in sites/example.com, the array should be defined as: * @code - * $sites = array( + * $sites = [ * '8080.www.drupal.org.my-site.test' => 'example.com', - * ); + * ]; * @endcode * * @param \Symfony\Component\HttpFoundation\Request $request @@ -1602,10 +1602,10 @@ public static function validateHostname(Request $request) { * requests. For example, * * @code - * $settings['trusted_host_patterns'] = array( + * $settings['trusted_host_patterns'] = [ * '^example\.com$', * '^*.example\.com$', - * ); + * ]; * @endcode * * @param \Symfony\Component\HttpFoundation\Request $request diff --git a/core/lib/Drupal/Core/Entity/DependencyTrait.php b/core/lib/Drupal/Core/Entity/DependencyTrait.php index 81112eb725b69e9215e53fb98c21f5a1fe50bfff..6da17d7f5de8a986b659051ac53b287fed36f95d 100644 --- a/core/lib/Drupal/Core/Entity/DependencyTrait.php +++ b/core/lib/Drupal/Core/Entity/DependencyTrait.php @@ -50,13 +50,13 @@ protected function addDependency($type, $name) { * @param array $dependencies * An array of dependencies keyed by the type of dependency. One example: * @code - * array( - * 'module' => array( + * [ + * 'module' => [ * 'node', * 'field', * 'image', - * ), - * ); + * ], + * ]; * @endcode * * @see \Drupal\Core\Entity\DependencyTrait::addDependency diff --git a/core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php b/core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php index ba6117d90e4a8dce5b9bfcaa7b177cedb389fdea..ffa0a02ab689625546711d690e314604d86cb8a6 100644 --- a/core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php +++ b/core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php @@ -37,10 +37,10 @@ interface EntityFormDisplayInterface extends EntityDisplayInterface { * // most common case), and will therefore be repeated as many times as * // needed, or 'multiple-values' (one single widget allows the input of * // several values; e.g., checkboxes, select box, etc.). - * 'field_foo' => array( + * 'field_foo' => [ * '#access' => TRUE if the current user has 'edit' grants for the field, * FALSE if not. - * 'widget' => array( + * 'widget' => [ * '#field_name' => The name of the field, * '#title' => The label of the field, * '#description' => The description text for the field, @@ -58,7 +58,7 @@ interface EntityFormDisplayInterface extends EntityDisplayInterface { * '#cardinality_multiple' => TRUE if the field can contain multiple * items, FALSE otherwise. * // One sub-array per copy of the widget, keyed by delta. - * 0 => array( + * 0 => [ * '#title' => The title to be displayed by the widget, * '#description' => The description text for the field, * '#required' => Whether the widget should be marked required, @@ -67,15 +67,15 @@ interface EntityFormDisplayInterface extends EntityDisplayInterface { * '#field_parents' => Same as above, * // The remaining elements in the sub-array depend on the widget. * ... - * ), - * 1 => array( + * ], + * 1 => [ * ... - * ), + * ], * ... - * ), + * ], * ... - * ), - * ) + * ], + * ] * @endcode * * Additionally, some processing data is placed in $form_state, and can be diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayRepositoryInterface.php b/core/lib/Drupal/Core/Entity/EntityDisplayRepositoryInterface.php index 7354869c535613d68846fac9d4e9f5b8ee8207f8..ca7ab71ae17b1ce3a3fd0369a7f6d0b89dad2c07 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayRepositoryInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayRepositoryInterface.php @@ -127,11 +127,11 @@ public function clearDisplayModeInfo(); * @code * \Drupal::service('entity_display.repository') * ->getViewDisplay('node', 'article', 'default') - * ->setComponent('body', array( + * ->setComponent('body', [ * 'type' => 'text_summary_or_trimmed', - * 'settings' => array('trim_length' => '200') + * 'settings' => ['trim_length' => '200'], * 'weight' => 1, - * )) + * ]) * ->removeComponent('field_image') * ->save(); * @endcode @@ -164,13 +164,13 @@ public function getViewDisplay($entity_type, $bundle, $view_mode = self::DEFAULT * @code * \Drupal::service('entity_display.repository') * ->getFormDisplay('node', 'article', 'default') - * ->setComponent('body', array( + * ->setComponent('body', [ * 'type' => 'text_textarea_with_summary', * 'weight' => 1, - * )) - * ->setComponent('field_image', array( + * ]) + * ->setComponent('field_image', [ * 'region' => 'hidden', - * )) + * ]) * ->save(); * @endcode * diff --git a/core/lib/Drupal/Core/Entity/Query/QueryAggregateInterface.php b/core/lib/Drupal/Core/Entity/Query/QueryAggregateInterface.php index aa7c42795b0dc3df7ce51de3e275e86926cc721b..0109fdeed01dd93106af8e1199200a4712aed60c 100644 --- a/core/lib/Drupal/Core/Entity/Query/QueryAggregateInterface.php +++ b/core/lib/Drupal/Core/Entity/Query/QueryAggregateInterface.php @@ -145,8 +145,8 @@ public function sortAggregate($field, $function, $direction = 'ASC', $langcode = * @endcode * Will return: * @code - * $result[0] = array('count_nid' => 3, 'type' => 'page'); - * $result[1] = array('count_nid' => 4, 'type' => 'article'); + * $result[0] = ['count_nid' => 3, 'type' => 'page']; + * $result[1] = ['count_nid' => 4, 'type' => 'article']; * @endcode */ public function execute(); diff --git a/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php b/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php index 36df82821cf77bc8de850b0dd8f987087f6606c0..b32c2be9082a74e4d8106de867000e9113b20459 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandlerInterface.php @@ -311,7 +311,7 @@ public function invokeAllDeprecated($description, $hook, array $args = []); * to be passed and alterable, modules provide additional variables assigned by * reference in the last $context argument: * @code - * $context = array( + * $context = [ * 'alterable' => &$alterable, * 'unalterable' => $unalterable, * 'foo' => 'bar', @@ -323,7 +323,7 @@ public function invokeAllDeprecated($description, $hook, array $args = []); * required that no implementation alters a passed object in $context, then an * object needs to be cloned: * @code - * $context = array( + * $context = [ * 'unalterable_object' => clone $object, * ); * $this->alter('my_module_data', $data, $context); @@ -336,7 +336,7 @@ public function invokeAllDeprecated($description, $hook, array $args = []); * array, ordered first by module, and then for each module, in the order of * values in $type. For example, when Form API is using $this->alter() to * execute both hook_form_alter() and hook_form_FORM_ID_alter() - * implementations, it passes array('form', 'form_' . $form_id) for $type. + * implementations, it passes ['form', 'form_' . $form_id] for $type. * @param mixed $data * The variable that will be passed to hook_TYPE_alter() implementations to be * altered. The type of this variable depends on the value of the $type @@ -369,7 +369,7 @@ public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL); * array, ordered first by module, and then for each module, in the order of * values in $type. For example, when Form API is using $this->alter() to * execute both hook_form_alter() and hook_form_FORM_ID_alter() - * implementations, it passes array('form', 'form_' . $form_id) for $type. + * implementations, it passes ['form', 'form_' . $form_id] for $type. * @param mixed $data * The variable that will be passed to hook_TYPE_alter() implementations to be * altered. The type of this variable depends on the value of the $type diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php index 645a42853ee12043d4711104dfb8efea70a881e8..defd107f3aa5df40dc5907b63318f867dea2757f 100644 --- a/core/lib/Drupal/Core/Field/FieldConfigBase.php +++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php @@ -136,10 +136,10 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn * * Example for an integer field: * @code - * array( - * array('value' => 1), - * array('value' => 2), - * ) + * [ + * ['value' => 1], + * ['value' => 2], + * ] * @endcode * * @var array diff --git a/core/lib/Drupal/Core/Field/FieldItemInterface.php b/core/lib/Drupal/Core/Field/FieldItemInterface.php index f6067d2cd515f0e880ba884a2d3972b7bc22ce13..32e81d7350cfe2aa1805bdf39236cb8db1d3356f 100644 --- a/core/lib/Drupal/Core/Field/FieldItemInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemInterface.php @@ -435,12 +435,12 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state); * An array of dependencies grouped by type (config, content, module, * theme). For example: * @code - * array( - * 'config' => array('user.role.anonymous', 'user.role.authenticated'), - * 'content' => array('node:article:f0a189e6-55fb-47fb-8005-5bef81c44d6d'), - * 'module' => array('node', 'user'), - * 'theme' => array('claro'), - * ); + * [ + * 'config' => ['user.role.anonymous', 'user.role.authenticated'], + * 'content' => ['node:article:f0a189e6-55fb-47fb-8005-5bef81c44d6d'], + * 'module' => ['node', 'user'], + * 'theme' => ['claro'], + * ]; * @endcode * * @see \Drupal\Core\Config\Entity\ConfigDependencyManager diff --git a/core/lib/Drupal/Core/Form/FormStateInterface.php b/core/lib/Drupal/Core/Form/FormStateInterface.php index 65720d44edf69756c18a8574141306454b53f609..f990cdc0df88371fc72fc5bb0f7da1b2ba4df29e 100644 --- a/core/lib/Drupal/Core/Form/FormStateInterface.php +++ b/core/lib/Drupal/Core/Form/FormStateInterface.php @@ -334,7 +334,7 @@ public function &getValues(); * @param string|array $key * Values are stored as a multi-dimensional associative array. If $key is a * string, it will return $values[$key]. If $key is an array, each element - * of the array will be used as a nested key. If $key = array('foo', 'bar') + * of the array will be used as a nested key. If $key = ['foo', 'bar'] * it will return $values['foo']['bar']. * @param mixed $default * (optional) The default value if the specified key does not exist. @@ -364,7 +364,7 @@ public function setValues(array $values); * Values are stored as a multi-dimensional associative array. If $key is a * string, it will use $values[$key] = $value. If $key is an array, each * element of the array will be used as a nested key. If - * $key = array('foo', 'bar') it will use $values['foo']['bar'] = $value. + * $key = ['foo', 'bar'] it will use $values['foo']['bar'] = $value. * @param mixed $value * The value to set. * @@ -379,7 +379,7 @@ public function setValue($key, $value); * Values are stored as a multi-dimensional associative array. If $key is a * string, it will use unset($values[$key]). If $key is an array, each * element of the array will be used as a nested key. If - * $key = array('foo', 'bar') it will use unset($values['foo']['bar']). + * $key = ['foo', 'bar'] it will use unset($values['foo']['bar']). * * @return $this */ @@ -392,7 +392,7 @@ public function unsetValue($key); * Values are stored as a multi-dimensional associative array. If $key is a * string, it will return isset($values[$key]). If $key is an array, each * element of the array will be used as a nested key. If - * $key = array('foo', 'bar') it will return isset($values['foo']['bar']). + * $key = ['foo', 'bar'] it will return isset($values['foo']['bar']). * * @return bool * TRUE if the $key is set, FALSE otherwise. @@ -406,7 +406,7 @@ public function hasValue($key); * Values are stored as a multi-dimensional associative array. If $key is a * string, it will return empty($values[$key]). If $key is an array, each * element of the array will be used as a nested key. If - * $key = array('foo', 'bar') it will return empty($values['foo']['bar']). + * $key = ['foo', 'bar'] it will return empty($values['foo']['bar']). * * @return bool * TRUE if the $key has no value, FALSE otherwise. @@ -433,8 +433,8 @@ public function isValueEmpty($key); * set $element['#parents'] to be an array giving the path through the form * array's keys to the element whose value you want to update. For instance, * if you want to update the value of $form['elem1']['elem2'], which should - * be stored in $form_state->getValue(array('elem1', 'elem2')), you would - * set $element['#parents'] = array('elem1','elem2'). + * be stored in $form_state->getValue(['elem1', 'elem2']), you would + * set $element['#parents'] = ['elem1','elem2']. * @param mixed $value * The new value for the form element. * @@ -483,33 +483,33 @@ public static function hasAnyErrors(); * any user input is valid. * * @code - * $form['actions']['previous'] = array( + * $form['actions']['previous'] = [ * '#type' => 'submit', * '#value' => t('Previous'), - * '#limit_validation_errors' => array(), // No validation. - * '#submit' => array('some_submit_function'), // #submit required. - * ); + * '#limit_validation_errors' => [], // No validation. + * '#submit' => ['some_submit_function'], // #submit required. + * ]; * @endcode * * Example 2: Require some, but not all, user input to be valid to process the * submission of a "Previous" button. * * @code - * $form['actions']['previous'] = array( + * $form['actions']['previous'] = [ * '#type' => 'submit', * '#value' => t('Previous'), - * '#limit_validation_errors' => array( + * '#limit_validation_errors' => [ * // Validate $form_state->getValue('step1'). - * array('step1'), - * // Validate $form_state->getValue(array('foo', 'bar')). - * array('foo', 'bar'), + * ['step1'], + * // Validate $form_state->getValue(['foo', 'bar']). + * ['foo', 'bar'], * ), - * '#submit' => array('some_submit_function'), // #submit required. + * '#submit' => ['some_submit_function'], // #submit required. * ); * @endcode * * This will require $form_state->getValue('step1') and everything within it - * (for example, $form_state->getValue(array('step1', 'choice'))) to be valid, + * (for example, $form_state->getValue(['step1', 'choice'])) to be valid, * so calls to self::setErrorByName('step1', $message) or * self::setErrorByName('step1][choice', $message) will prevent the submit * handlers from running, and result in the error message being displayed to @@ -517,10 +517,10 @@ public static function hasAnyErrors(); * self::setErrorByName('step2][groupX][choiceY', $message) will be * suppressed, resulting in the message not being displayed to the user, and * the submit handlers will run despite $form_state->getValue('step2') and - * $form_state->getValue(array('step2', 'groupX', 'choiceY')) containing + * $form_state->getValue(['step2', 'groupX', 'choiceY']) containing * invalid values. Errors for an invalid $form_state->getValue('foo') will be * suppressed, but errors flagging invalid values for - * $form_state->getValue(array('foo', 'bar')) and everything within it will + * $form_state->getValue(['foo', 'bar']) and everything within it will * be flagged and submission prevented. * * Partial form validation is implemented by suppressing errors rather than by @@ -533,7 +533,7 @@ public static function hasAnyErrors(); * * @param string $name * The name of the form element. If the #parents property of your form - * element is array('foo', 'bar', 'baz') then you may set an error on 'foo' + * element is ['foo', 'bar', 'baz'] then you may set an error on 'foo' * or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every * element where the #parents array starts with 'foo'. * @param string $message diff --git a/core/lib/Drupal/Core/Form/FormSubmitterInterface.php b/core/lib/Drupal/Core/Form/FormSubmitterInterface.php index 66132f53d6d2eaf673425f7ec98d43518f07b201..c3e0089b079189b4cdd66b8e89404e4542e039dc 100644 --- a/core/lib/Drupal/Core/Form/FormSubmitterInterface.php +++ b/core/lib/Drupal/Core/Form/FormSubmitterInterface.php @@ -55,13 +55,13 @@ public function executeSubmitHandlers(&$form, FormStateInterface &$form_state); * And here is an example of how to redirect to 'node/123?foo=bar#baz': * @code * $form_state->setRedirect('entity.node.canonical', - * array('node' => 123), - * array( - * 'query' => array( + * ['node' => 123], + * [ + * 'query' => [ * 'foo' => 'bar', - * ), + * ], * 'fragment' => 'baz', - * ), + * ], * ); * @endcode * diff --git a/core/lib/Drupal/Core/Mail/MailManager.php b/core/lib/Drupal/Core/Mail/MailManager.php index f3dc4803a9f7d689c2d8df454ee75e28614c98b5..647d85291402efd76fc4d82f46281369f41d20c5 100644 --- a/core/lib/Drupal/Core/Mail/MailManager.php +++ b/core/lib/Drupal/Core/Mail/MailManager.php @@ -108,21 +108,21 @@ public function __construct(\Traversable $namespaces, CacheBackendInterface $cac * file, you might set the variable as something like: * * @code - * array( + * [ * 'default' => 'php_mail', * 'user' => 'devel_mail_log', - * ); + * ]; * @endcode * * Finally, a different system can be specified for a specific message ID (see * the $key param), such as one of the keys used by the contact module: * * @code - * array( + * [ * 'default' => 'php_mail', * 'user' => 'devel_mail_log', * 'contact_page_autoreply' => 'null_mail', - * ); + * ]; * @endcode * * Other possible uses for system include a mail-sending plugin that actually diff --git a/core/lib/Drupal/Core/Mail/MailManagerInterface.php b/core/lib/Drupal/Core/Mail/MailManagerInterface.php index 6ff083d8cbbb1ea09dd1e7f840b64b2f13c3693d..bfdd291d8043b3c59c7e6c525a888db3c390c578 100644 --- a/core/lib/Drupal/Core/Mail/MailManagerInterface.php +++ b/core/lib/Drupal/Core/Mail/MailManagerInterface.php @@ -74,7 +74,7 @@ interface MailManagerInterface extends PluginManagerInterface { * message for sending later: * * @code - * $params = array('current_conditions' => $data); + * $params = ['current_conditions' => $data]; * $to = 'user@example.com'; * $message = \Drupal::service('plugin.manager.mail')->mail('example', 'notice', $to, $langcode, $params, FALSE); * // Only add to the spool if sending was not canceled. diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php b/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php index 8eb9289b17953d35da67e3f58d20cf8d08edc7b3..3314490e807e8d5e27c17446724dae4086b54799 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorageInterface.php @@ -202,7 +202,7 @@ public function loadSubtreeData($id, $max_relative_depth = NULL); * two parents (1, 6) looks like the following: * * @code - * array( + * [ * 'p1' => 1, * 'p2' => 6, * 'p3' => 8, @@ -212,7 +212,7 @@ public function loadSubtreeData($id, $max_relative_depth = NULL); * 'p7' => 0, * 'p8' => 0, * 'p9' => 0 - * ) + * ] * @endcode */ public function getRootPathIds($id); diff --git a/core/lib/Drupal/Core/Menu/menu.api.php b/core/lib/Drupal/Core/Menu/menu.api.php index a2879a7837bb938a4516d1f93170503762277d80..2fe95dffa17dea676cc7ec38d277f3f3d897234a 100644 --- a/core/lib/Drupal/Core/Menu/menu.api.php +++ b/core/lib/Drupal/Core/Menu/menu.api.php @@ -128,12 +128,12 @@ * interface elements whose render arrays have a '#contextual_links' element * defined. For example, a block render array might look like this, in part: * @code - * array( - * '#contextual_links' => array( - * 'block' => array( - * 'route_parameters' => array('block' => $entity->id()), - * ), - * ), + * [ + * '#contextual_links' => [ + * 'block' => [ + * 'route_parameters' => ['block' => $entity->id()], + * ], + * ], * @endcode * In this array, the outer key 'block' defines a "group" for contextual * links, and the inner array provides values for the route's placeholder @@ -196,12 +196,12 @@ * $tree = $menu_tree->load($menu_name, $parameters); * * // Transform the tree using the manipulators you want. - * $manipulators = array( + * $manipulators = [ * // Only show links that are accessible for the current user. - * array('callable' => 'menu.default_tree_manipulators:checkAccess'), + * ['callable' => 'menu.default_tree_manipulators:checkAccess'], * // Use the default sorting of menu links. - * array('callable' => 'menu.default_tree_manipulators:generateIndexAndSort'), - * ); + * ['callable' => 'menu.default_tree_manipulators:generateIndexAndSort'], + * ]; * $tree = $menu_tree->transform($tree, $manipulators); * * // Finally, build a renderable array from the transformed tree. @@ -385,7 +385,7 @@ function hook_local_tasks_alter(&$local_tasks) { * The route parameters passed to each route_name of the contextual links. * For example: * @code - * array('node' => $node->id()) + * ['node' => $node->id()] * @endcode * * @see \Drupal\Core\Menu\ContextualLinkManager diff --git a/core/lib/Drupal/Core/Render/Element/Actions.php b/core/lib/Drupal/Core/Render/Element/Actions.php index 7437ab9e6d498bb686ce40707b8ba741079eb057..604ed6cacc46fe6c1f34a1c267d1636975d77ced 100644 --- a/core/lib/Drupal/Core/Render/Element/Actions.php +++ b/core/lib/Drupal/Core/Render/Element/Actions.php @@ -16,11 +16,11 @@ * * Usage example: * @code - * $form['actions'] = array('#type' => 'actions'); - * $form['actions']['submit'] = array( + * $form['actions'] = ['#type' => 'actions']; + * $form['actions']['submit'] = [ * '#type' => 'submit', * '#value' => $this->t('Save'), - * ); + * ]; * @endcode */ #[RenderElement('actions')] diff --git a/core/lib/Drupal/Core/Render/Element/Button.php b/core/lib/Drupal/Core/Render/Element/Button.php index bde0453842eb49cf8f04a80b8a898c0173a1c711..7e022e3dbe73050f2cd92feffee50ca2835b63ea 100644 --- a/core/lib/Drupal/Core/Render/Element/Button.php +++ b/core/lib/Drupal/Core/Render/Element/Button.php @@ -21,10 +21,10 @@ * * Usage Example: * @code - * $form['actions']['preview'] = array( + * $form['actions']['preview'] = [ * '#type' => 'button', * '#value' => $this->t('Preview'), - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Submit diff --git a/core/lib/Drupal/Core/Render/Element/Checkbox.php b/core/lib/Drupal/Core/Render/Element/Checkbox.php index e86f82da50befea6cffaf6ff397f4837900b2354..41a7db32e9e05d71daf94a33c273b9d092b3e33c 100644 --- a/core/lib/Drupal/Core/Render/Element/Checkbox.php +++ b/core/lib/Drupal/Core/Render/Element/Checkbox.php @@ -14,10 +14,10 @@ * * Usage example: * @code - * $form['copy'] = array( + * $form['copy'] = [ * '#type' => 'checkbox', * '#title' => $this->t('Send me a copy'), - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Checkboxes diff --git a/core/lib/Drupal/Core/Render/Element/Checkboxes.php b/core/lib/Drupal/Core/Render/Element/Checkboxes.php index 8a7643f0e84e199f0e0de2346346cac41886ec5f..0cb852dac71d7f568a484c68e414508dd3a9f988 100644 --- a/core/lib/Drupal/Core/Render/Element/Checkboxes.php +++ b/core/lib/Drupal/Core/Render/Element/Checkboxes.php @@ -16,12 +16,12 @@ * * Usage example: * @code - * $form['favorites']['colors'] = array( + * $form['favorites']['colors'] = [ * '#type' => 'checkboxes', - * '#options' => array('blue' => $this->t('Blue'), 'red' => $this->t('Red')), + * '#options' => ['blue' => $this->t('Blue'), 'red' => $this->t('Red')], * '#title' => $this->t('Which colors do you like?'), * ... - * ); + * ]; * @endcode * * Element properties may be set on single option items as follows. diff --git a/core/lib/Drupal/Core/Render/Element/Color.php b/core/lib/Drupal/Core/Render/Element/Color.php index 99ef2116662272f0adea7f2df5ebe2596ae8daea..c79a833dcce24bdc77fbf793aadf194bfe430f52 100644 --- a/core/lib/Drupal/Core/Render/Element/Color.php +++ b/core/lib/Drupal/Core/Render/Element/Color.php @@ -15,11 +15,11 @@ * * Example usage: * @code - * $form['color'] = array( + * $form['color'] = [ * '#type' => 'color', * '#title' => $this->t('Color'), * '#default_value' => '#ffffff', - * ); + * ]; * @endcode */ #[FormElement('color')] diff --git a/core/lib/Drupal/Core/Render/Element/Details.php b/core/lib/Drupal/Core/Render/Element/Details.php index 4834363787910e5f43a2a3550a06f44809332eab..b85474ba15fd3a6f2c00a4744cfb9c5c318c5ae0 100644 --- a/core/lib/Drupal/Core/Render/Element/Details.php +++ b/core/lib/Drupal/Core/Render/Element/Details.php @@ -21,15 +21,15 @@ * * Usage example: * @code - * $form['author'] = array( + * $form['author'] = [ * '#type' => 'details', * '#title' => $this->t('Author'), - * ); + * ]; * - * $form['author']['name'] = array( + * $form['author']['name'] = [ * '#type' => 'textfield', * '#title' => $this->t('Name'), - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Fieldset diff --git a/core/lib/Drupal/Core/Render/Element/Dropbutton.php b/core/lib/Drupal/Core/Render/Element/Dropbutton.php index 6834c6890551c6ec589ac17e00f1c036f6a8a93b..87769c718d597ddb12f84e466339f511e125f172 100644 --- a/core/lib/Drupal/Core/Render/Element/Dropbutton.php +++ b/core/lib/Drupal/Core/Render/Element/Dropbutton.php @@ -24,20 +24,20 @@ * * Usage Example: * @code - * $form['actions']['extra_actions'] = array( + * $form['actions']['extra_actions'] = [ * '#type' => 'dropbutton', * '#dropbutton_type' => 'small', - * '#links' => array( - * 'simple_form' => array( + * '#links' => [ + * 'simple_form' => [ * 'title' => $this->t('Simple Form'), * 'url' => Url::fromRoute('fapi_example.simple_form'), - * ), - * 'demo' => array( + * ], + * 'demo' => [ * 'title' => $this->t('Build Demo'), * 'url' => Url::fromRoute('fapi_example.build_demo'), - * ), - * ), - * ); + * ], + * ], + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Operations diff --git a/core/lib/Drupal/Core/Render/Element/Fieldset.php b/core/lib/Drupal/Core/Render/Element/Fieldset.php index 87d89244688b1344d2e0fbe684cfcb5a0259361a..1311e7899c559f5ebb2ff1836bb22daf5456e303 100644 --- a/core/lib/Drupal/Core/Render/Element/Fieldset.php +++ b/core/lib/Drupal/Core/Render/Element/Fieldset.php @@ -9,15 +9,15 @@ * * Usage example: * @code - * $form['author'] = array( + * $form['author'] = [ * '#type' => 'fieldset', * '#title' => $this->t('Author'), - * ); + * ]; * - * $form['author']['name'] = array( + * $form['author']['name'] = [ * '#type' => 'textfield', * '#title' => $this->t('Name'), - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Fieldgroup diff --git a/core/lib/Drupal/Core/Render/Element/FormElementBase.php b/core/lib/Drupal/Core/Render/Element/FormElementBase.php index a35a677019545b77216755bb528ceeb6c1f80d09..75da91227dc4cf80bf5458e3bbcffe6d23e45079 100644 --- a/core/lib/Drupal/Core/Render/Element/FormElementBase.php +++ b/core/lib/Drupal/Core/Render/Element/FormElementBase.php @@ -166,7 +166,7 @@ public static function validatePattern(&$element, FormStateInterface $form_state * field with properties: * @code * '#autocomplete_route_name' => 'my_module.autocomplete', - * '#autocomplete_route_parameters' => array('a' => $some_key, 'b' => $some_id), + * '#autocomplete_route_parameters' => ['a' => $some_key, 'b' => $some_id], * @endcode * If the user types "keywords" in that field, the full path called would be: * 'my_module_autocomplete/$some_key/$some_id?q=keywords' diff --git a/core/lib/Drupal/Core/Render/Element/Hidden.php b/core/lib/Drupal/Core/Render/Element/Hidden.php index 36ba9e4842d189ab865d7f955aa0c42bde062fba..946f625635b81bbeeeae2e05892fbe8340891d82 100644 --- a/core/lib/Drupal/Core/Render/Element/Hidden.php +++ b/core/lib/Drupal/Core/Render/Element/Hidden.php @@ -18,7 +18,7 @@ * * Usage example: * @code - * $form['entity_id'] = array('#type' => 'hidden', '#value' => $entity_id); + * $form['entity_id'] = ['#type' => 'hidden', '#value' => $entity_id]; * @endcode * * @see \Drupal\Core\Render\Element\Value diff --git a/core/lib/Drupal/Core/Render/Element/Link.php b/core/lib/Drupal/Core/Render/Element/Link.php index 6aaf0b6c74b42be0e1065118fb6a88d3ec22151f..a64c5ed708ae001708372296334742a3c7c12727 100644 --- a/core/lib/Drupal/Core/Render/Element/Link.php +++ b/core/lib/Drupal/Core/Render/Element/Link.php @@ -126,24 +126,24 @@ public static function preRenderLink($element) { * A typical example comes from node links, which are stored in a renderable * array similar to this: * @code - * $build['links'] = array( + * $build['links'] = [ * '#theme' => 'links__node', - * '#pre_render' => array(Link::class, 'preRenderLinks'), - * 'comment' => array( + * '#pre_render' => [Link::class, 'preRenderLinks'], + * 'comment' => [ * '#theme' => 'links__node__comment', - * '#links' => array( + * '#links' => [ * // An array of links associated with node comments, suitable for * // passing in to links.html.twig. * ), * ), - * 'translation' => array( + * 'translation' => [ * '#theme' => 'links__node__translation', - * '#links' => array( + * '#links' => [ * // An array of links associated with node translation, suitable for * // passing in to links.html.twig. - * ), - * ), - * ); + * ], + * ], + * ]; * @endcode * * In this example, the links are grouped by functionality, which can be diff --git a/core/lib/Drupal/Core/Render/Element/MachineName.php b/core/lib/Drupal/Core/Render/Element/MachineName.php index 7c87f2d08a5c5ba4479845bae5c794d450dd63a8..02b1fbff858be73c8e5e71cbe419486ee563ffd7 100644 --- a/core/lib/Drupal/Core/Render/Element/MachineName.php +++ b/core/lib/Drupal/Core/Render/Element/MachineName.php @@ -33,7 +33,7 @@ * stored in form state so AJAX forms can be reliably validated. * - source: (optional) The #array_parents of the form element containing the * human-readable name (i.e., as contained in the $form structure) to use as - * source for the machine name. Defaults to array('label'). + * source for the machine name. Defaults to ['label']. * - label: (optional) Text to display as label for the machine name value * after the human-readable name form element. Defaults to t('Machine name'). * - replace_pattern: (optional) A regular expression (without delimiters) @@ -55,16 +55,16 @@ * * Usage example: * @code - * $form['id'] = array( + * $form['id'] = [ * '#type' => 'machine_name', * '#default_value' => $this->entity->id(), * '#disabled' => !$this->entity->isNew(), * '#maxlength' => 64, * '#description' => $this->t('A unique name for this item. It must only contain lowercase letters, numbers, and underscores.'), - * '#machine_name' => array( - * 'exists' => array($this, 'exists'), - * ), - * ); + * '#machine_name' => [ + * 'exists' => [$this, 'exists'], + * ], + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Textfield @@ -170,7 +170,7 @@ public static function processMachineName(&$element, FormStateInterface $form_st } $element['#attributes'] += ['dir' => LanguageInterface::DIRECTION_LTR]; - // The source element defaults to array('name'), but may have been overridden. + // The source element defaults to ['name'], but may have been overridden. if (empty($element['#machine_name']['source'])) { return $element; } diff --git a/core/lib/Drupal/Core/Render/Element/Number.php b/core/lib/Drupal/Core/Render/Element/Number.php index f8de491a4b2130eec16f7294a8cf387be04245d5..4c93dcc87002d38ea51a62f74ee38954e43a16ec 100644 --- a/core/lib/Drupal/Core/Render/Element/Number.php +++ b/core/lib/Drupal/Core/Render/Element/Number.php @@ -20,10 +20,10 @@ * * Usage example: * @code - * $form['quantity'] = array( + * $form['quantity'] = [ * '#type' => 'number', * '#title' => $this->t('Quantity'), - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Range diff --git a/core/lib/Drupal/Core/Render/Element/Password.php b/core/lib/Drupal/Core/Render/Element/Password.php index 35889885f42efd2efdc345c67e5e7a3f42b84be5..31edc5b978d9cc182db887b8fbf7ba2d22f09477 100644 --- a/core/lib/Drupal/Core/Render/Element/Password.php +++ b/core/lib/Drupal/Core/Render/Element/Password.php @@ -15,12 +15,12 @@ * * Usage example: * @code - * $form['pass'] = array( + * $form['pass'] = [ * '#type' => 'password', * '#title' => $this->t('Password'), * '#size' => 25, * '#pattern' => '[01]+', - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\PasswordConfirm diff --git a/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php b/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php index b0a9f9783ed508b83f51362a4db8593b249a05e2..1190b981a4ef072aaae0d210bdb19cd80d14d0fa 100644 --- a/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php +++ b/core/lib/Drupal/Core/Render/Element/PasswordConfirm.php @@ -16,11 +16,11 @@ * * Usage example: * @code - * $form['pass'] = array( + * $form['pass'] = [ * '#type' => 'password_confirm', * '#title' => $this->t('Password'), * '#size' => 25, - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Password diff --git a/core/lib/Drupal/Core/Render/Element/Radios.php b/core/lib/Drupal/Core/Render/Element/Radios.php index c8ccd0b3e175604f61d61ab4af101ae1060ae524..dfa2ebbaf9cc6292df4a228feacbcd6cb68b3fbb 100644 --- a/core/lib/Drupal/Core/Render/Element/Radios.php +++ b/core/lib/Drupal/Core/Render/Element/Radios.php @@ -15,12 +15,12 @@ * * Usage example: * @code - * $form['settings']['active'] = array( + * $form['settings']['active'] = [ * '#type' => 'radios', * '#title' => $this->t('Poll status'), * '#default_value' => 1, - * '#options' => array(0 => $this->t('Closed'), 1 => $this->t('Active')), - * ); + * '#options' => [0 => $this->t('Closed'), 1 => $this->t('Active')], + * ]; * @endcode * * Element properties may be set on single option items as follows. diff --git a/core/lib/Drupal/Core/Render/Element/Range.php b/core/lib/Drupal/Core/Render/Element/Range.php index 9176869b38fe9a0ca7b86cca46552bbda2398fa4..a27ceaa7c578cbdecb7e9574dac0aa881a8e54d3 100644 --- a/core/lib/Drupal/Core/Render/Element/Range.php +++ b/core/lib/Drupal/Core/Render/Element/Range.php @@ -18,10 +18,10 @@ * * Usage example: * @code - * $form['quantity'] = array( + * $form['quantity'] = [ * '#type' => 'range', * '#title' => $this->t('Quantity'), - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Number diff --git a/core/lib/Drupal/Core/Render/Element/Search.php b/core/lib/Drupal/Core/Render/Element/Search.php index 6f063e1181688947fc3e65c1fb43ea0169d81a9e..2c878b08c30664a58c66ef12366f6cd28a86bcd1 100644 --- a/core/lib/Drupal/Core/Render/Element/Search.php +++ b/core/lib/Drupal/Core/Render/Element/Search.php @@ -10,10 +10,10 @@ * * Usage example: * @code - * $form['search'] = array( + * $form['search'] = [ * '#type' => 'search', * '#title' => $this->t('Search'), - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Textfield diff --git a/core/lib/Drupal/Core/Render/Element/Submit.php b/core/lib/Drupal/Core/Render/Element/Submit.php index 194a45fe8c06043aac8e89fbc0ca90ee685c3920..980f4ff6c5917c297d30e3fde18f90065c34a5a9 100644 --- a/core/lib/Drupal/Core/Render/Element/Submit.php +++ b/core/lib/Drupal/Core/Render/Element/Submit.php @@ -18,10 +18,10 @@ * * Usage Example: * @code - * $form['actions']['submit'] = array( + * $form['actions']['submit'] = [ * '#type' => 'submit', * '#value' => $this->t('Save'), - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Button diff --git a/core/lib/Drupal/Core/Render/Element/Table.php b/core/lib/Drupal/Core/Render/Element/Table.php index c3e17db87b74fe1615e9871d2a467a8572379886..9026d05914f863b9c55ddb35cbe640c58bbdbc32 100644 --- a/core/lib/Drupal/Core/Render/Element/Table.php +++ b/core/lib/Drupal/Core/Render/Element/Table.php @@ -335,44 +335,44 @@ public static function validateTable(&$element, FormStateInterface $form_state, * * Simple example usage: * @code - * $form['table'] = array( + * $form['table'] = [ * '#type' => 'table', - * '#header' => array($this->t('Title'), array('data' => $this->t('Operations'), 'colspan' => '1')), + * '#header' => [$this->t('Title'), ['data' => $this->t('Operations'), 'colspan' => '1']], * // Optionally, to add tableDrag support: - * '#tabledrag' => array( - * array( + * '#tabledrag' => [ + * [ * 'action' => 'order', * 'relationship' => 'sibling', * 'group' => 'thing-weight', - * ), - * ), - * ); + * ], + * ], + * ]; * foreach ($things as $row => $thing) { * $form['table'][$row]['#weight'] = $thing['weight']; * - * $form['table'][$row]['title'] = array( + * $form['table'][$row]['title'] = [ * '#type' => 'textfield', * '#default_value' => $thing['title'], - * ); + * ]; * * // Optionally, to add tableDrag support: * $form['table'][$row]['#attributes']['class'][] = 'draggable'; - * $form['table'][$row]['weight'] = array( + * $form['table'][$row]['weight'] = [ * '#type' => 'textfield', - * '#title' => $this->t('Weight for @title', array('@title' => $thing['title'])), + * '#title' => $this->t('Weight for @title', ['@title' => $thing['title']]), * '#title_display' => 'invisible', * '#size' => 4, * '#default_value' => $thing['weight'], - * '#attributes' => array('class' => array('thing-weight')), + * '#attributes' => ['class' => ['thing-weight']], * ); * * // The amount of link columns should be identical to the 'colspan' * // attribute in #header above. - * $form['table'][$row]['edit'] = array( + * $form['table'][$row]['edit'] = [ * '#type' => 'link', * '#title' => $this->t('Edit'), * '#url' => Url::fromRoute('entity.test_entity.edit_form', ['test_entity' => $row]), - * ); + * ]; * } * @endcode * diff --git a/core/lib/Drupal/Core/Render/Element/Tableselect.php b/core/lib/Drupal/Core/Render/Element/Tableselect.php index 0ef2871f138767f1e98a0dd4e6d7cb64b6cc4b1d..4f188385b71f3c761a23effbbc851781941766f9 100644 --- a/core/lib/Drupal/Core/Render/Element/Tableselect.php +++ b/core/lib/Drupal/Core/Render/Element/Tableselect.php @@ -39,12 +39,12 @@ * 3 => ['color' => 'Blue', 'shape' => 'Hexagon', '#disabled' => TRUE], * ]; * - * $form['table'] = array( + * $form['table'] = [ * '#type' => 'tableselect', * '#header' => $header, * '#options' => $options, * '#empty' => $this->t('No shapes found'), - * ); + * ]; * @endcode * * See https://www.drupal.org/node/945102 for a full explanation. @@ -118,31 +118,31 @@ public static function valueCallback(&$element, $input, FormStateInterface $form * table row's HTML attributes; see table.html.twig. An example of per-row * options: * @code - * $options = array( - * array( + * $options = [ + * [ * 'title' => $this->t('How to Learn Drupal'), * 'content_type' => $this->t('Article'), * 'status' => 'published', - * '#attributes' => array('class' => array('article-row')), - * ), - * array( + * '#attributes' => ['class' => ['article-row']], + * ], + * [ * 'title' => $this->t('Privacy Policy'), * 'content_type' => $this->t('Page'), * 'status' => 'published', - * '#attributes' => array('class' => array('page-row')), - * ), - * ); - * $header = array( + * '#attributes' => ['class' => ['page-row']], + * ], + * ]; + * $header = [ * 'title' => $this->t('Title'), * 'content_type' => $this->t('Content type'), * 'status' => $this->t('Status'), - * ); - * $form['table'] = array( + * ]; + * $form['table'] = [ * '#type' => 'tableselect', * '#header' => $header, * '#options' => $options, * '#empty' => $this->t('No content available.'), - * ); + * ]; * @endcode * * @return array diff --git a/core/lib/Drupal/Core/Render/Element/Tel.php b/core/lib/Drupal/Core/Render/Element/Tel.php index 45b0a0e0afab766fcf41522246d91456f3dbb5fe..93ae0673a9ae6303b420815759bd74451d505c45 100644 --- a/core/lib/Drupal/Core/Render/Element/Tel.php +++ b/core/lib/Drupal/Core/Render/Element/Tel.php @@ -17,11 +17,11 @@ * * Usage example: * @code - * $form['phone'] = array( + * $form['phone'] = [ * '#type' => 'tel', * '#title' => $this->t('Phone'), * '#pattern' => '[^\d]*', - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element diff --git a/core/lib/Drupal/Core/Render/Element/Textarea.php b/core/lib/Drupal/Core/Render/Element/Textarea.php index 5e34300dc74da5c2e37999f2de7a2b0d1964df36..44f1e069282b8e9a6350b91e9d8c0cde2b7b5c02 100644 --- a/core/lib/Drupal/Core/Render/Element/Textarea.php +++ b/core/lib/Drupal/Core/Render/Element/Textarea.php @@ -17,10 +17,10 @@ * * Usage example: * @code - * $form['text'] = array( + * $form['text'] = [ * '#type' => 'textarea', * '#title' => $this->t('Text'), - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Textfield diff --git a/core/lib/Drupal/Core/Render/Element/Textfield.php b/core/lib/Drupal/Core/Render/Element/Textfield.php index aa42d6bd2e806df79f735873db220fbabac0e06b..f87cd24726d161b86574934cde1d73400f10ad85 100644 --- a/core/lib/Drupal/Core/Render/Element/Textfield.php +++ b/core/lib/Drupal/Core/Render/Element/Textfield.php @@ -20,7 +20,7 @@ * * Usage example: * @code - * $form['title'] = array( + * $form['title'] = [ * '#type' => 'textfield', * '#title' => $this->t('Subject'), * '#default_value' => $node->title, @@ -28,7 +28,7 @@ * '#maxlength' => 128, * '#pattern' => 'some-prefix-[a-z]+', * '#required' => TRUE, - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Color diff --git a/core/lib/Drupal/Core/Render/Element/Url.php b/core/lib/Drupal/Core/Render/Element/Url.php index efb6a72674652ac04124148e24c55f48f8a38def..6d39d938a51cde6508c1403525897454c2220335 100644 --- a/core/lib/Drupal/Core/Render/Element/Url.php +++ b/core/lib/Drupal/Core/Render/Element/Url.php @@ -17,13 +17,13 @@ * * Usage example: * @code - * $form['homepage'] = array( + * $form['homepage'] = [ * '#type' => 'url', * '#title' => $this->t('Home Page'), * '#size' => 30, * '#pattern' => '*.example.com', * ... - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Textfield diff --git a/core/lib/Drupal/Core/Render/Element/Value.php b/core/lib/Drupal/Core/Render/Element/Value.php index ce6f7097de78b116a516055bd4fd57355247507b..ce6efe9620ff6edc90af8de6015b7924c5312aa7 100644 --- a/core/lib/Drupal/Core/Render/Element/Value.php +++ b/core/lib/Drupal/Core/Render/Element/Value.php @@ -16,7 +16,7 @@ * * Usage Example: * @code - * $form['entity_id'] = array('#type' => 'value', '#value' => $entity_id); + * $form['entity_id'] = ['#type' => 'value', '#value' => $entity_id]; * @endcode */ #[FormElement('value')] diff --git a/core/lib/Drupal/Core/Render/Element/VerticalTabs.php b/core/lib/Drupal/Core/Render/Element/VerticalTabs.php index 4c221a36b1b95871ef644bec86a11fb417100499..eea7d9753ac0c657121a505ccdfcd2757a4c5f67 100644 --- a/core/lib/Drupal/Core/Render/Element/VerticalTabs.php +++ b/core/lib/Drupal/Core/Render/Element/VerticalTabs.php @@ -18,32 +18,32 @@ * * Usage example: * @code - * $form['information'] = array( + * $form['information'] = [ * '#type' => 'vertical_tabs', * '#default_tab' => 'edit-publication', - * ); + * ]; * - * $form['author'] = array( + * $form['author'] = [ * '#type' => 'details', * '#title' => $this->t('Author'), * '#group' => 'information', - * ); + * ]; * - * $form['author']['name'] = array( + * $form['author']['name'] = [ * '#type' => 'textfield', * '#title' => $this->t('Name'), - * ); + * ]; * - * $form['publication'] = array( + * $form['publication'] = [ * '#type' => 'details', * '#title' => $this->t('Publication'), * '#group' => 'information', - * ); + * ]; * - * $form['publication']['publisher'] = array( + * $form['publication']['publisher'] = [ * '#type' => 'textfield', * '#title' => $this->t('Publisher'), - * ); + * ]; * @endcode */ #[FormElement('vertical_tabs')] diff --git a/core/lib/Drupal/Core/Render/Element/Weight.php b/core/lib/Drupal/Core/Render/Element/Weight.php index cc691dedf1605237d3378b9f8e904ed738daa991..012a996af60303e1090f3a3b93950668ca6fa7fd 100644 --- a/core/lib/Drupal/Core/Render/Element/Weight.php +++ b/core/lib/Drupal/Core/Render/Element/Weight.php @@ -17,12 +17,12 @@ * * Usage example: * @code - * $form['weight'] = array( + * $form['weight'] = [ * '#type' => 'weight', * '#title' => $this->t('Weight'), * '#default_value' => $edit['weight'], * '#delta' => 10, - * ); + * ]; * @endcode */ #[FormElement('weight')] diff --git a/core/lib/Drupal/Core/Render/RendererInterface.php b/core/lib/Drupal/Core/Render/RendererInterface.php index 310e4fcc836a9621001461601b602713e474f72e..92fa661f6b0fd061da94bd90c386b32e5941871c 100644 --- a/core/lib/Drupal/Core/Render/RendererInterface.php +++ b/core/lib/Drupal/Core/Render/RendererInterface.php @@ -241,24 +241,24 @@ public function renderPlaceholder($placeholder, array $elements); * of overrides as the value in #theme_wrappers array. * For example, if we have a render element as follows: * @code - * array( + * [ * '#theme' => 'image', - * '#attributes' => array('class' => array('foo')), - * '#theme_wrappers' => array('container'), - * ); + * '#attributes' => ['class' => ['foo']], + * '#theme_wrappers' => ['container'], + * ]; * @endcode * and we need to pass the class 'bar' as an attribute for 'container', we * can rewrite our element thus: * @code - * array( + * [ * '#theme' => 'image', - * '#attributes' => array('class' => array('foo')), - * '#theme_wrappers' => array( - * 'container' => array( - * '#attributes' => array('class' => array('bar')), - * ), - * ), - * ); + * '#attributes' => ['class' => ['foo']], + * '#theme_wrappers' => [ + * 'container' => [ + * '#attributes' => ['class' => ['bar']], + * ], + * ], + * ]; * @endcode * - If this element has an array of #post_render functions defined, they * are called sequentially to modify the rendered #children. Unlike diff --git a/core/lib/Drupal/Core/Render/theme.api.php b/core/lib/Drupal/Core/Render/theme.api.php index ac317fb4e9972b1abae224ec541fd4d0b498fbad..2218830aba615fa16e6e3024c3b4469048d96961 100644 --- a/core/lib/Drupal/Core/Render/theme.api.php +++ b/core/lib/Drupal/Core/Render/theme.api.php @@ -49,15 +49,15 @@ * preprocessing functions. For example, the core Search module defines a theme * hook for a search result item in search_theme(): * @code - * return array( - * 'search_result' => array( - * 'variables' => array( + * return [ + * 'search_result' => [ + * 'variables' => [ * 'result' => NULL, * 'plugin_id' => NULL, - * ), + * ], * 'file' => 'search.pages.inc', - * ), - * ); + * ], + * ]; * @endcode * Given this definition, the template file with the default implementation is * search-result.html.twig, which can be found in the @@ -688,7 +688,7 @@ function hook_theme_suggestions_HOOK(array $variables) { * * @code * function MY_MODULE_theme_suggestions_alter(array &$suggestions, array &$variables, $hook) { - * if (\Drupal::currentUser()->isAuthenticated() && in_array($hook, array('node', 'taxonomy_term'))) { + * if (\Drupal::currentUser()->isAuthenticated() && in_array($hook, ['node', 'taxonomy_term'])) { * $suggestions[] = $hook . '__' . 'logged_in'; * } * } @@ -1281,24 +1281,24 @@ function hook_theme($existing, $type, $theme, $path) { * * For example: * @code - * $theme_registry['block_content_add_list'] = array ( + * $theme_registry['block_content_add_list'] = [ * 'template' => 'block-content-add-list', * 'path' => 'core/themes/claro/templates', * 'type' => 'theme_engine', * 'theme path' => 'core/themes/claro', - * 'includes' => array ( + * 'includes' => [ * 0 => 'core/modules/block_content/block_content.pages.inc', - * ), - * 'variables' => array ( + * ], + * 'variables' => [ * 'content' => NULL, - * ), - * 'preprocess functions' => array ( + * ], + * 'preprocess functions' => [ * 0 => 'template_preprocess', * 1 => 'template_preprocess_block_content_add_list', * 2 => 'contextual_preprocess', * 3 => 'claro_preprocess_block_content_add_list', - * ), - * ); + * ], + * ]; * @endcode * * @param $theme_registry diff --git a/core/lib/Drupal/Core/Site/SettingsEditor.php b/core/lib/Drupal/Core/Site/SettingsEditor.php index e9a8c4c99f052ad89a32409df1b81ffd6f32ebec..2a131cf876790db8f126d0c2077182b1cede9c69 100644 --- a/core/lib/Drupal/Core/Site/SettingsEditor.php +++ b/core/lib/Drupal/Core/Site/SettingsEditor.php @@ -27,10 +27,10 @@ private function __construct() {} * clutter up the file. * * @code - * $settings['settings']['config_sync_directory'] = (object) array( + * $settings['settings']['config_sync_directory'] = (object) [ * 'value' => 'config_hash/sync', * 'required' => TRUE, - * ); + * ]; * @endcode * gets dumped as: * @code diff --git a/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php b/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php index 06a1d1f7712c9f06e01b43d40463fa0c819d03e8..d6961e6ddaf0507849e32781227fb9725de0f9f5 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php @@ -90,7 +90,7 @@ class TranslatableMarkup extends FormattableMarkup { * as user names or link URLs into translated text. Variable substitution * looks like this: * @code - * new TranslatableMarkup("@name's blog", array('@name' => $account->getDisplayName())); + * new TranslatableMarkup("@name's blog", ['@name' => $account->getDisplayName()]); * @endcode * Basically, you can put placeholders like @name into your string, and the * method will substitute the sanitized values at translation time. (See the diff --git a/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php index 1ceb951c160ec23a87350a7dde73dd1c9b12deaa..3f3fde2e9be1c44742a58f949cfd2b9cc46b0715 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslationInterface.php @@ -76,7 +76,7 @@ public function translateString(TranslatableMarkup $translated_string); * $output = $string_translation->formatPlural($update_count, * 'Changed the content type of 1 post from %old-type to %new-type.', * 'Changed the content type of @count posts from %old-type to %new-type.', - * array('%old-type' => $info->old_type, '%new-type' => $info->new_type)); + * ['%old-type' => $info->old_type, '%new-type' => $info->new_type)]; * @endcode * * @param int $count diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index a08fdafd17c23d17b51e5fa02ec188cb7b228f96..63f21c2d1626cce1e41e9233c84907bdab261b20 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -12,8 +12,8 @@ * To use, optionally pass in an associative array of defined attributes, or * add attributes using array syntax. For example: * @code - * $attributes = new Attribute(array('id' => 'socks')); - * $attributes['class'] = array('black-cat', 'white-cat'); + * $attributes = new Attribute(['id' => 'socks']); + * $attributes['class'] = ['black-cat', 'white-cat']; * $attributes['class'][] = 'black-white-cat'; * echo '<cat' . $attributes . '>'; * // Produces <cat id="socks" class="black-cat white-cat black-white-cat"> @@ -21,8 +21,8 @@ * * $attributes always prints out all the attributes. For example: * @code - * $attributes = new Attribute(array('id' => 'socks')); - * $attributes['class'] = array('black-cat', 'white-cat'); + * $attributes = new Attribute(['id' => 'socks']); + * $attributes['class'] = ['black-cat', 'white-cat']; * $attributes['class'][] = 'black-white-cat'; * echo '<cat class="cat ' . $attributes['class'] . '"' . $attributes . '>'; * // Produces <cat class="cat black-cat white-cat black-white-cat" id="socks" class="cat black-cat white-cat black-white-cat"> @@ -47,7 +47,7 @@ * @code * $path = 'javascript:alert("xss");'; * $path = UrlHelper::stripDangerousProtocols($path); - * $attributes = new Attribute(array('href' => $path)); + * $attributes = new Attribute(['href' => $path]); * echo '<a' . $attributes . '>'; * // Produces <a href="alert("xss");"> * @endcode diff --git a/core/lib/Drupal/Core/Template/AttributeArray.php b/core/lib/Drupal/Core/Template/AttributeArray.php index 2f003f2de6e4555571d3926228767a6bdf34969f..d2f927c3042016b36360e15e805cb85fec049a90 100644 --- a/core/lib/Drupal/Core/Template/AttributeArray.php +++ b/core/lib/Drupal/Core/Template/AttributeArray.php @@ -11,7 +11,7 @@ * Correct: * @code * $attributes = new Attribute(); - * $attributes['class'] = array(); + * $attributes['class'] = []; * $attributes['class'][] = 'cat'; * @endcode * Incorrect: diff --git a/core/lib/Drupal/Core/Template/AttributeString.php b/core/lib/Drupal/Core/Template/AttributeString.php index 4cf705bea8d6fb2c70ddb338672406b9458f9fbb..bce832e374a01bf44b2b98445117284693b22a4f 100644 --- a/core/lib/Drupal/Core/Template/AttributeString.php +++ b/core/lib/Drupal/Core/Template/AttributeString.php @@ -10,7 +10,7 @@ * To use with the Attribute class, set the key to be the attribute name * and the value the attribute value. * @code - * $attributes = new Attribute(array()); + * $attributes = new Attribute([]); * $attributes['id'] = 'socks'; * $attributes['style'] = 'background-color:white'; * echo '<cat ' . $attributes . '>'; diff --git a/core/lib/Drupal/Core/Test/TestDiscovery.php b/core/lib/Drupal/Core/Test/TestDiscovery.php index c504dcad795c3e563a23957d3820037ced35e085..a90587c52dd398a72bbc2ffc556b918c2fbbf017 100644 --- a/core/lib/Drupal/Core/Test/TestDiscovery.php +++ b/core/lib/Drupal/Core/Test/TestDiscovery.php @@ -129,14 +129,14 @@ public function registerTestNamespaces() { * to. * * @code - * $groups['block'] => array( - * 'Drupal\Tests\block\Functional\BlockTest' => array( + * $groups['block'] => [ + * 'Drupal\Tests\block\Functional\BlockTest' => [ * 'name' => 'Drupal\Tests\block\Functional\BlockTest', * 'description' => 'Tests block UI CRUD functionality.', * 'group' => 'block', * 'groups' => ['block', 'group2', 'group3'], - * ), - * ); + * ], + * ]; * @endcode * * @todo Remove singular grouping; retain list of groups in 'group' key. diff --git a/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php b/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php index 90074aa1b9466db273f793b46fb3afda8fb7d46d..71dc3b56bdfe28c8198379107717e0d2e5d02419 100644 --- a/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php +++ b/core/lib/Drupal/Core/Theme/ThemeManagerInterface.php @@ -86,7 +86,7 @@ public function setActiveTheme(ActiveTheme $active_theme); * need to be passed and alterable, modules provide additional variables * assigned by reference in the last $context argument: * @code - * $context = array( + * $context = [ * 'alterable' => &$alterable, * 'unalterable' => $unalterable, * 'foo' => 'bar', @@ -98,9 +98,9 @@ public function setActiveTheme(ActiveTheme $active_theme); * required that no implementation alters a passed object in $context, then an * object needs to be cloned: * @code - * $context = array( + * $context = [ * 'unalterable_object' => clone $object, - * ); + * ]; * $this->alter('my_module_data', $data, $context); * @endcode * @@ -110,7 +110,7 @@ public function setActiveTheme(ActiveTheme $active_theme); * array, in which case $theme_TYPE_alter() is invoked for each value in the * array. When Form API is using $this->alter() to * execute both $theme_form_alter() and $theme_form_FORM_ID_alter() - * implementations, it passes array('form', 'form_' . $form_id) for $type. + * implementations, it passes ['form', 'form_' . $form_id] for $type. * @param mixed $data * The variable that will be passed to $theme_TYPE_alter() implementations * to be altered. The type of this variable depends on the value of the diff --git a/core/lib/Drupal/Core/TypedData/DataDefinitionInterface.php b/core/lib/Drupal/Core/TypedData/DataDefinitionInterface.php index 1236c8d955b5ba87708b4edd860b71aea8c53a2f..fbbe9ca9dd24bef5d6e637dd782098da74d0e452 100644 --- a/core/lib/Drupal/Core/TypedData/DataDefinitionInterface.php +++ b/core/lib/Drupal/Core/TypedData/DataDefinitionInterface.php @@ -158,19 +158,19 @@ public function getSetting($setting_name); * Constraints are defined via an array, having constraint plugin IDs as key * and constraint options as values, e.g. * @code - * $constraints = array( - * 'Range' => array('min' => 5, 'max' => 10), - * 'NotBlank' => array(), - * ); + * $constraints = [ + * 'Range' => ['min' => 5, 'max' => 10], + * 'NotBlank' => [], + * ]; * @endcode * Options have to be specified using another array if the constraint has more * than one or zero options. If it has exactly one option, the value should be * specified without nesting it into another array: * @code - * $constraints = array( + * $constraints = [ * 'EntityType' => 'node', * 'Bundle' => 'article', - * ); + * ]; * @endcode * * Note that the specified constraints must be compatible with the data type, diff --git a/core/lib/Drupal/Core/Utility/LinkGeneratorInterface.php b/core/lib/Drupal/Core/Utility/LinkGeneratorInterface.php index 66786d2c46b42d398c1149ac4a57f20c24463021..1085ec2cfeb05bcb69ea4c6c42b2c39d79c6085a 100644 --- a/core/lib/Drupal/Core/Utility/LinkGeneratorInterface.php +++ b/core/lib/Drupal/Core/Utility/LinkGeneratorInterface.php @@ -25,7 +25,7 @@ interface LinkGeneratorInterface { * However, for links enclosed in translatable text you should use t() and * embed the HTML anchor tag directly in the translated string. For example: * @code - * $text = t('Visit the <a href=":url">content types</a> page', array(':url' => Url::fromRoute('entity.node_type.collection')->toString())); + * $text = t('Visit the <a href=":url">content types</a> page', [':url' => Url::fromRoute('entity.node_type.collection')->toString()]); * @endcode * This keeps the context of the link title ('settings' in the example) for * translators. diff --git a/core/lib/Drupal/Core/Utility/Token.php b/core/lib/Drupal/Core/Utility/Token.php index d50afd4f2c62fb8a59f095f3761eb7c5e910c6ce..9367ee32992809708bf43edd16dbccdbdb4d1ca6 100644 --- a/core/lib/Drupal/Core/Utility/Token.php +++ b/core/lib/Drupal/Core/Utility/Token.php @@ -45,7 +45,7 @@ * * // [date:...] tokens use the current date automatically. * $token_service = \Drupal::token(); - * $data = array('node' => $node, 'user' => $user); + * $data = ['node' => $node, 'user' => $user]; * $result = $token_service->replace($text, $data); * return $result * @endcode @@ -376,13 +376,13 @@ public function generate($type, array $tokens, array $data, array $options, Bubb * Used to extract a group of 'chained' tokens (such as [node:author:name]) * from the full list of tokens found in text. For example: * @code - * $data = array( + * $data = [ * 'author:name' => '[node:author:name]', * 'title' => '[node:title]', * 'created' => '[node:created]', - * ); + * ]; * $results = Token::findWithPrefix($data, 'author'); - * $results == array('name' => '[node:author:name]'); + * $results == ['name' => '[node:author:name]']; * @endcode * * @param array $tokens diff --git a/core/lib/Drupal/Core/Utility/token.api.php b/core/lib/Drupal/Core/Utility/token.api.php index 9fd09d9794d51118e8b4b38096632b9007bb76a7..81826b255f87b8b840361f0efd6e1f419552bf0f 100644 --- a/core/lib/Drupal/Core/Utility/token.api.php +++ b/core/lib/Drupal/Core/Utility/token.api.php @@ -58,7 +58,7 @@ * For example: * @code * 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); * } * @endcode * diff --git a/core/modules/block/tests/src/Traits/BlockCreationTrait.php b/core/modules/block/tests/src/Traits/BlockCreationTrait.php index 9420a2bb2ca116d417344d8dbe6180f5ace0c10c..9ed781d3339c5e33e78483031a0ab391220f2e98 100644 --- a/core/modules/block/tests/src/Traits/BlockCreationTrait.php +++ b/core/modules/block/tests/src/Traits/BlockCreationTrait.php @@ -23,9 +23,9 @@ trait BlockCreationTrait { * Override the defaults by specifying the key and value in the array, for * example: * @code - * $this->drupalPlaceBlock('system_powered_by_block', array( + * $this->drupalPlaceBlock('system_powered_by_block', [ * 'label' => t('Hello, world!'), - * )); + * ]); * @endcode * The following defaults are provided: * - label: Random string. diff --git a/core/modules/contextual/src/Element/ContextualLinks.php b/core/modules/contextual/src/Element/ContextualLinks.php index 657c6433a4ebac89237151a35e4df0dd7cfdbdfb..e13836dcb7d732232d9a29dda0b240e5e3dbdc5d 100644 --- a/core/modules/contextual/src/Element/ContextualLinks.php +++ b/core/modules/contextual/src/Element/ContextualLinks.php @@ -46,14 +46,14 @@ public function getInfo() { * - route_parameters: The route parameters passed to the URL generator. * - metadata: Any additional data needed in order to alter the link. * @code - * array('#contextual_links' => array( - * 'block' => array( - * 'route_parameters' => array('block' => 'system.menu-tools'), - * ), - * 'menu' => array( - * 'route_parameters' => array('menu' => 'tools'), - * ), - * )) + * ['#contextual_links' => [ + * 'block' => [ + * 'route_parameters' => ['block' => 'system.menu-tools'], + * ], + * 'menu' => [ + * 'route_parameters' => ['menu' => 'tools'], + * ], + * ]] * @endcode * * @return array diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module index cbc870be54e042068816b7e5f6a57a7377278f92..ed851cf18c03570025934add69192c3f95aa10d9 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -52,7 +52,7 @@ * * // make sure hook_field_storage_config_create() is invoked correctly * assertEquals(1, count($mem['field_test_field_storage_config_create'])); - * assertEquals(array($field), $mem['field_test_field_storage_config_create'][0]); + * assertEquals([$field], $mem['field_test_field_storage_config_create'][0]); * @endcode * * @param $key diff --git a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php index ed33d16b00ca815f024557e326394d6fffca3ce4..2e9f436a728acb65316ee3e03969ce1e9ccb58ee 100644 --- a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php +++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php @@ -102,8 +102,8 @@ public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entit * @return array * Example usage: * @code - * return array( - * 'content' => array( + * return [ + * 'content' => [ * // label for the region. * 'title' => $this->t('Content'), * // Indicates if the region is visible in the UI. @@ -111,8 +111,8 @@ public function getEntityFromRouteMatch(RouteMatchInterface $route_match, $entit * // A message to indicate that there is nothing to be displayed in * // the region. * 'message' => $this->t('No field is displayed.'), - * ), - * ); + * ], + * ]; * @endcode */ public function getRegions() { diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 987d52db52e7425fd3826db4a38b33644e6046f4..e0adbc162092aeb8513c3bdb30767767f350e6da 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -404,14 +404,14 @@ function template_preprocess_text_format_wrapper(&$variables) { * 'module-name/filter-id' (only used when $long is TRUE) for each * filter in one or more text formats. Example: * @code - * array( - * 'Full HTML' => array( - * 0 => array( + * [ + * 'Full HTML' => [ + * 0 => [ * 'tip' => 'Web page addresses and email addresses turn into links automatically.', * 'id' => 'filter/2', - * ), - * ), - * ); + * ], + * ], + * ]; * @endcode * - long: (optional) Whether the passed-in filter tips contain extended * explanations, i.e. intended to be output on the path 'filter/tips' diff --git a/core/modules/filter/src/Element/TextFormat.php b/core/modules/filter/src/Element/TextFormat.php index 8cf8f2b567f9cf1224b827529b4289132550681c..fa18e2522b0701ca5646ffeb270f2fedd3e35909 100644 --- a/core/modules/filter/src/Element/TextFormat.php +++ b/core/modules/filter/src/Element/TextFormat.php @@ -22,12 +22,12 @@ * * Usage Example: * @code - * $form['body'] = array( + * $form['body'] = [ * '#type' => 'text_format', * '#title' => 'Body', * '#format' => 'full_html', * '#default_value' => '<p>The quick brown fox jumped over the lazy dog.</p>', - * ); + * ]; * @endcode * * @see \Drupal\Core\Render\Element\Textarea diff --git a/core/modules/filter/src/FilterProcessResult.php b/core/modules/filter/src/FilterProcessResult.php index 5c256118f584e7f1431c9e5e1fa3b0fa800a4f00..e9c8d44719c8bc06d0028a7f5442f2a648714336 100644 --- a/core/modules/filter/src/FilterProcessResult.php +++ b/core/modules/filter/src/FilterProcessResult.php @@ -42,11 +42,11 @@ * $result = new FilterProcessResult($text); * * // Associate assets to be attached. - * $result->setAttachments(array( - * 'library' => array( + * $result->setAttachments([ + * 'library' => [ * 'filter/caption', - * ), - * )); + * ], + * ]); * * // Associate cache contexts to vary by. * $result->setCacheContexts(['language']); diff --git a/core/modules/filter/src/Plugin/FilterInterface.php b/core/modules/filter/src/Plugin/FilterInterface.php index 7714f03e61405b1fcecb331b169694cb300523bf..f03a94b1252dad78b1d32c247ef0e3b46508f34b 100644 --- a/core/modules/filter/src/Plugin/FilterInterface.php +++ b/core/modules/filter/src/Plugin/FilterInterface.php @@ -206,8 +206,8 @@ public function process($text, $langcode); * * Here is a concrete example, for a very granular filter: * @code - * array( - * 'allowed' => array( + * [ + * 'allowed' => [ * // Allows any attribute with any value on the <div> tag. * 'div' => TRUE, * // Allows no attributes on the <p> tag. @@ -215,31 +215,31 @@ public function process($text, $langcode); * // Allows the following attributes on the <a> tag: * // - 'href', with any value; * // - 'rel', with the value 'nofollow' value. - * 'a' => array( + * 'a' => [ * 'href' => TRUE, - * 'rel' => array('nofollow' => TRUE), - * ), + * 'rel' => ['nofollow' => TRUE], + * ], * // Only allows the 'src' and 'alt' attributes on the <alt> tag, * // with any value. - * 'img' => array( + * 'img' => [ * 'src' => TRUE, * 'alt' => TRUE, - * ), + * ], * // Forbid the 'style' and 'on*' ('onClick' etc.) attributes on any * // tag. - * '*' => array( + * '*' => [ * 'style' => FALSE, * 'on*' => FALSE, - * ), - * ) - * ) + * ], + * ] + * ] * @endcode * * The simplest example possible: a filter that doesn't allow any HTML: * @code - * array( - * 'allowed' => array() - * ) + * [ + * 'allowed' => [] + * ] * @endcode * * And for a filter that applies no restrictions, i.e. allows any HTML: diff --git a/core/modules/filter/tests/src/Kernel/FilterKernelTest.php b/core/modules/filter/tests/src/Kernel/FilterKernelTest.php index 4b334c296a96076e0d06e10727803aa13709e96b..619952a9f75719856e0599af7274a11399170f6b 100644 --- a/core/modules/filter/tests/src/Kernel/FilterKernelTest.php +++ b/core/modules/filter/tests/src/Kernel/FilterKernelTest.php @@ -978,12 +978,12 @@ public function testUrlFilter() { * strings and whose values are Booleans indicating whether the output is * expected or not. For example: * @code - * $tests = array( - * 'Input string' => array( + * $tests = [ + * 'Input string' => [ * '<p>Input string</p>' => TRUE, * 'Input string<br' => FALSE, - * ), - * ); + * ], + * ]; * @endcode * * @internal diff --git a/core/modules/migrate/src/Plugin/Migration.php b/core/modules/migrate/src/Plugin/Migration.php index 1b9a8b1604237aa2a1becc9b025e17f4ef8749d4..1343d1d5723ca8bfbdf8ed896f86b3c7a52c376e 100644 --- a/core/modules/migrate/src/Plugin/Migration.php +++ b/core/modules/migrate/src/Plugin/Migration.php @@ -228,15 +228,15 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn * * The migration_dependencies value is structured like this: * @code - * array( - * 'required' => array( + * [ + * 'required' => [ * // An array of migration IDs that must be run before this migration. - * ), - * 'optional' => array( + * ], + * 'optional' => [ * // An array of migration IDs that, if they exist, must be run before * // this migration. - * ), - * ); + * ], + * ]; * @endcode * * @var array diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index 01b29092a70454dd75b4fdfc7eec7008ef8d0aa0..793170dc220961476da1208b77a1d50ce0307da2 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -39,20 +39,20 @@ * access modules can also grant "view all" permission on their custom realms; * for example, a module could create a record in {node_access} with: * @code - * $record = array( + * $record = [ * 'nid' => 0, * 'gid' => 888, * 'realm' => 'example_realm', * 'grant_view' => 1, * 'grant_update' => 0, * 'grant_delete' => 0, - * ); + * ]; * \Drupal::database()->insert('node_access')->fields($record)->execute(); * @endcode * And then in its hook_node_grants() implementation, it would need to return: * @code * if ($op == 'view') { - * $grants['example_realm'] = array(888); + * $grants['example_realm'] = [888]; * } * @endcode * If you decide to do this, be aware that the node_access_rebuild() function @@ -124,14 +124,14 @@ function hook_node_grants(\Drupal\Core\Session\AccountInterface $account, $opera * A "deny all" grant may be used to deny all access to a particular node or * node translation: * @code - * $grants[] = array( + * $grants[] = [ * 'realm' => 'all', * 'gid' => 0, * 'grant_view' => 0, * 'grant_update' => 0, * 'grant_delete' => 0, * 'langcode' => 'ca', - * ); + * ]; * @endcode * Note that another module node access module could override this by granting * access to one or more nodes, since grants are additive. To enforce that diff --git a/core/modules/node/tests/src/Traits/NodeCreationTrait.php b/core/modules/node/tests/src/Traits/NodeCreationTrait.php index 8f811064421fa4e5262ce05acc75666da85d9424..9a7fbc50baf9c0dc0df47fbaf27e2dac4c6979ce 100644 --- a/core/modules/node/tests/src/Traits/NodeCreationTrait.php +++ b/core/modules/node/tests/src/Traits/NodeCreationTrait.php @@ -48,19 +48,19 @@ public function getNodeByTitle($title, $reset = FALSE) { * in the array, for example: * * @code - * $this->drupalCreateNode(array( + * $this->drupalCreateNode([ * 'title' => t('Hello, world!'), * 'type' => 'article', - * )); + * ]); * @endcode * The following defaults are provided, if the node has the field in * question: * - body: Random string using the default filter format: * @code - * $values['body'][0] = array( + * $values['body'][0] = [ * 'value' => $this->randomMachineName(32), * 'format' => filter_default_format(), - * ); + * ]; * @endcode * - title: Random string. * - type: 'page'. diff --git a/core/modules/responsive_image/responsive_image.module b/core/modules/responsive_image/responsive_image.module index c3d551e1a5d9b58d855a243d036eae3a314e2ba0..ddbe497469b51ca2026689122ff3898c3a558eff 100644 --- a/core/modules/responsive_image/responsive_image.module +++ b/core/modules/responsive_image/responsive_image.module @@ -246,25 +246,25 @@ function template_preprocess_responsive_image(&$variables) { * can contain image style mappings of mixed types (both 'image_style' and * 'sizes'). For example: * @code - * $responsive_img_style = ResponsiveImageStyle::create(array( + * $responsive_img_style = ResponsiveImageStyle::create([ * 'id' => 'style_one', * 'label' => 'Style One', * 'breakpoint_group' => 'responsive_image_test_module', - * )); - * $responsive_img_style->addImageStyleMapping('responsive_image_test_module.mobile', '1x', array( + * ]); + * $responsive_img_style->addImageStyleMapping('responsive_image_test_module.mobile', '1x', [ * 'image_mapping_type' => 'image_style', * 'image_mapping' => 'thumbnail', - * )) - * ->addImageStyleMapping('responsive_image_test_module.narrow', '1x', array( + * ]) + * ->addImageStyleMapping('responsive_image_test_module.narrow', '1x', [ * 'image_mapping_type' => 'sizes', - * 'image_mapping' => array( + * 'image_mapping' => [ * 'sizes' => '(min-width: 700px) 700px, 100vw', - * 'sizes_image_styles' => array( + * 'sizes_image_styles' => [ * 'large' => 'large', * 'medium' => 'medium', - * ), - * ), - * )) + * ], + * ], + * ]) * ->save(); * @endcode * The above responsive image style will result in a <picture> tag like this: diff --git a/core/modules/user/user.module b/core/modules/user/user.module index d538823c98451c89227784113b65218a34d9f210..ab35c9439539ceaaf3d9abc2c07828a7db90f494 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -842,13 +842,13 @@ function user_user_role_delete(RoleInterface $role) { * Any value that evaluates to FALSE will cause the permission to be * revoked. * @code - * array( + * [ * 'administer nodes' => 0, // Revoke 'administer nodes' * 'administer blocks' => FALSE, // Revoke 'administer blocks' * 'access user profiles' => 1, // Grant 'access user profiles' * 'access content' => TRUE, // Grant 'access content' * 'access comments' => 'access comments', // Grant 'access comments' - * ) + * ] * @endcode * Existing permissions are not changed, unless specified in $permissions. * diff --git a/core/modules/views/src/Annotation/ViewsDisplay.php b/core/modules/views/src/Annotation/ViewsDisplay.php index 2aae108086a4bb536955952418f6d7380c4cd073..238dfa7eff299bb27c3095fa0991480fc83fed32 100644 --- a/core/modules/views/src/Annotation/ViewsDisplay.php +++ b/core/modules/views/src/Annotation/ViewsDisplay.php @@ -85,10 +85,10 @@ class ViewsDisplay extends ViewsPluginAnnotationBase { * * For example: * @code - * array( + * [ * 'page', * 'block', - * ) + * ] * @endcode * * If you don't specify it there will be contextual links rendered for all diff --git a/core/modules/views/src/Plugin/Derivative/ViewsLocalTask.php b/core/modules/views/src/Plugin/Derivative/ViewsLocalTask.php index 72347530181f7f9d3b23ad54fbc7e0130d800ca5..86801d8da50e3aa3e141042fa3e29255b8288ada 100644 --- a/core/modules/views/src/Plugin/Derivative/ViewsLocalTask.php +++ b/core/modules/views/src/Plugin/Derivative/ViewsLocalTask.php @@ -153,10 +153,10 @@ public function alterLocalTasks(&$local_tasks) { * A list of arrays containing the $view and $display_id. * * @code - * array( - * array($view, $display_id), - * array($view, $display_id), - * ); + * [ + * [$view, $display_id], + * [$view, $display_id], + * ]; * @endcode */ protected function getApplicableMenuViews() { diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index c154930fe49791a6ed8240a0426e1ca5b77784d0..57c858928174357c7ec03d8bb9db5e34d421e4fc 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -149,12 +149,12 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, ?array &$ /** * Information about options for all kinds of purposes will be held here. * @code - * 'option_name' => array( + * 'option_name' => [ * - 'default' => default value, * - 'contains' => (optional) array of items this contains, with its own * defaults, etc. If contains is set, the default will be ignored and - * assumed to be array(). - * ), + * assumed to be []. + * ], * @endcode * * @return array diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php index 6cd39aa1a31cdf959ee77e1ab7960a677af17200..c63dab1e953852e508467a8a29355fd7373f8b23 100644 --- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php @@ -179,7 +179,7 @@ public function cacheFlush() { * go there: * * @code - * strtr($output, array('<!--post-FIELD-1-->', 'output for FIELD of nid 1'); + * strtr($output, ['<!--post-FIELD-1-->', 'output for FIELD of nid 1']); * @endcode * * All of the cached result data will be available in $view->result, as well, diff --git a/core/modules/views/src/Plugin/views/field/Boolean.php b/core/modules/views/src/Plugin/views/field/Boolean.php index a2f84c4d27fef6996400942c4b22ee2f02f6de90..f2eb8f639b87ed21dd4654b8d2148d55c19c9bcd 100644 --- a/core/modules/views/src/Plugin/views/field/Boolean.php +++ b/core/modules/views/src/Plugin/views/field/Boolean.php @@ -19,9 +19,9 @@ * - output formats: An array where the first entry is displayed on boolean true * and the second is displayed on boolean false. An example for sticky is: * @code - * 'output formats' => array( - * 'sticky' => array(t('Sticky'), ''), - * ), + * 'output formats' => [ + * 'sticky' => [t('Sticky'), ''], + * ], * @endcode * * @ingroup views_field_handlers diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php index d6eb4eb5e28413c3a2d5f6069e3dc4da213ff4c8..f01a3b24d9e811c5ab5146c318805525bf685166 100644 --- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php +++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php @@ -34,9 +34,9 @@ * The array is in one of these forms: * @code * // Simple form, for fields within the same table. - * array('identifier' => fieldname) + * ['identifier' => fieldname] * // Form for fields in a different table. - * array('identifier' => array('table' => tablename, 'field' => fieldname)) + * ['identifier' => ['table' => tablename, 'field' => fieldname]] * @endcode * As many fields as are necessary may be in this array. * - click sortable: If TRUE (default), this field may be click sorted. @@ -181,7 +181,7 @@ public function query() { * field alias used. The value is either a string in which case it's * assumed to be a field on this handler's table; or it's an array in the * form of - * @code array('table' => $tablename, 'field' => $fieldname) @endcode + * @code ['table' => $tablename, 'field' => $fieldname] @endcode */ protected function addAdditionalFields($fields = NULL) { if (!isset($fields)) { @@ -1702,28 +1702,28 @@ protected function getFieldTokenPlaceholder() { * Recursive function to add replacements for nested query string parameters. * * E.g. if you pass in the following array: - * array( - * 'foo' => array( + * [ + * 'foo' => [ * 'a' => 'value', * 'b' => 'value', * 'c.d' => 'invalid value', * '&invalid' => 'invalid value', - * ), - * 'bar' => array( + * ], + * 'bar' => [ * 'a' => 'value', - * 'b' => array( - * 'c' => 'value', - * ), - * ), - * ); + * 'b' => [ + * 'c' => value, + * ], + * ], + * ]; * * Would yield the following array of tokens: - * array( + * [ * '{{ arguments.foo.a }}' => 'value', * '{{ arguments.foo.b }}' => 'value', * '{{ arguments.bar.a }}' => 'value', * '{{ arguments.bar.b.c }}' => 'value', - * ); + * ]; * * @param $array * An array of values. diff --git a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php index daadb546f6688b0139a67557777e04b50150c198..795671963da74c9a8351c5e2ec0afcc61f2f6920 100644 --- a/core/modules/views/src/Plugin/views/join/JoinPluginBase.php +++ b/core/modules/views/src/Plugin/views/join/JoinPluginBase.php @@ -25,13 +25,13 @@ * @endcode * Use this configuration: * @code - * $configuration = array( + * $configuration = [ * 'table' => 'two', * 'field' => 'field_b', * 'left_table' => 'one', * 'left_field' => 'field_a', * 'operator' => '=', - * ); + * ]; * $join = Views::pluginManager('join')->createInstance('standard', $configuration); * @endcode * Note that the default join type is a LEFT join when 'type' is not supplied in @@ -45,19 +45,19 @@ * @endcode * Use this configuration: * @code - * $configuration = array( + * $configuration = [ * 'table' => 'two', * 'field' => 'field_b', * 'left_table' => 'one', * 'left_formula' => 'MAX(one.field_a)', * 'operator' => '=', - * 'extra' => array( - * 0 => array( + * 'extra' => [ + * 0 => [ * 'left_field' => 'field_c', * 'value' => 'some_val', - * ), - * ), - * ); + * ], + * ], + * ]; * $join = Views::pluginManager('join')->createInstance('standard', $configuration); * @endcode * @@ -67,20 +67,20 @@ * @endcode * Use this configuration: * @code - * $configuration = array( + * $configuration = [ * 'type' => 'INNER', * 'table' => 'two', * 'field' => 'field_b', * 'left_table' => 'one', * 'left_field' => 'field_a', * 'operator' => '=', - * 'extra' => array( - * 0 => array( + * 'extra' => [ + * 0 => [ * 'left_field' => 'field_c', * 'value' => 'some_val', - * ), - * ), - * ); + * ], + * ], + * ]; * $join = Views::pluginManager('join')->createInstance('standard', $configuration); * @endcode * @@ -90,20 +90,20 @@ * @endcode * Use this configuration: * @code - * $configuration = array( + * $configuration = [ * 'type' => 'INNER', * 'table' => 'two', * 'field' => 'field_b', * 'left_table' => 'one', * 'left_field' => 'field_a', * 'operator' => '=', - * 'extra' => array( - * 0 => array( + * 'extra' => [ + * 0 => [ * 'field' => 'field_d', * 'value' => 'other_val', - * ), - * ), - * ); + * ], + * ], + * ]; * $join = Views::pluginManager('join')->createInstance('standard', $configuration); * @endcode * @@ -113,20 +113,20 @@ * @endcode * Use this configuration: * @code - * $configuration = array( + * $configuration = [ * 'type' => 'INNER', * 'table' => 'two', * 'field' => 'field_b', * 'left_table' => 'one', * 'left_field' => 'field_a', * 'operator' => '=', - * 'extra' => array( - * 0 => array( + * 'extra' => [ + * 0 => [ * 'left_field' => 'field_c', * 'field' => 'field_d', - * ), - * ), - * ); + * ], + * ], + * ]; * $join = Views::pluginManager('join')->createInstance('standard', $configuration); * @endcode * diff --git a/core/modules/views/src/Plugin/views/style/StylePluginBase.php b/core/modules/views/src/Plugin/views/style/StylePluginBase.php index d8ecefc83ae635f459b73847249d9ca49c07d00d..8acb4e87f43b5d887f36aca166cc6de190af424d 100644 --- a/core/modules/views/src/Plugin/views/style/StylePluginBase.php +++ b/core/modules/views/src/Plugin/views/style/StylePluginBase.php @@ -538,26 +538,26 @@ public function renderGroupingSets($sets) { * A nested set structure is generated if multiple grouping fields are used. * * @code - * array( - * 'grouping_field_1:grouping_1' => array( + * [ + * 'grouping_field_1:grouping_1' => [ * 'group' => 'grouping_field_1:content_1', * 'level' => 0, - * 'rows' => array( - * 'grouping_field_2:grouping_a' => array( + * 'rows' => [ + * 'grouping_field_2:grouping_a' => [ * 'group' => 'grouping_field_2:content_a', * 'level' => 1, - * 'rows' => array( + * 'rows' => [ * $row_index_1 => $row_1, * $row_index_2 => $row_2, * // ... - * ) - * ), - * ), - * ), - * 'grouping_field_1:grouping_2' => array( + * ] + * ], + * ], + * ], + * 'grouping_field_1:grouping_2' => [ * // ... - * ), - * ) + * ], + * ] * @endcode */ public function renderGrouping($records, $groupings = [], $group_rendered = NULL) { diff --git a/core/modules/views/src/Views.php b/core/modules/views/src/Views.php index 2373ebbc219bee0ddce78f8e8328a0ddb10aabc9..a7feae2c34b8d49bc84e9b4128eccfa334843eeb 100644 --- a/core/modules/views/src/Views.php +++ b/core/modules/views/src/Views.php @@ -200,10 +200,10 @@ public static function getEnabledDisplayExtenders() { * A list of arrays containing the $view_id and $display_id. * * @code - * array( - * array($view_id, $display_id), - * array($view_id, $display_id), - * ); + * [ + * [$view_id, $display_id], + * [$view_id, $display_id], + * ]; * @endcode */ public static function getApplicableViews($type) { diff --git a/core/modules/views/tests/src/Kernel/Plugin/BlockDependenciesTest.php b/core/modules/views/tests/src/Kernel/Plugin/BlockDependenciesTest.php index 0d0e255b81f9252ee562f0dd10a331fb8ad614b4..e208b46237bf3d2ba20caabc13bb367ac872ac22 100644 --- a/core/modules/views/tests/src/Kernel/Plugin/BlockDependenciesTest.php +++ b/core/modules/views/tests/src/Kernel/Plugin/BlockDependenciesTest.php @@ -78,9 +78,9 @@ public function testViewsBlock() { * Override the defaults by specifying the key and value in the array, for * example: * @code - * $this->createBlock('system_powered_by_block', array( + * $this->createBlock('system_powered_by_block', [ * 'label' => 'Hello, world!', - * )); + * ]); * @endcode * The following defaults are provided: * - label: Random string. diff --git a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php index baaa1b7fb342214329dce1a6fd204f3cc6fd309e..c48f034254cd651ccb6bc60cda86d22b5ef2a2f5 100644 --- a/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php +++ b/core/modules/views_ui/src/Form/Ajax/RearrangeFilter.php @@ -79,12 +79,12 @@ public function buildForm(array $form, FormStateInterface $form_state) { /** * Filter groups is an array that contains: - * array( + * [ * 'operator' => 'and' || 'or', - * 'groups' => array( + * 'groups' => [ * $group_id => 'and' || 'or', - * ), - * ); + * ], + * ]; */ $grouping = count(array_keys($groups['groups'])) > 1; @@ -333,7 +333,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { /** * Adds one to each key of an array. * - * For example array(0 => 'foo') would be array(1 => 'foo'). + * For example [0 => 'foo'] would be [1 => 'foo']. * * @param array $array * The array to increment keys on. diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index 5af8cb248eefeee3570e142cc8f529c2f921ba57..e787ae464fa30c0f49cd3ca209c559ef0682836c 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -62,6 +62,7 @@ <exclude name="Drupal.Commenting.DocComment.SpacingBeforeTags"/> </rule> <rule ref="Drupal.Commenting.DocCommentAlignment"/> + <rule ref="Drupal.Commenting.DocCommentLongArraySyntax"/> <rule ref="Drupal.Commenting.DocCommentStar"/> <rule ref="Drupal.Commenting.FileComment"/> <rule ref="Drupal.Commenting.FunctionComment"> diff --git a/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php b/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php index 78551c68aab5f8b9c544400297fa101bcae3764b..2ca37dc1006d23a8e577295a1bb34380bab8862a 100644 --- a/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php +++ b/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php @@ -261,7 +261,7 @@ protected function testDemonstrationWarningMessage() { * For example: * @code * // Create a user. - * $account = $this->drupalCreateUser(array()); + * $account = $this->drupalCreateUser([]); * $this->drupalLogin($account); * // Load real user object. * $pass_raw = $account->passRaw; diff --git a/core/tests/Drupal/KernelTests/ConfigFormTestBase.php b/core/tests/Drupal/KernelTests/ConfigFormTestBase.php index f392a2d586dd04536e55fb05fc109134eb83388a..9cad9328d856da8916cb67852d1bd212f184274e 100644 --- a/core/tests/Drupal/KernelTests/ConfigFormTestBase.php +++ b/core/tests/Drupal/KernelTests/ConfigFormTestBase.php @@ -26,13 +26,13 @@ abstract class ConfigFormTestBase extends KernelTestBase { * Contains details for form key, configuration object name, and config key. * Example: * @code - * array( - * 'user_mail_cancel_confirm_body' => array( + * [ + * 'user_mail_cancel_confirm_body' => [ * '#value' => $this->randomString(), * '#config_name' => 'user.mail', * '#config_key' => 'cancel_confirm.body', - * ), - * ); + * ], + * ]; * @endcode * * @var array diff --git a/core/tests/Drupal/Tests/UiHelperTrait.php b/core/tests/Drupal/Tests/UiHelperTrait.php index e52f20e0b07e3a0f7d908823fc551c694ec6bbb5..5e6e9176b10064ae5ec73a69724819f1f169744a 100644 --- a/core/tests/Drupal/Tests/UiHelperTrait.php +++ b/core/tests/Drupal/Tests/UiHelperTrait.php @@ -138,7 +138,7 @@ protected function submitForm(array $edit, $submit, $form_html_id = NULL) { * For example: * @code * // Create a user. - * $account = $this->drupalCreateUser(array()); + * $account = $this->drupalCreateUser([]); * $this->drupalLogin($account); * // Load real user object. * $pass_raw = $account->passRaw;