diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayRepositoryInterface.php b/core/lib/Drupal/Core/Entity/EntityDisplayRepositoryInterface.php index ca7ab71ae1..7354869c53 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', [ + * ->setComponent('body', array( * 'type' => 'text_summary_or_trimmed', - * 'settings' => ['trim_length' => '200'], + * 'settings' => array('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', [ + * ->setComponent('body', array( * 'type' => 'text_textarea_with_summary', * 'weight' => 1, - * ]) - * ->setComponent('field_image', [ + * )) + * ->setComponent('field_image', array( * 'region' => 'hidden', - * ]) + * )) * ->save(); * @endcode * diff --git a/core/lib/Drupal/Core/Render/Element/Hidden.php b/core/lib/Drupal/Core/Render/Element/Hidden.php index 32edb6ff87..3864e8389f 100644 --- a/core/lib/Drupal/Core/Render/Element/Hidden.php +++ b/core/lib/Drupal/Core/Render/Element/Hidden.php @@ -17,7 +17,7 @@ * * Usage example: * @code - * $form['entity_id'] = ['#type' => 'hidden', '#value' => $entity_id]; + * $form['entity_id'] = array('#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 9ec68c45e7..adbd38584a 100644 --- a/core/lib/Drupal/Core/Render/Element/Link.php +++ b/core/lib/Drupal/Core/Render/Element/Link.php @@ -126,31 +126,31 @@ 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'] = [ + * $build['links'] = array( * '#theme' => 'links__node', - * '#pre_render' => [Link::class, 'preRenderLinks'], - * 'comment' => [ + * '#pre_render' => array(Link::class, 'preRenderLinks'), + * 'comment' => array( * '#theme' => 'links__node__comment', - * '#links' => [ + * '#links' => array( * // An array of links associated with node comments, suitable for * // passing in to links.html.twig. - * ], - * ], - * 'statistics' => [ + * ), + * ), + * 'statistics' => array( * '#theme' => 'links__node__statistics', - * '#links' => [ + * '#links' => array( * // An array of links associated with node statistics, suitable for * // passing in to links.html.twig. - * ], - * ], - * 'translation' => [ + * ), + * ), + * 'translation' => array( * '#theme' => 'links__node__translation', - * '#links' => [ + * '#links' => array( * // 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/Number.php b/core/lib/Drupal/Core/Render/Element/Number.php index d16802f295..8f7efca552 100644 --- a/core/lib/Drupal/Core/Render/Element/Number.php +++ b/core/lib/Drupal/Core/Render/Element/Number.php @@ -19,10 +19,10 @@ * * Usage example: * @code - * $form['quantity'] = [ + * $form['quantity'] = array( * '#type' => 'number', * '#title' => $this->t('Quantity'), - * ]; + * ); * @endcode * * @see \Drupal\Core\Render\Element\Range diff --git a/core/lib/Drupal/Core/Render/theme.api.php b/core/lib/Drupal/Core/Render/theme.api.php index 462a182461..ce20efa960 100644 --- a/core/lib/Drupal/Core/Render/theme.api.php +++ b/core/lib/Drupal/Core/Render/theme.api.php @@ -1288,24 +1288,24 @@ function hook_theme($existing, $type, $theme, $path) { * * For example: * @code - * $theme_registry['block_content_add_list'] = [ + * $theme_registry['block_content_add_list'] = array ( * 'template' => 'block-content-add-list', * 'path' => 'core/themes/claro/templates', * 'type' => 'theme_engine', * 'theme path' => 'core/themes/claro', - * 'includes' => [ + * 'includes' => array ( * 0 => 'core/modules/block_content/block_content.pages.inc', - * ], - * 'variables' => [ + * ), + * 'variables' => array ( * 'content' => NULL, - * ], - * 'preprocess functions' => [ + * ), + * 'preprocess functions' => array ( * 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 2a131cf876..e9a8c4c99f 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) [ + * $settings['settings']['config_sync_directory'] = (object) array( * 'value' => 'config_hash/sync', * 'required' => TRUE, - * ]; + * ); * @endcode * gets dumped as: * @code diff --git a/core/lib/Drupal/Core/Test/TestDiscovery.php b/core/lib/Drupal/Core/Test/TestDiscovery.php index 8bc6a8d51c..9e394a4342 100644 --- a/core/lib/Drupal/Core/Test/TestDiscovery.php +++ b/core/lib/Drupal/Core/Test/TestDiscovery.php @@ -137,14 +137,14 @@ public function registerTestNamespaces() { * to. * * @code - * $groups['block'] => [ - * 'Drupal\Tests\block\Functional\BlockTest' => [ + * $groups['block'] => array( + * 'Drupal\Tests\block\Functional\BlockTest' => array( * '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/Utility/Token.php b/core/lib/Drupal/Core/Utility/Token.php index a9957c5176..689e5e57a1 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 = ['node' => $node, 'user' => $user]; + * $data = array('node' => $node, 'user' => $user); * $result = $token_service->replace($text, $data); * return $result * @endcode diff --git a/core/modules/book/src/Controller/BookController.php b/core/modules/book/src/Controller/BookController.php index bb09ae9719..d84a8d15c3 100644 --- a/core/modules/book/src/Controller/BookController.php +++ b/core/modules/book/src/Controller/BookController.php @@ -8,6 +8,7 @@ use Drupal\Core\Link; use Drupal\Core\Render\RendererInterface; use Drupal\Core\Url; +use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -19,6 +20,8 @@ */ class BookController extends ControllerBase { + use StringTranslationTrait; + /** * The book manager. * @@ -76,7 +79,7 @@ public static function create(ContainerInterface $container) { public function adminOverview() { $rows = []; - $headers = [t('Book'), t('Operations')]; + $headers = [$this->t('Book'), $this->t('Operations')]; // Add any recognized books to the table list. foreach ($this->bookManager->getAllBooks() as $book) { /** @var \Drupal\Core\Url $url */ @@ -89,7 +92,7 @@ public function adminOverview() { ]; $links = []; $links['edit'] = [ - 'title' => t('Edit order and titles'), + 'title' => $this->t('Edit order and titles'), 'url' => Url::fromRoute('book.admin_edit', ['node' => $book['nid']]), ]; $row[] = [ @@ -104,7 +107,7 @@ public function adminOverview() { '#type' => 'table', '#header' => $headers, '#rows' => $rows, - '#empty' => t('No books available.'), + '#empty' => $this->t('No books available.'), ]; } @@ -155,7 +158,7 @@ public function bookExport($type, NodeInterface $node) { // @todo Convert the custom export functionality to serializer. if (!method_exists($this->bookExport, $method)) { - $this->messenger()->addStatus(t('Unknown export format.')); + $this->messenger()->addStatus($this->t('Unknown export format.')); throw new NotFoundHttpException(); } diff --git a/core/modules/config/src/Controller/ConfigController.php b/core/modules/config/src/Controller/ConfigController.php index 0c0f486865..c1cd7e50fb 100644 --- a/core/modules/config/src/Controller/ConfigController.php +++ b/core/modules/config/src/Controller/ConfigController.php @@ -12,6 +12,7 @@ use Drupal\Core\File\FileSystemInterface; use Drupal\Core\Serialization\Yaml; use Drupal\Core\Url; +use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\system\FileDownloadController; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; 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 b48f096634..91ca8c0f90 100644 --- a/core/modules/field/tests/modules/field_test/field_test.module +++ b/core/modules/field/tests/modules/field_test/field_test.module @@ -50,7 +50,7 @@ * * // make sure hook_field_storage_config_create() is invoked correctly * assertEquals(1, count($mem['field_test_field_storage_config_create'])); - * assertEquals([$field], $mem['field_test_field_storage_config_create'][0]); + * assertEquals(array($field), $mem['field_test_field_storage_config_create'][0]); * @endcode * * @param $key diff --git a/core/modules/system/src/Controller/SystemController.php b/core/modules/system/src/Controller/SystemController.php index afb715dad9..1e2d077f41 100644 --- a/core/modules/system/src/Controller/SystemController.php +++ b/core/modules/system/src/Controller/SystemController.php @@ -15,6 +15,7 @@ use Drupal\Core\Menu\MenuTreeParameters; use Drupal\Core\Theme\ThemeAccessCheck; use Drupal\Core\Url; +use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\system\SystemManager; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -24,6 +25,7 @@ class SystemController extends ControllerBase { use ModuleDependencyMessageTrait; + use StringTranslationTrait; /** * System Manager Service. @@ -335,7 +337,7 @@ public function themesPage() { 'attributes' => ['title' => $this->t('Set @theme as default theme', ['@theme' => $theme->info['name']])], ]; } - $admin_theme_options[$theme->getName()] = $theme->info['name'] . ($theme->isExperimental() ? ' (' . t('Experimental') . ')' : ''); + $admin_theme_options[$theme->getName()] = $theme->info['name'] . ($theme->isExperimental() ? ' (' . $this->t('Experimental') . ')' : ''); } else { $theme->operations[] = [ diff --git a/core/modules/system/src/Controller/SystemInfoController.php b/core/modules/system/src/Controller/SystemInfoController.php index 16f8bf946b..27ed5ea906 100644 --- a/core/modules/system/src/Controller/SystemInfoController.php +++ b/core/modules/system/src/Controller/SystemInfoController.php @@ -6,6 +6,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Response; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\system\SystemManager; use Drupal\Core\StringTranslation\StringTranslationTrait; diff --git a/core/modules/tracker/src/Controller/TrackerController.php b/core/modules/tracker/src/Controller/TrackerController.php index aeb65755ee..5aecc38ca9 100644 --- a/core/modules/tracker/src/Controller/TrackerController.php +++ b/core/modules/tracker/src/Controller/TrackerController.php @@ -11,6 +11,7 @@ use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Session\AccountInterface; +use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\user\UserInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -19,6 +20,8 @@ */ class TrackerController extends ControllerBase { + use StringTranslationTrait; + /** * The database connection. * @@ -211,7 +214,7 @@ public function buildContent(UserInterface $user = NULL) { 'data-history-node-last-comment-timestamp' => $tracker_data[$node->id()]->last_comment_timestamp ?? 0, ], 'last updated' => [ - 'data' => t('@time ago', [ + 'data' => $this->t('@time ago', [ '@time' => $this->dateFormatter->formatTimeDiffSince($last_activity), ]), ], diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php index 9624d6b270..d372baedc2 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, ['', 'output for FIELD of nid 1']); + * strtr($output, array('', '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/Views.php b/core/modules/views/src/Views.php index a7feae2c34..2373ebbc21 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 - * [ - * [$view_id, $display_id], - * [$view_id, $display_id], - * ]; + * array( + * array($view_id, $display_id), + * array($view_id, $display_id), + * ); * @endcode */ public static function getApplicableViews($type) { diff --git a/core/modules/views_ui/src/Controller/ViewsUIController.php b/core/modules/views_ui/src/Controller/ViewsUIController.php index b81bf43175..e731bef825 100644 --- a/core/modules/views_ui/src/Controller/ViewsUIController.php +++ b/core/modules/views_ui/src/Controller/ViewsUIController.php @@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\JsonResponse; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\ReplaceCommand; +use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Component\Utility\Html; /** @@ -23,6 +24,8 @@ */ class ViewsUIController extends ControllerBase { + use StringTranslationTrait; + /** * Stores the Views data cache object. * @@ -83,7 +86,7 @@ public function reportFields() { } } - $header = [t('Field name'), t('Used in')]; + $header = [$this->t('Field name'), $this->t('Used in')]; $rows = []; foreach ($fields as $field_name => $views) { $rows[$field_name]['data'][0]['data']['#plain_text'] = $field_name; @@ -104,7 +107,7 @@ public function reportFields() { '#type' => 'table', '#header' => $header, '#rows' => $rows, - '#empty' => t('No fields have been used in views yet.'), + '#empty' => $this->t('No fields have been used in views yet.'), ]; return $output; @@ -136,9 +139,9 @@ public function reportPlugins() { ksort($rows); return [ '#type' => 'table', - '#header' => [t('Type'), t('Name'), t('Provided by'), t('Used in')], + '#header' => [$this->t('Type'), $this->t('Name'), $this->t('Provided by'), $this->t('Used in')], '#rows' => $rows, - '#empty' => t('There are no enabled views.'), + '#empty' => $this->t('There are no enabled views.'), ]; } diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index 905d523bde..ed5acf2e73 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -61,7 +61,6 @@ - diff --git a/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php b/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php index 180a4a166f..246b555153 100644 --- a/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php +++ b/core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php @@ -260,7 +260,7 @@ protected function testDemonstrationWarningMessage() { * For example: * @code * // Create a user. - * $account = $this->drupalCreateUser([]); + * $account = $this->drupalCreateUser(array()); * $this->drupalLogin($account); * // Load real user object. * $pass_raw = $account->passRaw; diff --git a/core/tests/Drupal/Tests/UiHelperTrait.php b/core/tests/Drupal/Tests/UiHelperTrait.php index b60951c9a4..e811de7ede 100644 --- a/core/tests/Drupal/Tests/UiHelperTrait.php +++ b/core/tests/Drupal/Tests/UiHelperTrait.php @@ -134,7 +134,7 @@ protected function submitForm(array $edit, $submit, $form_html_id = NULL) { * For example: * @code * // Create a user. - * $account = $this->drupalCreateUser([]); + * $account = $this->drupalCreateUser(array()); * $this->drupalLogin($account); * // Load real user object. * $pass_raw = $account->passRaw;