diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 6ec930dd3460b9f6a424eed16657ee8deb781747..ae29202ba90cbcdd0d9ed2584033a6baa860ed6d 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -174,7 +174,7 @@ function _drupal_log_error($error, $fatal = FALSE) { // implementations to use it. \Drupal::logger('php')->log($severity, '%type: @message in %function (line %line of %file) @backtrace_string.', $error + ['backtrace' => $backtrace, 'exception' => $exception, 'severity_level' => $severity]); } - catch (\Exception $e) { + catch (\Exception) { // We can't log, for example because the database connection is not // available. At least try to log to PHP error log. error_log(strtr('Failed to log error: ' . Error::DEFAULT_ERROR_MESSAGE . ' @backtrace_string', $error)); @@ -322,7 +322,7 @@ function _drupal_get_error_level() { try { $error_level = \Drupal::config('system.logging')->get('error_level'); } - catch (\Exception $e) { + catch (\Exception) { $error_level = $GLOBALS['config']['system.logging']['error_level'] ?? ERROR_REPORTING_HIDE; } diff --git a/core/includes/form.inc b/core/includes/form.inc index d6a2eb1c4c201f121dfd510ffef1f64e1e809812..98b6783ec1f86aa2d1463f079f33e13aedf56070 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -904,7 +904,7 @@ function batch_process($redirect = NULL, ?Url $url = NULL, $redirect_callback = try { $batch['id'] = $batch['progressive'] ? \Drupal::service(BatchStorageInterface::class)->getId() : 'non-progressive'; } - catch (IntegrityConstraintViolationException $e) { + catch (IntegrityConstraintViolationException) { // @todo this is here to support the update path to deprecate // Connection::nextId(). Remove in Drupal 11. $connection = \Drupal::database(); diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 80c45ac2251844222a6b25daeb367870a7061583..68ef6a2c81a219cd465c6bb4d2ef0100adb7f61a 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -385,7 +385,7 @@ function install_begin_request($class_loader, &$install_state) { $sync_directory = Settings::get('config_sync_directory', FALSE); $install_state['config_verified'] = file_exists($sync_directory); } - catch (Exception $e) { + catch (Exception) { $install_state['config_verified'] = FALSE; } $install_state['database_verified'] = install_verify_database_settings($site_path); @@ -399,7 +399,7 @@ function install_begin_request($class_loader, &$install_state) { $table = array_key_last($system_schema); $install_state['base_system_verified'] = Database::getConnection()->schema()->tableExists($table); } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // The last defined table of the base system_schema() does not exist yet. // $install_state['base_system_verified'] defaults to FALSE, so the code // following below will use the minimal installer service container. @@ -1142,7 +1142,7 @@ function install_verify_completed_task() { } // Do not trigger an error if the database query fails, since the database // might not be set up yet. - catch (\Exception $e) { + catch (\Exception) { } if (isset($task)) { if ($task == 'done') { @@ -1191,7 +1191,7 @@ function install_verify_database_ready() { } // Do not trigger an error if the database query fails, since the database // might not be set up yet. - catch (\Exception $e) { + catch (\Exception) { } } if ($existing_install) { @@ -1218,7 +1218,7 @@ function install_database_errors($database, $settings_file) { Database::addConnectionInfo('default', 'default', $database); $errors = $driverExtension->getInstallTasks()->runTasks(); } - catch (UnknownExtensionException $e) { + catch (UnknownExtensionException) { $errors['driver'] = t("In your %settings_file file you have configured @drupal to use a %driver server, however your PHP installation currently does not support this database type.", ['%settings_file' => $settings_file, '@drupal' => drupal_install_profile_distribution_name(), '%driver' => $database['driver']]); } return $errors; @@ -2401,7 +2401,7 @@ function install_config_import_batch() { return $batch_builder->toArray(); } - catch (ConfigImporterException $e) { + catch (ConfigImporterException) { global $install_state; // There are validation errors. $messenger = \Drupal::messenger(); @@ -2460,7 +2460,7 @@ function install_config_revert_install_changes() { try { $config_importer->import(); } - catch (ConfigImporterException $e) { + catch (ConfigImporterException) { $messenger = \Drupal::messenger(); // There are validation errors. $messenger->addError(t('The configuration synchronization failed validation.')); diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 1603c5c65de7661e9bcd544f6b72b84a2954fef4..8968147bdb900f027178e9ac4a8e72d5b9ceb047 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -233,7 +233,7 @@ function theme_get_setting($setting_name, $theme = NULL) { $cache[$theme]->merge($theme_settings); } } - catch (StorageException $e) { + catch (StorageException) { } // If the theme does not support a particular feature, override the global @@ -1245,7 +1245,7 @@ function template_preprocess_page(&$variables) { try { $variables['is_front'] = \Drupal::service('path.matcher')->isFrontPage(); } - catch (Exception $e) { + catch (Exception) { // If the database is not yet available, set default values for these // variables. $variables['is_front'] = FALSE; diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index c5f644405e2a0f2ba31f9255d70220392e8175fa..9138f742fd587db13725b51e3c72e31766dc6a86 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -46,7 +46,7 @@ function _drupal_maintenance_theme() { $custom_theme = $config->get('default'); } } - catch (\Exception $e) { + catch (\Exception) { // Whatever went wrong (often a database connection problem), we are // about to fall back to a sensible theme so there is no need for special // handling. diff --git a/core/includes/update.inc b/core/includes/update.inc index 5e8ccf9a1301e6421ccc9d44b1a765f638170166..e65da109dd6ed29eea34a9d09389e99f78d5caab 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -317,7 +317,7 @@ function update_get_update_list() { } // It is possible that the system schema has orphaned entries, so the // incompatibility checking might throw an exception. - catch (UnknownExtensionException $e) { + catch (UnknownExtensionException) { $args = [ '%name' => $module, ':url' => 'https://www.drupal.org/node/3137656', diff --git a/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php b/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php index 415079376fbf948379f32fa07372f15515e05824..1db14568a433c7fc2eae1d7f0d1f95f757287cb4 100644 --- a/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php +++ b/core/lib/Drupal/Component/PhpStorage/MTimeProtectedFastFileStorage.php @@ -158,7 +158,7 @@ public function garbageCollection() { try { $dir_iterator = new \FilesystemIterator($directory, $flags); } - catch (\UnexpectedValueException $e) { + catch (\UnexpectedValueException) { // FilesystemIterator throws an UnexpectedValueException if the // specified path is not a directory, or if it is not accessible. continue; diff --git a/core/lib/Drupal/Component/Plugin/PluginManagerBase.php b/core/lib/Drupal/Component/Plugin/PluginManagerBase.php index d8500f3456edac603904007d576fb24f88aeb061..7467915ea53f1fed668abe7e5624a3ffd16907e2 100644 --- a/core/lib/Drupal/Component/Plugin/PluginManagerBase.php +++ b/core/lib/Drupal/Component/Plugin/PluginManagerBase.php @@ -75,7 +75,7 @@ public function createInstance($plugin_id, array $configuration = []) { try { return $this->getFactory()->createInstance($plugin_id, $configuration); } - catch (PluginNotFoundException $e) { + catch (PluginNotFoundException) { return $this->handlePluginNotFound($plugin_id, $configuration); } } diff --git a/core/lib/Drupal/Core/Access/AccessManager.php b/core/lib/Drupal/Core/Access/AccessManager.php index cac1b7609b2055b8de64c124bd4a1fefafcd5ccb..24486c3c3e9d23ac84b3d385225cafdc0717f7a6 100644 --- a/core/lib/Drupal/Core/Access/AccessManager.php +++ b/core/lib/Drupal/Core/Access/AccessManager.php @@ -92,12 +92,12 @@ public function checkNamedRoute($route_name, array $parameters = [], ?AccountInt $route_match = new RouteMatch($route_name, $route, $upcasted_parameters, $parameters); return $this->check($route_match, $account, NULL, $return_as_object); } - catch (RouteNotFoundException $e) { + catch (RouteNotFoundException) { // Cacheable until extensions change. $result = AccessResult::forbidden()->addCacheTags(['config:core.extension']); return $return_as_object ? $result : $result->isAllowed(); } - catch (ParamNotConvertedException $e) { + catch (ParamNotConvertedException) { // Uncacheable because conversion of the parameter may not have been // possible due to dynamic circumstances. $result = AccessResult::forbidden()->setCacheMaxAge(0); diff --git a/core/lib/Drupal/Core/Access/CustomAccessCheck.php b/core/lib/Drupal/Core/Access/CustomAccessCheck.php index 20ed9a251f12c9a797a09e9324fe82658074c4d0..bdb5ed5508cd0bf2f3f996be1b2f8d390ac87440 100644 --- a/core/lib/Drupal/Core/Access/CustomAccessCheck.php +++ b/core/lib/Drupal/Core/Access/CustomAccessCheck.php @@ -55,7 +55,7 @@ public function access(Route $route, RouteMatchInterface $route_match, AccountIn try { $callable = $this->callableResolver->getCallableFromDefinition($route->getRequirement('_custom_access')); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // The custom access controller method was not found. throw new \BadMethodCallException(sprintf('The "%s" method is not callable as a _custom_access callback in route "%s"', $route->getRequirement('_custom_access'), $route->getPath())); } diff --git a/core/lib/Drupal/Core/Asset/AssetDumper.php b/core/lib/Drupal/Core/Asset/AssetDumper.php index 1b85eb63c87f683de7e4a114e9ade41ab575c905..13d2a88f4651b4184ca63e508f590601554450ec 100644 --- a/core/lib/Drupal/Core/Asset/AssetDumper.php +++ b/core/lib/Drupal/Core/Asset/AssetDumper.php @@ -57,7 +57,7 @@ public function dumpToUri(string $data, string $file_extension, string $uri): st return FALSE; } } - catch (FileException $e) { + catch (FileException) { return FALSE; } // If CSS/JS gzip compression is enabled then create a gzipped version of @@ -73,7 +73,7 @@ public function dumpToUri(string $data, string $file_extension, string $uri): st return FALSE; } } - catch (FileException $e) { + catch (FileException) { return FALSE; } } diff --git a/core/lib/Drupal/Core/Batch/BatchStorage.php b/core/lib/Drupal/Core/Batch/BatchStorage.php index 03a3394b78b709008c50f84aa8d7169135fa93e9..cce0379e2d6422d967cffbd6ff4a07510dfa0672 100644 --- a/core/lib/Drupal/Core/Batch/BatchStorage.php +++ b/core/lib/Drupal/Core/Batch/BatchStorage.php @@ -171,9 +171,9 @@ protected function ensureTableExists() { // If another process has already created the batch table, attempting to // recreate it will throw an exception. In this case just catch the // exception and do nothing. - catch (DatabaseException $e) { + catch (DatabaseException) { } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } return TRUE; diff --git a/core/lib/Drupal/Core/Cache/ChainedFastBackend.php b/core/lib/Drupal/Core/Cache/ChainedFastBackend.php index 7426aba15133b09c636f35854c7572c87ef6acb8..c2b3533d68e55b47f3a1e122ed05f02b19714bc4 100644 --- a/core/lib/Drupal/Core/Cache/ChainedFastBackend.php +++ b/core/lib/Drupal/Core/Cache/ChainedFastBackend.php @@ -142,7 +142,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) { try { $items = $this->fastBackend->getMultiple($cids, $allow_invalid); } - catch (\Exception $e) { + catch (\Exception) { $cids = $cids_copy; $items = []; } diff --git a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php index 1c0a127cb56311691cc1d69dfcaacc329db91ec0..162dff754c859341382bbbdc8cd72a333247535e 100644 --- a/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php +++ b/core/lib/Drupal/Core/Cache/Context/CacheContextsManager.php @@ -320,7 +320,7 @@ public function assertValidTokens($context_tokens) { try { $this->validateTokens($context_tokens); } - catch (\LogicException $e) { + catch (\LogicException) { return FALSE; } diff --git a/core/lib/Drupal/Core/Cache/DatabaseBackend.php b/core/lib/Drupal/Core/Cache/DatabaseBackend.php index 07348ca65e52f3fb5e6af49f03485ea8382f2d0c..956662df40f2ac20de31b8a321ecfcec42705b87 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Cache/DatabaseBackend.php @@ -130,7 +130,7 @@ public function getMultiple(&$cids, $allow_invalid = FALSE) { try { $result = $this->connection->query('SELECT [cid], [data], [created], [expire], [serialized], [tags], [checksum] FROM {' . $this->connection->escapeTable($this->bin) . '} WHERE [cid] IN ( :cids[] ) ORDER BY [cid]', [':cids[]' => array_keys($cid_mapping)]); } - catch (\Exception $e) { + catch (\Exception) { // Nothing to do. } $cache = []; @@ -411,7 +411,7 @@ public function garbageCollection() { ->condition('expire', $this->time->getRequestTime(), '<') ->execute(); } - catch (\Exception $e) { + catch (\Exception) { // If the table does not exist, it surely does not have garbage in it. // If the table exists, the next garbage collection will clean up. // There is nothing to do. @@ -445,7 +445,7 @@ protected function ensureBinExists() { // If another process has already created the cache table, attempting to // recreate it will throw an exception. In this case just catch the // exception and do nothing. - catch (DatabaseException $e) { + catch (DatabaseException) { return TRUE; } return FALSE; diff --git a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php index 4ab1589c11518e6087eca3ef2ed59717ada3d2f5..aa41952128c240b3d1a4bd00a664dd70834f00fc 100644 --- a/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php +++ b/core/lib/Drupal/Core/Cache/DatabaseCacheTagsChecksum.php @@ -81,9 +81,9 @@ protected function ensureTableExists() { // If another process has already created the cachetags table, attempting to // recreate it will throw an exception. In this case just catch the // exception and do nothing. - catch (DatabaseException $e) { + catch (DatabaseException) { } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } return TRUE; diff --git a/core/lib/Drupal/Core/Command/DbImportCommand.php b/core/lib/Drupal/Core/Command/DbImportCommand.php index eeae570c5c45d5b8853f69ef078ef9e1c3154f38..8a23bc01b62fbc2d15a425882e00e3b3523337b4 100644 --- a/core/lib/Drupal/Core/Command/DbImportCommand.php +++ b/core/lib/Drupal/Core/Command/DbImportCommand.php @@ -62,7 +62,7 @@ protected function runScript(Connection $connection, $script) { try { require $script; } - catch (SchemaObjectExistsException $e) { + catch (SchemaObjectExistsException) { throw new \RuntimeException('An existing Drupal installation exists at this location. Try removing all tables or changing the database prefix in your settings.php file.'); } Database::setActiveConnection($old_key); diff --git a/core/lib/Drupal/Core/Command/InstallCommand.php b/core/lib/Drupal/Core/Command/InstallCommand.php index da40673bdaaf0ddf137a8435933c9dab9babc656..a622a3b09677ce7b5027d096a2476e0f8025a8f9 100644 --- a/core/lib/Drupal/Core/Command/InstallCommand.php +++ b/core/lib/Drupal/Core/Command/InstallCommand.php @@ -131,7 +131,7 @@ protected function isDrupalInstalled() { Settings::initialize($kernel->getAppRoot(), $kernel->getSitePath(), $this->classLoader); $kernel->boot(); } - catch (ConnectionNotDefinedException $e) { + catch (ConnectionNotDefinedException) { return FALSE; } return !empty(Database::getConnectionInfo()); diff --git a/core/lib/Drupal/Core/Command/ServerCommand.php b/core/lib/Drupal/Core/Command/ServerCommand.php index 09559db2aafa522f8fe6355ed199ff12152f6fed..776cfdab3d697e3f766777330383304c7f1e8daf 100644 --- a/core/lib/Drupal/Core/Command/ServerCommand.php +++ b/core/lib/Drupal/Core/Command/ServerCommand.php @@ -73,7 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int try { $kernel = $this->boot(); } - catch (ConnectionNotDefinedException $e) { + catch (ConnectionNotDefinedException) { $io->getErrorStyle()->error("No installation found. Use the 'install' command."); return 1; } diff --git a/core/lib/Drupal/Core/Condition/ConditionAccessResolverTrait.php b/core/lib/Drupal/Core/Condition/ConditionAccessResolverTrait.php index 1af98160dea5cf6e0ad0108024266697920ecf14..5c95ca91e63e16383adb6e0b6ed5c9908b7de454 100644 --- a/core/lib/Drupal/Core/Condition/ConditionAccessResolverTrait.php +++ b/core/lib/Drupal/Core/Condition/ConditionAccessResolverTrait.php @@ -25,7 +25,7 @@ protected function resolveConditions($conditions, $condition_logic) { try { $pass = $condition->execute(); } - catch (ContextException $e) { + catch (ContextException) { // If a condition is missing context and is not negated, consider that a // fail. $pass = $condition->isNegated(); diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php index 81a0b50c65210b5960e963ab7f2d2f8bf3818476..32876d14d29d74e97070bc4e8632ecd0de1635db 100644 --- a/core/lib/Drupal/Core/Config/DatabaseStorage.php +++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php @@ -173,10 +173,10 @@ protected function ensureTableExists() { // If another process has already created the config table, attempting to // recreate it will throw an exception. In this case just catch the // exception and do nothing. - catch (DatabaseException $e) { + catch (DatabaseException) { return TRUE; } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } return TRUE; diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index ae5bb80f0c8853468c386f4403b9cd450bf116a8..db2020bc4de3c28ee3bdf1afc8a390c2f57fc435 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -1457,7 +1457,7 @@ public function hasJson(): bool { try { return (bool) $this->query('SELECT JSON_TYPE(\'1\')'); } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } } diff --git a/core/lib/Drupal/Core/Datetime/Element/Datelist.php b/core/lib/Drupal/Core/Datetime/Element/Datelist.php index 2b34059c0318c6d59493831939723d8b87685732..1b918131a8707327bed6305cdfc6563b3f62e75f 100644 --- a/core/lib/Drupal/Core/Datetime/Element/Datelist.php +++ b/core/lib/Drupal/Core/Datetime/Element/Datelist.php @@ -68,7 +68,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form try { $date = DrupalDateTime::createFromArray($input, $element['#date_timezone']); } - catch (\Exception $e) { + catch (\Exception) { $form_state->setError($element, t('Selected combination of day and month is not valid.')); } if ($date instanceof DrupalDateTime && !$date->hasErrors()) { diff --git a/core/lib/Drupal/Core/Datetime/Element/Datetime.php b/core/lib/Drupal/Core/Datetime/Element/Datetime.php index 60da4a4b55c1640c1d78cb7ef5a3b82cfa44a4ee..b6b40ab68827558c4cf1199aad3498ef42df6743 100644 --- a/core/lib/Drupal/Core/Datetime/Element/Datetime.php +++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php @@ -94,7 +94,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form $date_time_input = trim($date_input . ' ' . $time_input); $date = DrupalDateTime::createFromFormat($date_time_format, $date_time_input, $element['#date_timezone']); } - catch (\Exception $e) { + catch (\Exception) { $date = NULL; } $input = [ diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/BackendCompilerPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/BackendCompilerPass.php index 058a85379063adb6f79fb2b7349fb95e0657efab..1cdeb7263cee7b1e0af5a6e2c140d1a67cc994de 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/BackendCompilerPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/BackendCompilerPass.php @@ -51,7 +51,7 @@ public function process(ContainerBuilder $container): void { $default_backend = $container->get('database')->databaseType(); $container->set('database', NULL); } - catch (\Exception $e) { + catch (\Exception) { // If Drupal is not installed or a test doesn't define database there // is nothing to override. return; diff --git a/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php b/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php index 840bc3c907c6ea67159a215d018e0ceef068ea86..d7edbafe39fbd2f881389cd97759519bcc89736d 100644 --- a/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php +++ b/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php @@ -60,7 +60,7 @@ public function __sleep(): array { } } } - catch (ContainerNotInitializedException $e) { + catch (ContainerNotInitializedException) { // No container, no problem. } diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 191f6d1291144b703af7f1b1bc3941306d44681a..2a0d76fadc0c5f615a3400b9325b599ef46c167d 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -1422,7 +1422,7 @@ protected function cacheDrupalContainer(array $container_definition) { try { $this->bootstrapContainer->get('cache.container')->set($this->getContainerCacheKey(), $container_definition); } - catch (\Exception $e) { + catch (\Exception) { // There is no way to get from the Cache API if the cache set was // successful or not, hence an Exception is caught and the caller informed // about the error condition. @@ -1453,7 +1453,7 @@ protected function getConfigStorage() { try { $this->configStorage = BootstrapConfigStorageFactory::get($this->classLoader); } - catch (\Exception $e) { + catch (\Exception) { $this->configStorage = new NullStorage(); } } @@ -1578,7 +1578,7 @@ public static function validateHostname(Request $request) { try { $http_host = $request->getHost(); } - catch (\UnexpectedValueException $e) { + catch (\UnexpectedValueException) { return FALSE; } @@ -1636,7 +1636,7 @@ protected static function setupTrustedHosts(Request $request, $host_patterns) { Request::setFactory([$request_factory, 'createRequest'](...)); } - catch (\UnexpectedValueException $e) { + catch (\UnexpectedValueException) { return FALSE; } diff --git a/core/lib/Drupal/Core/Entity/EntityBase.php b/core/lib/Drupal/Core/Entity/EntityBase.php index f18253f1579e3b8caf48dc856de1ebf6c9c0dc39..d66a20bce3b4ad54ce69515701685d8c96a0b731 100644 --- a/core/lib/Drupal/Core/Entity/EntityBase.php +++ b/core/lib/Drupal/Core/Entity/EntityBase.php @@ -305,10 +305,10 @@ public function uriRelationships() { try { $this->toUrl($link_relation_type)->toString(TRUE)->getGeneratedUrl(); } - catch (RouteNotFoundException $e) { + catch (RouteNotFoundException) { return FALSE; } - catch (MissingMandatoryParametersException $e) { + catch (MissingMandatoryParametersException) { return FALSE; } return TRUE; diff --git a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php index 2167ba35f3d6556afe59d3a6f83c20fe0e7c229d..dec8dbf14017a1cbc8bcd05c88e2034824dd89b0 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php @@ -73,7 +73,7 @@ public function onConfigImporterValidate(ConfigImporterEvent $event) { try { Config::validateName($name); } - catch (ConfigNameException $e) { + catch (ConfigNameException) { $message = $this->t('The config name @config_name is invalid.', ['@config_name' => $name]); $event->getConfigImporter()->logError($message); } diff --git a/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php index ca78786ff69feab94e8690dfd36416375088311c..a051e901df19bb3a93e66e8971a57b53b4ec3e81 100644 --- a/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/RedirectResponseSubscriber.php @@ -65,7 +65,7 @@ public function checkRedirectUrl(ResponseEvent $event) { try { $response->setTargetUrl($destination); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { } } @@ -79,7 +79,7 @@ public function checkRedirectUrl(ResponseEvent $event) { $safe_response = LocalRedirectResponse::createFromRedirectResponse($response); $safe_response->setRequestContext($this->requestContext); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // If the above failed, it's because the redirect target wasn't // local. Do not follow that redirect. Log an error message instead, // then return a 400 response to the client with the error message. diff --git a/core/lib/Drupal/Core/Extension/ExtensionList.php b/core/lib/Drupal/Core/Extension/ExtensionList.php index b0af9c5e17276068dc5fc77f43e040442265285a..2cff427d7054a908ec1061259c1f97da61c46227 100644 --- a/core/lib/Drupal/Core/Extension/ExtensionList.php +++ b/core/lib/Drupal/Core/Extension/ExtensionList.php @@ -172,7 +172,7 @@ public function reset() { try { $this->state->delete($this->getPathNamesCacheId()); } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // Ignore exceptions caused by a non existing {key_value} table in the // early installer. } diff --git a/core/lib/Drupal/Core/Extension/ExtensionPathResolver.php b/core/lib/Drupal/Core/Extension/ExtensionPathResolver.php index 5045949ae7774ae371638198daf8a3a677c7026b..a3e86aedcf1abba24ac5187b2813dec94d29997f 100644 --- a/core/lib/Drupal/Core/Extension/ExtensionPathResolver.php +++ b/core/lib/Drupal/Core/Extension/ExtensionPathResolver.php @@ -57,7 +57,7 @@ public function getPathname(string $type, string $name): ?string { try { return $this->extensionLists[$type]->getPathname($name); } - catch (UnknownExtensionException $e) { + catch (UnknownExtensionException) { // Catch the exception. This will result in triggering an error. // If the filename is still unknown, create a user-level error message. trigger_error(sprintf('The following %s is missing from the file system: %s', $type, $name), E_USER_WARNING); diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index 00540bc618d8172d53ca020e42a3f1301b29acd4..dd426811d7cd1de15f9ab151f7cd072b6809e982 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -61,7 +61,7 @@ public function parse($filename) { try { $parsed_info['core_incompatible'] = !Semver::satisfies(\Drupal::VERSION, $parsed_info['core_version_requirement']); } - catch (\UnexpectedValueException $exception) { + catch (\UnexpectedValueException) { throw new InfoParserException("The 'core_version_requirement' constraint ({$parsed_info['core_version_requirement']}) is not a valid value in $filename"); } if (isset($parsed_info['version']) && $parsed_info['version'] === 'VERSION') { diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php index aae51480856ee255d9c9f57756ab5110933fdca4..3090314a597140b82246cba6de9ee2c9ff94e0aa 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php @@ -68,7 +68,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { try { $uri = $entity->toUrl(); } - catch (UndefinedLinkTemplateException $e) { + catch (UndefinedLinkTemplateException) { // This exception is thrown by \Drupal\Core\Entity\Entity::urlInfo() // and it means that the entity type doesn't have a link template nor // a valid "uri_callback", so don't bother trying to output a link for diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index ef3d79d36ee5a1ecc822bfc43c5e35937c24a8e9..e614255f51869b6da1e682c4a0a08cbba427c28a 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -168,7 +168,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) try { $target_type_info = \Drupal::entityTypeManager()->getDefinition($target_type); } - catch (PluginNotFoundException $e) { + catch (PluginNotFoundException) { throw new FieldException(sprintf("Field '%s' on entity type '%s' references a target entity type '%s' which does not exist.", $field_definition->getName(), $field_definition->getTargetEntityTypeId(), diff --git a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php index e8971f85dd7ef3504146e0e6005abf92229e108c..a1450b9b9ef374a93fc78958147fc9c57732732f 100644 --- a/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php +++ b/core/lib/Drupal/Core/FileTransfer/Form/FileTransferAuthorizeForm.php @@ -207,7 +207,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $form_state->setResponse($response); } } - catch (\Exception $e) { + catch (\Exception) { // If there is no database available, we don't care and just skip // this part entirely. } diff --git a/core/lib/Drupal/Core/Flood/DatabaseBackend.php b/core/lib/Drupal/Core/Flood/DatabaseBackend.php index 618ec64c18d82a9dcb8bb104e9aa09ca8cab7d2c..ec6bd4c01de4879bfcf8f829b1c5fc70c0a4a806 100644 --- a/core/lib/Drupal/Core/Flood/DatabaseBackend.php +++ b/core/lib/Drupal/Core/Flood/DatabaseBackend.php @@ -164,9 +164,9 @@ protected function ensureTableExists() { // If another process has already created the table, attempting to create // it will throw an exception. In this case just catch the exception and do // nothing. - catch (DatabaseException $e) { + catch (DatabaseException) { } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } return TRUE; diff --git a/core/lib/Drupal/Core/Form/ConfirmFormHelper.php b/core/lib/Drupal/Core/Form/ConfirmFormHelper.php index e5f5d23e891d9ec8f67dbfcfc7aee552db092141..66b407964d354e72b12ac947fad3dfdf04a6ba26 100644 --- a/core/lib/Drupal/Core/Form/ConfirmFormHelper.php +++ b/core/lib/Drupal/Core/Form/ConfirmFormHelper.php @@ -33,7 +33,7 @@ public static function buildCancelLink(ConfirmFormInterface $form, Request $requ try { $url = Url::fromUserInput('/' . ltrim($options['path'], '/'), $options); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // Suppress the exception and fall back to the form's cancel URL. } } diff --git a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php index 1fba360804859092715015929993c0e2091e3da1..27ef431353198b3569070b57b675dc9dff4585c2 100644 --- a/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php +++ b/core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php @@ -123,7 +123,7 @@ public function apply($operation, array $arguments = []) { // Get the plugin to use for the operation and apply the operation. return $this->getToolkitOperation($operation)->apply($arguments); } - catch (PluginNotFoundException $e) { + catch (PluginNotFoundException) { $this->logger->error("The selected image handling toolkit '@toolkit' can not process operation '@operation'.", ['@toolkit' => $this->getPluginId(), '@operation' => $operation]); return FALSE; } diff --git a/core/lib/Drupal/Core/Installer/InstallerRedirectTrait.php b/core/lib/Drupal/Core/Installer/InstallerRedirectTrait.php index 6945e88ffe63618d844edf2199fb02367b84fb7d..f6acafb6a8f266c5aea0a0e18d680c7c6d3d1cfe 100644 --- a/core/lib/Drupal/Core/Installer/InstallerRedirectTrait.php +++ b/core/lib/Drupal/Core/Installer/InstallerRedirectTrait.php @@ -75,7 +75,7 @@ protected function shouldRedirectToInstaller(\Throwable $exception, ?Connection try { return !$connection->schema()->tableExists('sequences'); } - catch (\Exception $e) { + catch (\Exception) { // If we still have an exception at this point, we need to be careful // since we should not redirect if the exception represents an error on // an already-installed site (for example, if the database server went diff --git a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php index 9b942d72a2a4d03ba0e0815e827c8e3a60bb1607..44d5d9df13fba12f5a31f374c59b1acde6d46f34 100644 --- a/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php +++ b/core/lib/Drupal/Core/KeyValueStore/DatabaseStorage.php @@ -87,7 +87,7 @@ public function getMultiple(array $keys) { } } } - catch (\Exception $e) { + catch (\Exception) { // @todo Perhaps if the database is never going to be available, // key/value requests should return FALSE in order to allow exception // handling to occur but for now, keep it an array, always. @@ -259,9 +259,9 @@ protected function ensureTableExists() { } // If the table already exists, then attempting to recreate it will throw an // exception. In this case just catch the exception and do nothing. - catch (DatabaseException $e) { + catch (DatabaseException) { } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } return TRUE; diff --git a/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php b/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php index 870f311fd9bde50d6b4b5e86bc681f1813b0a15c..73fd501267e981a51486252ea25cf67077f1c5be 100644 --- a/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php +++ b/core/lib/Drupal/Core/Lock/DatabaseLockBackend.php @@ -80,7 +80,7 @@ public function acquire($name, $timeout = 30.0) { // We never need to try again. $retry = FALSE; } - catch (IntegrityConstraintViolationException $e) { + catch (IntegrityConstraintViolationException) { // Suppress the error. If this is our first pass through the loop, // then $retry is FALSE. In this case, the insert failed because some // other request acquired the lock but did not release it. We decide @@ -183,9 +183,9 @@ protected function ensureTableExists() { // If another process has already created the semaphore table, attempting to // recreate it will throw an exception. In this case just catch the // exception and do nothing. - catch (DatabaseException $e) { + catch (DatabaseException) { } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } return TRUE; diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index 7f8054da093843bd867f71a50825704e45530c29..78f1d3de5d21e160e177c40e786243024dc21c2f 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -1137,12 +1137,12 @@ protected function ensureTableExists() { try { $this->connection->schema()->createTable($this->table, static::schemaDefinition()); } - catch (DatabaseException $e) { + catch (DatabaseException) { // If another process has already created the config table, attempting to // recreate it will throw an exception. In this case just catch the // exception and do nothing. } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } return TRUE; diff --git a/core/lib/Drupal/Core/ParamConverter/MenuLinkPluginConverter.php b/core/lib/Drupal/Core/ParamConverter/MenuLinkPluginConverter.php index 852b6b2cc665bcd1a1e407e504fb576ff321e928..21b2f26f6d10fda8e3c331dc0c9737b2fecc480e 100644 --- a/core/lib/Drupal/Core/ParamConverter/MenuLinkPluginConverter.php +++ b/core/lib/Drupal/Core/ParamConverter/MenuLinkPluginConverter.php @@ -36,7 +36,7 @@ public function convert($value, $definition, $name, array $defaults) { try { return $this->menuLinkManager->createInstance($value); } - catch (PluginException $e) { + catch (PluginException) { // Suppress the error. } } diff --git a/core/lib/Drupal/Core/Path/PathValidator.php b/core/lib/Drupal/Core/Path/PathValidator.php index c132210ca636234277f26109de90942e2313e6b7..fd8dbe02a3ee87b18530d13fd037ac6c5db70e3a 100644 --- a/core/lib/Drupal/Core/Path/PathValidator.php +++ b/core/lib/Drupal/Core/Path/PathValidator.php @@ -160,16 +160,16 @@ protected function getPathAttributes($path, Request $request, $access_check) { $router->setContext((new RequestContext())->fromRequest($request)); $result = $router->match($path); } - catch (ResourceNotFoundException $e) { + catch (ResourceNotFoundException) { $result = FALSE; } - catch (ParamNotConvertedException $e) { + catch (ParamNotConvertedException) { $result = FALSE; } - catch (AccessDeniedHttpException $e) { + catch (AccessDeniedHttpException) { $result = FALSE; } - catch (MethodNotAllowedException $e) { + catch (MethodNotAllowedException) { $result = FALSE; } diff --git a/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php b/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php index 2a32b504f324d7a725793fa65689488e1a37d8e3..e7dde93d0f8458b2f13bc4ecbcca17fe3439ca64 100644 --- a/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php +++ b/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php @@ -51,7 +51,7 @@ protected function getProviderName($provider) { try { return $this->getModuleExtensionList()->getName($provider); } - catch (UnknownExtensionException $e) { + catch (UnknownExtensionException) { // Otherwise, return the machine name. return $provider; } diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php index 248cf7adbf251cf13236e091ee61031bb23ce355..a7bcc13be23ef850608685504b11486ebebdc9a7 100644 --- a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php +++ b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php @@ -118,7 +118,7 @@ public function applyContextMapping(ContextAwarePluginInterface $plugin, $contex try { $context = $plugin->getContext($context_id); } - catch (ContextException $e) { + catch (ContextException) { $context = NULL; } diff --git a/core/lib/Drupal/Core/Queue/DatabaseQueue.php b/core/lib/Drupal/Core/Queue/DatabaseQueue.php index 11a33c602ec8eb20cf703ee7596dbd5a8c9faf91..ca2b8339d5cac8a13fe466ae0a3a4db2cd76c26a 100644 --- a/core/lib/Drupal/Core/Queue/DatabaseQueue.php +++ b/core/lib/Drupal/Core/Queue/DatabaseQueue.php @@ -273,9 +273,9 @@ protected function ensureTableExists() { // If another process has already created the queue table, attempting to // recreate it will throw an exception. In this case just catch the // exception and do nothing. - catch (DatabaseException $e) { + catch (DatabaseException) { } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } return TRUE; diff --git a/core/lib/Drupal/Core/Render/Element/Color.php b/core/lib/Drupal/Core/Render/Element/Color.php index c79a833dcce24bdc77fbf793aadf194bfe430f52..a63ea60c10afe3a0b00ebf0c845ec45f443656b1 100644 --- a/core/lib/Drupal/Core/Render/Element/Color.php +++ b/core/lib/Drupal/Core/Render/Element/Color.php @@ -62,7 +62,7 @@ public static function validateColor(&$element, FormStateInterface $form_state, try { $form_state->setValueForElement($element, ColorUtility::rgbToHex(ColorUtility::hexToRgb($value))); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { $form_state->setError($element, t('%name must be a valid color.', ['%name' => empty($element['#title']) ? $element['#parents'][0] : $element['#title']])); } } diff --git a/core/lib/Drupal/Core/Routing/LazyRouteCollection.php b/core/lib/Drupal/Core/Routing/LazyRouteCollection.php index f19f4f4d65f678056b43d8bcf05624de944b5455..cf5e80874df34f7f3281099bfa3aa85d7db7629d 100644 --- a/core/lib/Drupal/Core/Routing/LazyRouteCollection.php +++ b/core/lib/Drupal/Core/Routing/LazyRouteCollection.php @@ -61,7 +61,7 @@ public function get($name): ?Route { try { return $this->provider->getRouteByName($name); } - catch (RouteNotFoundException $e) { + catch (RouteNotFoundException) { return NULL; } } diff --git a/core/lib/Drupal/Core/Routing/MatcherDumper.php b/core/lib/Drupal/Core/Routing/MatcherDumper.php index 0e15546bb3a0ec194d77803e8e5edee7d61998ce..78619fdd7213fa355420313fa022d6df452e7fa9 100644 --- a/core/lib/Drupal/Core/Routing/MatcherDumper.php +++ b/core/lib/Drupal/Core/Routing/MatcherDumper.php @@ -181,12 +181,12 @@ protected function ensureTableExists() { try { $this->connection->schema()->createTable($this->tableName, $this->schemaDefinition()); } - catch (DatabaseException $e) { + catch (DatabaseException) { // If another process has already created the config table, attempting to // recreate it will throw an exception. In this case just catch the // exception and do nothing. } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } return TRUE; diff --git a/core/lib/Drupal/Core/Routing/RouteProvider.php b/core/lib/Drupal/Core/Routing/RouteProvider.php index a0b4384ad7f46a995573416dbc28822622c10f76..0123ca0ec2e3c48647821a0da4ea150eda9a79e5 100644 --- a/core/lib/Drupal/Core/Routing/RouteProvider.php +++ b/core/lib/Drupal/Core/Routing/RouteProvider.php @@ -233,7 +233,7 @@ public function preLoadRoutes($names) { $this->cache->set($cid, $routes, Cache::PERMANENT, ['routes']); } - catch (\Exception $e) { + catch (\Exception) { $routes = []; } } @@ -370,7 +370,7 @@ protected function getRoutesByPath($path) { ]) ->fetchAll(\PDO::FETCH_ASSOC); } - catch (\Exception $e) { + catch (\Exception) { $routes = []; } diff --git a/core/lib/Drupal/Core/Session/SessionHandler.php b/core/lib/Drupal/Core/Session/SessionHandler.php index 0c33bb8d6915c195afb60e46661eb113d67ae41f..fe1247158cd143850eca8c024eafa503907fd8dd 100644 --- a/core/lib/Drupal/Core/Session/SessionHandler.php +++ b/core/lib/Drupal/Core/Session/SessionHandler.php @@ -215,9 +215,9 @@ protected function ensureTableExists(): bool { // If another process has already created the table, attempting to create // it will throw an exception. In this case just catch the exception and do // nothing. - catch (DatabaseException $e) { + catch (DatabaseException) { } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } return TRUE; diff --git a/core/lib/Drupal/Core/Template/ComponentNodeVisitor.php b/core/lib/Drupal/Core/Template/ComponentNodeVisitor.php index da7a5e85bbfe3ef9d546dc54402b9a61b279ee7e..8e13b3c1074ff8a337b46b25bbd606b530842423 100644 --- a/core/lib/Drupal/Core/Template/ComponentNodeVisitor.php +++ b/core/lib/Drupal/Core/Template/ComponentNodeVisitor.php @@ -112,7 +112,7 @@ protected function getComponent(Node $node): ?Component { try { return $this->pluginManager->find($component_id); } - catch (ComponentNotFoundException $e) { + catch (ComponentNotFoundException) { return NULL; } } @@ -147,7 +147,7 @@ protected function validateSlots(Component $component, Node $node): void { try { $it = $node->getIterator(); } - catch (\Exception $e) { + catch (\Exception) { return; } if ($it instanceof \SeekableIterator) { diff --git a/core/lib/Drupal/Core/Template/Loader/ComponentLoader.php b/core/lib/Drupal/Core/Template/Loader/ComponentLoader.php index 2be45eb0abd633942fd0404ea76c89c8c5cfe96d..d141d202ecb0ddb828da6ca7c4873ddd730335ca 100644 --- a/core/lib/Drupal/Core/Template/Loader/ComponentLoader.php +++ b/core/lib/Drupal/Core/Template/Loader/ComponentLoader.php @@ -87,7 +87,7 @@ public function getSourceContext($name): Source { $component = $this->pluginManager->find($name); $path = $component->getTemplatePath(); } - catch (ComponentNotFoundException $e) { + catch (ComponentNotFoundException) { return new Source('', $name, ''); } $original_code = file_get_contents($path); @@ -101,7 +101,7 @@ public function getCacheKey($name): string { try { $component = $this->pluginManager->find($name); } - catch (ComponentNotFoundException $e) { + catch (ComponentNotFoundException) { throw new LoaderError('Unable to find component'); } return implode('--', array_filter([ @@ -119,7 +119,7 @@ public function isFresh(string $name, int $time): bool { try { $component = $this->pluginManager->find($name); } - catch (ComponentNotFoundException $e) { + catch (ComponentNotFoundException) { throw new LoaderError('Unable to find component'); } // If any of the templates, or the component definition, are fresh. Then the diff --git a/core/lib/Drupal/Core/Test/SimpletestTestRunResultsStorage.php b/core/lib/Drupal/Core/Test/SimpletestTestRunResultsStorage.php index 28398f9b7381537517d50b249c9589ccf922e4d1..80514a8ac4dc23cfabe013344e6d45256b9ab312 100644 --- a/core/lib/Drupal/Core/Test/SimpletestTestRunResultsStorage.php +++ b/core/lib/Drupal/Core/Test/SimpletestTestRunResultsStorage.php @@ -37,13 +37,13 @@ public static function getConnection(): Connection { try { $connection = Database::getConnection('default', 'test-runner'); } - catch (ConnectionNotDefinedException $e) { + catch (ConnectionNotDefinedException) { // Check whether there is a backup of the original default connection. // @see FunctionalTestSetupTrait::prepareEnvironment() try { $connection = Database::getConnection('default', 'simpletest_original_default'); } - catch (ConnectionNotDefinedException $e) { + catch (ConnectionNotDefinedException) { // If FunctionalTestSetupTrait::prepareEnvironment() failed, the // test-specific database connection does not exist yet/anymore, so // fall back to the default of the (UI) test runner. diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php index 2da346aced47808df57320cce37437cf1bde0101..b0449e30f2a585b3f4f8cd09b4a79dcc58249197 100644 --- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php +++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidator.php @@ -69,7 +69,7 @@ public function validate($value, Constraint $constraint): void { $valid = FALSE; } } - catch (\Exception $e) { + catch (\Exception) { // Invalid durations or dates might throw exceptions. $valid = FALSE; } diff --git a/core/modules/announcements_feed/src/AnnounceRenderer.php b/core/modules/announcements_feed/src/AnnounceRenderer.php index 420c7620e33c5d96fce124a4d7cd92d83cff6ead..522f3f12d3002ec685f07a62d50e769273b37cb2 100644 --- a/core/modules/announcements_feed/src/AnnounceRenderer.php +++ b/core/modules/announcements_feed/src/AnnounceRenderer.php @@ -39,7 +39,7 @@ public function render(): array { try { $announcements = $this->announceFetcher->fetch(); } - catch (\Exception $e) { + catch (\Exception) { return [ '#theme' => 'status_messages', '#message_list' => [ diff --git a/core/modules/block/src/BlockAccessControlHandler.php b/core/modules/block/src/BlockAccessControlHandler.php index e971e8dfeb543524e122b9847132aec999976019..dfeafa8d3f7ac4d814ffc3108e73cc8050f3410e 100644 --- a/core/modules/block/src/BlockAccessControlHandler.php +++ b/core/modules/block/src/BlockAccessControlHandler.php @@ -91,10 +91,10 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter $contexts = $this->contextRepository->getRuntimeContexts(array_values($condition->getContextMapping())); $this->contextHandler->applyContextMapping($condition, $contexts); } - catch (MissingValueContextException $e) { + catch (MissingValueContextException) { $missing_value = TRUE; } - catch (ContextException $e) { + catch (ContextException) { $missing_context = TRUE; } } @@ -123,12 +123,12 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter } $access = $block_plugin->access($account, TRUE); } - catch (MissingValueContextException $e) { + catch (MissingValueContextException) { // The contexts exist but have no value. Deny access without // disabling caching. $access = AccessResult::forbidden(); } - catch (ContextException $e) { + catch (ContextException) { // If any context is missing then we might be missing cacheable // metadata, and don't know based on what conditions the block is // accessible or not. Make sure the result cannot be cached. diff --git a/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php index d6d500dbaed3e835f64ce2ccb167a1e1bf101bca..231b9aef4284e7a5e1b5426e6a1864ee903b53d2 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentCreationTest.php @@ -227,7 +227,7 @@ public function testFailedBlockCreation(): void { $this->createBlockContent('fail_creation'); $this->fail('Expected exception has not been thrown.'); } - catch (\Exception $e) { + catch (\Exception) { // Expected exception; just continue testing. } diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php index c023f4a541a1efba88496527d576ece8a81fd581..adaeef9d8e53246f957b5ce0fe65f9df48924e3f 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php @@ -127,7 +127,7 @@ protected function doTestBasicTranslation() { try { $entity->save(); } - catch (\Exception $e) { + catch (\Exception) { $this->fail('Blocks can have translations with the same "info" value.'); } diff --git a/core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php b/core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php index e057700653acaf57f0ad2a4f755696508f454874..4492f4ec99450f4f19aefe5a8142191366809a42 100644 --- a/core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php +++ b/core/modules/ckeditor5/src/Controller/CKEditor5ImageController.php @@ -115,10 +115,10 @@ public function upload(Request $request): Response { throw new UnprocessableEntityHttpException((string) $uploadResult->getViolations()); } } - catch (FileException $e) { + catch (FileException) { throw new HttpException(500, 'File could not be saved'); } - catch (LockAcquiringException $e) { + catch (LockAcquiringException) { throw new HttpException(503, sprintf('File "%s" is already locked for writing.', $upload->getClientOriginalName()), NULL, ['Retry-After' => 1]); } diff --git a/core/modules/ckeditor5/src/Plugin/Validation/Constraint/EnabledConfigurablePluginsConstraintValidator.php b/core/modules/ckeditor5/src/Plugin/Validation/Constraint/EnabledConfigurablePluginsConstraintValidator.php index 6950ace03ddddcd67b33d71c4f2ac86e80a1d103..27fc566ece2ed6065b28540e4a8ff55b28d38b2e 100644 --- a/core/modules/ckeditor5/src/Plugin/Validation/Constraint/EnabledConfigurablePluginsConstraintValidator.php +++ b/core/modules/ckeditor5/src/Plugin/Validation/Constraint/EnabledConfigurablePluginsConstraintValidator.php @@ -35,7 +35,7 @@ public function validate($settings, Constraint $constraint): void { try { $plugin_settings = $this->context->getRoot()->get('settings.plugins')->getValue(); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { $plugin_settings = []; } diff --git a/core/modules/ckeditor5/src/Plugin/Validation/Constraint/ToolbarItemConditionsMetConstraintValidator.php b/core/modules/ckeditor5/src/Plugin/Validation/Constraint/ToolbarItemConditionsMetConstraintValidator.php index 126755cb7e6a39cb8ed4a3421c07a7148c4bce59..c67b1bd73afa5cf89de6abccdd9bbe291805e45a 100644 --- a/core/modules/ckeditor5/src/Plugin/Validation/Constraint/ToolbarItemConditionsMetConstraintValidator.php +++ b/core/modules/ckeditor5/src/Plugin/Validation/Constraint/ToolbarItemConditionsMetConstraintValidator.php @@ -35,7 +35,7 @@ public function validate($toolbar_item, Constraint $constraint): void { try { $definition = $this->findDefinitionForToolbarItem($toolbar_item); } - catch (\OutOfBoundsException $e) { + catch (\OutOfBoundsException) { // No plugin definition found for this toolbar item. It's the // responsibility of another validation constraint to raise this problem. // @see \Drupal\ckeditor5\Plugin\Validation\Constraint\ToolbarItemConstraint diff --git a/core/modules/comment/tests/src/Functional/CommentTypeTest.php b/core/modules/comment/tests/src/Functional/CommentTypeTest.php index 9ac706b12a5fba3e87f369891773f0fa93c20cc9..097560027541329718da9b9be28d4041752e7686 100644 --- a/core/modules/comment/tests/src/Functional/CommentTypeTest.php +++ b/core/modules/comment/tests/src/Functional/CommentTypeTest.php @@ -200,7 +200,7 @@ public function testCommentTypeDeletion(): void { $this->addDefaultCommentField('comment', 'comment', 'bar'); $this->fail('Exception not thrown.'); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // Expected exception; just continue testing. } diff --git a/core/modules/config/src/Controller/ConfigController.php b/core/modules/config/src/Controller/ConfigController.php index 0c0f48686537e01340e93144708f0eeeac33e94c..65e08dfea324d9a654376b51bf3d078846d819a5 100644 --- a/core/modules/config/src/Controller/ConfigController.php +++ b/core/modules/config/src/Controller/ConfigController.php @@ -134,7 +134,7 @@ public function downloadExport() { try { $this->fileSystem->delete($this->fileSystem->getTempDirectory() . '/config.tar.gz'); } - catch (FileException $e) { + catch (FileException) { // Ignore failed deletes. } diff --git a/core/modules/config/src/Form/ConfigSingleImportForm.php b/core/modules/config/src/Form/ConfigSingleImportForm.php index c53eb2254e5ff8fca86c231ea840feb378e66201..ae8e9f69ed10a97f0035e13218a279a4c2b2df36 100644 --- a/core/modules/config/src/Form/ConfigSingleImportForm.php +++ b/core/modules/config/src/Form/ConfigSingleImportForm.php @@ -305,7 +305,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) { $config_importer->validate(); $form_state->set('config_importer', $config_importer); } - catch (ConfigImporterException $e) { + catch (ConfigImporterException) { // There are validation errors. $item_list = [ '#theme' => 'item_list', @@ -351,7 +351,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { } batch_set($batch_builder->toArray()); } - catch (ConfigImporterException $e) { + catch (ConfigImporterException) { // There are validation errors. $this->messenger()->addError($this->t('The configuration import failed for the following reasons:')); foreach ($config_importer->getErrors() as $message) { diff --git a/core/modules/config/src/Form/ConfigSync.php b/core/modules/config/src/Form/ConfigSync.php index 65412c5967274170b3a5cbacf5ee9709e455816e..f59b9d6fced523228f088a957f6163369a9c1686 100644 --- a/core/modules/config/src/Form/ConfigSync.php +++ b/core/modules/config/src/Form/ConfigSync.php @@ -293,7 +293,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { batch_set($batch_builder->toArray()); } - catch (ConfigImporterException $e) { + catch (ConfigImporterException) { // There are validation errors. $this->messenger()->addError($this->t('The configuration cannot be imported because it failed validation for the following reasons:')); foreach ($config_importer->getErrors() as $message) { diff --git a/core/modules/config/tests/src/Functional/ConfigEntityTest.php b/core/modules/config/tests/src/Functional/ConfigEntityTest.php index 686e379cbaf1c75e52bc3fb0efa96937e5e604a5..7253459564fcff80d01a69ee09d145e885c1d1c0 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityTest.php @@ -179,7 +179,7 @@ public function testCRUD(): void { '@max' => static::MAX_ID_LENGTH, ])); } - catch (ConfigEntityIdLengthException $e) { + catch (ConfigEntityIdLengthException) { // Expected exception; just continue testing. } @@ -193,7 +193,7 @@ public function testCRUD(): void { $same_id->save(); $this->fail('Not possible to overwrite an entity.'); } - catch (EntityStorageException $e) { + catch (EntityStorageException) { // Expected exception; just continue testing. } diff --git a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php index 00b6f4b56c2d4cca14e1c70aa11be7a622e771e6..80a5221c74aef2238a1f3fa714fb42824f2940ff 100644 --- a/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php +++ b/core/modules/config/tests/src/Functional/ConfigInstallWebTest.php @@ -237,7 +237,7 @@ public function testConfigModuleRequirements(): void { try { \Drupal::service('file_system')->deleteRecursive($directory); } - catch (FileException $e) { + catch (FileException) { // Ignore failed deletes. } $this->drupalGet('/admin/reports/status'); diff --git a/core/modules/config_translation/config_translation.api.php b/core/modules/config_translation/config_translation.api.php index 8e337309c02c2c11f080c0aff513ef7c5b11bcd5..64a219de8a67eb0d34fb550a8bfa790124ab3cdc 100644 --- a/core/modules/config_translation/config_translation.api.php +++ b/core/modules/config_translation/config_translation.api.php @@ -44,7 +44,7 @@ function hook_config_translation_info(&$info) { try { $base_route = $route_provider->getRouteByName('entity.field_config.' . $entity_type_id . '_field_edit_form'); } - catch (RouteNotFoundException $e) { + catch (RouteNotFoundException) { // Ignore non-existent routes. } diff --git a/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php b/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php index 82d988aa9a09951cda40b95fc19884d5aa9fe186..12f79fea7257a9e741fbc018b30d0848a124329b 100644 --- a/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php +++ b/core/modules/config_translation/src/Access/ConfigTranslationFormAccess.php @@ -37,7 +37,7 @@ public function access(RouteMatchInterface $route_match, AccountInterface $accou return $this->doCheckAccess($account, $mapper, $source_language, $target_language); } - catch (ConfigMapperLanguageException $exception) { + catch (ConfigMapperLanguageException) { return AccessResult::forbidden(); } } diff --git a/core/modules/config_translation/src/Access/ConfigTranslationOverviewAccess.php b/core/modules/config_translation/src/Access/ConfigTranslationOverviewAccess.php index 6d3690fea2979f3ed5c9d5c3402d6eb733fcb000..cac497f7ef66d98ddfa46e41cd6482788305686e 100644 --- a/core/modules/config_translation/src/Access/ConfigTranslationOverviewAccess.php +++ b/core/modules/config_translation/src/Access/ConfigTranslationOverviewAccess.php @@ -60,7 +60,7 @@ public function access(RouteMatchInterface $route_match, AccountInterface $accou try { $langcode = $mapper->getLangcode(); } - catch (ConfigMapperLanguageException $exception) { + catch (ConfigMapperLanguageException) { // ConfigTranslationController shows a helpful message if the language // codes do not match, so do not let that prevent granting access. $langcode = 'en'; diff --git a/core/modules/config_translation/src/Controller/ConfigTranslationController.php b/core/modules/config_translation/src/Controller/ConfigTranslationController.php index 55be906a69de2e0fae9b306582cdc283a6057881..9529ac65a685805d53014840e7210188d971b232 100644 --- a/core/modules/config_translation/src/Controller/ConfigTranslationController.php +++ b/core/modules/config_translation/src/Controller/ConfigTranslationController.php @@ -147,7 +147,7 @@ public function itemPage(Request $request, RouteMatchInterface $route_match, $pl $original_langcode = $mapper->getLangcode(); $operations_access = TRUE; } - catch (ConfigMapperLanguageException $exception) { + catch (ConfigMapperLanguageException) { $items = []; foreach ($mapper->getConfigNames() as $config_name) { $langcode = $mapper->getLangcodeFromConfig($config_name); diff --git a/core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateUserProfileTranslationRollbackTest.php b/core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateUserProfileTranslationRollbackTest.php index e9783463fe90c685203d2d5001d383113028538c..c4127882965a4a1b3cfaaaeef0e5733e9d2320e9 100644 --- a/core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateUserProfileTranslationRollbackTest.php +++ b/core/modules/config_translation/tests/src/Kernel/Migrate/d6/MigrateUserProfileTranslationRollbackTest.php @@ -61,7 +61,7 @@ public function testRollback(): void { (new MigrateExecutable($migration, $this))->rollback(); } } - catch (\Exception $e) { + catch (\Exception) { } } diff --git a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php index d20ac0d49272d81d240f71361207f6741e821e9c..c6813dd7d6609af080071bcaacea9c63d65f35ff 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php @@ -453,7 +453,7 @@ public function testGetLangcode(): void { $this->configNamesMapper->getLangcode(); $this->fail(); } - catch (\RuntimeException $e) { + catch (\RuntimeException) { } } diff --git a/core/modules/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php b/core/modules/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php index ca3cfb6a0049fd869a4fbc15cb8b3ee6d3ca4c33..b9278374000c49ba00d54a3efe1ff91c02f2823c 100644 --- a/core/modules/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php +++ b/core/modules/content_moderation/src/Form/ContentModerationConfigureEntityTypesForm.php @@ -103,7 +103,7 @@ public function buildForm(array $form, FormStateInterface $form_state, ?Workflow try { $this->entityType = $this->entityTypeManager->getDefinition($entity_type_id); } - catch (PluginNotFoundException $e) { + catch (PluginNotFoundException) { throw new NotFoundHttpException(); } diff --git a/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateStorageSchemaTest.php b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateStorageSchemaTest.php index 2f01fb2e56e5603879a6cd3803181be06017670b..e3d7e7568af264c5c0f334dd38ea9c9dfe5b6ad0 100644 --- a/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateStorageSchemaTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/ContentModerationStateStorageSchemaTest.php @@ -140,7 +140,7 @@ protected function assertStorageException(array $values, bool $has_exception): v try { ContentModerationState::updateOrCreateFromEntity($entity); } - catch (\Exception $e) { + catch (\Exception) { $exception_triggered = TRUE; } $this->assertEquals($has_exception, $exception_triggered); diff --git a/core/modules/datetime/src/DateTimeComputed.php b/core/modules/datetime/src/DateTimeComputed.php index b54ca96aa61c11943df6dffa33cdfcde889c4dfb..8de9ded60d20b5f2bb9bf7945a9f5b8ce94340e9 100644 --- a/core/modules/datetime/src/DateTimeComputed.php +++ b/core/modules/datetime/src/DateTimeComputed.php @@ -69,7 +69,7 @@ public function getValue() { } } } - catch (\Exception $e) { + catch (\Exception) { // @todo Handle this. } return $this->date; diff --git a/core/modules/datetime/src/Plugin/Validation/Constraint/DateTimeFormatConstraintValidator.php b/core/modules/datetime/src/Plugin/Validation/Constraint/DateTimeFormatConstraintValidator.php index 16d2f794c424f46f7d7928b987a5a218c2b52136..8c67c05fbe7946a3a3d9165dffde2cfa6c5d438c 100644 --- a/core/modules/datetime/src/Plugin/Validation/Constraint/DateTimeFormatConstraintValidator.php +++ b/core/modules/datetime/src/Plugin/Validation/Constraint/DateTimeFormatConstraintValidator.php @@ -30,14 +30,14 @@ public function validate($item, Constraint $constraint): void { try { $date = DateTimePlus::createFromFormat($format, $value, new \DateTimeZone(DateTimeItemInterface::STORAGE_TIMEZONE)); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { $this->context->addViolation($constraint->badFormat, [ '@value' => $value, '@format' => $format, ]); return; } - catch (\UnexpectedValueException $e) { + catch (\UnexpectedValueException) { $this->context->addViolation($constraint->badValue, [ '@value' => $value, '@format' => $format, diff --git a/core/modules/editor/src/Entity/Editor.php b/core/modules/editor/src/Entity/Editor.php index 25ff5f8e9922bdf93ad8a968f202e01644d04fbf..54d32a8dcbf7137d190234d0dc2ad8d448a71a63 100644 --- a/core/modules/editor/src/Entity/Editor.php +++ b/core/modules/editor/src/Entity/Editor.php @@ -105,7 +105,7 @@ public function __construct(array $values, $entity_type) { $plugin = $this->editorPluginManager()->createInstance($this->editor); $this->settings += $plugin->getDefaultSettings(); } - catch (PluginNotFoundException $e) { + catch (PluginNotFoundException) { // When a Text Editor plugin has gone missing, still allow the Editor // config entity to be constructed. The only difference is that default // settings are not added. diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php index 4afd420822e6052507236604a4df0bf0579de46b..e5d68f9fced93d2fae1d96f60bdf1f983c8fe719 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -688,7 +688,7 @@ public function getOptionsProvider($property_name, FieldableEntityInterface $ent try { $items = $entity->get($this->getName()); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // When a field doesn't exist, create a new field item list using a // temporary base field definition. This step is necessary since there // may not be a field configuration for the storage when creating a new diff --git a/core/modules/field/src/Plugin/migrate/process/FieldType.php b/core/modules/field/src/Plugin/migrate/process/FieldType.php index a4410b2119836674772f53b6d74f86892b50c03d..52d5cc5ba15a4b4abb0dcc8bade82a556affafb9 100644 --- a/core/modules/field/src/Plugin/migrate/process/FieldType.php +++ b/core/modules/field/src/Plugin/migrate/process/FieldType.php @@ -71,7 +71,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable $plugin_id = $this->fieldPluginManager->getPluginIdFromFieldType($field_type, [], $this->migration); return $this->fieldPluginManager->createInstance($plugin_id, [], $this->migration)->getFieldType($row); } - catch (PluginNotFoundException $e) { + catch (PluginNotFoundException) { return parent::transform($value, $migrate_executable, $row, $destination_property); } } diff --git a/core/modules/field/src/Plugin/migrate/process/ProcessField.php b/core/modules/field/src/Plugin/migrate/process/ProcessField.php index 80bf8254365794a2119b82307d1293df867d58c2..e308d9e28ac43ca54631526adf0e8f32488df100 100644 --- a/core/modules/field/src/Plugin/migrate/process/ProcessField.php +++ b/core/modules/field/src/Plugin/migrate/process/ProcessField.php @@ -104,7 +104,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable try { return $this->callMethodOnFieldPlugin($this->fieldPluginManager, $value, $method, $row); } - catch (PluginNotFoundException $e) { + catch (PluginNotFoundException) { return NULL; } } diff --git a/core/modules/field/tests/src/Kernel/FieldCrudTest.php b/core/modules/field/tests/src/Kernel/FieldCrudTest.php index 57ebe04bf314f8df906e0ddcfecda00fa4937f06..c22812ceb6b81f3faf0299143f1a3977cb64776b 100644 --- a/core/modules/field/tests/src/Kernel/FieldCrudTest.php +++ b/core/modules/field/tests/src/Kernel/FieldCrudTest.php @@ -107,7 +107,7 @@ public function testCreateField(): void { FieldConfig::create($this->fieldDefinition)->save(); $this->fail('Cannot create two fields with the same field / bundle combination.'); } - catch (EntityStorageException $e) { + catch (EntityStorageException) { // Expected exception; just continue testing. } @@ -117,7 +117,7 @@ public function testCreateField(): void { FieldConfig::create($this->fieldDefinition)->save(); $this->fail('Cannot create a field with a non-existing storage.'); } - catch (FieldException $e) { + catch (FieldException) { // Expected exception; just continue testing. } diff --git a/core/modules/file/file.module b/core/modules/file/file.module index d59cc8dc2e0532b42c03a2ac868a8c1a1a601517..b1a5c3eb489b94ed0f25ac12a21f0820aae3ff4c 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -409,24 +409,24 @@ function file_save_upload($form_field_name, $validators = [], $destination = FAL } $files[$i] = $file; } - catch (FileExistsException $e) { + catch (FileExistsException) { \Drupal::messenger()->addError(t('Destination file "%file" exists', ['%file' => $destination . $uploaded_file->getFilename()])); $files[$i] = FALSE; } - catch (InvalidStreamWrapperException $e) { + catch (InvalidStreamWrapperException) { \Drupal::messenger()->addError(t('The file could not be uploaded because the destination "%destination" is invalid.', ['%destination' => $destination])); $files[$i] = FALSE; } - catch (FileWriteException $e) { + catch (FileWriteException) { \Drupal::messenger()->addError(t('File upload error. Could not move uploaded file.')); \Drupal::logger('file')->notice('Upload error. Could not move uploaded file %file to destination %destination.', ['%file' => $uploaded_file->getClientOriginalName(), '%destination' => $destination . '/' . $uploaded_file->getClientOriginalName()]); $files[$i] = FALSE; } - catch (FileException $e) { + catch (FileException) { \Drupal::messenger()->addError(t('The file %filename could not be uploaded because the name is invalid.', ['%filename' => $uploaded_file->getClientOriginalName()])); $files[$i] = FALSE; } - catch (LockAcquiringException $e) { + catch (LockAcquiringException) { \Drupal::messenger()->addError(t('File already locked for writing.')); $files[$i] = FALSE; } diff --git a/core/modules/file/src/Entity/File.php b/core/modules/file/src/Entity/File.php index fee3b5e2d3d04e04f7b673371db6cafd8ce83d0c..c7885e81f369ba92768ae7c3ccbe22efaeb4fc94 100644 --- a/core/modules/file/src/Entity/File.php +++ b/core/modules/file/src/Entity/File.php @@ -211,7 +211,7 @@ public static function preDelete(EntityStorageInterface $storage, array $entitie try { \Drupal::service('file_system')->delete($entity->getFileUri()); } - catch (FileException $e) { + catch (FileException) { // Ignore and continue. } } diff --git a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php index 414fbceac953e124e3c6bbc6cf5e9fab9e85c226..caab7bcc6b0cf10f4db86d11933d4bf6c1004dd9 100644 --- a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php +++ b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php @@ -176,7 +176,7 @@ public function post(Request $request, $entity_type_id, $bundle, $field_name) { catch (FileExistsException $e) { throw new HttpException(statusCode: 500, message: $e->getMessage(), previous: $e); } - catch (FileException $e) { + catch (FileException) { throw new HttpException(500, 'Temporary file could not be moved to file location'); } diff --git a/core/modules/help/src/HelpTwigExtension.php b/core/modules/help/src/HelpTwigExtension.php index fdd0085ee1e279ca1dc38ff8687b6d8f706b9324..e41ad66503dc5f82b2cff7b2aa41a42054b64d65 100644 --- a/core/modules/help/src/HelpTwigExtension.php +++ b/core/modules/help/src/HelpTwigExtension.php @@ -97,7 +97,7 @@ public function getRouteLink(string $text, string $route, array $parameters = [] $build = ['#markup' => $text]; } } - catch (RouteNotFoundException | MissingMandatoryParametersException | InvalidParameterException $e) { + catch (RouteNotFoundException | MissingMandatoryParametersException | InvalidParameterException) { // If the route had one of these exceptions, return the link text. $build = ['#markup' => $text]; } @@ -127,7 +127,7 @@ public function getTopicLink(string $topic_id): array { try { $plugin = $this->pluginManager->createInstance($topic_id); } - catch (PluginNotFoundException $e) { + catch (PluginNotFoundException) { // Not a topic. $plugin = FALSE; } diff --git a/core/modules/image/image.install b/core/modules/image/image.install index d715309587679e4d4290afe4022bb2575bcea060..a7e5d2fa58eeaca3df915516a5a5fb6891349481 100644 --- a/core/modules/image/image.install +++ b/core/modules/image/image.install @@ -27,7 +27,7 @@ function image_uninstall() { try { $file_system->deleteRecursive(\Drupal::config('system.file')->get('default_scheme') . '://styles'); } - catch (FileException $e) { + catch (FileException) { // Ignore failed deletes. } } diff --git a/core/modules/image/src/Entity/ImageStyle.php b/core/modules/image/src/Entity/ImageStyle.php index abb6160dffd71612230183c602d8968ca9ebdea7..17ac3abbdeaef7c49e7d063e2a0ffe976c88199e 100644 --- a/core/modules/image/src/Entity/ImageStyle.php +++ b/core/modules/image/src/Entity/ImageStyle.php @@ -236,7 +236,7 @@ public function buildUrl($path, $clean_urls = NULL) { $request = \Drupal::request(); $clean_urls = RequestHelper::isCleanUrl($request); } - catch (ServiceNotFoundException $e) { + catch (ServiceNotFoundException) { } } @@ -274,7 +274,7 @@ public function flush($path = NULL) { try { $file_system->delete($derivative_uri); } - catch (FileException $e) { + catch (FileException) { // Ignore failed deletes. } } @@ -287,7 +287,7 @@ public function flush($path = NULL) { try { $file_system->deleteRecursive($directory); } - catch (FileException $e) { + catch (FileException) { // Ignore failed deletes. } } diff --git a/core/modules/image/src/Form/ImageEffectFormBase.php b/core/modules/image/src/Form/ImageEffectFormBase.php index 1e9cd77c898dbfeeb40663423fefc28ca0369aae..8541b5c449ad03b983a8454e14b07c6dd907a339 100644 --- a/core/modules/image/src/Form/ImageEffectFormBase.php +++ b/core/modules/image/src/Form/ImageEffectFormBase.php @@ -58,7 +58,7 @@ public function buildForm(array $form, FormStateInterface $form_state, ?ImageSty try { $this->imageEffect = $this->prepareImageEffect($image_effect); } - catch (PluginNotFoundException $e) { + catch (PluginNotFoundException) { throw new NotFoundHttpException("Invalid effect id: '$image_effect'."); } $request = $this->getRequest(); diff --git a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php index 29fa146d487431b8ca07785c3ddc5d7eda143a1f..547f47278b4477d9ae615f07121615ef03575a27 100644 --- a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php +++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php @@ -376,7 +376,7 @@ public static function generateSampleValue(FieldDefinitionInterface $field_defin try { $file_system->move($tmp_file, $destination); } - catch (FileException $e) { + catch (FileException) { // Ignore failed move. } if ($path = $random->image($file_system->realpath($destination), $min_resolution, $max_resolution)) { diff --git a/core/modules/jsonapi/src/Controller/EntryPoint.php b/core/modules/jsonapi/src/Controller/EntryPoint.php index 6763d9e9a3d08d47d485017a593ecacd596e6f55..1aac73cc42afc8fd1b1ef80521fcb5ab2a3cfb41 100644 --- a/core/modules/jsonapi/src/Controller/EntryPoint.php +++ b/core/modules/jsonapi/src/Controller/EntryPoint.php @@ -118,7 +118,7 @@ public function index() { // itself and the currently authenticated user. $cacheability = $cacheability->merge($me_url); } - catch (RouteNotFoundException $e) { + catch (RouteNotFoundException) { // Do not add the link if the route is disabled or marked as internal. } } diff --git a/core/modules/jsonapi/src/Controller/FileUpload.php b/core/modules/jsonapi/src/Controller/FileUpload.php index 7e869a0d51979e46ad81e4046b2a26ecc65f8825..0867d2c0e35f9bf8eea6352f6d065bf0237e15ce 100644 --- a/core/modules/jsonapi/src/Controller/FileUpload.php +++ b/core/modules/jsonapi/src/Controller/FileUpload.php @@ -204,7 +204,7 @@ protected function handleFileUploadForResource(Request $request, ResourceType $r catch (FileExistsException $e) { throw new HttpException(500, $e->getMessage(), $e); } - catch (FileException $e) { + catch (FileException) { throw new HttpException(500, 'Temporary file could not be moved to file location'); } diff --git a/core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php b/core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php index e7d55cdfc67751d412cbb1948ded50ea573a1f46..f9ea4a5f5cf1bfbbd7e10f0be9dc5c2176221c3c 100644 --- a/core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php @@ -114,7 +114,7 @@ public function denormalize($data, $class, $format = NULL, array $context = []): try { $entity_storage = $this->entityTypeManager->getStorage($entity_type_id); } - catch (PluginNotFoundException $e) { + catch (PluginNotFoundException) { throw new BadRequestHttpException("Invalid type specified for related resource: '" . $relationship['data'][0]['type'] . "'"); } // In order to maintain the order ($delta) of the relationships, we need diff --git a/core/modules/jsonapi/src/Revisions/VersionNegotiator.php b/core/modules/jsonapi/src/Revisions/VersionNegotiator.php index d0e2d9a822c62e321a6ee8c82020be80c3f37fba..82978ece4dcfea5d1a58fa50a4c30f3f84360188 100644 --- a/core/modules/jsonapi/src/Revisions/VersionNegotiator.php +++ b/core/modules/jsonapi/src/Revisions/VersionNegotiator.php @@ -71,10 +71,10 @@ public function getRevision(EntityInterface $entity, $resource_version_identifie } return $this->negotiators[$version_negotiator_name]->getRevision($entity, $version_argument); } - catch (VersionNotFoundException $exception) { + catch (VersionNotFoundException) { static::throwNotFoundHttpException($entity, $resource_version_identifier); } - catch (InvalidVersionIdentifierException $exception) { + catch (InvalidVersionIdentifierException) { static::throwBadRequestHttpException($resource_version_identifier); } } diff --git a/core/modules/language/src/ConfigurableLanguageManager.php b/core/modules/language/src/ConfigurableLanguageManager.php index 67ff2a991cbaf821873a5ac7d908775931d4e0d5..929c81b38ffdb80a992b81cb2428c10bb1c22aa1 100644 --- a/core/modules/language/src/ConfigurableLanguageManager.php +++ b/core/modules/language/src/ConfigurableLanguageManager.php @@ -423,7 +423,7 @@ public function getLanguageSwitchLinks($type, Url $url) { try { return $url instanceof Url && $url->access(); } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } }); diff --git a/core/modules/language/tests/src/Kernel/LanguageDependencyInjectionTest.php b/core/modules/language/tests/src/Kernel/LanguageDependencyInjectionTest.php index 155075ce50931f31b8b0d0463f04e81d2e470579..ae1dc298de6815cc882590bc009d28154e1ac948 100644 --- a/core/modules/language/tests/src/Kernel/LanguageDependencyInjectionTest.php +++ b/core/modules/language/tests/src/Kernel/LanguageDependencyInjectionTest.php @@ -47,7 +47,7 @@ public function testDependencyInjectedNewDefaultLanguage(): void { $fr->delete(); $this->fail('Expected DeleteDefaultLanguageException thrown.'); } - catch (DeleteDefaultLanguageException $e) { + catch (DeleteDefaultLanguageException) { // Expected exception; just continue testing. } diff --git a/core/modules/language/tests/src/Kernel/LanguageNegotiatorPluginTest.php b/core/modules/language/tests/src/Kernel/LanguageNegotiatorPluginTest.php index 9673ec3ab92fda969c653114162ac54ef1f2b6be..c6ce283b4ba189f589cfd22096530514b5c9ba9c 100644 --- a/core/modules/language/tests/src/Kernel/LanguageNegotiatorPluginTest.php +++ b/core/modules/language/tests/src/Kernel/LanguageNegotiatorPluginTest.php @@ -47,7 +47,7 @@ public function testLanguageNegotiatorNoPlugin(): void { try { $languageNegotiator->initializeType(LanguageInterface::TYPE_URL); } - catch (PluginNotFoundException $exception) { + catch (PluginNotFoundException) { $this->fail('Plugin not found exception unhandled.'); } $log_message = $logger->cleanLogs()[0]; diff --git a/core/modules/layout_builder/src/SectionStorage/SectionStorageManager.php b/core/modules/layout_builder/src/SectionStorage/SectionStorageManager.php index c4c7a866c2768f7d9f72928d3a88fc8a2d0df1a8..0bc8c321684ac0847c855e0ddd7268400708b7f2 100644 --- a/core/modules/layout_builder/src/SectionStorage/SectionStorageManager.php +++ b/core/modules/layout_builder/src/SectionStorage/SectionStorageManager.php @@ -75,7 +75,7 @@ public function load($type, array $contexts = []) { try { $this->contextHandler->applyContextMapping($plugin, $contexts); } - catch (ContextException $e) { + catch (ContextException) { return NULL; } return $plugin; diff --git a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php index c8d45a5b84d63cf2d96088bc9b4076aaa8de3fd0..f07c51e324aca72541f55d6b8bef9fbcf8cd40bd 100644 --- a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php +++ b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php @@ -238,7 +238,7 @@ protected function buildUrl(LinkItemInterface $item) { try { $url = $item->getUrl(); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // @todo Add logging here in https://www.drupal.org/project/drupal/issues/3348020 $url = Url::fromRoute('<none>'); } diff --git a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php index b596be82f73c7c889693876bc13edf7057fc4de7..4055221c60967d244f29632d5aa093957f1b1c68 100644 --- a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php +++ b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php @@ -192,7 +192,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $display_uri = static::getUriAsDisplayableString($item->uri); } } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // If $item->uri is invalid, show value as is, so the user can see what // to edit. // @todo Add logging here in https://www.drupal.org/project/drupal/issues/3348020 diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraintValidator.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraintValidator.php index b7031dd686208629a17b6dceafbfbfedc7139dc1..3bde4a57aed6cdebacb9b9215fb140bb4ecef15b 100644 --- a/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraintValidator.php +++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkAccessConstraintValidator.php @@ -49,7 +49,7 @@ public function validate($value, Constraint $constraint): void { $url = $value->getUrl(); } // If the URL is malformed this constraint cannot check access. - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { return; } // Disallow URLs if the current user doesn't have the 'link to any page' diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidator.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidator.php index a7d52bc58d6ac616b13e8ebde6b1d25fb91ea70e..5141e35608a300306f696da175388e8ef90e8dbc 100644 --- a/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidator.php +++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkExternalProtocolsConstraintValidator.php @@ -21,7 +21,7 @@ public function validate($value, Constraint $constraint): void { $url = $value->getUrl(); } // If the URL is malformed this constraint cannot check further. - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { return; } // Disallow external URLs using untrusted protocols. diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraintValidator.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraintValidator.php index 0711971c0b2701688fd174a94a9df7965f523737..30cc4780a2a7a7315e9fd25919773f8f6dbdedbf 100644 --- a/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraintValidator.php +++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkNotExistingInternalConstraintValidator.php @@ -23,7 +23,7 @@ public function validate($value, Constraint $constraint): void { $url = $value->getUrl(); } // If the URL is malformed this constraint cannot check further. - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { return; } @@ -34,13 +34,13 @@ public function validate($value, Constraint $constraint): void { } // The following exceptions are all possible during URL generation, and // should be considered as disallowed URLs. - catch (RouteNotFoundException $e) { + catch (RouteNotFoundException) { $allowed = FALSE; } - catch (InvalidParameterException $e) { + catch (InvalidParameterException) { $allowed = FALSE; } - catch (MissingMandatoryParametersException $e) { + catch (MissingMandatoryParametersException) { $allowed = FALSE; } if (!$allowed) { diff --git a/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraintValidator.php b/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraintValidator.php index 603f0d0d5f2833933bc5cf190f9beb2633813ab1..374500a5b40a6d7812660b86b58837f37766c109 100644 --- a/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraintValidator.php +++ b/core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraintValidator.php @@ -26,7 +26,7 @@ public function validate($value, Constraint $constraint): void { try { $url = $link_item->getUrl(); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { $uri_is_valid = FALSE; } diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index 36a11f30559d8dc2e89e9e5ed679ac2ee8ac39c1..44696b0874a68ca3daa99fc9dbe9d2c995267cf2 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -255,7 +255,7 @@ function locale_translate_batch_import($file, array $options, &$context) { } } } - catch (Exception $exception) { + catch (Exception) { // Import failed. Store the data of the failing file. $context['results']['failed_files'][] = $file; \Drupal::logger('locale')->notice('Unable to import translations file: @file', ['@file' => $file->uri]); @@ -518,7 +518,7 @@ function locale_translate_delete_translation_files(array $projects = [], array $ try { \Drupal::service('file_system')->delete($file->uri); } - catch (FileException $e) { + catch (FileException) { $fail = TRUE; } } diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install index 6053bfb158e10bf2b6369a18c0097f52e4d2dae9..0b204f7103db879cb9cba4859454fb2879604650 100644 --- a/core/modules/locale/locale.install +++ b/core/modules/locale/locale.install @@ -46,7 +46,7 @@ function locale_uninstall() { try { $file_system->delete($locale_js_directory . '/' . $langcode . '_' . $file_suffix . '.js'); } - catch (FileException $e) { + catch (FileException) { // Ignore and continue. } } diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 32adcb36c42841f3f6f6551e5abebe45bffcf15f..88fbdfe04d5b4266aee34a92db106c35d7d18f11 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -1272,7 +1272,7 @@ function _locale_rebuild_js($langcode = NULL) { try { $file_system->delete($dir . '/' . $language->getId() . '_' . $locale_javascripts[$language->getId()] . '.js'); } - catch (FileException $e) { + catch (FileException) { // Ignore. } $locale_javascripts[$language->getId()] = ''; @@ -1311,7 +1311,7 @@ function _locale_rebuild_js($langcode = NULL) { $status = 'error'; } } - catch (FileException $e) { + catch (FileException) { // Do nothing. } } diff --git a/core/modules/media/media.install b/core/modules/media/media.install index 00a1d3269f67c8915cd70010235807ac98bab7dc..ec43e36cb36d86f738e9390555f964b39bf9b11b 100644 --- a/core/modules/media/media.install +++ b/core/modules/media/media.install @@ -38,7 +38,7 @@ function media_install() { try { $file_system->copy($file->uri, $destination, FileExists::Error); } - catch (FileException $e) { + catch (FileException) { // Ignore and continue. } diff --git a/core/modules/media/src/OEmbed/Provider.php b/core/modules/media/src/OEmbed/Provider.php index c3ea5a4855b4283e5164bb35f7152848c435915f..415bc9677a788748920dd1cb647af9b4bae8b521 100644 --- a/core/modules/media/src/OEmbed/Provider.php +++ b/core/modules/media/src/OEmbed/Provider.php @@ -56,7 +56,7 @@ public function __construct($name, $url, array $endpoints) { $this->endpoints[] = new Endpoint($endpoint['url'], $this, $endpoint['schemes'], $endpoint['formats'], $endpoint['discovery']); } } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // Just skip all the invalid endpoints. // @todo Log the exception message to help with debugging in // https://www.drupal.org/project/drupal/issues/2972846. diff --git a/core/modules/media/src/Plugin/media/Source/OEmbed.php b/core/modules/media/src/Plugin/media/Source/OEmbed.php index b300fadc677b30dd10ed9685760a1ca5539ebf8b..3f58ca120511badd58c223b8f2e3254eac284ef0 100644 --- a/core/modules/media/src/Plugin/media/Source/OEmbed.php +++ b/core/modules/media/src/Plugin/media/Source/OEmbed.php @@ -455,7 +455,7 @@ protected function getLocalThumbnailUri(Resource $resource, MediaInterface $medi '%error' => $e->getMessage(), ]); } - catch (FileException $e) { + catch (FileException) { $this->logger->warning('Could not download remote thumbnail from {url}.', [ 'url' => $remote_thumbnail_url, ]); diff --git a/core/modules/migrate/src/Controller/MigrateMessageController.php b/core/modules/migrate/src/Controller/MigrateMessageController.php index 360482801e1dbe5f311fc1bca10f026456790389..385b89f343b8cfa8ee8f94c15a8c8a68480b18e3 100644 --- a/core/modules/migrate/src/Controller/MigrateMessageController.php +++ b/core/modules/migrate/src/Controller/MigrateMessageController.php @@ -146,7 +146,7 @@ public function details(string $migration_id, Request $request): array { try { $fields = $source_plugin->fields(); } - catch (DatabaseConnectionRefusedException | DatabaseNotFoundException | RequirementsException | \PDOException $e) { + catch (DatabaseConnectionRefusedException | DatabaseNotFoundException | RequirementsException | \PDOException) { } $source_id_field_names = array_keys($source_plugin->getIds()); diff --git a/core/modules/migrate/src/MigrateExecutable.php b/core/modules/migrate/src/MigrateExecutable.php index e3d16b4ac7354433ab36b481f592c2cc9de20e20..0a3c13928e00089f5354ca6c57bf86e3c96de077 100644 --- a/core/modules/migrate/src/MigrateExecutable.php +++ b/core/modules/migrate/src/MigrateExecutable.php @@ -452,7 +452,7 @@ protected function processPipeline(Row $row, string $destination, array $plugins try { $value = $plugin->transform($value, $this, $row, $destination); } - catch (MigrateSkipProcessException $e) { + catch (MigrateSkipProcessException) { $value = NULL; break; } diff --git a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php index 5a7485772dbcedf94af3bb93bd5a67761fe6f55c..1df1b2f96c7d13e4438f162db238c9bad83a3015 100644 --- a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php +++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php @@ -657,7 +657,7 @@ public function lookupDestinationIds(array $source_id_values) { try { return $query->execute()->fetchAll(\PDO::FETCH_NUM); } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // It's possible that the query will cause an exception to be thrown. For // example, the URL alias migration uses a dummy node ID of 'INVALID_NID' // to cause the lookup to return no results. On PostgreSQL this causes an @@ -824,7 +824,7 @@ protected function countHelper($status = NULL, $table = NULL) { try { $count = (int) $query->countQuery()->execute()->fetchField(); } - catch (DatabaseException $e) { + catch (DatabaseException) { // The table does not exist, therefore there are no records. $count = 0; } diff --git a/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php b/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php index 487a252e4b97b6d82a5d1cbf158ccc73fd62bdca..e42d235302011ea0d22a0069d6f64a3f01e2050b 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php +++ b/core/modules/migrate/src/Plugin/migrate/process/FileCopy.php @@ -191,7 +191,7 @@ protected function writeFile($source, $destination, FileExists|int $fileExists = return $this->fileSystem->copy($source, $destination, $fileExists); } } - catch (FileException $e) { + catch (FileException) { return FALSE; } } diff --git a/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php index c8357abfc89997a87091e9a0f84f8d6b888b159e..5c4554caede01dc6945a64f6a8c7463ea0cd709c 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php +++ b/core/modules/migrate/src/Plugin/migrate/process/MigrationLookup.php @@ -250,10 +250,10 @@ public function transform($value, MigrateExecutableInterface $migrate_executable try { $destination_ids = $this->migrateStub->createStub($stub_migration, $source_id_values[$stub_migration], [], FALSE); } - catch (\LogicException $e) { + catch (\LogicException) { // For BC reasons, we must allow attempting to stub a derived migration. } - catch (PluginNotFoundException $e) { + catch (PluginNotFoundException) { // For BC reasons, we must allow attempting to stub a non-existent // migration. } diff --git a/core/modules/migrate/src/Plugin/migrate/process/SubProcess.php b/core/modules/migrate/src/Plugin/migrate/process/SubProcess.php index 120e57758181c781e0c0607e1289d05ea2ae9c9d..ee58a51879a01e10aeb7dc268d3a8cc10cd73686 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/SubProcess.php +++ b/core/modules/migrate/src/Plugin/migrate/process/SubProcess.php @@ -212,7 +212,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable try { $migrate_executable->processRow($new_row, $this->configuration['process']); } - catch (MigrateSkipRowException $e) { + catch (MigrateSkipRowException) { continue; } $destination = $new_row->getDestination(); diff --git a/core/modules/migrate/tests/src/Kernel/Plugin/MigrationPluginListTest.php b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationPluginListTest.php index cd318fdd23d39a195ae3dc378d1bc1f5c2acd295..41121f455093527d8553f59a903e8e839a797263 100644 --- a/core/modules/migrate/tests/src/Kernel/Plugin/MigrationPluginListTest.php +++ b/core/modules/migrate/tests/src/Kernel/Plugin/MigrationPluginListTest.php @@ -111,7 +111,7 @@ public function testGetDefinitions(): void { try { $source_plugin->checkRequirements(); } - catch (RequirementsException $e) { + catch (RequirementsException) { unset($source_plugins[$id]); } } diff --git a/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php b/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php index b11e3c43a6e04feb8f255deddf6b47d8f9d4f3cb..a5e01ab202bd870debf33a5b8f262a5a4facd8f7 100644 --- a/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php +++ b/core/modules/migrate/tests/src/Kernel/process/DownloadTest.php @@ -83,7 +83,7 @@ public function testWriteProtectedDestination(): void { $fix_permissions(); $this->fail('MigrateException was not thrown for non-writable destination URI.'); } - catch (MigrateException $e) { + catch (MigrateException) { $this->assertTrue(TRUE, 'MigrateException was thrown for non-writable destination URI.'); $fix_permissions(); } diff --git a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php index 67e979bd116978f680f444dfa823543dc14af384..555db5589233ebaa98de8b1e8c5af490e58958d1 100644 --- a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php @@ -924,7 +924,7 @@ public function testSetUpdate(): void { $id_map->setUpdate([]); $this->assertFalse(FALSE, 'MigrateException not thrown, when source identifiers were provided to update.'); } - catch (MigrateException $e) { + catch (MigrateException) { $this->assertTrue(TRUE, "MigrateException thrown, when source identifiers were not provided to update."); } } diff --git a/core/modules/migrate_drupal/src/FieldDiscovery.php b/core/modules/migrate_drupal/src/FieldDiscovery.php index f1c4745ece90dba00dc6380a8e938a3b46083edb..4a26c9708d60026c49fed7f061d5ec8b830f97b2 100644 --- a/core/modules/migrate_drupal/src/FieldDiscovery.php +++ b/core/modules/migrate_drupal/src/FieldDiscovery.php @@ -184,7 +184,7 @@ protected function getFieldPlugin($field_type, MigrationInterface $migration) { $plugin_id = $this->fieldPluginManager->getPluginIdFromFieldType($field_type, ['core' => $core], $migration); $plugin = $this->fieldPluginManager->createInstance($plugin_id, ['core' => $core], $migration); } - catch (PluginNotFoundException $ex) { + catch (PluginNotFoundException) { $plugin = FALSE; } $this->fieldPluginCache[$core][$field_type] = $plugin; diff --git a/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php b/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php index 5df2c0b06f2ee5633e71b846bf38a5fa86d25b51..035b2e5fb6689f1914f0360c8ec6c1795fd48b99 100644 --- a/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php +++ b/core/modules/migrate_drupal/src/MigrationConfigurationTrait.php @@ -78,7 +78,7 @@ protected function getSystemData(Connection $connection) { $system_data[$result['type']][$result['name']] = $result; } } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // The table might not exist for example in tests. } return $system_data; @@ -167,7 +167,7 @@ protected function getMigrations($database_state_key, $drupal_version) { } $migrations[] = $migration; } - catch (RequirementsException $e) { + catch (RequirementsException) { // Migrations which are not applicable given the source and destination // site configurations (e.g., what modules are enabled) will be silently // ignored. @@ -212,7 +212,7 @@ public static function getLegacyDrupalVersion(Connection $connection) { ->query('SELECT [schema_version] FROM {system} WHERE [name] = :module', [':module' => 'system']) ->fetchField(); } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // All database errors return FALSE. } } diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php index 7ee0786dfc06e072b5722fb7a5447008f0890392..e5c094342b210f75509fa75651f40ae44389d00d 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php @@ -77,7 +77,7 @@ public function getSystemData() { $this->systemData[$result['type']][$result['name']] = $result; } } - catch (\Exception $e) { + catch (\Exception) { // The table might not exist for example in tests. } } @@ -169,7 +169,7 @@ protected function variableGet($name, $default) { ->fetchField(); } // The table might not exist. - catch (\Exception $e) { + catch (\Exception) { $result = FALSE; } return $result !== FALSE ? unserialize($result) : $default; diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php index 2b874381d1cc078fbae39ca235505177324bfad7..2a639219a00eccc1309cb8b06592ff7a55673282 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php @@ -148,7 +148,7 @@ protected function getEntityTranslationSourceLanguage($entity_type, $entity_id) ->fetchField(); } // The table might not exist. - catch (\Exception $e) { + catch (\Exception) { return FALSE; } } diff --git a/core/modules/migrate_drupal/tests/src/Kernel/dependencies/MigrateDependenciesTest.php b/core/modules/migrate_drupal/tests/src/Kernel/dependencies/MigrateDependenciesTest.php index 92351d30a3540feeed12d6c8c36aad9715a3bcf8..762b36308cdedd79c21ec14d58ef5eec433e0090 100644 --- a/core/modules/migrate_drupal/tests/src/Kernel/dependencies/MigrateDependenciesTest.php +++ b/core/modules/migrate_drupal/tests/src/Kernel/dependencies/MigrateDependenciesTest.php @@ -40,7 +40,7 @@ public function testMigrationDependenciesOrder(): void { catch (RequirementsException $e) { $this->assertEquals('Missing migrations d6_comment_type, d6_user, d6_comment_entity_display, d6_node_type, d6_comment_entity_form_display, d6_node_settings, d6_filter_format, d6_node:company, d6_node:employee, d6_node:forum, d6_node:page, d6_node:story, d6_node:test_planet.', $e->getMessage()); } - catch (\Exception $e) { + catch (\Exception) { $this->fail("The requirements check threw an exception, but it was not the expected RequirementsException"); } } diff --git a/core/modules/migrate_drupal_ui/src/Form/ReviewForm.php b/core/modules/migrate_drupal_ui/src/Form/ReviewForm.php index 08172325a6f3173588e1d24d66f7d3df2eedaeff..977ee488ac566d98b6a3895785719b5439633a65 100644 --- a/core/modules/migrate_drupal_ui/src/Form/ReviewForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/ReviewForm.php @@ -301,7 +301,7 @@ protected function prepareOutput(array $migration_state) { try { $destination_module_names[] = $this->moduleExtensionList->getName($destination_module); } - catch (UnknownExtensionException $e) { + catch (UnknownExtensionException) { $destination_module_names[] = $destination_module; } } diff --git a/core/modules/mysql/src/Driver/Database/mysql/Install/Tasks.php b/core/modules/mysql/src/Driver/Database/mysql/Install/Tasks.php index b7b7a14908c9733c3aa695aa03e95d7403c77d95..3743235a6a86ea574612778ceafb2ff860862ba3 100644 --- a/core/modules/mysql/src/Driver/Database/mysql/Install/Tasks.php +++ b/core/modules/mysql/src/Driver/Database/mysql/Install/Tasks.php @@ -53,7 +53,7 @@ public function name() { } return $this->t('MySQL, Percona Server, or equivalent'); } - catch (ConnectionNotDefinedException $e) { + catch (ConnectionNotDefinedException) { return $this->t('MySQL, MariaDB, Percona Server, or equivalent'); } } diff --git a/core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php b/core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php index 2c19b5984e341aa48d4947d40fa0134f42e5e050..7e6e7fcb588231d808dda38e39133ce8d9df644a 100644 --- a/core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php +++ b/core/modules/mysql/tests/src/Kernel/mysql/SchemaTest.php @@ -142,7 +142,7 @@ public function testIndexLength(): void { $this->schema->addIndex('test_table_index_length', 'test_separate', [['test_field_text', 200]], $table_specification); $this->fail('\Drupal\Core\Database\SchemaObjectExistsException exception missed.'); } - catch (SchemaObjectExistsException $e) { + catch (SchemaObjectExistsException) { // Expected exception; just continue testing. } @@ -150,7 +150,7 @@ public function testIndexLength(): void { $this->schema->addIndex('test_table_non_existing', 'test_separate', [['test_field_text', 200]], $table_specification); $this->fail('\Drupal\Core\Database\SchemaObjectDoesNotExistException exception missed.'); } - catch (SchemaObjectDoesNotExistException $e) { + catch (SchemaObjectDoesNotExistException) { // Expected exception; just continue testing. } @@ -325,7 +325,7 @@ public function testGeneratedInvisiblePrimaryKey(): void { try { $this->connection->query("SET sql_generate_invisible_primary_key = 1;")->execute(); } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { $this->markTestSkipped('This test requires the SESSION_VARIABLES_ADMIN privilege.'); } $this->schema->createTable('test_primary_key', [ diff --git a/core/modules/navigation/src/NavigationContentLinks.php b/core/modules/navigation/src/NavigationContentLinks.php index ccdd0630261eb77a8a0e49961153f90e9b840f2f..8093b417b597eca5a5270d2dbaf2c85f96ecd103 100644 --- a/core/modules/navigation/src/NavigationContentLinks.php +++ b/core/modules/navigation/src/NavigationContentLinks.php @@ -197,7 +197,7 @@ private function addLink(string $link_name, array $link, array &$links): void { $this->routeProvider->getRouteByName($link['route_name']); $links[$link_name] = $link + ['menu_name' => 'content', 'provider' => 'navigation']; } - catch (RouteNotFoundException $e) { + catch (RouteNotFoundException) { // The module isn't installed, or the route (such as provided by a view) // has been deleted. } diff --git a/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php index b5fdc54a90fffe2ceeb2ebf5659369521c5246ba..184492e8f7b18590bf752b2478a2c5895f185f3a 100644 --- a/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php +++ b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php @@ -80,7 +80,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { try { $node_types->checkRequirements(); } - catch (RequirementsException $e) { + catch (RequirementsException) { // If the d6_node_type requirements failed, that means we do not have a // Drupal source database configured - there is nothing to generate. return $this->derivatives; @@ -111,7 +111,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives[$node_type] = $migration->getPluginDefinition(); } } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // Once we begin iterating the source plugin it is possible that the // source tables will not exist. This can happen when the // MigrationPluginManager gathers up the migration definitions but we do diff --git a/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php index 59b071413c6a5ac11338670fc5454b7697f932fd..994a41e01b1059e860013dc9c3339d2e45c92eb6 100644 --- a/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php +++ b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php @@ -80,7 +80,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { try { $node_types->checkRequirements(); } - catch (RequirementsException $e) { + catch (RequirementsException) { // If the d7_node_type requirements failed, that means we do not have a // Drupal source database configured - there is nothing to generate. return $this->derivatives; @@ -121,7 +121,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives[$node_type] = $migration->getPluginDefinition(); } } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // Once we begin iterating the source plugin it is possible that the // source tables will not exist. This can happen when the // MigrationPluginManager gathers up the migration definitions but we do diff --git a/core/modules/node/tests/src/Functional/NodeCreationTest.php b/core/modules/node/tests/src/Functional/NodeCreationTest.php index 5b68c2f621812663ecb1a75ba031265909accae6..bcf7cb57d5ba99abffc8e92761a29e9aacbb6f96 100644 --- a/core/modules/node/tests/src/Functional/NodeCreationTest.php +++ b/core/modules/node/tests/src/Functional/NodeCreationTest.php @@ -142,7 +142,7 @@ public function testFailedPageCreation(): void { Node::create($edit)->save(); $this->fail('Expected exception has not been thrown.'); } - catch (\Exception $e) { + catch (\Exception) { // Expected exception; just continue testing. } diff --git a/core/modules/node/tests/src/Functional/NodeQueryAlterTest.php b/core/modules/node/tests/src/Functional/NodeQueryAlterTest.php index eedf8e81d432baa08fd2af2fc924214a59f71445..f8acd2cf6b52a1f815a80dc0edc4404106125741 100644 --- a/core/modules/node/tests/src/Functional/NodeQueryAlterTest.php +++ b/core/modules/node/tests/src/Functional/NodeQueryAlterTest.php @@ -93,7 +93,7 @@ public function testNodeQueryAlterLowLevelWithAccess(): void { $result = $query->execute()->fetchAll(); $this->assertCount(4, $result, 'User with access can see correct nodes'); } - catch (\Exception $e) { + catch (\Exception) { $this->fail('Altered query is malformed'); } } @@ -112,7 +112,7 @@ public function testNodeQueryAlterWithRevisions(): void { $this->assertCount(4, $result, 'User with access can see correct nodes'); } - catch (\Exception $e) { + catch (\Exception) { $this->fail('Altered query is malformed'); } } @@ -135,7 +135,7 @@ public function testNodeQueryAlterLowLevelNoAccess(): void { $result = $query->execute()->fetchAll(); $this->assertCount(0, $result, 'User with no access cannot see nodes'); } - catch (\Exception $e) { + catch (\Exception) { $this->fail('Altered query is malformed'); } } @@ -199,7 +199,7 @@ public function testNodeQueryAlterOverride(): void { $result = $query->execute()->fetchAll(); $this->assertCount(0, $result, 'User view privileges are not overridden'); } - catch (\Exception $e) { + catch (\Exception) { $this->fail('Altered query is malformed'); } @@ -221,7 +221,7 @@ public function testNodeQueryAlterOverride(): void { $result = $query->execute()->fetchAll(); $this->assertCount(4, $result, 'User view privileges are overridden'); } - catch (\Exception $e) { + catch (\Exception) { $this->fail('Altered query is malformed'); } \Drupal::state()->delete('node_access_test.no_access_uid'); diff --git a/core/modules/options/tests/src/Kernel/OptionsFieldTest.php b/core/modules/options/tests/src/Kernel/OptionsFieldTest.php index ad7eee65fbf9c0fec5372dfcb29be70d6a14d8dc..9a1e045ac727046b5758211130e999805c576043 100644 --- a/core/modules/options/tests/src/Kernel/OptionsFieldTest.php +++ b/core/modules/options/tests/src/Kernel/OptionsFieldTest.php @@ -44,7 +44,7 @@ public function testUpdateAllowedValues(): void { $this->fieldStorage->save(); $this->fail('Cannot update a list field storage to not include keys with existing data.'); } - catch (FieldStorageDefinitionUpdateForbiddenException $e) { + catch (FieldStorageDefinitionUpdateForbiddenException) { // Expected exception; just continue testing. } // Empty the value, so that we can actually remove the option. diff --git a/core/modules/pgsql/src/Driver/Database/pgsql/Connection.php b/core/modules/pgsql/src/Driver/Database/pgsql/Connection.php index e757e5a7fd66baa0f8f22710a598cd13813bdff8..aad885b410973430627a5f18e1bd4d19495272b2 100644 --- a/core/modules/pgsql/src/Driver/Database/pgsql/Connection.php +++ b/core/modules/pgsql/src/Driver/Database/pgsql/Connection.php @@ -404,7 +404,7 @@ public function hasJson(): bool { try { return (bool) $this->query('SELECT JSON_TYPEOF(\'1\')'); } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } } diff --git a/core/modules/pgsql/src/Driver/Database/pgsql/Insert.php b/core/modules/pgsql/src/Driver/Database/pgsql/Insert.php index 843b23d414e2f482ac7d40fa027806417356c9c7..675f4b9c314f510e03ccd552bdcb913b3c7eb0d3 100644 --- a/core/modules/pgsql/src/Driver/Database/pgsql/Insert.php +++ b/core/modules/pgsql/src/Driver/Database/pgsql/Insert.php @@ -134,7 +134,7 @@ public function __toString() { $query .= ' RETURNING ' . $table_information->serial_fields[0]; } } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // If we fail to get the table information it is probably because the // table does not exist yet so adding the returning statement is pointless // because the query will fail. This happens for tables created on demand, diff --git a/core/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.php b/core/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.php index eb3a5d73b6d4f6be110d614a54233809d112fb71..366cd1ab45537536fbf6778203dafd69cd0e9c27 100644 --- a/core/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.php +++ b/core/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.php @@ -137,7 +137,7 @@ protected function checkEncoding() { ])); } } - catch (\Exception $e) { + catch (\Exception) { $this->fail(t('Drupal could not determine the encoding of the database was set to UTF-8')); } } @@ -161,7 +161,7 @@ public function checkBinaryOutput() { try { $database_connection->query($query); } - catch (\Exception $e) { + catch (\Exception) { // Ignore possible errors when the user doesn't have the necessary // privileges to ALTER the database. } @@ -213,7 +213,7 @@ public function checkStandardConformingStrings() { try { $database_connection->query($query); } - catch (\Exception $e) { + catch (\Exception) { // Ignore possible errors when the user doesn't have the necessary // privileges to ALTER the database. } diff --git a/core/modules/search/tests/src/Functional/SearchCommentTest.php b/core/modules/search/tests/src/Functional/SearchCommentTest.php index 60acdbb94116844e3e14919f4034a357ca5653c1..84bbf9e18d05b72da16750f3a597f210551a123f 100644 --- a/core/modules/search/tests/src/Functional/SearchCommentTest.php +++ b/core/modules/search/tests/src/Functional/SearchCommentTest.php @@ -336,7 +336,7 @@ public function assertCommentAccess(bool $assume_access, string $message): void $this->assertSession()->pageTextContains('Your search yielded no results.'); } } - catch (ResponseTextException $exception) { + catch (ResponseTextException) { $this->fail($message); } } diff --git a/core/modules/serialization/tests/src/Kernel/SerializationTest.php b/core/modules/serialization/tests/src/Kernel/SerializationTest.php index 8d85786495ab971502b334eafb9451b5c0b0a5ef..fcdc5a61cdf1a6cf0f65ce111a80d68032bbe760 100644 --- a/core/modules/serialization/tests/src/Kernel/SerializationTest.php +++ b/core/modules/serialization/tests/src/Kernel/SerializationTest.php @@ -52,7 +52,7 @@ public function testSerializerComponentRegistration(): void { $this->serializer->serialize($object, 'unsupported_format'); $this->fail('The serializer was expected to throw an exception for an unsupported format, but did not.'); } - catch (UnexpectedValueException $e) { + catch (UnexpectedValueException) { // Expected exception; just continue testing. } } diff --git a/core/modules/shortcut/src/Controller/ShortcutController.php b/core/modules/shortcut/src/Controller/ShortcutController.php index d70cd7e07f929da502f5f67a9462d98f53c85adc..c8ea798baf6f4f7c3c509c39c88483f6c7644a7c 100644 --- a/core/modules/shortcut/src/Controller/ShortcutController.php +++ b/core/modules/shortcut/src/Controller/ShortcutController.php @@ -42,7 +42,7 @@ public function deleteShortcutLinkInline(ShortcutInterface $shortcut) { $shortcut->delete(); $this->messenger()->addStatus($this->t('The shortcut %title has been deleted.', ['%title' => $label])); } - catch (\Exception $e) { + catch (\Exception) { $this->messenger()->addStatus($this->t('Unable to delete the shortcut for %title.', ['%title' => $label]), 'error'); } diff --git a/core/modules/shortcut/src/Controller/ShortcutSetController.php b/core/modules/shortcut/src/Controller/ShortcutSetController.php index dc93c97eed424bf6ff8ba938d56c87616eec402d..28d5e5e6338e8f003923bb1b72b28718f08a9805 100644 --- a/core/modules/shortcut/src/Controller/ShortcutSetController.php +++ b/core/modules/shortcut/src/Controller/ShortcutSetController.php @@ -59,7 +59,7 @@ public function addShortcutLinkInline(ShortcutSetInterface $shortcut_set, Reques $shortcut->save(); $this->messenger()->addStatus($this->t('Added a shortcut for %title.', ['%title' => $shortcut->label()])); } - catch (\Exception $e) { + catch (\Exception) { $this->messenger()->addError($this->t('Unable to add a shortcut for %title.', ['%title' => $shortcut->label()])); } diff --git a/core/modules/sqlite/src/Driver/Database/sqlite/Connection.php b/core/modules/sqlite/src/Driver/Database/sqlite/Connection.php index 73a6c12a5f101c8a2292c9da13896915c2389904..cbd49e0e4d8d1918a41085dc3ffcd1410e8de86c 100644 --- a/core/modules/sqlite/src/Driver/Database/sqlite/Connection.php +++ b/core/modules/sqlite/src/Driver/Database/sqlite/Connection.php @@ -178,7 +178,7 @@ public function __destruct() { unlink($this->connectionOptions['database'] . '-' . $prefix); } } - catch (\Exception $e) { + catch (\Exception) { // Ignore the exception and continue. There is nothing we can do here // to report the error or fail safe. } diff --git a/core/modules/system/src/Controller/ThemeController.php b/core/modules/system/src/Controller/ThemeController.php index cf393b9b9647a99bd998b10eb8b1797d6990c51e..2ab81cf3a2d1d2727c259532a020d15231351a71 100644 --- a/core/modules/system/src/Controller/ThemeController.php +++ b/core/modules/system/src/Controller/ThemeController.php @@ -149,7 +149,7 @@ public function install(Request $request) { catch (UnmetDependenciesException $e) { $this->messenger()->addError($e->getTranslatedMessage($this->getStringTranslation(), $theme)); } - catch (MissingDependencyException $e) { + catch (MissingDependencyException) { $this->messenger()->addError($this->t('Unable to install @theme due to missing module dependencies.', ['@theme' => $theme])); } diff --git a/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php index 3895f317623da3406a15bd5f4486e4c41f0391a3..b3192f0648c4bf237f08d523076ef394e520d4d2 100644 --- a/core/modules/system/src/Form/ThemeSettingsForm.php +++ b/core/modules/system/src/Form/ThemeSettingsForm.php @@ -477,7 +477,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $values['logo_path'] = $filename; } } - catch (FileException $e) { + catch (FileException) { // Ignore. } try { @@ -488,7 +488,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $values['toggle_favicon'] = 1; } } - catch (FileException $e) { + catch (FileException) { // Ignore. } unset($values['logo_upload']); diff --git a/core/modules/system/src/PathBasedBreadcrumbBuilder.php b/core/modules/system/src/PathBasedBreadcrumbBuilder.php index 26c3066581dfb062933e8dbef7459dd251491c7c..7f2c43c412810f3e6a06b27b039e1997abc3740e 100644 --- a/core/modules/system/src/PathBasedBreadcrumbBuilder.php +++ b/core/modules/system/src/PathBasedBreadcrumbBuilder.php @@ -227,7 +227,7 @@ protected function getRequestForPath($path, array $exclude) { $request->attributes->add($this->router->matchRequest($request)); return $request; } - catch (ParamNotConvertedException | ResourceNotFoundException | MethodNotAllowedException | AccessDeniedHttpException | NotFoundHttpException $e) { + catch (ParamNotConvertedException | ResourceNotFoundException | MethodNotAllowedException | AccessDeniedHttpException | NotFoundHttpException) { return NULL; } } diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php index 20c698e57334ed3d142ecdf9099dba677208e96c..433b968adaee363526e99ca0b2fe731b8c052746 100644 --- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php +++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php @@ -293,7 +293,7 @@ public function save($destination) { $this->fileSystem->move($destination, $permanent_destination, FileExists::Replace); return TRUE; } - catch (FileException $e) { + catch (FileException) { return FALSE; } } diff --git a/core/modules/system/src/SecurityAdvisories/SecurityAdvisoriesFetcher.php b/core/modules/system/src/SecurityAdvisories/SecurityAdvisoriesFetcher.php index cf1c4353230b1a4460176997375490ae53b13b4b..1e04f7f9671e989e00661fb2ba757aa0df6c7a0b 100644 --- a/core/modules/system/src/SecurityAdvisories/SecurityAdvisoriesFetcher.php +++ b/core/modules/system/src/SecurityAdvisories/SecurityAdvisoriesFetcher.php @@ -198,7 +198,7 @@ protected function matchesExistingVersion(SecurityAdvisory $sa): bool { try { $insecure_project_version = ExtensionVersion::createFromVersionString($insecure_version); } - catch (\UnexpectedValueException $exception) { + catch (\UnexpectedValueException) { // An invalid version string should not halt the evaluation of valid // versions in $insecure_versions. Version numbers that start with // core prefix besides '8.x-' are allowed in $insecure_versions, diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 2092aee4491b545a7cff277928b1719950844790..230f083077108f2473600e3d2d825a27262a4130 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -320,7 +320,7 @@ function system_theme_suggestions_maintenance_page(array $variables) { try { \Drupal::service('path.matcher')->isFrontPage(); } - catch (Exception $e) { + catch (Exception) { // The database is not yet available. $offline = TRUE; } diff --git a/core/modules/system/tests/modules/lazy_route_provider_install_test/lazy_route_provider_install_test.module b/core/modules/system/tests/modules/lazy_route_provider_install_test/lazy_route_provider_install_test.module index 7989d765e4e6f77c485bc09bfea69d5097774594..ea226e9d473200c6ea6e39078c5dd2fb22fceff8 100644 --- a/core/modules/system/tests/modules/lazy_route_provider_install_test/lazy_route_provider_install_test.module +++ b/core/modules/system/tests/modules/lazy_route_provider_install_test/lazy_route_provider_install_test.module @@ -14,7 +14,7 @@ function lazy_route_provider_install_test_menu_links_discovered_alter(&$links) { // Ensure that calling this does not cause a recursive rebuild. \Drupal::service('router.route_provider')->getAllRoutes(); } - catch (\RuntimeException $e) { + catch (\RuntimeException) { $message = 'failed'; } \Drupal::state()->set(__FUNCTION__, $message); diff --git a/core/modules/system/tests/modules/router_test_directory/src/TestControllers.php b/core/modules/system/tests/modules/router_test_directory/src/TestControllers.php index 605ef69d5a236131c3cd536cfe75b042fb2f8ae3..3dec25a306552ce0b4fc7abaa139cb5c96c498d6 100644 --- a/core/modules/system/tests/modules/router_test_directory/src/TestControllers.php +++ b/core/modules/system/tests/modules/router_test_directory/src/TestControllers.php @@ -61,7 +61,7 @@ public function test9($uid) { $text = sprintf('User route "%s" was matched.', $match[RouteObjectInterface::ROUTE_NAME]); } } - catch (ParamNotConvertedException $e) { + catch (ParamNotConvertedException) { } return new Response($text); } diff --git a/core/modules/system/tests/modules/service_provider_test/src/ServiceProviderTestServiceProvider.php b/core/modules/system/tests/modules/service_provider_test/src/ServiceProviderTestServiceProvider.php index 2e266d90ed9cf87b21055ef13ab837f0b1a7bfc8..199399e15ea4f7ec057a2a7c6dda9ec2f9bed484 100644 --- a/core/modules/system/tests/modules/service_provider_test/src/ServiceProviderTestServiceProvider.php +++ b/core/modules/system/tests/modules/service_provider_test/src/ServiceProviderTestServiceProvider.php @@ -26,7 +26,7 @@ public function alter(ContainerBuilder $container) { $this_module_relative_path = $module_handler->getModule('service_provider_test')->getPath(); $container->setParameter('service_provider_test_path', $this_module_relative_path); } - catch (\Exception $e) { + catch (\Exception) { throw new \LogicException('Unable to identify installation path of this module.'); } diff --git a/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php b/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php index d27a70185042abeeee0b5d52148fc6bf3efb39d2..9e43becec91786d44974c64743eefed528578c4a 100644 --- a/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php +++ b/core/modules/system/tests/src/Functional/Bootstrap/DrupalMessengerServiceTest.php @@ -115,7 +115,7 @@ public function testStatusMessageAssertions(): void { try { $this->assertSession()->statusMessageContains('This message is not real'); } - catch (AssertionFailedError $e) { + catch (AssertionFailedError) { $expected_failure_occurred = TRUE; } $this->assertTrue($expected_failure_occurred, 'WebAssert::statusMessageContains() did not fail when it should have failed.'); @@ -124,7 +124,7 @@ public function testStatusMessageAssertions(): void { try { $this->assertSession()->statusMessageNotContains('markup'); } - catch (AssertionFailedError $e) { + catch (AssertionFailedError) { $expected_failure_occurred = TRUE; } $this->assertTrue($expected_failure_occurred, 'WebAssert::statusMessageNotContains() did not fail when it should have failed.'); @@ -133,7 +133,7 @@ public function testStatusMessageAssertions(): void { try { $this->assertSession()->statusMessageExists('error'); } - catch (AssertionFailedError $e) { + catch (AssertionFailedError) { $expected_failure_occurred = TRUE; } $this->assertTrue($expected_failure_occurred, 'WebAssert::statusMessageExists() did not fail when it should have failed.'); @@ -142,7 +142,7 @@ public function testStatusMessageAssertions(): void { try { $this->assertSession()->statusMessageNotExists(); } - catch (AssertionFailedError $e) { + catch (AssertionFailedError) { $expected_failure_occurred = TRUE; } $this->assertTrue($expected_failure_occurred, 'WebAssert::statusMessageNotExists() did not fail when it should have failed.'); diff --git a/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php b/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php index 5fe28a2e80771161fd47c7d6d0f1e15b09e284d7..125cefe724743cb58d06f6f534b4ded72641480d 100644 --- a/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php +++ b/core/modules/system/tests/src/Functional/FileTransfer/FileTransferTest.php @@ -85,7 +85,7 @@ public function testJail(): void { try { $this->testConnection->copyDirectory($source, sys_get_temp_dir()); } - catch (FileTransferException $e) { + catch (FileTransferException) { $got_it = TRUE; } $this->assertTrue($got_it, 'Was not able to copy a directory outside of the jailed area.'); @@ -94,7 +94,7 @@ public function testJail(): void { try { $this->testConnection->copyDirectory($source, $this->root . '/' . PublicStream::basePath()); } - catch (FileTransferException $e) { + catch (FileTransferException) { $got_it = FALSE; } $this->assertTrue($got_it, 'Was able to copy a directory inside of the jailed area'); diff --git a/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php b/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php index c2a2d60a1f90a3c50f7eef80d73132d77630157c..b7816aa2006dc59d47a6556fbcca44160f388139 100644 --- a/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php +++ b/core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php @@ -409,7 +409,7 @@ public function testAssertBreadcrumbTrait(): void { $this->assertBreadcrumb('menu-test/breadcrumb1', []); $this->fail($message); } - catch (ExpectationFailedException $e) { + catch (ExpectationFailedException) { $this->assertTrue(TRUE, $message); } @@ -419,7 +419,7 @@ public function testAssertBreadcrumbTrait(): void { $this->assertBreadcrumb('menu-test/breadcrumb1', $home); $this->fail($message); } - catch (ExpectationFailedException $e) { + catch (ExpectationFailedException) { $this->assertTrue(TRUE, $message); } @@ -436,7 +436,7 @@ public function testAssertBreadcrumbTrait(): void { $this->assertBreadcrumb('menu-test/breadcrumb1', $trail); $this->fail($message); } - catch (ExpectationFailedException $e) { + catch (ExpectationFailedException) { $this->assertTrue(TRUE, $message); } } diff --git a/core/modules/system/tests/src/Functional/Module/UninstallTest.php b/core/modules/system/tests/src/Functional/Module/UninstallTest.php index 8059d850c421eb5cf9af596d40ee7479075f86d3..09328e51d8b06ab2000c8fc001fa76cc84dd6d7f 100644 --- a/core/modules/system/tests/src/Functional/Module/UninstallTest.php +++ b/core/modules/system/tests/src/Functional/Module/UninstallTest.php @@ -198,7 +198,7 @@ public function testFailedInstallStatus(): void { $this->container->get('module_installer')->install(['module_installer_config_test']); $this->fail($message); } - catch (EntityMalformedException $e) { + catch (EntityMalformedException) { // Expected exception; just continue testing. } diff --git a/core/modules/system/tests/src/Functional/Routing/RouterTest.php b/core/modules/system/tests/src/Functional/Routing/RouterTest.php index 5208c73b873c666f4e03bc4952c0ddb38763212c..77413a47ea2b396f91c7da0eea96ca710de843b1 100644 --- a/core/modules/system/tests/src/Functional/Routing/RouterTest.php +++ b/core/modules/system/tests/src/Functional/Routing/RouterTest.php @@ -315,7 +315,7 @@ public function testRouterUninstallInstall(): void { \Drupal::service('router.route_provider')->getRouteByName('router_test.1'); $this->fail('Route was delete on uninstall.'); } - catch (RouteNotFoundException $e) { + catch (RouteNotFoundException) { // Expected exception; just continue testing. } // Install the module again. diff --git a/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php b/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php index 301661b7ea330504c32cd98ef78ef6e03914fdc2..b9c6fc8d2e7f8b785a234aad76e1bd66825412c8 100644 --- a/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php +++ b/core/modules/system/tests/src/Functional/Theme/TwigTransTest.php @@ -121,7 +121,7 @@ public function testEmptyTwigTransTags(): void { catch (SyntaxError $e) { $this->assertStringContainsString('{% trans %} tag cannot be empty', $e->getMessage()); } - catch (\Exception $e) { + catch (\Exception) { $this->fail('{% trans %}{% endtrans %} threw an unexpected exception.'); } } diff --git a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php index 53f9b662fb9f131c8e14be44f66c6c17fdf4c01c..fa1f33e058f23767bd0eaf29be0ed5cfbb446f60 100644 --- a/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php +++ b/core/modules/system/tests/src/Kernel/Extension/ModuleHandlerTest.php @@ -105,7 +105,7 @@ public function testDependencyResolution(): void { $result = $this->moduleInstaller()->install(['dblog']); $this->fail('ModuleInstaller::install() throws an exception if dependencies are missing.'); } - catch (MissingDependencyException $e) { + catch (MissingDependencyException) { // Expected exception; just continue testing. } @@ -288,7 +288,7 @@ public function testUninstallContentDependency(): void { $this->moduleInstaller()->uninstall(['entity_test']); $this->fail($message); } - catch (ModuleUninstallValidatorException $e) { + catch (ModuleUninstallValidatorException) { // Expected exception; just continue testing. } @@ -298,7 +298,7 @@ public function testUninstallContentDependency(): void { $this->moduleInstaller()->uninstall(['help']); $this->fail($message); } - catch (ModuleUninstallValidatorException $e) { + catch (ModuleUninstallValidatorException) { // Expected exception; just continue testing. } diff --git a/core/modules/taxonomy/src/Plugin/migrate/D6TermNodeDeriver.php b/core/modules/taxonomy/src/Plugin/migrate/D6TermNodeDeriver.php index ca3dc227fc6693985e312e7038b2706eac5b9110..57286981398e6ad59ddb25b8dfeaf333dcabb937 100644 --- a/core/modules/taxonomy/src/Plugin/migrate/D6TermNodeDeriver.php +++ b/core/modules/taxonomy/src/Plugin/migrate/D6TermNodeDeriver.php @@ -64,7 +64,7 @@ public function getDerivativeDefinitions($base_plugin_definition, $base_plugin_d $this->derivatives[$source_vid] = $definition; } } - catch (\Exception $e) { + catch (\Exception) { // It is possible no D6 tables are loaded so just eat exceptions. } return $this->derivatives; diff --git a/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php b/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php index 2306b87f472ca7294b0703aaffda969a9eee73a6..1091e189140b31b2ff203b29a53aa64a0e8d63ed 100644 --- a/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php +++ b/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php @@ -64,7 +64,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { try { $vocabulary_source_plugin->checkRequirements(); } - catch (RequirementsException $e) { + catch (RequirementsException) { // If the d7_taxonomy_vocabulary requirements failed, that means we do not // have a Drupal source database configured - there is nothing to // generate. @@ -89,7 +89,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives[$bundle] = $migration->getPluginDefinition(); } } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // Once we begin iterating the source plugin it is possible that the // source tables will not exist. This can happen when the // MigrationPluginManager gathers up the migration definitions but we do diff --git a/core/modules/update/src/ProjectCoreCompatibility.php b/core/modules/update/src/ProjectCoreCompatibility.php index 16356093b583cd2d631549a8b0037988c270ff38..f2d835a3b1fa8108ade653c95136eac509dd569c 100644 --- a/core/modules/update/src/ProjectCoreCompatibility.php +++ b/core/modules/update/src/ProjectCoreCompatibility.php @@ -172,7 +172,7 @@ protected function isCoreCompatible($core_compatibility_constraint) { try { return Semver::satisfies($this->existingCoreVersion, $core_compatibility_constraint); } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } } diff --git a/core/modules/update/src/UpdateProcessor.php b/core/modules/update/src/UpdateProcessor.php index 6702ec67edac0de4f77781f303a56f163ae7271e..4945a478490ba2b5ed7d81965e0b73cf389aca7c 100644 --- a/core/modules/update/src/UpdateProcessor.php +++ b/core/modules/update/src/UpdateProcessor.php @@ -231,7 +231,7 @@ protected function parseXml($raw_xml) { try { $xml = new \SimpleXMLElement($raw_xml); } - catch (\Exception $e) { + catch (\Exception) { // SimpleXMLElement::__construct produces an E_WARNING error message for // each error found in the XML data and throws an exception if errors // were detected. Catch any exception and return failure (NULL). diff --git a/core/modules/update/update.compare.inc b/core/modules/update/update.compare.inc index 465446beec60e3ae309502a688f821d8243d6888..ed909ea7b3e08eac4d87e5dc81bbd3d066794fc2 100644 --- a/core/modules/update/update.compare.inc +++ b/core/modules/update/update.compare.inc @@ -372,7 +372,7 @@ function update_calculate_project_update_status(&$project_data, $available) { try { $release_module_version = ExtensionVersion::createFromVersionString($release->getVersion()); } - catch (UnexpectedValueException $exception) { + catch (UnexpectedValueException) { continue; } // This release is supported only if it is in a supported branch and is diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc index 97333a082593a3086b5501b22545d2938907724d..87330e337c3e3af315f03035230093cf716d9c63 100644 --- a/core/modules/update/update.manager.inc +++ b/core/modules/update/update.manager.inc @@ -176,7 +176,7 @@ function update_manager_archive_extract($file, $directory) { try { \Drupal::service('file_system')->deleteRecursive($extract_location); } - catch (FileException $e) { + catch (FileException) { // Ignore failed deletes. } } diff --git a/core/modules/update/update.module b/core/modules/update/update.module index e1ed9d852acab41eb61c15b8e21730788e9163ab..3b6010b089b461055d00d19941ce38dedf41486f 100644 --- a/core/modules/update/update.module +++ b/core/modules/update/update.module @@ -704,7 +704,7 @@ function update_delete_file_if_stale($path) { \Drupal::service('file_system')->deleteRecursive($path); return TRUE; } - catch (FileException $e) { + catch (FileException) { // Ignore failed deletes. } } diff --git a/core/modules/user/src/Plugin/migrate/ProfileValues.php b/core/modules/user/src/Plugin/migrate/ProfileValues.php index 979f873f3e55b8a6373cd179e6cd6ea1dcbf3d5c..573c9b557a83de03293222f1f0c1a1e455e842b3 100644 --- a/core/modules/user/src/Plugin/migrate/ProfileValues.php +++ b/core/modules/user/src/Plugin/migrate/ProfileValues.php @@ -55,7 +55,7 @@ public function getProcess() { } } } - catch (RequirementsException $e) { + catch (RequirementsException) { // The checkRequirements() call will fail when the profile module does // not exist on the source site, or if the required migrations have not // yet run. diff --git a/core/modules/user/src/Plugin/migrate/User.php b/core/modules/user/src/Plugin/migrate/User.php index 356c4e3b4431602346b4185dabb1b6ef0118b7f4..c0829792c243913ecba4fbad724ef4f7493f221b 100644 --- a/core/modules/user/src/Plugin/migrate/User.php +++ b/core/modules/user/src/Plugin/migrate/User.php @@ -39,7 +39,7 @@ public function getProcess() { $this->process[$name] = $name; } } - catch (RequirementsException $e) { + catch (RequirementsException) { // The checkRequirements() call will fail when the profile module does // not exist on the source site. } diff --git a/core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php b/core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php index f8f5ea845be160ee3033a9620a51f8bcbd0c7b64..f5340a9a595d4e0e72ddf2ab226cd50176a48c54 100644 --- a/core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php +++ b/core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php @@ -223,7 +223,7 @@ public function onEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeI // and casting. $view->trustData()->save(); } - catch (\Exception $e) { + catch (\Exception) { // In case the view could not be saved, log an error message that the // view needs to be updated manually instead of failing the entire // entity update process. diff --git a/core/modules/views/src/Plugin/views/argument/MonthDate.php b/core/modules/views/src/Plugin/views/argument/MonthDate.php index 8fd0e2913f23c1563c91fff0b7b77c55da8c7644..81ef9985b26173e6243bf14240abc5c207f8a9ba 100644 --- a/core/modules/views/src/Plugin/views/argument/MonthDate.php +++ b/core/modules/views/src/Plugin/views/argument/MonthDate.php @@ -30,7 +30,7 @@ public function summaryName($data) { try { return $this->dateFormatter->format(strtotime("2005" . $month . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { return parent::summaryName($data); } } @@ -43,7 +43,7 @@ public function title() { try { return $this->dateFormatter->format(strtotime("2005" . $month . "15" . " 00:00:00 UTC"), 'custom', $this->format, 'UTC'); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { return parent::title(); } } diff --git a/core/modules/views/src/Plugin/views/field/EntityLabel.php b/core/modules/views/src/Plugin/views/field/EntityLabel.php index 6ac4f505c3a55be9e3373f4a781be0b4ef24ab7a..be511de8eabd40e8f9f9cb22b81e95f2f90b6f77 100644 --- a/core/modules/views/src/Plugin/views/field/EntityLabel.php +++ b/core/modules/views/src/Plugin/views/field/EntityLabel.php @@ -111,10 +111,10 @@ public function render(ResultRow $values) { $this->options['alter']['url'] = $entity->toUrl(); $this->options['alter']['make_link'] = TRUE; } - catch (UndefinedLinkTemplateException $e) { + catch (UndefinedLinkTemplateException) { $this->options['alter']['make_link'] = FALSE; } - catch (EntityMalformedException $e) { + catch (EntityMalformedException) { $this->options['alter']['make_link'] = FALSE; } } diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index ff1ee74da94ce7c20a63d63ee58944917f97e5ae..24980bab6b9a2507060d32e4f512860cfa6b9a06 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -1964,7 +1964,7 @@ public function hasUrl($args = NULL, $display_id = NULL) { try { $this->routeProvider->getRouteByName($display_handler->getRouteName()); } - catch (RouteNotFoundException $e) { + catch (RouteNotFoundException) { return FALSE; } diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index fe840b638cd121c20c625bf8c8a61ef366278bbd..d63eaf523fca5295dd7c80049e88b8fb4bcfcc4e 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -303,7 +303,7 @@ function template_preprocess_views_view_summary(&$variables) { $url->setRouteParameters($parameters); } - catch (Exception $e) { + catch (Exception) { // If the given route doesn't exist, default to <front> $url = Url::fromRoute('<front>'); } @@ -389,7 +389,7 @@ function template_preprocess_views_view_summary_unformatted(&$variables) { $url->setRouteParameters($parameters); } - catch (Exception $e) { + catch (Exception) { // If the given route doesn't exist, default to <front> $url = Url::fromRoute('<front>'); } diff --git a/core/modules/views/views.tokens.inc b/core/modules/views/views.tokens.inc index 915ad807f6ec09f3663540c02dcbbbd3dc9cc2bb..e980580248d8416d449bb244ce8fc58b8f0a3154 100644 --- a/core/modules/views/views.tokens.inc +++ b/core/modules/views/views.tokens.inc @@ -107,7 +107,7 @@ function views_tokens($type, $tokens, array $data, array $options, BubbleableMet ->toString(); } } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // The view has no URL so we leave the value empty. $replacements[$original] = ''; } diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php index 295452ef32427659629a08afcce3c0b77d393f07..131a224ce771460f983f800768ed2bd4e446696e 100644 --- a/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -476,7 +476,7 @@ public function getDisplayDetails($view, $display) { $url = Url::fromUri("base:$path"); } } - catch (NotAcceptableHttpException $e) { + catch (NotAcceptableHttpException) { $url = '/' . $path; } diff --git a/core/modules/views_ui/src/ViewListBuilder.php b/core/modules/views_ui/src/ViewListBuilder.php index b494fbc78c3d0a256556ac8df6cd3fe15bca154c..06c422e2a18249d96d1ba15a03a8e9598cc00b41 100644 --- a/core/modules/views_ui/src/ViewListBuilder.php +++ b/core/modules/views_ui/src/ViewListBuilder.php @@ -268,7 +268,7 @@ protected function getDisplaysList(EntityInterface $view) { // https://www.drupal.org/node/2423913 $rendered_path = Link::fromTextAndUrl('/' . $path, Url::fromUserInput('/' . $path))->toString(); } - catch (NotAcceptableHttpException $e) { + catch (NotAcceptableHttpException) { $rendered_path = '/' . $path; } } diff --git a/core/modules/workflows/src/Form/WorkflowTransitionDeleteForm.php b/core/modules/workflows/src/Form/WorkflowTransitionDeleteForm.php index 22c939c8a755e17a5fc89a36e68f2a0b1c46bbee..2c24619b901bb6b981e5417be1b9c100751affe0 100644 --- a/core/modules/workflows/src/Form/WorkflowTransitionDeleteForm.php +++ b/core/modules/workflows/src/Form/WorkflowTransitionDeleteForm.php @@ -82,7 +82,7 @@ public function buildForm(array $form, FormStateInterface $form_state, ?Workflow try { $this->transition = $workflow->getTypePlugin()->getTransition($workflow_transition); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { throw new NotFoundHttpException(); } $this->workflow = $workflow; diff --git a/core/modules/workflows/tests/src/Unit/WorkflowTest.php b/core/modules/workflows/tests/src/Unit/WorkflowTest.php index 76fae5af6f67cec63dc09a1101aac811a7a2db78..a17b8f7bf0b54cb31a2261eda4aa531e602a0f79 100644 --- a/core/modules/workflows/tests/src/Unit/WorkflowTest.php +++ b/core/modules/workflows/tests/src/Unit/WorkflowTest.php @@ -369,7 +369,7 @@ public function testAddTransitionConsistentAfterFromCatch(): void { try { $workflow->getTypePlugin()->addTransition('publish', 'Publish', ['draft'], 'published'); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { } // Ensure that the workflow is not left in an inconsistent state after an // exception is thrown from Workflow::setTransitionFromStates() whilst diff --git a/core/modules/workspaces/src/Form/WorkspaceActivateForm.php b/core/modules/workspaces/src/Form/WorkspaceActivateForm.php index 56fee541ea2e1948376844bddaf2bf255ffba38b..27f206e3ff47cfb9001ceb4d4ac7388ad0b257d7 100644 --- a/core/modules/workspaces/src/Form/WorkspaceActivateForm.php +++ b/core/modules/workspaces/src/Form/WorkspaceActivateForm.php @@ -111,7 +111,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->workspaceManager->setActiveWorkspace($this->entity); $this->messenger->addMessage($this->t('%workspace_label is now the active workspace.', ['%workspace_label' => $this->entity->label()])); } - catch (WorkspaceAccessException $e) { + catch (WorkspaceAccessException) { $this->messenger->addError($this->t('You do not have access to activate the %workspace_label workspace.', ['%workspace_label' => $this->entity->label()])); } diff --git a/core/modules/workspaces/src/Form/WorkspaceSwitcherForm.php b/core/modules/workspaces/src/Form/WorkspaceSwitcherForm.php index bfde0f4631c7239043b3a67001104281ef972078..0c3a400fddcf721e8f6a2252a84e2893d1b89251 100644 --- a/core/modules/workspaces/src/Form/WorkspaceSwitcherForm.php +++ b/core/modules/workspaces/src/Form/WorkspaceSwitcherForm.php @@ -140,7 +140,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->workspaceManager->setActiveWorkspace($workspace); $this->messenger->addMessage($this->t('%workspace_label is now the active workspace.', ['%workspace_label' => $workspace->label()])); } - catch (WorkspaceAccessException $e) { + catch (WorkspaceAccessException) { $this->messenger->addError($this->t('You do not have access to activate the %workspace_label workspace.', ['%workspace_label' => $workspace->label()])); } } diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist index e787ae464fa30c0f49cd3ca209c559ef0682836c..de57305b2b633af9e014da53a917dbe53ddca339 100644 --- a/core/phpcs.xml.dist +++ b/core/phpcs.xml.dist @@ -265,6 +265,7 @@ </properties> </rule> <rule ref="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/> + <rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch" /> <rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"> <properties> <property name="spacesCountAroundEqualsSign" value="0" /> diff --git a/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php b/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php index 14452a50541adbf26810e01852730dedacef4cba..7fce5fcdacfb5c6f65b53f194a6e4bf44df2a1d2 100644 --- a/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php +++ b/core/profiles/demo_umami/modules/demo_umami_content/src/InstallHelper.php @@ -867,7 +867,7 @@ protected function createFileEntity($path) { try { $uri = $this->fileSystem->copy($path, 'public://' . $filename, FileExists::Replace); } - catch (FileException $e) { + catch (FileException) { $uri = FALSE; } $file = $this->entityTypeManager->getStorage('file')->create([ diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/CommandsTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/CommandsTest.php index beca0e2ebc10e5ecdcb9c2299f226b659654b171..df3db8567eac671a88fc98ad7bf258eecf40efce 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/CommandsTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/CommandsTest.php @@ -53,7 +53,7 @@ public function testAjaxCommands(): void { $session->getDriver()->getWebDriverSession()->getAlert_text(); return TRUE; } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } }); diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/MessageCommandTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/MessageCommandTest.php index ac347e8c45dc61b50afd2d1af428edb736b688d1..aa1218d6e41e21e8ed3d21c7b6760ac440f148a2 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/MessageCommandTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/MessageCommandTest.php @@ -132,7 +132,7 @@ public function testJsStatusMessageAssertions(): void { try { $this->assertSession()->statusMessageContainsAfterWait('Not a real message', NULL, 1000); } - catch (ExpectationFailedException $e) { + catch (ExpectationFailedException) { $expected_failure_occurred = TRUE; } $this->assertTrue($expected_failure_occurred, 'JsWebAssert::statusMessageContainsAfterWait() did not fail when it should have failed.'); @@ -141,7 +141,7 @@ public function testJsStatusMessageAssertions(): void { try { $this->assertSession()->statusMessageNotContainsAfterWait('I am a warning', NULL, 1000); } - catch (ExpectationFailedException $e) { + catch (ExpectationFailedException) { $expected_failure_occurred = TRUE; } $this->assertTrue($expected_failure_occurred, 'JsWebAssert::statusMessageNotContainsAfterWait() did not fail when it should have failed.'); @@ -150,7 +150,7 @@ public function testJsStatusMessageAssertions(): void { try { $this->assertSession()->statusMessageExistsAfterWait('error', 1000); } - catch (ExpectationFailedException $e) { + catch (ExpectationFailedException) { $expected_failure_occurred = TRUE; } $this->assertTrue($expected_failure_occurred, 'JsWebAssert::statusMessageExistsAfterWait() did not fail when it should have failed.'); @@ -159,7 +159,7 @@ public function testJsStatusMessageAssertions(): void { try { $this->assertSession()->statusMessageNotExistsAfterWait('warning', 1000); } - catch (ExpectationFailedException $e) { + catch (ExpectationFailedException) { $expected_failure_occurred = TRUE; } $this->assertTrue($expected_failure_occurred, 'JsWebAssert::statusMessageNotExistsAfterWait() did not fail when it should have failed.'); diff --git a/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php b/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php index ffdbc41533911397f74b9a92c6b50cf8db7480cd..a5508e50c42520e2757144ee4100652827129131 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/DrupalSelenium2Driver.php @@ -230,7 +230,7 @@ public function dragTo($sourceXpath, $destinationXpath) { try { parent::dragTo($sourceXpath, $destinationXpath); } - catch (Exception $e) { + catch (Exception) { // Do not care if this fails for any reason. It is a source of random // fails. The calling code should be doing assertions on the results of // dragging anyway. See upstream issues: diff --git a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php index 861aa7da2f6d9a745a2f241a9dd058a1d0e7f440..d28034f59c3c34aa53d9ed4b3776dc0ee7f92706 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php @@ -142,7 +142,7 @@ public function execute($requestMethod, $url, $parameters = NULL, $extraOptions } return [$rawResult, $info]; } - catch (CurlExec $exception) { + catch (CurlExec) { $retries++; } } diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php index 1cc4925b129568d2c29e823b6de4f07aebc46da5..db25caf24b316d0f047b4ad67d5e1dc680db2aae 100644 --- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php +++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php @@ -245,7 +245,7 @@ public function testXpathAsserts(): void { $this->assertSession()->fieldExists('notexisting'); $this->fail('The "notexisting" field was found.'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } @@ -253,7 +253,7 @@ public function testXpathAsserts(): void { $this->assertSession()->fieldNotExists('edit-name'); $this->fail('The "edit-name" field was not found.'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } } @@ -272,7 +272,7 @@ public function testFieldAssertsForTextfields(): void { $this->assertSession()->fieldNotExists('name'); $this->fail('The "name" field was not found based on name.'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } @@ -281,7 +281,7 @@ public function testFieldAssertsForTextfields(): void { $this->assertSession()->fieldNotExists('edit-name'); $this->fail('The "name" field was not found based on id.'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } @@ -294,7 +294,7 @@ public function testFieldAssertsForTextfields(): void { $this->assertSession()->fieldExists('invalid_name_and_id'); $this->fail('The "invalid_name_and_id" field was found.'); } - catch (ElementNotFoundException $e) { + catch (ElementNotFoundException) { // Expected exception; just continue testing. } // *** 3. assertNoFieldById(). @@ -305,7 +305,7 @@ public function testFieldAssertsForTextfields(): void { $this->assertSession()->fieldNotExists('edit-description'); $this->fail('The "description" field, with no value was not found.'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } @@ -314,7 +314,7 @@ public function testFieldAssertsForTextfields(): void { $this->assertSession()->fieldNotExists('name', NULL); $this->fail('The "name" field was not found.'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } @@ -328,7 +328,7 @@ public function testFieldAssertsForTextfields(): void { try { $this->assertSession()->fieldValueNotEquals('edit-name', ''); } - catch (ExpectationFailedException $e) { + catch (ExpectationFailedException) { // Expected exception; just continue testing. } @@ -336,7 +336,7 @@ public function testFieldAssertsForTextfields(): void { try { $this->assertSession()->fieldValueNotEquals('edit-name', 'not the value'); } - catch (ExpectationFailedException $e) { + catch (ExpectationFailedException) { // Expected exception; just continue testing. } @@ -348,7 +348,7 @@ public function testFieldAssertsForTextfields(): void { $this->assertSession()->fieldValueNotEquals('name', 'Test name'); $this->fail('fieldValueNotEquals failed to throw an exception.'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } @@ -361,7 +361,7 @@ public function testFieldAssertsForTextfields(): void { $this->assertSession()->fieldValueEquals('name', 'not the value'); $this->fail('fieldValueEquals failed to throw an exception.'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } @@ -394,7 +394,7 @@ public function testFieldAssertsForCheckbox(): void { $this->assertSession()->fieldValueNotEquals('checkbox_enabled', '1'); $this->fail('fieldValueNotEquals failed to throw an exception.'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } @@ -424,7 +424,7 @@ public function testFieldAssertsForCheckbox(): void { $this->assertSession()->fieldNotExists('edit-checkbox-disabled', NULL); $this->fail('The "edit-checkbox-disabled" field was not found by ID, using NULL value.'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } @@ -437,7 +437,7 @@ public function testFieldAssertsForCheckbox(): void { $this->assertSession()->checkboxNotChecked('incorrect_checkbox_id'); $this->fail('The "incorrect_checkbox_id" field was found'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } @@ -446,7 +446,7 @@ public function testFieldAssertsForCheckbox(): void { $this->assertSession()->checkboxNotChecked('edit-checkbox-enabled'); $this->fail('The "edit-checkbox-enabled" field was not found in a checked state.'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } @@ -456,7 +456,7 @@ public function testFieldAssertsForCheckbox(): void { $this->assertSession()->checkboxChecked('edit-checkbox-disabled'); $this->fail('The "edit-checkbox-disabled" field was found and checked.'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } } diff --git a/core/tests/Drupal/FunctionalTests/WebAssertTest.php b/core/tests/Drupal/FunctionalTests/WebAssertTest.php index a8ca8bcac1094685e071b202f94a077922d3feee..ae3c014115545d259aafd497fa04b96f4e553119 100644 --- a/core/tests/Drupal/FunctionalTests/WebAssertTest.php +++ b/core/tests/Drupal/FunctionalTests/WebAssertTest.php @@ -336,7 +336,7 @@ public function testFieldAssertsForButton(): void { $this->assertSession()->buttonNotExists('Duplicate button 2'); $this->fail('The "duplicate_button" field with the value Duplicate button 2 was not found.'); } - catch (ExpectationException $e) { + catch (ExpectationException) { // Expected exception; just continue testing. } } diff --git a/core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php b/core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php index 90d0fe6b8f91850591cc50964c5cd5dfa96b0f1f..929901e8b120ec4ac07f3026e8a80efa0ad943e1 100644 --- a/core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php +++ b/core/tests/Drupal/KernelTests/Components/ComponentRenderTest.php @@ -156,7 +156,7 @@ protected function checkPropValidation(): void { $this->renderComponentRenderArray($build); $this->fail('Invalid prop did not cause an exception'); } - catch (\Throwable $e) { + catch (\Throwable) { $this->addToAssertionCount(1); } @@ -170,7 +170,7 @@ protected function checkPropValidation(): void { $this->renderComponentRenderArray($build); $this->fail('Invalid prop did not cause an exception'); } - catch (\Throwable $e) { + catch (\Throwable) { $this->addToAssertionCount(1); } } @@ -189,7 +189,7 @@ protected function checkArrayObjectTypeCast(): void { $this->renderComponentRenderArray($build); $this->addToAssertionCount(1); } - catch (\Throwable $e) { + catch (\Throwable) { $this->fail('Empty array was not converted to object'); } } @@ -207,7 +207,7 @@ protected function checkNonExistingComponent(): void { $this->renderComponentRenderArray($build); $this->fail('Invalid prop did not cause an exception'); } - catch (\Throwable $e) { + catch (\Throwable) { $this->addToAssertionCount(1); } } diff --git a/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php b/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php index 88888b997356e4dbe733cdeca19c2e5b985ac2b6..4c970cf5b19bf73ccb87dd54f8c0b809f0bcdd22 100644 --- a/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php @@ -231,7 +231,7 @@ public function testSetGet(): void { $backend->set('assertion_test', 'value', Cache::PERMANENT, ['node' => [3, 5, 7]]); $this->fail('::set() was called with invalid cache tags, but runtime assertion did not fail.'); } - catch (\AssertionError $e) { + catch (\AssertionError) { // Do nothing; continue testing in extending classes. } } @@ -435,7 +435,7 @@ public function testSetMultiple(): void { $backend->setMultiple($items); $this->fail('::setMultiple() was called with invalid cache tags, but runtime assertion did not fail.'); } - catch (\AssertionError $e) { + catch (\AssertionError) { // Do nothing; continue testing in extending classes. } } diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php index c337f574d62e18480c9d1d501a09ad5fff6b2741..dc7b5f49fdbc9ccb3619b0b41bd5dea342810876 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigCRUDTest.php @@ -219,7 +219,7 @@ public function testNameValidation(): void { $config = $this->config($name); $config->save(); } - catch (ConfigNameException $e) { + catch (ConfigNameException) { unset($test_characters[$i]); } } @@ -231,7 +231,7 @@ public function testNameValidation(): void { $config = $this->config($name); $config->save(); } - catch (ConfigNameException $e) { + catch (ConfigNameException) { $this->fail('ConfigNameException was not thrown for a valid object name.'); } @@ -331,7 +331,7 @@ public function testDataTypes(): void { $config->set('stream', fopen(__FILE__, 'r'))->save(); $this->fail('No Exception thrown upon saving invalid data type.'); } - catch (UnsupportedDataTypeConfigException $e) { + catch (UnsupportedDataTypeConfigException) { // Expected exception; just continue testing. } @@ -346,7 +346,7 @@ public function testDataTypes(): void { $config->set('stream', fopen(__FILE__, 'r'))->save(); $this->fail('No Exception thrown upon saving invalid data type.'); } - catch (UnsupportedDataTypeConfigException $e) { + catch (UnsupportedDataTypeConfigException) { // Expected exception; just continue testing. } } diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php index 981e1b451a44ab6e338c86651b5064c27dcbb80c..988f8833ce0904f60d84bffb3b5c2a9bfb08d7ef 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigEntityStorageTest.php @@ -43,7 +43,7 @@ public function testUUIDConflict(): void { $entity->save(); $this->fail('Exception thrown when attempting to save a configuration entity with a UUID that does not match the existing UUID.'); } - catch (ConfigDuplicateUUIDException $e) { + catch (ConfigDuplicateUUIDException) { // Expected exception; just continue testing. } diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php index 326e2a823d9625e48018ba7e4ff3b1fd5a0ddec4..02a8fd035dce7cd048c0b8a19db96a89e6f97a7f 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImportRenameValidationTest.php @@ -112,7 +112,7 @@ public function testRenameValidation(): void { $this->configImporter->import(); $this->fail('Expected ConfigImporterException thrown when a renamed configuration entity does not match the existing entity type.'); } - catch (ConfigImporterException $e) { + catch (ConfigImporterException) { $expected = [ new FormattableMarkup('Entity type mismatch on rename. @old_type not equal to @new_type for existing configuration @old_name and staged configuration @new_name.', ['@old_type' => 'node_type', '@new_type' => 'config_test', '@old_name' => 'node.type.' . $content_type->id(), '@new_name' => 'config_test.dynamic.' . $test_entity_id]), ]; @@ -154,7 +154,7 @@ public function testRenameSimpleConfigValidation(): void { $this->configImporter->import(); $this->fail('Expected ConfigImporterException thrown when simple configuration is renamed.'); } - catch (ConfigImporterException $e) { + catch (ConfigImporterException) { $expected = [ new FormattableMarkup('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', ['@old_name' => 'config_test.old', '@new_name' => 'config_test.new']), ]; diff --git a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php index 620126e5012b2566b691c5e729d1500b52434c7c..f997950b1203111bb7ece67a528cc67c21f12e99 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php @@ -888,7 +888,7 @@ public function testInvalidStep(): void { $config_importer->doSyncStep('a_non_existent_step', $context); $this->fail('Expected \InvalidArgumentException thrown'); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // Expected exception; just continue testing. } $this->assertFalse(\Drupal::isConfigSyncing(), 'After an invalid step \Drupal::isConfigSyncing() returns FALSE'); diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php index 6b8c310517285888234c0870d64f549921a92ca1..49981e687138aa355977a448453af11b9f1887e8 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/ConfigStorageTestBase.php @@ -143,7 +143,7 @@ public function testInvalidStorage(): void { $this->invalidStorage->delete($name); $this->fail('Exception not thrown upon deleting from a non-existing storage bin.'); } - catch (\Exception $e) { + catch (\Exception) { // An exception occurred as expected; just continue. } diff --git a/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php b/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php index e8c1f674950fbe9b1a419fe5ae35015871fbe6f4..9124c85b7de4812964dff77849e89be66b132bc7 100644 --- a/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Config/Storage/DatabaseStorageTest.php @@ -70,7 +70,7 @@ public function testExceptionIsThrownIfQueryFails(): void { $this->storage->exists('config.settings'); $this->fail('Expected exception not thrown from exists()'); } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // Exception was expected } @@ -78,7 +78,7 @@ public function testExceptionIsThrownIfQueryFails(): void { $this->storage->read('config.settings'); $this->fail('Expected exception not thrown from read()'); } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // Exception was expected } @@ -86,7 +86,7 @@ public function testExceptionIsThrownIfQueryFails(): void { $this->storage->readMultiple(['config.settings', 'config.settings2']); $this->fail('Expected exception not thrown from readMultiple()'); } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // Exception was expected } @@ -94,7 +94,7 @@ public function testExceptionIsThrownIfQueryFails(): void { $this->storage->write('config.settings', ['data' => '']); $this->fail('Expected exception not thrown from deleteAll()'); } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // Exception was expected } @@ -102,7 +102,7 @@ public function testExceptionIsThrownIfQueryFails(): void { $this->storage->listAll(); $this->fail('Expected exception not thrown from listAll()'); } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // Exception was expected } @@ -110,7 +110,7 @@ public function testExceptionIsThrownIfQueryFails(): void { $this->storage->deleteAll(); $this->fail('Expected exception not thrown from deleteAll()'); } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // Exception was expected } @@ -118,7 +118,7 @@ public function testExceptionIsThrownIfQueryFails(): void { $this->storage->getAllCollectionNames(); $this->fail('Expected exception not thrown from getAllCollectionNames()'); } - catch (DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper) { // Exception was expected } diff --git a/core/tests/Drupal/KernelTests/Core/Database/DatabaseEventTest.php b/core/tests/Drupal/KernelTests/Core/Database/DatabaseEventTest.php index 09b353f155d214b3d1ecc51cdf282c916a057556..cc5184f6b3c3ae99f5d8e431916fcc870c0a892c 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/DatabaseEventTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DatabaseEventTest.php @@ -67,7 +67,7 @@ public function testStatementExecutionEvents(): void { $this->connection->query('bananas on the palm tree'); $this->fail('An exception was expected, but was not thrown'); } - catch (\Exception $e) { + catch (\Exception) { // Expected, keep going. } $this->assertSame(3, $subscriber->countStatementStarts); diff --git a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php index d8f410aca2b19636e8a9f86c32af26b18b0052a1..c6687669c3336e390ae845bf7a3edf8a29ca9446 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificSchemaTestBase.php @@ -72,7 +72,7 @@ public function tryInsert(string $table = 'test_table'): bool { ->execute(); return TRUE; } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } } @@ -96,7 +96,7 @@ public function tryUnsignedInsert(string $table_name, string $column_name): bool ->execute(); return TRUE; } - catch (\Exception $e) { + catch (\Exception) { return FALSE; } } @@ -115,7 +115,7 @@ protected function tryInsertExpectsIntegrityConstraintViolationException(string ->execute(); $this->fail('Expected IntegrityConstraintViolationException not thrown'); } - catch (IntegrityConstraintViolationException $e) { + catch (IntegrityConstraintViolationException) { // Do nothing, it's the expected behavior. } } @@ -730,7 +730,7 @@ public function testChangePrimaryKeyToSerial(): void { ->execute(); $this->fail('Expected IntegrityConstraintViolationException not thrown'); } - catch (IntegrityConstraintViolationException $e) { + catch (IntegrityConstraintViolationException) { } // Ensure auto numbering now works. diff --git a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php index 6fd3182ea270992b01ed65d0dc47d2fc663759fb..42f9ea03902c80aaeff0a5b3fc7477eef3efbf45 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php @@ -561,7 +561,7 @@ public function testQueryFailureInTransaction(): void { $this->connection->query('SELECT [age] FROM {test} WHERE [name] = :name', [':name' => 'David'])->fetchField(); $this->fail('Using the query method should have failed.'); } - catch (\Exception $e) { + catch (\Exception) { // Just continue testing. } @@ -573,7 +573,7 @@ public function testQueryFailureInTransaction(): void { $this->fail('Select query should have failed.'); } - catch (\Exception $e) { + catch (\Exception) { // Just continue testing. } @@ -588,7 +588,7 @@ public function testQueryFailureInTransaction(): void { $this->fail('Insert query should have failed.'); } - catch (\Exception $e) { + catch (\Exception) { // Just continue testing. } @@ -601,7 +601,7 @@ public function testQueryFailureInTransaction(): void { $this->fail('Update query should have failed.'); } - catch (\Exception $e) { + catch (\Exception) { // Just continue testing. } @@ -613,7 +613,7 @@ public function testQueryFailureInTransaction(): void { $this->fail('Delete query should have failed.'); } - catch (\Exception $e) { + catch (\Exception) { // Just continue testing. } @@ -629,7 +629,7 @@ public function testQueryFailureInTransaction(): void { $this->fail('Merge query should have failed.'); } - catch (\Exception $e) { + catch (\Exception) { // Just continue testing. } @@ -647,7 +647,7 @@ public function testQueryFailureInTransaction(): void { $this->fail('Upsert query should have failed.'); } - catch (\Exception $e) { + catch (\Exception) { // Just continue testing. } diff --git a/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php b/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php index dcea763eccbd6bc994276d7bdbb252bcbb10cc56..447779349ce705e6ba9ea4e4b9b86353aa11e7e5 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php @@ -239,7 +239,7 @@ public function testRowCount(): void { $result->rowCount(); $exception = FALSE; } - catch (RowCountException $e) { + catch (RowCountException) { $exception = TRUE; } $this->assertTrue($exception, 'Exception was thrown'); diff --git a/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php b/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php index 2aa2ff497afa60d2976722eba308c974821633a8..c58f27d26337ab94c9d5edcd6d92c96c4d38ee81 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/InsertDefaultsTest.php @@ -36,7 +36,7 @@ public function testDefaultEmptyInsert(): void { // This is only executed if no exception has been thrown. $this->fail('Expected exception NoFieldsException has not been thrown.'); } - catch (NoFieldsException $e) { + catch (NoFieldsException) { // Expected exception; just continue testing. } diff --git a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php index b2a7fe09bbb4b1459469bb18bd78c7a5e6a65060..6a0f4355ca228ae327588f32bcbf50abaa7160fe 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php @@ -52,7 +52,7 @@ public function testArrayArgumentsSQLInjection(): void { $this->connection->query("SELECT * FROM {test} WHERE [name] = :name", [':name' => $condition])->fetchObject(); $this->fail('SQL injection attempt via array arguments should result in a database exception.'); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // Expected exception; just continue testing. } diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php index a0cfc20cbb793f4fc1db31b89296917adb682572..e00bc97fcd085c54cd0e2840ac6178f474c4a822 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php @@ -393,7 +393,7 @@ public function testSelectWithRowCount(): void { $result->rowCount(); $exception = FALSE; } - catch (RowCountException $e) { + catch (RowCountException) { $exception = TRUE; } $this->assertTrue($exception, 'Exception was thrown'); diff --git a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php index 8d1c4fd2ab05ad594fcb74d4d47f2a868cc13414..738aab892c22c224a8930acfe4d2def5c85bcb59 100644 --- a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php +++ b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php @@ -190,7 +190,7 @@ public function testPreventChangeOfSitePath(): void { try { $kernel->setSitePath('/dev/null'); } - catch (\LogicException $e) { + catch (\LogicException) { $pass = TRUE; } $this->assertTrue($pass, 'Throws LogicException if DrupalKernel::setSitePath() is called after boot'); diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php index 02ebbb76e345249d5e8084a0cdeb6f2ef94b0d84..392e69890360242cebe7f3363aee5a06d5e4aae1 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php @@ -559,7 +559,7 @@ public function testEntityRollback(): void { EntityTest::create(['name' => 'fail_insert'])->save(); $this->fail('Expected exception has not been thrown.'); } - catch (\Exception $e) { + catch (\Exception) { // Expected exception; just continue testing. } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php index 7d0ea21b1881510d2a9c4cc400b3e3b62cdc0c1e..168442a56486e7f07cea2303d6bc2defba213ec0 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityDefinitionUpdateTest.php @@ -146,7 +146,7 @@ public function testEntityTypeUpdateWithEntityStorageChange(): void { $this->entityDefinitionUpdateManager->updateEntityType($entity_type); $this->fail('EntityStorageException thrown when trying to apply an update that requires shared table schema changes.'); } - catch (EntityStorageException $e) { + catch (EntityStorageException) { // Expected exception; just continue testing. } } @@ -504,7 +504,7 @@ public function testBundleFieldCreateDeleteWithExistingEntities(): void { ->execute(); $this->fail($message); } - catch (IntegrityConstraintViolationException $e) { + catch (IntegrityConstraintViolationException) { // Now provide a value for the 'not null' column. This is expected to // succeed. $values['new_bundle_field_shape'] = $this->randomString(); @@ -829,7 +829,7 @@ public function testBaseFieldUpdateWithExistingData(): void { $this->applyEntityUpdates(); $this->fail('FieldStorageDefinitionUpdateForbiddenException thrown when trying to update a field schema that has data.'); } - catch (FieldStorageDefinitionUpdateForbiddenException $e) { + catch (FieldStorageDefinitionUpdateForbiddenException) { // Expected exception; just continue testing. } } @@ -853,7 +853,7 @@ public function testBundleFieldUpdateWithExistingData(): void { $this->applyEntityUpdates(); $this->fail('FieldStorageDefinitionUpdateForbiddenException thrown when trying to update a field schema that has data.'); } - catch (FieldStorageDefinitionUpdateForbiddenException $e) { + catch (FieldStorageDefinitionUpdateForbiddenException) { // Expected exception; just continue testing. } } @@ -1038,7 +1038,7 @@ public function testSingleActionCalls(): void { $this->entityDefinitionUpdateManager->installEntityType(new ContentEntityType(['id' => 'foo'])); $this->fail($message); } - catch (PluginNotFoundException $e) { + catch (PluginNotFoundException) { // Expected exception; just continue testing. } @@ -1051,7 +1051,7 @@ public function testSingleActionCalls(): void { $this->entityDefinitionUpdateManager->installFieldStorageDefinition('bar', 'foo', 'entity_test', $storage_definition); $this->fail($message); } - catch (PluginNotFoundException $e) { + catch (PluginNotFoundException) { // Expected exception; just continue testing. } @@ -1180,7 +1180,7 @@ public function testBaseFieldEntityKeyUpdateWithExistingData(): void { $this->applyEntityUpdates(); $this->fail($message); } - catch (EntityStorageException $e) { + catch (EntityStorageException) { // Expected exception; just continue testing. } @@ -1196,7 +1196,7 @@ public function testBaseFieldEntityKeyUpdateWithExistingData(): void { $entity->save(); $this->fail($message); } - catch (EntityStorageException $e) { + catch (EntityStorageException) { // Expected exception; just continue testing. } } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php index 40d849d25f13fda8599b9af077797867e0f77ebf..f2edea50c407123feaf97848d3cea12f6e2f2435 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityReferenceFieldTest.php @@ -275,7 +275,7 @@ public function testAutocreateApi(): void { }); $this->fail($message); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // Expected exception; just continue testing. } $this->assertUserAutocreate($entity, function (EntityInterface $entity, UserInterface $user) { @@ -309,7 +309,7 @@ public function testAutocreateApi(): void { }); $this->fail($message); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // Expected exception; just continue testing. } $this->assertUserRoleAutocreate($entity, function (EntityInterface $entity, RoleInterface $role) { @@ -426,7 +426,7 @@ public function testTargetEntityNoLoad(): void { ->create(['name' => $this->randomString()]); $entity->target_reference = $target_id; } - catch (EntityStorageException $e) { + catch (EntityStorageException) { $this->fail($message); } @@ -437,7 +437,7 @@ public function testTargetEntityNoLoad(): void { $storage->load($target_id); $this->fail($message); } - catch (EntityStorageException $e) { + catch (EntityStorageException) { // Expected exception; just continue testing. } } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php index 3ddc5f0e751121914cbcac254c167da3c2bbb7dd..53bfb56c2a77249da12b19828542649be25f4acd 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php @@ -68,7 +68,7 @@ protected function doTestEntityLanguageMethods($entity_type) { $entity->addTranslation($this->langcodes[1]); $this->fail('Adding a translation to a language-neutral entity results in an error.'); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // Expected exception; just continue testing. } @@ -106,7 +106,7 @@ protected function doTestEntityLanguageMethods($entity_type) { $entity->getTranslation($this->langcodes[2])->get($this->fieldName)->value; $this->fail('Getting a non existing translation results in an error.'); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // Expected exception; just continue testing. } @@ -118,7 +118,7 @@ protected function doTestEntityLanguageMethods($entity_type) { $entity->getTranslation('invalid')->get($this->fieldName)->value; $this->fail('Getting an invalid translation results in an error.'); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // Expected exception; just continue testing. } @@ -127,7 +127,7 @@ protected function doTestEntityLanguageMethods($entity_type) { $entity->getTranslation('invalid')->set($this->fieldName, NULL); $this->fail("$entity_type: Setting a translation for an invalid language throws an exception."); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // Expected exception; just continue testing. } @@ -352,7 +352,7 @@ protected function doTestEntityTranslationAPI($entity_type) { $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED); $this->fail('A language-neutral translation cannot be retrieved.'); } - catch (\LogicException $e) { + catch (\LogicException) { // Expected exception; just continue testing. } @@ -390,7 +390,7 @@ protected function doTestEntityTranslationAPI($entity_type) { $translation->{$langcode_key}->value = $this->langcodes[2]; $this->fail('The translation language cannot be changed.'); } - catch (\LogicException $e) { + catch (\LogicException) { // Expected exception; just continue testing. } @@ -398,7 +398,7 @@ protected function doTestEntityTranslationAPI($entity_type) { try { $translation->{$langcode_key}->value = $langcode; } - catch (\LogicException $e) { + catch (\LogicException) { $this->fail('The translation language can be reassigned the same value.'); } @@ -411,7 +411,7 @@ protected function doTestEntityTranslationAPI($entity_type) { try { $translation->{$default_langcode_key}->value = $default; } - catch (\LogicException $e) { + catch (\LogicException) { $this->fail('The default translation flag can be reassigned the same value.'); } @@ -419,7 +419,7 @@ protected function doTestEntityTranslationAPI($entity_type) { $translation->{$default_langcode_key}->value = !$default; $this->fail('The default translation flag cannot be changed.'); } - catch (\LogicException $e) { + catch (\LogicException) { // Expected exception; just continue testing. } @@ -457,7 +457,7 @@ protected function doTestEntityTranslationAPI($entity_type) { $translation->{$method}('name', $this->randomMachineName()); $this->fail("The $method method raises an exception when trying to manipulate a removed translation."); } - catch (\Exception $e) { + catch (\Exception) { // Expected exception; just continue testing. } } @@ -478,7 +478,7 @@ protected function doTestEntityTranslationAPI($entity_type) { $entity->removeTranslation($invalid_langcode); $this->fail("Removing an invalid translation ($invalid_langcode) causes an exception to be thrown."); } - catch (\Exception $e) { + catch (\Exception) { // Expected exception; just continue testing. } } @@ -706,7 +706,7 @@ public function testFieldDefinitions(): void { $entity_field_manager->getBaseFieldDefinitions($entity_type); $this->fail("Field $name cannot be translatable."); } - catch (\LogicException $e) { + catch (\LogicException) { // Expected exception; just continue testing. } } @@ -768,7 +768,7 @@ protected function doTestLanguageChange($entity_type) { $entity->{$langcode_key}->value = $this->langcodes[2]; $this->fail('An exception is thrown when setting the default language to an existing translation language'); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { // Expected exception; just continue testing. } } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php index b9e8f2b806612390a3adf059d4175e4271551320..d28100b7dbd2d5b156cfdce04c465c593ac7d1e6 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldSqlStorageTest.php @@ -374,7 +374,7 @@ public function testFieldUpdateFailure(): void { $field_storage->save(); $this->fail('Update succeeded.'); } - catch (\Exception $e) { + catch (\Exception) { // Expected exception; just continue testing. } diff --git a/core/tests/Drupal/KernelTests/Core/File/FileDeleteTest.php b/core/tests/Drupal/KernelTests/Core/File/FileDeleteTest.php index 1b6cbd1df171fddd04488fcbb64efb67b5000f3f..6a81aa2b1892613ead22a45a0e368e1753697d94 100644 --- a/core/tests/Drupal/KernelTests/Core/File/FileDeleteTest.php +++ b/core/tests/Drupal/KernelTests/Core/File/FileDeleteTest.php @@ -45,7 +45,7 @@ public function testDirectory(): void { \Drupal::service('file_system')->delete($directory); $this->fail('Expected NotRegularFileException'); } - catch (NotRegularFileException $e) { + catch (NotRegularFileException) { // Ignore. } $this->assertDirectoryExists($directory); diff --git a/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php b/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php index 1ca7fcbd2ded5517794b44d97a0d2566fcba42e7..d001abbba4fa3dbae2e5bfa287bc3cac4708c2e8 100644 --- a/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/KeyValueStore/KeyValueContentEntityStorageTest.php @@ -63,7 +63,7 @@ public function testCRUD(): void { $empty->toUrl(); $this->fail('EntityMalformedException was thrown.'); } - catch (EntityMalformedException $e) { + catch (EntityMalformedException) { // Expected exception; just continue testing. } @@ -72,7 +72,7 @@ public function testCRUD(): void { $empty->save(); $this->fail('EntityMalformedException was thrown.'); } - catch (EntityMalformedException $e) { + catch (EntityMalformedException) { // Expected exception; just continue testing. } @@ -85,7 +85,7 @@ public function testCRUD(): void { $empty_id->save(); $this->fail('EntityMalformedException was thrown.'); } - catch (EntityMalformedException $e) { + catch (EntityMalformedException) { // Expected exception; just continue testing. } @@ -111,7 +111,7 @@ public function testCRUD(): void { try { $status = $entity_test->save(); } - catch (EntityMalformedException $e) { + catch (EntityMalformedException) { $this->fail('EntityMalformedException was not thrown.'); } @@ -143,7 +143,7 @@ public function testCRUD(): void { $same_id->save(); $this->fail('Not possible to overwrite an entity.'); } - catch (EntityStorageException $e) { + catch (EntityStorageException) { // Expected exception; just continue testing. } diff --git a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php index eceb9c16fc6e80ef827522cf517152da7226fa5f..2c739858ac6543b79ab051d4bd91c16af92da893 100644 --- a/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php +++ b/core/tests/Drupal/KernelTests/Core/Menu/MenuTreeStorageTest.php @@ -217,7 +217,7 @@ public function testMenuDisabledChildLinks(): void { $this->moveMenuLink('test1', 'footerA'); $this->fail('Exception was not thrown'); } - catch (PluginException $e) { + catch (PluginException) { // Expected exception; just continue testing. } // The opposite move should work, and change the has_children flag. diff --git a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php index 4bb9c5efa29acadf53aba138f7022e20741cc200..d85207fc8760893890a938cbc39fc3ac399a6ce3 100644 --- a/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php +++ b/core/tests/Drupal/KernelTests/Core/Routing/RouteProviderTest.php @@ -383,7 +383,7 @@ public function testOutlinePathMatchDefaults(): void { $this->assertCount(1, $routes, 'The correct number of routes was found.'); $this->assertNotNull($routes->get('foo'), 'The first matching route was found.'); } - catch (ResourceNotFoundException $e) { + catch (ResourceNotFoundException) { $this->fail('No matching route found with default argument value.'); } } @@ -422,7 +422,7 @@ public function testOutlinePathMatchDefaultsCollision(): void { $this->assertCount(1, $routes, 'The correct number of routes was found.'); $this->assertNotNull($routes->get('foo'), 'The first matching route was found.'); } - catch (ResourceNotFoundException $e) { + catch (ResourceNotFoundException) { $this->fail('No matching route found with default argument value.'); } } @@ -461,7 +461,7 @@ public function testOutlinePathMatchDefaultsCollision2(): void { $this->assertNotNull($routes->get('foo'), 'The second matching route was found.'); $this->assertNull($routes->get('eep'), 'Non-matching route was not found.'); } - catch (ResourceNotFoundException $e) { + catch (ResourceNotFoundException) { $this->fail('No matching route found with default argument value.'); } } @@ -500,7 +500,7 @@ public function testOutlinePathMatchDefaultsCollision3(): void { $this->assertNotNull($routes->get('foo2'), 'The second matching route was found.'); $this->assertNull($routes->get('eep'), 'Non-matching route was not found.'); } - catch (ResourceNotFoundException $e) { + catch (ResourceNotFoundException) { $this->fail('No matching route found with default argument value.'); } } @@ -535,7 +535,7 @@ public function testOutlinePathMatchZero(): void { $this->assertCount(1, $routes, 'The correct number of routes was found.'); } - catch (ResourceNotFoundException $e) { + catch (ResourceNotFoundException) { $this->fail('No matchout route found with 0 as argument value'); } } @@ -680,7 +680,7 @@ public function testRouteByName(): void { try { $provider->getRouteByName('invalid_name'); } - catch (RouteNotFoundException $e) { + catch (RouteNotFoundException) { $exception_thrown = TRUE; } $this->assertTrue($exception_thrown, 'Random route was not found.'); diff --git a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php index a7048f38eef0538548808612c27953be5e7b9356..96b8620434cc6283ed441d305669f3784a66f229 100644 --- a/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php +++ b/core/tests/Drupal/KernelTests/Core/TypedData/TypedDataTest.php @@ -457,7 +457,7 @@ public function testTypedDataLists(): void { $typed_data->setValue('string'); $this->fail('No exception has been thrown when setting an invalid value.'); } - catch (\Exception $e) { + catch (\Exception) { // Expected exception; just continue testing. } } @@ -575,7 +575,7 @@ public function testTypedDataMaps(): void { $typed_data->get('invalid'); $this->fail('No exception has been thrown when getting an invalid value.'); } - catch (\Exception $e) { + catch (\Exception) { // Expected exception; just continue testing. } @@ -584,7 +584,7 @@ public function testTypedDataMaps(): void { $typed_data->setValue('invalid'); $this->fail('No exception has been thrown when setting an invalid value.'); } - catch (\Exception $e) { + catch (\Exception) { // Expected exception; just continue testing. } diff --git a/core/tests/Drupal/TestSite/Commands/TestSiteTearDownCommand.php b/core/tests/Drupal/TestSite/Commands/TestSiteTearDownCommand.php index 5820a7a48fcb6a746b8d29ab20f3d3093c81a873..9acc0d8d7b998494ab8d05fc594d3258a77c695e 100644 --- a/core/tests/Drupal/TestSite/Commands/TestSiteTearDownCommand.php +++ b/core/tests/Drupal/TestSite/Commands/TestSiteTearDownCommand.php @@ -47,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int try { $test_database = new TestDatabase($db_prefix); } - catch (\InvalidArgumentException $e) { + catch (\InvalidArgumentException) { $io = new SymfonyStyle($input, $output); $io->getErrorStyle()->error("Invalid database prefix: $db_prefix\n\nValid database prefixes match the regular expression '/test(\d+)$/'. For example, 'test12345678'."); // Display the synopsis of the command like Composer does. diff --git a/core/tests/Drupal/TestTools/ErrorHandler/BootstrapErrorHandler.php b/core/tests/Drupal/TestTools/ErrorHandler/BootstrapErrorHandler.php index ab3d0c8a1c3c08bd77669babdf023e4d37965ef1..71079770a1a9c32da5b4a9ef4e9645a1c5bbd696 100644 --- a/core/tests/Drupal/TestTools/ErrorHandler/BootstrapErrorHandler.php +++ b/core/tests/Drupal/TestTools/ErrorHandler/BootstrapErrorHandler.php @@ -73,7 +73,7 @@ public function __invoke(int $errorNumber, string $errorString, string $errorFil try { call_user_func($this->phpUnitErrorHandler, $errorNumber, $errorString, $errorFile, $errorLine); } - catch (NoTestCaseObjectOnCallStackException $e) { + catch (NoTestCaseObjectOnCallStackException) { // If we end up here, it's likely because a test's processing has // finished already and we are processing an error that occurred while // dealing with STDOUT rewinding or truncating. Do nothing. diff --git a/core/tests/Drupal/Tests/Component/DrupalComponentTest.php b/core/tests/Drupal/Tests/Component/DrupalComponentTest.php index 3f42a89a80a69545161c4e0462833a17757358c7..c43a24939090f2e3959ea52747e009f5c653dd6a 100644 --- a/core/tests/Drupal/Tests/Component/DrupalComponentTest.php +++ b/core/tests/Drupal/Tests/Component/DrupalComponentTest.php @@ -150,7 +150,7 @@ public function testAssertNoCoreUsage($expected_pass, $file_data): void { $pass = TRUE; $this->assertNoCoreUsage($file_uri); } - catch (AssertionFailedError $e) { + catch (AssertionFailedError) { $pass = FALSE; } $this->assertEquals($expected_pass, $pass, $expected_pass ? diff --git a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php index 576815f249bdd07b3ae8926629aa26fc342a3341..7003c9746408139cadf1686ce64ddc53e9a939dc 100644 --- a/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php +++ b/core/tests/Drupal/Tests/Core/Extension/ThemeHandlerTest.php @@ -103,7 +103,7 @@ public function testThemeLibrariesEmpty(): void { $this->themeHandler->addTheme($theme); $this->assertTrue(TRUE, 'Empty libraries key in theme.info.yml does not cause PHP warning'); } - catch (\Exception $e) { + catch (\Exception) { $this->fail('Empty libraries key in theme.info.yml causes PHP warning.'); } } diff --git a/core/tests/Drupal/Tests/Core/Theme/Component/SchemaCompatibilityCheckerTest.php b/core/tests/Drupal/Tests/Core/Theme/Component/SchemaCompatibilityCheckerTest.php index 723819f1ace9f55450a4857fa914d8f92674d672..1fb29d8ac9d8e13718c942508ae6a69d40fe0d3a 100644 --- a/core/tests/Drupal/Tests/Core/Theme/Component/SchemaCompatibilityCheckerTest.php +++ b/core/tests/Drupal/Tests/Core/Theme/Component/SchemaCompatibilityCheckerTest.php @@ -36,7 +36,7 @@ public function testIsCompatible(array $first_schema, array $second_schema, bool $this->checker->isCompatible($first_schema, $second_schema); $is_compatible = TRUE; } - catch (IncompatibleComponentSchema $e) { + catch (IncompatibleComponentSchema) { $is_compatible = FALSE; } $this->assertSame($expected, $is_compatible); diff --git a/core/themes/claro/claro.theme b/core/themes/claro/claro.theme index a4d6adff13ab76797b7dcad02a434028a1dc39c0..79481b37246d700a22515f72e5e8862b3a600b81 100644 --- a/core/themes/claro/claro.theme +++ b/core/themes/claro/claro.theme @@ -360,7 +360,7 @@ function claro_theme_suggestions_maintenance_page_alter(&$suggestions) { try { $is_front = \Drupal::service('path.matcher')->isFrontPage(); } - catch (Exception $e) { + catch (Exception) { // An exception could mean that the database is offline. This scenario // should also be rendered using the frontpage template. $is_front = TRUE; diff --git a/core/themes/starterkit_theme/src/StarterKit.php b/core/themes/starterkit_theme/src/StarterKit.php index d3b459944b39f160d7661c674d8eb9c4eccec07e..058a26e39abcf3223445eebb6bc607111a46f553 100644 --- a/core/themes/starterkit_theme/src/StarterKit.php +++ b/core/themes/starterkit_theme/src/StarterKit.php @@ -14,7 +14,7 @@ public static function postProcess(string $working_dir, string $machine_name, st try { file_put_contents($readme_file, "$theme_name theme, generated from starterkit_theme. Additional information on generating themes can be found in the [Starterkit documentation](https://www.drupal.org/docs/core-modules-and-themes/core-themes/starterkit-theme)."); } - catch (\Throwable $th) { + catch (\Throwable) { } }