From 9d6d91cd15e6d09aee948ce885175011006651ed Mon Sep 17 00:00:00 2001 From: nod_ <nod_@598310.no-reply.drupal.org> Date: Wed, 5 Mar 2025 08:54:14 +0100 Subject: [PATCH] Issue #3508608 by quietone, sivaji_ganesh_jojodae, borisson_: Fix LongLineDeclaration in core/lib --- .../lib/Drupal/Component/Gettext/PoHeader.php | 20 ++++- core/lib/Drupal/Component/Utility/Xss.php | 81 ++++++++++++++++++- core/lib/Drupal/Core/Asset/CssOptimizer.php | 13 ++- .../Core/Cache/CacheTagsChecksumTrait.php | 4 +- .../Command/GenerateProxyClassCommand.php | 6 +- .../Deriver/EntityMethodDeriver.php | 5 +- .../lib/Drupal/Core/Config/ConfigImporter.php | 29 +++++-- .../Drupal/Core/Config/DatabaseStorage.php | 12 ++- .../Core/Config/Entity/Query/QueryFactory.php | 5 +- .../Config/Importer/ConfigImporterBatch.php | 5 +- .../Drupal/Core/Database/Install/Tasks.php | 6 +- core/lib/Drupal/Core/DrupalKernel.php | 9 ++- .../Entity/Element/EntityAutocomplete.php | 10 ++- .../Drupal/Core/Entity/EntityDisplayBase.php | 8 +- .../Core/Entity/EntityDisplayRepository.php | 5 +- .../Drupal/Core/Entity/EntityFieldManager.php | 5 +- core/lib/Drupal/Core/Entity/EntityForm.php | 7 +- .../EntityLastInstalledSchemaRepository.php | 5 +- .../Drupal/Core/Entity/EntityListBuilder.php | 10 ++- .../Core/Entity/EntityTypeBundleInfo.php | 5 +- .../Event/BundleConfigImportValidate.php | 7 +- .../Sql/SqlContentEntityStorageSchema.php | 12 ++- .../ConfigImportSubscriber.php | 20 ++++- .../Drupal/Core/Field/FieldFilteredMarkup.php | 25 +++++- core/lib/Drupal/Core/Field/FieldItemList.php | 5 +- .../Field/FieldFormatter/BooleanFormatter.php | 10 ++- .../FieldFormatter/TimestampFormatter.php | 5 +- .../Plugin/Field/FieldType/StringItem.php | 5 +- core/lib/Drupal/Core/Field/WidgetBase.php | 10 ++- core/lib/Drupal/Core/File/HtaccessWriter.php | 5 +- .../Drupal/Core/FileTransfer/FTPExtension.php | 5 +- .../Drupal/Core/FileTransfer/FileTransfer.php | 5 +- core/lib/Drupal/Core/FileTransfer/Local.php | 5 +- core/lib/Drupal/Core/FileTransfer/SSH.php | 10 ++- core/lib/Drupal/Core/Form/FormBuilder.php | 6 +- core/lib/Drupal/Core/Form/FormSubmitter.php | 5 +- core/lib/Drupal/Core/Form/FormValidator.php | 6 +- core/lib/Drupal/Core/Image/Image.php | 7 +- .../Core/ImageToolkit/ImageToolkitBase.php | 5 +- .../ImageToolkitOperationManager.php | 5 +- .../Core/Installer/Form/SiteConfigureForm.php | 7 +- .../Core/KeyValueStore/DatabaseStorage.php | 7 +- .../lib/Drupal/Core/Mail/MailFormatHelper.php | 5 +- .../lib/Drupal/Core/Render/Element/Number.php | 10 ++- .../HtmlResponseAttachmentsProcessor.php | 11 ++- core/lib/Drupal/Core/Routing/UrlGenerator.php | 8 +- .../Core/StreamWrapper/PrivateStream.php | 6 +- .../Core/Template/ComponentNodeVisitor.php | 5 +- .../Drupal/Core/Template/DebugExtension.php | 10 ++- .../Drupal/Core/Template/TwigExtension.php | 9 ++- core/lib/Drupal/Core/Test/AssertMailTrait.php | 10 ++- core/lib/Drupal/Core/Updater/Updater.php | 5 +- core/lib/Drupal/Core/Utility/TableSort.php | 5 +- .../Core/Utility/UnroutedUrlAssembler.php | 6 +- core/phpcs.xml.dist | 1 + 55 files changed, 447 insertions(+), 71 deletions(-) diff --git a/core/lib/Drupal/Component/Gettext/PoHeader.php b/core/lib/Drupal/Component/Gettext/PoHeader.php index 5ba4f88eacd2..64ce6bc6be64 100644 --- a/core/lib/Drupal/Component/Gettext/PoHeader.php +++ b/core/lib/Drupal/Component/Gettext/PoHeader.php @@ -277,7 +277,25 @@ private function parseHeader($header) { */ private function parseArithmetic($string) { // Operator precedence table. - $precedence = ["(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8]; + $precedence = [ + "(" => -1, + ")" => -1, + "?" => 1, + ":" => 1, + "||" => 3, + "&&" => 4, + "==" => 5, + "!=" => 5, + "<" => 6, + ">" => 6, + "<=" => 6, + ">=" => 6, + "+" => 7, + "-" => 7, + "*" => 8, + "/" => 8, + "%" => 8, + ]; // Right associativity. $right_associativity = ["?" => 1, ":" => 1]; diff --git a/core/lib/Drupal/Component/Utility/Xss.php b/core/lib/Drupal/Component/Utility/Xss.php index 8e1d7d38eb22..64f35aea080c 100644 --- a/core/lib/Drupal/Component/Utility/Xss.php +++ b/core/lib/Drupal/Component/Utility/Xss.php @@ -18,7 +18,86 @@ class Xss { * * @see \Drupal\Component\Utility\Xss::filterAdmin() */ - protected static $adminTags = ['a', 'abbr', 'acronym', 'address', 'article', 'aside', 'b', 'bdi', 'bdo', 'big', 'blockquote', 'br', 'caption', 'cite', 'code', 'col', 'colgroup', 'command', 'dd', 'del', 'details', 'dfn', 'div', 'dl', 'dt', 'em', 'figcaption', 'figure', 'footer', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'mark', 'menu', 'meter', 'nav', 'ol', 'output', 'p', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'small', 'span', 'strong', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time', 'tr', 'tt', 'u', 'ul', 'var', 'wbr']; + protected static $adminTags = [ + 'a', + 'abbr', + 'acronym', + 'address', + 'article', + 'aside', + 'b', + 'bdi', + 'bdo', + 'big', + 'blockquote', + 'br', + 'caption', + 'cite', + 'code', + 'col', + 'colgroup', + 'command', + 'dd', + 'del', + 'details', + 'dfn', + 'div', + 'dl', + 'dt', + 'em', + 'figcaption', + 'figure', + 'footer', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'header', + 'hgroup', + 'hr', + 'i', + 'img', + 'ins', + 'kbd', + 'li', + 'mark', + 'menu', + 'meter', + 'nav', + 'ol', + 'output', + 'p', + 'pre', + 'progress', + 'q', + 'rp', + 'rt', + 'ruby', + 's', + 'samp', + 'section', + 'small', + 'span', + 'strong', + 'sub', + 'summary', + 'sup', + 'table', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'time', + 'tr', + 'tt', + 'u', + 'ul', + 'var', + 'wbr', + ]; /** * The default list of HTML tags allowed by filter(). diff --git a/core/lib/Drupal/Core/Asset/CssOptimizer.php b/core/lib/Drupal/Core/Asset/CssOptimizer.php index 062b4d422865..9b5559c696d5 100644 --- a/core/lib/Drupal/Core/Asset/CssOptimizer.php +++ b/core/lib/Drupal/Core/Asset/CssOptimizer.php @@ -92,7 +92,11 @@ protected function processFile($css_asset) { // Anchor all paths in the CSS with its base URL, ignoring external and // absolute paths and paths starting with '#'. - return preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+|#|%23)([^\'")]+)[\'"]?\s*\)/i', [$this, 'rewriteFileURI'], $contents); + return preg_replace_callback( + '/url\(\s*[\'"]?(?![a-z]+:|\/+|#|%23)([^\'")]+)[\'"]?\s*\)/i', + [$this, 'rewriteFileURI'], + $contents + ); } /** @@ -264,7 +268,12 @@ protected function processCss($contents, $optimize = FALSE) { // This happens recursively but omits external files and local files // with supports- or media-query qualifiers, as those are conditionally // loaded depending on the user agent. - $contents = preg_replace_callback('/@import\s*(?:url\(\s*)?[\'"]?(?![a-z]+:)(?!\/\/)([^\'"\()]+)[\'"]?\s*\)?\s*;/', [$this, 'loadNestedFile'], $contents); + $contents = preg_replace_callback( + '/@import\s*(?:url\(\s*)?[\'"]?(?![a-z]+:)(?!\/\/)([^\'"\()]+)[\'"]?\s*\)?\s*;/', [ + $this, + 'loadNestedFile', + ], + $contents); return $contents; } diff --git a/core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php b/core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php index 0a6724fb1cde..28af2ae2b8d2 100644 --- a/core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php +++ b/core/lib/Drupal/Core/Cache/CacheTagsChecksumTrait.php @@ -72,7 +72,9 @@ public function invalidateTags(array $tags) { $in_transaction = $this->getDatabaseConnection()->inTransaction(); if ($in_transaction) { if (empty($this->delayedTags)) { - $this->getDatabaseConnection()->transactionManager()->addPostTransactionCallback([$this, 'rootTransactionEndCallback']); + $this->getDatabaseConnection() + ->transactionManager() + ->addPostTransactionCallback([$this, 'rootTransactionEndCallback']); } $this->delayedTags = Cache::mergeTags($this->delayedTags, $tags); } diff --git a/core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php b/core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php index 889c828ec5cd..f39932237075 100644 --- a/core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php +++ b/core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php @@ -78,7 +78,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int */ {{ proxy_class_string }} EOF; - $file_string = str_replace(['{{ proxy_class_name }}', '{{ proxy_class_string }}'], [$proxy_class_name, $proxy_class_string], $file_string); + $file_string = str_replace( + ['{{ proxy_class_name }}', '{{ proxy_class_string }}'], + [$proxy_class_name, $proxy_class_string], + $file_string + ); mkdir(dirname($proxy_filename), 0775, TRUE); file_put_contents($proxy_filename, $file_string); diff --git a/core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/Deriver/EntityMethodDeriver.php b/core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/Deriver/EntityMethodDeriver.php index b1c5ccff3841..93ad6df8e75a 100644 --- a/core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/Deriver/EntityMethodDeriver.php +++ b/core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/Deriver/EntityMethodDeriver.php @@ -93,7 +93,10 @@ public function getDerivativeDefinitions($base_plugin_definition) { * The base plugin definition that will used to create the derivative. */ private function processMethod(\ReflectionMethod $method, ActionMethod $action_attribute, ConfigEntityTypeInterface $entity_type, array $derivative): void { - $derivative['admin_label'] = $action_attribute->adminLabel ?: $this->t('@entity_type @method', ['@entity_type' => $entity_type->getLabel(), '@method' => $method->name]); + $derivative['admin_label'] = $action_attribute->adminLabel ?: $this->t('@entity_type @method', [ + '@entity_type' => $entity_type->getLabel(), + '@method' => $method->name, + ]); $derivative['constructor_args'] = [ 'method' => $method->name, 'exists' => $action_attribute->exists, diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index 86359e6e8fe3..3b30c2d99f37 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -675,10 +675,17 @@ protected function processConfigurations(&$context) { $this->processConfiguration($operation['collection'], $operation['op'], $operation['name']); } if ($operation['collection'] == StorageInterface::DEFAULT_COLLECTION) { - $context['message'] = $this->t('Synchronizing configuration: @op @name.', ['@op' => $operation['op'], '@name' => $operation['name']]); + $context['message'] = $this->t('Synchronizing configuration: @op @name.', [ + '@op' => $operation['op'], + '@name' => $operation['name'], + ]); } else { - $context['message'] = $this->t('Synchronizing configuration: @op @name in @collection.', ['@op' => $operation['op'], '@name' => $operation['name'], '@collection' => $operation['collection']]); + $context['message'] = $this->t('Synchronizing configuration: @op @name in @collection.', [ + '@op' => $operation['op'], + '@name' => $operation['name'], + '@collection' => $operation['collection'], + ]); } $processed_count = 0; foreach ($this->storageComparer->getAllCollectionNames() as $collection) { @@ -819,11 +826,19 @@ public function validate() { $old_entity_type_id = $this->configManager->getEntityTypeIdByName($names['old_name']); $new_entity_type_id = $this->configManager->getEntityTypeIdByName($names['new_name']); if ($old_entity_type_id != $new_entity_type_id) { - $this->logError($this->t('Entity type mismatch on rename. @old_type not equal to @new_type for existing configuration @old_name and staged configuration @new_name.', ['@old_type' => $old_entity_type_id, '@new_type' => $new_entity_type_id, '@old_name' => $names['old_name'], '@new_name' => $names['new_name']])); + $this->logError($this->t('Entity type mismatch on rename. @old_type not equal to @new_type for existing configuration @old_name and staged configuration @new_name.', [ + '@old_type' => $old_entity_type_id, + '@new_type' => $new_entity_type_id, + '@old_name' => $names['old_name'], + '@new_name' => $names['new_name'], + ])); } // Has to be a configuration entity. if (!$old_entity_type_id) { - $this->logError($this->t('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', ['@old_name' => $names['old_name'], '@new_name' => $names['new_name']])); + $this->logError($this->t('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', [ + '@old_name' => $names['old_name'], + '@new_name' => $names['new_name'], + ])); } } $this->eventDispatcher->dispatch(new ConfigImporterEvent($this), ConfigEvents::IMPORT_VALIDATE); @@ -864,7 +879,11 @@ protected function processConfiguration($collection, $op, $name) { } } catch (\Exception $e) { - $this->logError($this->t('Unexpected error during import with operation @op for @name: @message', ['@op' => $op, '@name' => $name, '@message' => $e->getMessage()])); + $this->logError($this->t('Unexpected error during import with operation @op for @name: @message', [ + '@op' => $op, + '@name' => $name, + '@message' => $e->getMessage(), + ])); // Error for that operation was logged, mark it as processed so that // the import can continue. $this->setProcessedConfiguration($collection, $op, $name); diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php index 1211ad9e7ff9..60da9de12470 100644 --- a/core/lib/Drupal/Core/Config/DatabaseStorage.php +++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php @@ -86,7 +86,10 @@ public function exists($name) { public function read($name) { $data = FALSE; try { - $raw = $this->connection->query('SELECT [data] FROM {' . $this->connection->escapeTable($this->table) . '} WHERE [collection] = :collection AND [name] = :name', [':collection' => $this->collection, ':name' => $name], $this->options)->fetchField(); + $raw = $this->connection->query('SELECT [data] FROM {' . $this->connection->escapeTable($this->table) . '} WHERE [collection] = :collection AND [name] = :name', [ + ':collection' => $this->collection, + ':name' => $name, + ], $this->options)->fetchField(); if ($raw !== FALSE) { $data = $this->decode($raw); } @@ -111,7 +114,12 @@ public function readMultiple(array $names) { $list = []; try { - $list = $this->connection->query('SELECT [name], [data] FROM {' . $this->connection->escapeTable($this->table) . '} WHERE [collection] = :collection AND [name] IN ( :names[] )', [':collection' => $this->collection, ':names[]' => $names], $this->options)->fetchAllKeyed(); + $list = $this->connection + ->query('SELECT [name], [data] FROM {' . $this->connection->escapeTable($this->table) . '} WHERE [collection] = :collection AND [name] IN ( :names[] )', [ + ':collection' => $this->collection, + ':names[]' => $names, + ], $this->options) + ->fetchAllKeyed(); foreach ($list as &$data) { $data = $this->decode($data); } diff --git a/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php b/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php index 064e5b4e9f57..b2525646a58a 100644 --- a/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php +++ b/core/lib/Drupal/Core/Config/Entity/Query/QueryFactory.php @@ -163,7 +163,10 @@ protected function deleteConfigKeyStore(ConfigEntityTypeInterface $entity_type, */ protected function getKeys(Config $config, $key, $get_method, ConfigEntityTypeInterface $entity_type) { if (str_ends_with($key, '*')) { - throw new InvalidLookupKeyException(strtr('%entity_type lookup key %key ends with a wildcard this can not be used as a lookup', ['%entity_type' => $entity_type->id(), '%key' => $key])); + throw new InvalidLookupKeyException(strtr('%entity_type lookup key %key ends with a wildcard this can not be used as a lookup', [ + '%entity_type' => $entity_type->id(), + '%key' => $key, + ])); } $parts = explode('.*', $key); // Remove leading dots. diff --git a/core/lib/Drupal/Core/Config/Importer/ConfigImporterBatch.php b/core/lib/Drupal/Core/Config/Importer/ConfigImporterBatch.php index 274e68173750..c401c3ae472d 100644 --- a/core/lib/Drupal/Core/Config/Importer/ConfigImporterBatch.php +++ b/core/lib/Drupal/Core/Config/Importer/ConfigImporterBatch.php @@ -70,7 +70,10 @@ public static function finish($success, $results, $operations) { // An error occurred. // $operations contains the operations that remained unprocessed. $error_operation = reset($operations); - $message = t('An error occurred while processing %error_operation with arguments: @arguments', ['%error_operation' => $error_operation[0], '@arguments' => print_r($error_operation[1], TRUE)]); + $message = t('An error occurred while processing %error_operation with arguments: @arguments', [ + '%error_operation' => $error_operation[0], + '@arguments' => print_r($error_operation[1], TRUE), + ]); $messenger->addError($message); } } diff --git a/core/lib/Drupal/Core/Database/Install/Tasks.php b/core/lib/Drupal/Core/Database/Install/Tasks.php index ce74667f9ebb..42d8a0dfce04 100644 --- a/core/lib/Drupal/Core/Database/Install/Tasks.php +++ b/core/lib/Drupal/Core/Database/Install/Tasks.php @@ -240,7 +240,11 @@ protected function checkEngineVersion() { // them or not. // @see https://www.php.net/manual/en/function.version-compare.php if ($this->minimumVersion() && version_compare(Database::getConnection()->version(), $this->minimumVersion() . '-AnyName', '<')) { - $this->fail($this->t("The database server version %version is less than the minimum required version %minimum_version.", ['%version' => Database::getConnection()->version(), '%minimum_version' => $this->minimumVersion()])); + $this->fail($this->t("The database server version %version is less than the minimum required version %minimum_version.", [ + '%version' => Database::getConnection() + ->version(), + '%minimum_version' => $this->minimumVersion(), + ])); } } diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 3082c0a6989a..78b728ebb83f 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -845,7 +845,14 @@ public function updateModules(array $module_list, array $module_filenames = []) * The cache key used for the service container. */ protected function getContainerCacheKey() { - $parts = ['service_container', $this->environment, \Drupal::VERSION, Settings::get('deployment_identifier'), PHP_OS, serialize(Settings::get('container_yamls'))]; + $parts = [ + 'service_container', + $this->environment, + \Drupal::VERSION, + Settings::get('deployment_identifier'), + PHP_OS, + serialize(Settings::get('container_yamls')), + ]; return implode(':', $parts); } diff --git a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php index dd9ad04534de..132aaa439974 100644 --- a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php +++ b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php @@ -258,7 +258,10 @@ public static function validateEntityAutocomplete(array &$element, FormStateInte $valid_ids = $handler->validateReferenceableEntities($ids); if ($invalid_ids = array_diff($ids, $valid_ids)) { foreach ($invalid_ids as $invalid_id) { - $form_state->setError($element, t('The referenced entity (%type: %id) does not exist.', ['%type' => $element['#target_type'], '%id' => $invalid_id])); + $form_state->setError($element, t('The referenced entity (%type: %id) does not exist.', [ + '%type' => $element['#target_type'], + '%id' => $invalid_id, + ])); } } } @@ -284,7 +287,10 @@ public static function validateEntityAutocomplete(array &$element, FormStateInte foreach ($invalid_new_entities as $entity) { /** @var \Drupal\Core\Entity\EntityInterface $entity */ - $form_state->setError($element, t('This entity (%type: %label) cannot be referenced.', ['%type' => $element['#target_type'], '%label' => $entity->label()])); + $form_state->setError($element, t('This entity (%type: %label) cannot be referenced.', [ + '%type' => $element['#target_type'], + '%label' => $entity->label(), + ])); } } } diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index 5751b5f446be..a23a97a570d4 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -396,7 +396,13 @@ public function getHighestWeight() { } // Let other modules feedback about their own additions. - $weights = array_merge($weights, \Drupal::moduleHandler()->invokeAll('field_info_max_weight', [$this->targetEntityType, $this->bundle, $this->displayContext, $this->mode])); + $weights = array_merge($weights, + \Drupal::moduleHandler()->invokeAll('field_info_max_weight', [ + $this->targetEntityType, + $this->bundle, + $this->displayContext, + $this->mode, + ])); return $weights ? max($weights) : NULL; } diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayRepository.php b/core/lib/Drupal/Core/Entity/EntityDisplayRepository.php index 18f86bb68669..a738e875e1d7 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayRepository.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayRepository.php @@ -116,7 +116,10 @@ protected function getAllDisplayModesByEntityType($display_type) { $this->displayModeInfo[$display_type][$display_mode_entity_type][$display_mode_name] = $display_mode->toArray(); } $this->moduleHandler->alter($key, $this->displayModeInfo[$display_type]); - $this->cacheSet("$key:$langcode", $this->displayModeInfo[$display_type], CacheBackendInterface::CACHE_PERMANENT, ['entity_types', 'entity_field_info']); + $this->cacheSet("$key:$langcode", $this->displayModeInfo[$display_type], CacheBackendInterface::CACHE_PERMANENT, [ + 'entity_types', + 'entity_field_info', + ]); } } diff --git a/core/lib/Drupal/Core/Entity/EntityFieldManager.php b/core/lib/Drupal/Core/Entity/EntityFieldManager.php index 29d96b24bc54..9788fb9c5d95 100644 --- a/core/lib/Drupal/Core/Entity/EntityFieldManager.php +++ b/core/lib/Drupal/Core/Entity/EntityFieldManager.php @@ -194,7 +194,10 @@ public function getBaseFieldDefinitions($entity_type_id) { else { // Rebuild the definitions and put it into the cache. $this->baseFieldDefinitions[$entity_type_id] = $this->buildBaseFieldDefinitions($entity_type_id); - $this->cacheSet($cid, $this->baseFieldDefinitions[$entity_type_id], Cache::PERMANENT, ['entity_types', 'entity_field_info']); + $this->cacheSet($cid, $this->baseFieldDefinitions[$entity_type_id], Cache::PERMANENT, [ + 'entity_types', + 'entity_field_info', + ]); } } return $this->baseFieldDefinitions[$entity_type_id]; diff --git a/core/lib/Drupal/Core/Entity/EntityForm.php b/core/lib/Drupal/Core/Entity/EntityForm.php index 6e3043bd1d96..132377c1bf8e 100644 --- a/core/lib/Drupal/Core/Entity/EntityForm.php +++ b/core/lib/Drupal/Core/Entity/EntityForm.php @@ -304,7 +304,12 @@ public function buildEntity(array $form, FormStateInterface $form_state) { // properties. if (isset($form['#entity_builders'])) { foreach ($form['#entity_builders'] as $function) { - call_user_func_array($form_state->prepareCallback($function), [$entity->getEntityTypeId(), $entity, &$form, &$form_state]); + call_user_func_array($form_state->prepareCallback($function), [ + $entity->getEntityTypeId(), + $entity, + &$form, + &$form_state, + ]); } } diff --git a/core/lib/Drupal/Core/Entity/EntityLastInstalledSchemaRepository.php b/core/lib/Drupal/Core/Entity/EntityLastInstalledSchemaRepository.php index 9f75e2d9aa9f..97ce41e75c63 100644 --- a/core/lib/Drupal/Core/Entity/EntityLastInstalledSchemaRepository.php +++ b/core/lib/Drupal/Core/Entity/EntityLastInstalledSchemaRepository.php @@ -105,7 +105,10 @@ public function deleteLastInstalledDefinition($entity_type_id) { // isn't currently fieldable, there might be legacy definitions or an // empty array stored from when it was. $this->keyValueFactory->get('entity.definitions.installed')->delete($entity_type_id . '.field_storage_definitions'); - $this->cacheBackend->deleteMultiple(['entity_type_definitions.installed', $entity_type_id . '.field_storage_definitions.installed']); + $this->cacheBackend->deleteMultiple([ + 'entity_type_definitions.installed', + $entity_type_id . '.field_storage_definitions.installed', + ]); $this->entityTypeDefinitions = NULL; return $this; } diff --git a/core/lib/Drupal/Core/Entity/EntityListBuilder.php b/core/lib/Drupal/Core/Entity/EntityListBuilder.php index 1eb4fc78caf7..767b85e08b63 100644 --- a/core/lib/Drupal/Core/Entity/EntityListBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityListBuilder.php @@ -155,7 +155,10 @@ protected function getDefaultOperations(EntityInterface $entity) { $label = $this->t('Edit @entity_label', ['@entity_label' => $entity->label()]); } else { - $label = $this->t('Edit @entity_bundle @entity_id', ['@entity_bundle' => $entity->bundle(), '@entity_id' => $entity->id()]); + $label = $this->t('Edit @entity_bundle @entity_id', [ + '@entity_bundle' => $entity->bundle(), + '@entity_id' => $entity->id(), + ]); } $attributes = $edit_url->getOption('attributes') ?: []; $attributes += ['aria-label' => $label]; @@ -173,7 +176,10 @@ protected function getDefaultOperations(EntityInterface $entity) { $label = $this->t('Delete @entity_label', ['@entity_label' => $entity->label()]); } else { - $label = $this->t('Delete @entity_bundle @entity_id', ['@entity_bundle' => $entity->bundle(), '@entity_id' => $entity->id()]); + $label = $this->t('Delete @entity_bundle @entity_id', [ + '@entity_bundle' => $entity->bundle(), + '@entity_id' => $entity->id(), + ]); } $attributes = $delete_url->getOption('attributes') ?: []; $attributes += ['aria-label' => $label]; diff --git a/core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php b/core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php index 0d763133855d..93a7bc6e2700 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php @@ -108,7 +108,10 @@ public function getAllBundleInfo() { } } $this->moduleHandler->alter('entity_bundle_info', $this->bundleInfo); - $this->cacheSet("entity_bundle_info:$langcode", $this->bundleInfo, Cache::PERMANENT, ['entity_types', 'entity_bundles']); + $this->cacheSet("entity_bundle_info:$langcode", $this->bundleInfo, Cache::PERMANENT, [ + 'entity_types', + 'entity_bundles', + ]); } } diff --git a/core/lib/Drupal/Core/Entity/Event/BundleConfigImportValidate.php b/core/lib/Drupal/Core/Entity/Event/BundleConfigImportValidate.php index 65933f026e7e..bc60ebc35b92 100644 --- a/core/lib/Drupal/Core/Entity/Event/BundleConfigImportValidate.php +++ b/core/lib/Drupal/Core/Entity/Event/BundleConfigImportValidate.php @@ -64,7 +64,12 @@ public function onConfigImporterValidate(ConfigImporterEvent $event) { ->execute(); if (!empty($entity_ids)) { $entity = $this->entityTypeManager->getStorage($entity_type_id)->load($bundle_id); - $event->getConfigImporter()->logError($this->t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', ['%entity_type' => $bundle_of_entity_type->getLabel(), '%bundle_label' => $bundle_of_entity_type->getBundleLabel(), '%bundle' => $entity->label()])); + $event->getConfigImporter() + ->logError($this->t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', [ + '%entity_type' => $bundle_of_entity_type->getLabel(), + '%bundle_label' => $bundle_of_entity_type->getBundleLabel(), + '%bundle' => $entity->label(), + ])); } } } diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php index 087ac1e1d246..6473a846133f 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php @@ -1378,7 +1378,11 @@ protected function initializeDataTable(ContentEntityTypeInterface $entity_type) 'description' => "The data table for $entity_type_id entities.", 'primary key' => [$id_key, $entity_type->getKey('langcode')], 'indexes' => [ - $entity_type_id . '__id__default_langcode__langcode' => [$id_key, $entity_type->getKey('default_langcode'), $entity_type->getKey('langcode')], + $entity_type_id . '__id__default_langcode__langcode' => [ + $id_key, + $entity_type->getKey('default_langcode'), + $entity_type->getKey('langcode'), + ], ], 'foreign keys' => [ $entity_type_id => [ @@ -1416,7 +1420,11 @@ protected function initializeRevisionDataTable(ContentEntityTypeInterface $entit 'description' => "The revision data table for $entity_type_id entities.", 'primary key' => [$revision_key, $entity_type->getKey('langcode')], 'indexes' => [ - $entity_type_id . '__id__default_langcode__langcode' => [$id_key, $entity_type->getKey('default_langcode'), $entity_type->getKey('langcode')], + $entity_type_id . '__id__default_langcode__langcode' => [ + $id_key, + $entity_type->getKey('default_langcode'), + $entity_type->getKey('langcode'), + ], ], 'foreign keys' => [ $entity_type_id => [ diff --git a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php index bc85f19ecaf1..a00d087e8347 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php @@ -162,7 +162,10 @@ protected function validateModules(ConfigImporter $config_importer) { if ($module_data[$dependent_module]->status && !in_array($dependent_module, $uninstalls, TRUE) && $dependent_module !== $install_profile) { $module_name = $module_data[$module]->info['name']; $dependent_module_name = $module_data[$dependent_module]->info['name']; - $config_importer->logError($this->t('Unable to uninstall the %module module since the %dependent_module module is installed.', ['%module' => $module_name, '%dependent_module' => $dependent_module_name])); + $config_importer->logError($this->t('Unable to uninstall the %module module since the %dependent_module module is installed.', [ + '%module' => $module_name, + '%dependent_module' => $dependent_module_name, + ])); } } // Ensure that modules can be uninstalled. @@ -209,14 +212,20 @@ protected function validateThemes(ConfigImporter $config_importer) { if (!isset($core_extension['theme'][$required_theme])) { $theme_name = $theme_data[$theme]->info['name']; $required_theme_name = $theme_data[$required_theme]->info['name']; - $config_importer->logError($this->t('Unable to install the %theme theme since it requires the %required_theme theme.', ['%theme' => $theme_name, '%required_theme' => $required_theme_name])); + $config_importer->logError($this->t('Unable to install the %theme theme since it requires the %required_theme theme.', [ + '%theme' => $theme_name, + '%required_theme' => $required_theme_name, + ])); } } foreach (array_keys($module_dependencies) as $required_module) { if (!isset($core_extension['module'][$required_module])) { $theme_name = $theme_data[$theme]->info['name']; $required_module_name = $module_data[$required_module]->info['name']; - $config_importer->logError($this->t('Unable to install the %theme theme since it requires the %required_module module.', ['%theme' => $theme_name, '%required_module' => $required_module_name])); + $config_importer->logError($this->t('Unable to install the %theme theme since it requires the %required_module module.', [ + '%theme' => $theme_name, + '%required_module' => $required_module_name, + ])); } } } @@ -229,7 +238,10 @@ protected function validateThemes(ConfigImporter $config_importer) { if ($theme_data[$dependent_theme]->status && !in_array($dependent_theme, $uninstalls, TRUE)) { $theme_name = $theme_data[$theme]->info['name']; $dependent_theme_name = $theme_data[$dependent_theme]->info['name']; - $config_importer->logError($this->t('Unable to uninstall the %theme theme since the %dependent_theme theme is installed.', ['%theme' => $theme_name, '%dependent_theme' => $dependent_theme_name])); + $config_importer->logError($this->t('Unable to uninstall the %theme theme since the %dependent_theme theme is installed.', [ + '%theme' => $theme_name, + '%dependent_theme' => $dependent_theme_name, + ])); } } } diff --git a/core/lib/Drupal/Core/Field/FieldFilteredMarkup.php b/core/lib/Drupal/Core/Field/FieldFilteredMarkup.php index 0e11196ba791..a0ed7a69fd26 100644 --- a/core/lib/Drupal/Core/Field/FieldFilteredMarkup.php +++ b/core/lib/Drupal/Core/Field/FieldFilteredMarkup.php @@ -56,7 +56,30 @@ public static function create($string) { * A list of allowed tags. */ public static function allowedTags() { - return ['a', 'b', 'big', 'code', 'del', 'em', 'i', 'ins', 'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img']; + return [ + 'a', + 'b', + 'big', + 'code', + 'del', + 'em', + 'i', + 'ins', + 'pre', + 'q', + 'small', + 'span', + 'strong', + 'sub', + 'sup', + 'tt', + 'ol', + 'ul', + 'li', + 'p', + 'br', + 'img', + ]; } /** diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index 8a1aecd73227..eb67000a61b2 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -267,7 +267,10 @@ public function getConstraints() { if ($cardinality != FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) { $options['max'] = $cardinality; if ($label = $this->getFieldDefinition()->getLabel()) { - $options['maxMessage'] = $this->t('%name: this field cannot hold more than @count values.', ['%name' => $label, '@count' => $cardinality]); + $options['maxMessage'] = $this->t('%name: this field cannot hold more than @count values.', [ + '%name' => $label, + '@count' => $cardinality, + ]); } $constraints[] = $this->getTypedDataManager() ->getValidationConstraintManager() diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php index 15a91041aebf..c93c0440e649 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/BooleanFormatter.php @@ -68,10 +68,16 @@ public function settingsForm(array $form, FormStateInterface $form_state) { foreach ($this->getOutputFormats() as $format_name => $format) { if (is_array($format)) { if ($format_name == 'default') { - $formats[$format_name] = $this->t('Field settings (@on_label / @off_label)', ['@on_label' => $format[0], '@off_label' => $format[1]]); + $formats[$format_name] = $this->t('Field settings (@on_label / @off_label)', [ + '@on_label' => $format[0], + '@off_label' => $format[1], + ]); } else { - $formats[$format_name] = $this->t('@on_label / @off_label', ['@on_label' => $format[0], '@off_label' => $format[1]]); + $formats[$format_name] = $this->t('@on_label / @off_label', [ + '@on_label' => $format[0], + '@off_label' => $format[1], + ]); } } else { diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php index aaeb0adf65f3..502b5e627bb1 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php @@ -125,7 +125,10 @@ public function settingsForm(array $form, FormStateInterface $form_state) { $date_formats = []; $requestTime = $this->time->getRequestTime(); foreach ($this->dateFormatStorage->loadMultiple() as $machine_name => $value) { - $date_formats[$machine_name] = $this->t('@name format: @date', ['@name' => $value->label(), '@date' => $this->dateFormatter->format($requestTime, $machine_name)]); + $date_formats[$machine_name] = $this->t('@name format: @date', [ + '@name' => $value->label(), + '@date' => $this->dateFormatter->format($requestTime, $machine_name), + ]); } $date_formats[static::CUSTOM_DATE_FORMAT] = $this->t('Custom'); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php index 75163e6f2c8a..cbe14fab7378 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php @@ -62,7 +62,10 @@ public function getConstraints() { $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); $options['max'] = $max_length; if ($label = $this->getFieldDefinition()->getLabel()) { - $options['maxMessage'] = $this->t('%name: may not be longer than @max characters.', ['%name' => $label, '@max' => $max_length]); + $options['maxMessage'] = $this->t('%name: may not be longer than @max characters.', [ + '%name' => $label, + '@max' => $max_length, + ]); } $constraints[] = $constraint_manager->create('ComplexData', [ 'value' => [ diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php index fd21961935c1..d130563c7067 100644 --- a/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -153,7 +153,10 @@ public function form(FieldItemListInterface $items, array &$form, FormStateInter 'items' => $items, 'default' => $this->isDefaultValueWidget($form_state), ]; - \Drupal::moduleHandler()->alter(['field_widget_complete_form', 'field_widget_complete_' . $this->getPluginId() . '_form'], $field_widget_complete_form, $form_state, $context); + \Drupal::moduleHandler()->alter([ + 'field_widget_complete_form', + 'field_widget_complete_' . $this->getPluginId() . '_form', + ], $field_widget_complete_form, $form_state, $context); return $field_widget_complete_form; } @@ -468,7 +471,10 @@ protected function formSingleElement(FieldItemListInterface $items, $delta, arra 'delta' => $delta, 'default' => $this->isDefaultValueWidget($form_state), ]; - \Drupal::moduleHandler()->alter(['field_widget_single_element_form', 'field_widget_single_element_' . $this->getPluginId() . '_form'], $element, $form_state, $context); + \Drupal::moduleHandler()->alter([ + 'field_widget_single_element_form', + 'field_widget_single_element_' . $this->getPluginId() . '_form', + ], $element, $form_state, $context); } return $element; diff --git a/core/lib/Drupal/Core/File/HtaccessWriter.php b/core/lib/Drupal/Core/File/HtaccessWriter.php index 26eeb17d7c80..c91510e63dc1 100644 --- a/core/lib/Drupal/Core/File/HtaccessWriter.php +++ b/core/lib/Drupal/Core/File/HtaccessWriter.php @@ -94,7 +94,10 @@ public function write($directory, $deny_public_access = TRUE, $force_overwrite = return TRUE; } - $this->logger->error("Security warning: Couldn't write .htaccess file. Create a .htaccess file in your %directory directory which contains the following lines: <pre><code>@htaccess</code></pre>", ['%directory' => $directory, '@htaccess' => FileSecurity::htaccessLines($deny_public_access)]); + $this->logger->error("Security warning: Couldn't write .htaccess file. Create a .htaccess file in your %directory directory which contains the following lines: <pre><code>@htaccess</code></pre>", [ + '%directory' => $directory, + '@htaccess' => FileSecurity::htaccessLines($deny_public_access), + ]); return FALSE; } diff --git a/core/lib/Drupal/Core/FileTransfer/FTPExtension.php b/core/lib/Drupal/Core/FileTransfer/FTPExtension.php index 8a23d701bf35..eb1c6fa46ae4 100644 --- a/core/lib/Drupal/Core/FileTransfer/FTPExtension.php +++ b/core/lib/Drupal/Core/FileTransfer/FTPExtension.php @@ -26,7 +26,10 @@ public function connect() { */ protected function copyFileJailed($source, $destination) { if (!@ftp_put($this->connection, $destination, $source, FTP_BINARY)) { - throw new FileTransferException("Cannot move @source to @destination", 0, ["@source" => $source, "@destination" => $destination]); + throw new FileTransferException("Cannot move @source to @destination", 0, [ + "@source" => $source, + "@destination" => $destination, + ]); } } diff --git a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php index 548f1159673d..b856b58fec79 100644 --- a/core/lib/Drupal/Core/FileTransfer/FileTransfer.php +++ b/core/lib/Drupal/Core/FileTransfer/FileTransfer.php @@ -268,7 +268,10 @@ final protected function checkPath($path) { ->realpath(substr($this->chroot . $path, 0, strlen($full_jail))); $full_path = $this->fixRemotePath($full_path, FALSE); if ($full_jail !== $full_path) { - throw new FileTransferException('@directory is outside of the @jail', 0, ['@directory' => $path, '@jail' => $this->jail]); + throw new FileTransferException('@directory is outside of the @jail', 0, [ + '@directory' => $path, + '@jail' => $this->jail, + ]); } } diff --git a/core/lib/Drupal/Core/FileTransfer/Local.php b/core/lib/Drupal/Core/FileTransfer/Local.php index 791f01a4fc3e..a622917bca8e 100644 --- a/core/lib/Drupal/Core/FileTransfer/Local.php +++ b/core/lib/Drupal/Core/FileTransfer/Local.php @@ -46,7 +46,10 @@ public static function factory($jail, $settings) { */ protected function copyFileJailed($source, $destination) { if (@!copy($source, $destination)) { - throw new FileTransferException('Cannot copy %source to %destination.', 0, ['%source' => $source, '%destination' => $destination]); + throw new FileTransferException('Cannot copy %source to %destination.', 0, [ + '%source' => $source, + '%destination' => $destination, + ]); } } diff --git a/core/lib/Drupal/Core/FileTransfer/SSH.php b/core/lib/Drupal/Core/FileTransfer/SSH.php index 3fd719021317..c7533994f93d 100644 --- a/core/lib/Drupal/Core/FileTransfer/SSH.php +++ b/core/lib/Drupal/Core/FileTransfer/SSH.php @@ -24,7 +24,10 @@ public function __construct($jail, $username, #[\SensitiveParameter] $password, public function connect() { $this->connection = @ssh2_connect($this->hostname, $this->port); if (!$this->connection) { - throw new FileTransferException('SSH Connection failed to @host:@port', 0, ['@host' => $this->hostname, '@port' => $this->port]); + throw new FileTransferException('SSH Connection failed to @host:@port', 0, [ + '@host' => $this->hostname, + '@port' => $this->port, + ]); } if (!@ssh2_auth_password($this->connection, $this->username, $this->password)) { throw new FileTransferException('The supplied username/password combination was not accepted.'); @@ -47,7 +50,10 @@ public static function factory($jail, $settings) { */ protected function copyFileJailed($source, $destination) { if (!@ssh2_scp_send($this->connection, $source, $destination)) { - throw new FileTransferException('Cannot copy @source_file to @destination_file.', 0, ['@source' => $source, '@destination' => $destination]); + throw new FileTransferException('Cannot copy @source_file to @destination_file.', 0, [ + '@source' => $source, + '@destination' => $destination, + ]); } } diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index cf47614b1818..ee3e4893feca 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -1007,7 +1007,11 @@ public function doBuildForm($form_id, &$element, FormStateInterface &$form_state if (isset($element['#process']) && !$element['#processed']) { foreach ($element['#process'] as $callback) { $complete_form = &$form_state->getCompleteForm(); - $element = call_user_func_array($form_state->prepareCallback($callback), [&$element, &$form_state, &$complete_form]); + $element = call_user_func_array($form_state->prepareCallback($callback), [ + &$element, + &$form_state, + &$complete_form, + ]); } $element['#processed'] = TRUE; } diff --git a/core/lib/Drupal/Core/Form/FormSubmitter.php b/core/lib/Drupal/Core/Form/FormSubmitter.php index a6c5c85f1d1b..0cc07f61201a 100644 --- a/core/lib/Drupal/Core/Form/FormSubmitter.php +++ b/core/lib/Drupal/Core/Form/FormSubmitter.php @@ -128,7 +128,10 @@ public function redirectForm(FormStateInterface $form_state) { // If no redirect was specified, redirect to the current path. elseif ($redirect === NULL) { $request = $this->requestStack->getCurrentRequest(); - $url = $this->urlGenerator->generateFromRoute('<current>', [], ['query' => $request->query->all(), 'absolute' => TRUE]); + $url = $this->urlGenerator->generateFromRoute('<current>', [], [ + 'query' => $request->query->all(), + 'absolute' => TRUE, + ]); } if ($url) { diff --git a/core/lib/Drupal/Core/Form/FormValidator.php b/core/lib/Drupal/Core/Form/FormValidator.php index cdab87663db0..d361271bf4d1 100644 --- a/core/lib/Drupal/Core/Form/FormValidator.php +++ b/core/lib/Drupal/Core/Form/FormValidator.php @@ -331,7 +331,11 @@ protected function doValidateForm(&$elements, FormStateInterface &$form_state, $ protected function performRequiredValidation(&$elements, FormStateInterface &$form_state) { // Verify that the value is not longer than #maxlength. if (isset($elements['#maxlength']) && mb_strlen($elements['#value']) > $elements['#maxlength']) { - $form_state->setError($elements, $this->t('@name cannot be longer than %max characters but is currently %length characters long.', ['@name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], '%max' => $elements['#maxlength'], '%length' => mb_strlen($elements['#value'])])); + $form_state->setError($elements, $this->t('@name cannot be longer than %max characters but is currently %length characters long.', [ + '@name' => empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'], + '%max' => $elements['#maxlength'], + '%length' => mb_strlen($elements['#value']), + ])); } if (isset($elements['#options']) && isset($elements['#value'])) { diff --git a/core/lib/Drupal/Core/Image/Image.php b/core/lib/Drupal/Core/Image/Image.php index f1fb28ddd32c..e61ff1be706c 100644 --- a/core/lib/Drupal/Core/Image/Image.php +++ b/core/lib/Drupal/Core/Image/Image.php @@ -146,7 +146,12 @@ public function apply($operation, array $arguments = []) { * {@inheritdoc} */ public function createNew($width, $height, $extension = 'png', $transparent_color = '#ffffff') { - return $this->apply('create_new', ['width' => $width, 'height' => $height, 'extension' => $extension, 'transparent_color' => $transparent_color]); + return $this->apply('create_new', [ + 'width' => $width, + 'height' => $height, + 'extension' => $extension, + 'transparent_color' => $transparent_color, + ]); } /** diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php index b603bd1fd99a..60d5618c8fd9 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php @@ -124,7 +124,10 @@ public function apply($operation, array $arguments = []) { return $this->getToolkitOperation($operation)->apply($arguments); } catch (PluginNotFoundException) { - $this->logger->error("The selected image handling toolkit '@toolkit' can not process operation '@operation'.", ['@toolkit' => $this->getPluginId(), '@operation' => $operation]); + $this->logger->error("The selected image handling toolkit '@toolkit' can not process operation '@operation'.", [ + '@toolkit' => $this->getPluginId(), + '@operation' => $operation, + ]); return FALSE; } catch (\Throwable $t) { diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php index 8fc2b8987db4..fab6b6f24d4d 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitOperationManager.php @@ -99,7 +99,10 @@ function ($definition) use ($toolkit_id, $operation) { return $this->getToolkitOperationPluginId($base_toolkit, $operation); } - $message = new FormattableMarkup("No image operation plugin for '@toolkit' toolkit and '@operation' operation.", ['@toolkit' => $toolkit_id, '@operation' => $operation]); + $message = new FormattableMarkup("No image operation plugin for '@toolkit' toolkit and '@operation' operation.", [ + '@toolkit' => $toolkit_id, + '@operation' => $operation, + ]); throw new PluginNotFoundException($toolkit_id . '.' . $operation, $message); } else { diff --git a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php index 16ad0ccede86..427a0999ca1e 100644 --- a/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php @@ -98,7 +98,12 @@ public function buildForm(array $form, FormStateInterface $form_state) { // successfully.) $post_params = $this->getRequest()->request->all(); if (empty($post_params) && (Settings::get('skip_permissions_hardening') || !drupal_verify_install_file($this->root . '/' . $settings_file, FILE_EXIST | FILE_READABLE | FILE_NOT_WRITABLE) || !drupal_verify_install_file($this->root . '/' . $settings_dir, FILE_NOT_WRITABLE, 'dir'))) { - $this->messenger()->addWarning($this->t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href=":handbook_url">online handbook</a>.', ['%dir' => $settings_dir, '%file' => $settings_file, ':handbook_url' => 'https://www.drupal.org/server-permissions'])); + $this->messenger() + ->addWarning($this->t('All necessary changes to %dir and %file have been made, so you should remove write permissions to them now in order to avoid security risks. If you are unsure how to do so, consult the <a href=":handbook_url">online handbook</a>.', [ + '%dir' => $settings_dir, + '%file' => $settings_file, + ':handbook_url' => 'https://www.drupal.org/server-permissions', + ])); } $form['#attached']['library'][] = 'system/drupal.system'; diff --git a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php index 4f3ae72090ba..ea5247bc750b 100644 --- a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php +++ b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php @@ -80,7 +80,12 @@ public function has($key) { public function getMultiple(array $keys) { $values = []; try { - $result = $this->connection->query('SELECT [name], [value] FROM {' . $this->connection->escapeTable($this->table) . '} WHERE [name] IN ( :keys[] ) AND [collection] = :collection', [':keys[]' => $keys, ':collection' => $this->collection])->fetchAllAssoc('name'); + $result = $this->connection + ->query('SELECT [name], [value] FROM {' . $this->connection->escapeTable($this->table) . '} WHERE [name] IN ( :keys[] ) AND [collection] = :collection', [ + ':keys[]' => $keys, + ':collection' => $this->collection, + ]) + ->fetchAllAssoc('name'); foreach ($keys as $key) { if (isset($result[$key])) { $values[$key] = $this->serializer->decode($result[$key]->value); diff --git a/core/lib/Drupal/Core/Mail/MailFormatHelper.php b/core/lib/Drupal/Core/Mail/MailFormatHelper.php index 2d6a72db3f07..260174eca748 100644 --- a/core/lib/Drupal/Core/Mail/MailFormatHelper.php +++ b/core/lib/Drupal/Core/Mail/MailFormatHelper.php @@ -64,7 +64,10 @@ public static function wrapMail($text, $indent = '') { $text = preg_replace('/(?(?<!^--) +\n| +\n)/m', "\n", $text); // Wrap each line at the needed width. $lines = explode("\n", $text); - array_walk($lines, '\Drupal\Core\Mail\MailFormatHelper::wrapMailLine', ['soft' => $soft, 'length' => strlen($indent)]); + array_walk($lines, '\Drupal\Core\Mail\MailFormatHelper::wrapMailLine', [ + 'soft' => $soft, + 'length' => strlen($indent), + ]); $text = implode("\n", $lines); } else { diff --git a/core/lib/Drupal/Core/Render/Element/Number.php b/core/lib/Drupal/Core/Render/Element/Number.php index bfc356689369..7096b2925beb 100644 --- a/core/lib/Drupal/Core/Render/Element/Number.php +++ b/core/lib/Drupal/Core/Render/Element/Number.php @@ -74,12 +74,18 @@ public static function validateNumber(&$element, FormStateInterface $form_state, // Ensure that the input is greater than the #min property, if set. if (isset($element['#min']) && $value < $element['#min']) { - $form_state->setError($element, t('%name must be higher than or equal to %min.', ['%name' => $name, '%min' => $element['#min']])); + $form_state->setError($element, t('%name must be higher than or equal to %min.', [ + '%name' => $name, + '%min' => $element['#min'], + ])); } // Ensure that the input is less than the #max property, if set. if (isset($element['#max']) && $value > $element['#max']) { - $form_state->setError($element, t('%name must be lower than or equal to %max.', ['%name' => $name, '%max' => $element['#max']])); + $form_state->setError($element, t('%name must be lower than or equal to %max.', [ + '%name' => $name, + '%max' => $element['#max'], + ])); } if (isset($element['#step']) && strtolower($element['#step']) != 'any') { diff --git a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php index 4e0ccfadc316..85cfb77a8fe8 100644 --- a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php +++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php @@ -102,7 +102,16 @@ public function processAttachments(AttachmentsInterface $response) { // Send a message back if the render array has unsupported #attached types. $unsupported_types = array_diff( array_keys($attached), - ['html_head', 'feed', 'html_head_link', 'http_header', 'library', 'html_response_attachment_placeholders', 'placeholders', 'drupalSettings'] + [ + 'html_head', + 'feed', + 'html_head_link', + 'http_header', + 'library', + 'html_response_attachment_placeholders', + 'placeholders', + 'drupalSettings', + ] ); if (!empty($unsupported_types)) { throw new \LogicException(sprintf('You are not allowed to use %s in #attached.', implode(', ', $unsupported_types))); diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php index e4c7c836fda1..20cc4df72083 100644 --- a/core/lib/Drupal/Core/Routing/UrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -87,7 +87,13 @@ class UrlGenerator implements UrlGeneratorInterface { * @param string[] $filter_protocols * (optional) An array of protocols allowed for URL generation. */ - public function __construct(RouteProviderInterface $provider, OutboundPathProcessorInterface $path_processor, OutboundRouteProcessorInterface $route_processor, RequestStack $request_stack, array $filter_protocols = ['http', 'https']) { + public function __construct( + RouteProviderInterface $provider, + OutboundPathProcessorInterface $path_processor, + OutboundRouteProcessorInterface $route_processor, + RequestStack $request_stack, + array $filter_protocols = ['http', 'https'], + ) { $this->provider = $provider; $this->context = new RequestContext(); diff --git a/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php b/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php index a6fd8bee4f41..138db63bb1ef 100644 --- a/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php @@ -49,7 +49,11 @@ public function getDirectoryPath() { */ public function getExternalUrl() { $path = str_replace('\\', '/', $this->getTarget()); - return Url::fromRoute('system.private_file_download', ['filepath' => $path], ['absolute' => TRUE, 'path_processing' => FALSE])->toString(); + return Url::fromRoute( + 'system.private_file_download', + ['filepath' => $path], + ['absolute' => TRUE, 'path_processing' => FALSE] + )->toString(); } /** diff --git a/core/lib/Drupal/Core/Template/ComponentNodeVisitor.php b/core/lib/Drupal/Core/Template/ComponentNodeVisitor.php index 8995307c76fd..61c64c74a357 100644 --- a/core/lib/Drupal/Core/Template/ComponentNodeVisitor.php +++ b/core/lib/Drupal/Core/Template/ComponentNodeVisitor.php @@ -62,7 +62,10 @@ public function leaveNode(Node $node, Environment $env): ?Node { $line ), $line); $print_nodes[] = new PrintNode(new FunctionExpression( - new TwigFunction('add_component_context', [$env->getExtension(ComponentsTwigExtension::class), 'addAdditionalContext'], ['needs_context' => TRUE]), + new TwigFunction('add_component_context', [ + $env->getExtension(ComponentsTwigExtension::class), + 'addAdditionalContext', + ], ['needs_context' => TRUE]), new Nodes([new ConstantExpression($component_id, $line)]), $line ), $line); diff --git a/core/lib/Drupal/Core/Template/DebugExtension.php b/core/lib/Drupal/Core/Template/DebugExtension.php index a6cabed13fa7..bbe22ea1ef0a 100644 --- a/core/lib/Drupal/Core/Template/DebugExtension.php +++ b/core/lib/Drupal/Core/Template/DebugExtension.php @@ -30,7 +30,15 @@ public function getFunctions(): array { // @see \Symfony\Component\VarDumper\VarDumper if (class_exists(self::SYMFONY_VAR_DUMPER_CLASS)) { return [ - new TwigFunction('dump', [self::class, 'dump'], ['needs_context' => TRUE, 'needs_environment' => TRUE, 'is_variadic' => TRUE]), + new TwigFunction( + 'dump', + [self::class, 'dump'], + [ + 'needs_context' => TRUE, + 'needs_environment' => TRUE, + 'is_variadic' => TRUE, + ] + ), ]; } diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php index 20472ec4f5fa..5afa135d0268 100644 --- a/core/lib/Drupal/Core/Template/TwigExtension.php +++ b/core/lib/Drupal/Core/Template/TwigExtension.php @@ -128,7 +128,14 @@ public function getFilters() { new TwigFilter('placeholder', [$this, 'escapePlaceholder'], ['is_safe' => ['html'], 'needs_environment' => TRUE]), // Replace twig's escape filter with our own. - new TwigFilter('drupal_escape', [$this, 'escapeFilter'], ['needs_environment' => TRUE, 'is_safe_callback' => 'twig_escape_filter_is_safe']), + new TwigFilter( + 'drupal_escape', + [$this, 'escapeFilter'], + [ + 'needs_environment' => TRUE, + 'is_safe_callback' => 'twig_escape_filter_is_safe', + ] + ), // Implements safe joining. // @todo Make that the default for |join? Upstream issue: diff --git a/core/lib/Drupal/Core/Test/AssertMailTrait.php b/core/lib/Drupal/Core/Test/AssertMailTrait.php index 80b74b52242e..d87eee04c07f 100644 --- a/core/lib/Drupal/Core/Test/AssertMailTrait.php +++ b/core/lib/Drupal/Core/Test/AssertMailTrait.php @@ -97,7 +97,10 @@ protected function assertMailString($field_name, $string, $email_depth, $message } } if (!$message) { - $message = new FormattableMarkup('Expected text found in @field of email message: "@expected".', ['@field' => $field_name, '@expected' => $string]); + $message = new FormattableMarkup('Expected text found in @field of email message: "@expected".', [ + '@field' => $field_name, + '@expected' => $string, + ]); } $this->assertTrue($string_found, $message); } @@ -121,7 +124,10 @@ protected function assertMailPattern($field_name, $regex, $message = '') { $mail = end($mails); $regex_found = preg_match("/$regex/", $mail[$field_name]); if (!$message) { - $message = new FormattableMarkup('Expected text found in @field of email message: "@expected".', ['@field' => $field_name, '@expected' => $regex]); + $message = new FormattableMarkup('Expected text found in @field of email message: "@expected".', [ + '@field' => $field_name, + '@expected' => $regex, + ]); } $this->assertTrue((bool) $regex_found, $message); } diff --git a/core/lib/Drupal/Core/Updater/Updater.php b/core/lib/Drupal/Core/Updater/Updater.php index aaacf151dcfa..0aedfbe7628e 100644 --- a/core/lib/Drupal/Core/Updater/Updater.php +++ b/core/lib/Drupal/Core/Updater/Updater.php @@ -354,7 +354,10 @@ public function prepareInstallDirectory(&$filetransfer, $directory) { catch (FileTransferException $e) { // phpcs:ignore Drupal.Semantics.FunctionT.NotLiteralString $message = $this->t($e->getMessage(), $e->arguments); - $throw_message = $this->t('Unable to create %directory due to the following: %reason', ['%directory' => $directory, '%reason' => $message]); + $throw_message = $this->t('Unable to create %directory due to the following: %reason', [ + '%directory' => $directory, + '%reason' => $message, + ]); throw new UpdaterException($throw_message); } } diff --git a/core/lib/Drupal/Core/Utility/TableSort.php b/core/lib/Drupal/Core/Utility/TableSort.php index 8da534c27926..0c33ba513106 100644 --- a/core/lib/Drupal/Core/Utility/TableSort.php +++ b/core/lib/Drupal/Core/Utility/TableSort.php @@ -80,7 +80,10 @@ public static function header(&$cell_content, array &$cell_attributes, array $he $context['sort'] = $cell_attributes['initial_click_sort'] ?? self::ASC; $image = ''; } - $cell_content = Link::createFromRoute(new FormattableMarkup('@cell_content@image', ['@cell_content' => $cell_content, '@image' => $image]), '<current>', [], [ + $cell_content = Link::createFromRoute(new FormattableMarkup('@cell_content@image', [ + '@cell_content' => $cell_content, + '@image' => $image, + ]), '<current>', [], [ 'attributes' => ['title' => $title, 'rel' => 'nofollow'], 'query' => array_merge($context['query'], [ 'sort' => $context['sort'], diff --git a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php index b4746186bf34..f87d6affaa68 100644 --- a/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php +++ b/core/lib/Drupal/Core/Utility/UnroutedUrlAssembler.php @@ -39,7 +39,11 @@ class UnroutedUrlAssembler implements UnroutedUrlAssemblerInterface { * @param string[] $filter_protocols * (optional) An array of protocols allowed for URL generation. */ - public function __construct(RequestStack $request_stack, OutboundPathProcessorInterface $path_processor, array $filter_protocols = ['http', 'https']) { + public function __construct( + RequestStack $request_stack, + OutboundPathProcessorInterface $path_processor, + array $filter_protocols = ['http', 'https'], + ) { UrlHelper::setAllowedProtocols($filter_protocols); $this->requestStack = $request_stack; $this->pathProcessor = $path_processor; diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index ce479f525336..b603987bf358 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -31,6 +31,7 @@ <!-- Drupal sniffs --> <rule ref="Drupal.Arrays.Array"/> <rule ref="Drupal.Arrays.Array.LongLineDeclaration"> + <include-pattern>core/lib/*</include-pattern> <include-pattern>core/modules/*/tests/modules/*</include-pattern> </rule> <rule ref="Drupal.CSS.ClassDefinitionNameSpacing"/> -- GitLab