diff --git a/core/includes/batch.inc b/core/includes/batch.inc index af7987fd8f..c4828c077b 100644 --- a/core/includes/batch.inc +++ b/core/includes/batch.inc @@ -354,7 +354,7 @@ function _batch_process() { // completion level of the current operation. $current = $total - $remaining + $finished; $percentage = _batch_api_percentage($total, $current); - $elapsed = isset($current_set['elapsed']) ? $current_set['elapsed'] : 0; + $elapsed = $current_set['elapsed'] ?? 0; $values = [ '@remaining' => $remaining, '@total' => $total, diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 9ef9f6a553..b30f2c1edc 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -381,8 +381,8 @@ function drupal_valid_test_ua($new_prefix = NULL) { // A valid Simpletest request will contain a hashed and salted authentication // code. Check if this code is present in a cookie or custom user agent // string. - $http_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : NULL; - $user_agent = isset($_COOKIE['SIMPLETEST_USER_AGENT']) ? $_COOKIE['SIMPLETEST_USER_AGENT'] : $http_user_agent; + $http_user_agent = $_SERVER['HTTP_USER_AGENT'] ?? NULL; + $user_agent = $_COOKIE['SIMPLETEST_USER_AGENT'] ?? $http_user_agent; if (isset($user_agent) && preg_match("/^simple(\w+\d+):(.+):(.+):(.+)$/", $user_agent, $matches)) { list(, $prefix, $time, $salt, $hmac) = $matches; $check_string = $prefix . ':' . $time . ':' . $salt; diff --git a/core/includes/common.inc b/core/includes/common.inc index f640a90121..44c39d35b0 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -355,8 +355,8 @@ function drupal_attach_tabledrag(&$element, array $options) { $tabledrag_id = (!isset($tabledrag_id)) ? 0 : $tabledrag_id + 1; // If a subgroup or source isn't set, assume it is the same as the group. - $target = isset($options['subgroup']) ? $options['subgroup'] : $group; - $source = isset($options['source']) ? $options['source'] : $target; + $target = $options['subgroup'] ?? $group; + $source = $options['source'] ?? $target; $element['#attached']['drupalSettings']['tableDrag'][$options['table_id']][$group][$tabledrag_id] = [ 'target' => $target, 'source' => $source, diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 045b2dd417..69543cf0af 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -323,7 +323,7 @@ function _drupal_get_error_level() { $error_level = \Drupal::config('system.logging')->get('error_level'); } catch (\Exception $e) { - $error_level = isset($GLOBALS['config']['system.logging']['error_level']) ? $GLOBALS['config']['system.logging']['error_level'] : ERROR_REPORTING_HIDE; + $error_level = $GLOBALS['config']['system.logging']['error_level'] ?? ERROR_REPORTING_HIDE; } // If there is no container or if it has no config.factory service, we are diff --git a/core/includes/form.inc b/core/includes/form.inc index d759c88625..52888f09d4 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -193,10 +193,10 @@ function template_preprocess_fieldset(&$variables) { $element = $variables['element']; Element::setAttributes($element, ['id']); RenderElement::setAttributes($element); - $variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : []; - $variables['prefix'] = isset($element['#field_prefix']) ? $element['#field_prefix'] : NULL; - $variables['suffix'] = isset($element['#field_suffix']) ? $element['#field_suffix'] : NULL; - $variables['title_display'] = isset($element['#title_display']) ? $element['#title_display'] : NULL; + $variables['attributes'] = $element['#attributes'] ?? []; + $variables['prefix'] = $element['#field_prefix'] ?? NULL; + $variables['suffix'] = $element['#field_suffix'] ?? NULL; + $variables['title_display'] = $element['#title_display'] ?? NULL; $variables['children'] = $element['#children']; $variables['required'] = !empty($element['#required']) ? $element['#required'] : NULL; @@ -477,8 +477,8 @@ function template_preprocess_form_element(&$variables) { $variables['title_display'] = $element['#title_display']; - $variables['prefix'] = isset($element['#field_prefix']) ? $element['#field_prefix'] : NULL; - $variables['suffix'] = isset($element['#field_suffix']) ? $element['#field_suffix'] : NULL; + $variables['prefix'] = $element['#field_prefix'] ?? NULL; + $variables['suffix'] = $element['#field_suffix'] ?? NULL; $variables['description'] = NULL; if (!empty($element['#description'])) { @@ -883,7 +883,7 @@ function batch_process($redirect = NULL, Url $url = NULL, $redirect_callback = N $process_info = [ 'current_set' => 0, 'progressive' => TRUE, - 'url' => isset($url) ? $url : Url::fromRoute('system.batch_page.html'), + 'url' => $url ?? Url::fromRoute('system.batch_page.html'), 'source_url' => Url::fromRouteMatch(\Drupal::routeMatch())->mergeOptions(['query' => \Drupal::request()->query->all()]), 'batch_redirect' => $redirect, 'theme' => \Drupal::theme()->getActiveTheme()->getName(), diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 95655c1378..73eb94507c 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1519,7 +1519,7 @@ function _install_get_version_info($version) { function install_load_profile(&$install_state) { $profile = $install_state['parameters']['profile']; $install_state['profiles'][$profile]->load(); - $install_state['profile_info'] = install_profile_info($profile, isset($install_state['parameters']['langcode']) ? $install_state['parameters']['langcode'] : 'en'); + $install_state['profile_info'] = install_profile_info($profile, $install_state['parameters']['langcode'] ?? 'en'); $sync_directory = Settings::get('config_sync_directory'); if (!empty($install_state['parameters']['existing_config']) && !empty($sync_directory)) { diff --git a/core/includes/install.inc b/core/includes/install.inc index e685221332..6a14f67eb1 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -114,7 +114,7 @@ function drupal_install_profile_distribution_name() { $profile = \Drupal::installProfile(); $info = \Drupal::service('extension.list.profile')->getExtensionInfo($profile); } - return isset($info['distribution']['name']) ? $info['distribution']['name'] : 'Drupal'; + return $info['distribution']['name'] ?? 'Drupal'; } /** @@ -132,7 +132,7 @@ function drupal_install_profile_distribution_version() { // installation state (it might not be saved anywhere yet). if (InstallerKernel::installationAttempted()) { global $install_state; - return isset($install_state['profile_info']['version']) ? $install_state['profile_info']['version'] : \Drupal::VERSION; + return $install_state['profile_info']['version'] ?? \Drupal::VERSION; } // At all other times, we load the profile via standard methods. else { diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 1b3e34f00a..931b426e68 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -151,7 +151,7 @@ function drupal_find_theme_functions($cache, $prefixes) { // refers to a base hook, not to another suggestion, and all suggestions // are found using the base hook's pattern, not a pattern from an // intermediary suggestion. - $pattern = isset($info['pattern']) ? $info['pattern'] : ($hook . '__'); + $pattern = $info['pattern'] ?? ($hook . '__'); // Grep only the functions which are within the prefix group. list($first_prefix,) = explode('_', $prefix, 2); if (!isset($info['base hook']) && !empty($pattern) && isset($grouped_functions[$first_prefix])) { @@ -212,7 +212,7 @@ function drupal_find_theme_templates($cache, $extension, $path) { } } $theme = \Drupal::theme()->getActiveTheme()->getName(); - $subtheme_paths = isset($theme_paths[$theme]) ? $theme_paths[$theme] : []; + $subtheme_paths = $theme_paths[$theme] ?? []; // Escape the periods in the extension. $regex = '/' . str_replace('.', '\.', $extension) . '$/'; @@ -261,7 +261,7 @@ function drupal_find_theme_templates($cache, $extension, $path) { // the use of 'pattern' and 'base hook'. $patterns = array_keys($files); foreach ($cache as $hook => $info) { - $pattern = isset($info['pattern']) ? $info['pattern'] : ($hook . '__'); + $pattern = $info['pattern'] ?? ($hook . '__'); if (!isset($info['base hook']) && !empty($pattern)) { // Transform _ in pattern to - to match file naming scheme // for the purposes of searching. @@ -1014,7 +1014,7 @@ function template_preprocess_table(&$variables) { unset($cell['data']); } // Flag the cell as a header or not and remove the flag. - $is_header = isset($cell['header']) ? $cell['header'] : TRUE; + $is_header = $cell['header'] ?? TRUE; unset($cell['header']); // Track responsive classes for each column as needed. Only the header @@ -1055,7 +1055,7 @@ function template_preprocess_table(&$variables) { // Check if we're dealing with a simple or complex row if (isset($row['data'])) { $cells = $row['data']; - $variables['no_striping'] = isset($row['no_striping']) ? $row['no_striping'] : FALSE; + $variables['no_striping'] = $row['no_striping'] ?? FALSE; // Set the attributes array and exclude 'data' and 'no_striping'. $row_attributes = $row; @@ -1782,7 +1782,7 @@ function template_preprocess_pager(&$variables) { $parameters = $variables['pager']['#parameters']; $quantity = empty($variables['pager']['#quantity']) ? 0 : $variables['pager']['#quantity']; $route_name = $variables['pager']['#route_name']; - $route_parameters = isset($variables['pager']['#route_parameters']) ? $variables['pager']['#route_parameters'] : []; + $route_parameters = $variables['pager']['#route_parameters'] ?? []; /** @var \Drupal\Core\Pager\PagerManagerInterface $pager_manager */ $pager_manager = \Drupal::service('pager.manager'); diff --git a/core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php b/core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php index 04b81a0c16..6a5ad4080e 100644 --- a/core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php +++ b/core/lib/Drupal/Component/Annotation/Doctrine/DocParser.php @@ -565,9 +565,7 @@ private function collectAnnotationMetadata($name) private function collectAttributeTypeMetadata(&$metadata, Attribute $attribute) { // handle internal type declaration - $type = isset(self::$typeMap[$attribute->type]) - ? self::$typeMap[$attribute->type] - : $attribute->type; + $type = self::$typeMap[$attribute->type] ?? $attribute->type; // handle the case if the property type is mixed if ('mixed' === $type) { diff --git a/core/lib/Drupal/Component/Annotation/Plugin.php b/core/lib/Drupal/Component/Annotation/Plugin.php index 504ff401d1..6bae9c4f6e 100644 --- a/core/lib/Drupal/Component/Annotation/Plugin.php +++ b/core/lib/Drupal/Component/Annotation/Plugin.php @@ -78,7 +78,7 @@ public function get() { * {@inheritdoc} */ public function getProvider() { - return isset($this->definition['provider']) ? $this->definition['provider'] : FALSE; + return $this->definition['provider'] ?? FALSE; } /** diff --git a/core/lib/Drupal/Component/DependencyInjection/Container.php b/core/lib/Drupal/Component/DependencyInjection/Container.php index 41684d3e70..127656539a 100644 --- a/core/lib/Drupal/Component/DependencyInjection/Container.php +++ b/core/lib/Drupal/Component/DependencyInjection/Container.php @@ -115,10 +115,10 @@ public function __construct(array $container_definition = []) { throw new InvalidArgumentException('The non-optimized format is not supported by this class. Use an optimized machine-readable format instead, e.g. as produced by \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper.'); } - $this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : []; - $this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : []; - $this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : []; - $this->frozen = isset($container_definition['frozen']) ? $container_definition['frozen'] : FALSE; + $this->aliases = $container_definition['aliases'] ?? []; + $this->parameters = $container_definition['parameters'] ?? []; + $this->serviceDefinitions = $container_definition['services'] ?? []; + $this->frozen = $container_definition['frozen'] ?? FALSE; // Register the service_container with itself. $this->services['service_container'] = $this; @@ -146,7 +146,7 @@ public function get($id, $invalid_behavior = ContainerInterface::EXCEPTION_ON_IN throw new ServiceCircularReferenceException($id, array_keys($this->loading)); } - $definition = isset($this->serviceDefinitions[$id]) ? $this->serviceDefinitions[$id] : NULL; + $definition = $this->serviceDefinitions[$id] ?? NULL; if (!$definition && $invalid_behavior === ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE) { if (!$id) { diff --git a/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php b/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php index be690488de..95c4e34d0c 100644 --- a/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php +++ b/core/lib/Drupal/Component/DependencyInjection/PhpArrayContainer.php @@ -34,10 +34,10 @@ public function __construct(array $container_definition = []) { // Do not call the parent's constructor as it would bail on the // machine-optimized format. - $this->aliases = isset($container_definition['aliases']) ? $container_definition['aliases'] : []; - $this->parameters = isset($container_definition['parameters']) ? $container_definition['parameters'] : []; - $this->serviceDefinitions = isset($container_definition['services']) ? $container_definition['services'] : []; - $this->frozen = isset($container_definition['frozen']) ? $container_definition['frozen'] : FALSE; + $this->aliases = $container_definition['aliases'] ?? []; + $this->parameters = $container_definition['parameters'] ?? []; + $this->serviceDefinitions = $container_definition['services'] ?? []; + $this->frozen = $container_definition['frozen'] ?? FALSE; // Register the service_container with itself. $this->services['service_container'] = $this; diff --git a/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php b/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php index 0cf5669543..f1ccb6d28d 100644 --- a/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php +++ b/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php @@ -292,11 +292,11 @@ public function addSubscriber(EventSubscriberInterface $subscriber) { $this->addListener($event_name, [$subscriber, $params]); } elseif (is_string($params[0])) { - $this->addListener($event_name, [$subscriber, $params[0]], isset($params[1]) ? $params[1] : 0); + $this->addListener($event_name, [$subscriber, $params[0]], $params[1] ?? 0); } else { foreach ($params as $listener) { - $this->addListener($event_name, [$subscriber, $listener[0]], isset($listener[1]) ? $listener[1] : 0); + $this->addListener($event_name, [$subscriber, $listener[0]], $listener[1] ?? 0); } } } diff --git a/core/lib/Drupal/Component/FileCache/FileCache.php b/core/lib/Drupal/Component/FileCache/FileCache.php index eea92ac194..256d5dd79f 100644 --- a/core/lib/Drupal/Component/FileCache/FileCache.php +++ b/core/lib/Drupal/Component/FileCache/FileCache.php @@ -68,7 +68,7 @@ public function __construct($prefix, $collection, $cache_backend_class = NULL, a public function get($filepath) { $filepaths = [$filepath]; $cached = $this->getMultiple($filepaths); - return isset($cached[$filepath]) ? $cached[$filepath] : NULL; + return $cached[$filepath] ?? NULL; } /** diff --git a/core/lib/Drupal/Component/Gettext/PoStreamReader.php b/core/lib/Drupal/Component/Gettext/PoStreamReader.php index a92bccb127..bbdd8e8ae6 100644 --- a/core/lib/Drupal/Component/Gettext/PoStreamReader.php +++ b/core/lib/Drupal/Component/Gettext/PoStreamReader.php @@ -526,7 +526,7 @@ public function setItemFromArray($value) { } $item = new PoItem(); - $item->setContext(isset($value['msgctxt']) ? $value['msgctxt'] : ''); + $item->setContext($value['msgctxt'] ?? ''); $item->setSource($value['msgid']); $item->setTranslation($value['msgstr']); $item->setPlural($plural); diff --git a/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php b/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php index 533b026236..f664a06fa3 100644 --- a/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php +++ b/core/lib/Drupal/Component/Plugin/ContextAwarePluginBase.php @@ -37,7 +37,7 @@ abstract class ContextAwarePluginBase extends PluginBase implements ContextAware * The plugin implementation definition. */ public function __construct(array $configuration, $plugin_id, $plugin_definition) { - $context_configuration = isset($configuration['context']) ? $configuration['context'] : []; + $context_configuration = $configuration['context'] ?? []; unset($configuration['context']); parent::__construct($configuration, $plugin_id, $plugin_definition); diff --git a/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php b/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php index 8d62175e60..977892ddab 100644 --- a/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php +++ b/core/lib/Drupal/Component/Transliteration/PhpTransliteration.php @@ -260,7 +260,7 @@ protected function lookupReplacement($code, $unknown_character = '?') { $this->readGenericData($bank); } $code = $code & 0xff; - return isset($this->genericMap[$bank][$code]) ? $this->genericMap[$bank][$code] : $unknown_character; + return $this->genericMap[$bank][$code] ?? $unknown_character; } /** diff --git a/core/lib/Drupal/Component/Utility/UserAgent.php b/core/lib/Drupal/Component/Utility/UserAgent.php index 934049033c..f7403e2fdd 100644 --- a/core/lib/Drupal/Component/Utility/UserAgent.php +++ b/core/lib/Drupal/Component/Utility/UserAgent.php @@ -68,7 +68,7 @@ public static function getBestMatchingLangcode($http_accept_language, $langcodes // to the same langcode for different qvalues. Keep the highest. $ua_langcodes[$langcode] = max( (int) ($qvalue * 1000), - (isset($ua_langcodes[$langcode]) ? $ua_langcodes[$langcode] : 0) + ($ua_langcodes[$langcode] ?? 0) ); } } @@ -113,7 +113,7 @@ public static function getBestMatchingLangcode($http_accept_language, $langcodes // If nothing matches below, the default qvalue is the one of the wildcard // language, if set, or is 0 (which will never match). - $qvalue = isset($ua_langcodes['*']) ? $ua_langcodes['*'] : 0; + $qvalue = $ua_langcodes['*'] ?? 0; // Find the longest possible prefix of the user agent supplied language // ('the language-range') that matches this site language ('the language diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php index 875c9d3ef9..55a3b4374c 100644 --- a/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php +++ b/core/lib/Drupal/Core/Ajax/AjaxResponseAttachmentsProcessor.php @@ -138,9 +138,9 @@ protected function buildAttachmentsCommands(AjaxResponse $response, Request $req // Resolve the attached libraries into asset collections. $assets = new AttachedAssets(); - $assets->setLibraries(isset($attachments['library']) ? $attachments['library'] : []) + $assets->setLibraries($attachments['library'] ?? []) ->setAlreadyLoadedLibraries(isset($ajax_page_state['libraries']) ? explode(',', $ajax_page_state['libraries']) : []) - ->setSettings(isset($attachments['drupalSettings']) ? $attachments['drupalSettings'] : []); + ->setSettings($attachments['drupalSettings'] ?? []); $css_assets = $this->assetResolver->getCssAssets($assets, $optimize_css); list($js_assets_header, $js_assets_footer) = $this->assetResolver->getJsAssets($assets, $optimize_js); diff --git a/core/lib/Drupal/Core/Annotation/Translation.php b/core/lib/Drupal/Core/Annotation/Translation.php index 14fdda986e..f63a9a0ab8 100644 --- a/core/lib/Drupal/Core/Annotation/Translation.php +++ b/core/lib/Drupal/Core/Annotation/Translation.php @@ -74,7 +74,7 @@ class Translation extends AnnotationBase { */ public function __construct(array $values) { $string = $values['value']; - $arguments = isset($values['arguments']) ? $values['arguments'] : []; + $arguments = $values['arguments'] ?? []; $options = []; if (!empty($values['context'])) { $options = [ diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php index 983baec616..e813e3cf7b 100644 --- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php +++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php @@ -242,7 +242,7 @@ public function buildByExtension($extension) { // Set the 'minified' flag on JS file assets, default to FALSE. if ($type == 'js' && $options['type'] == 'file') { - $options['minified'] = isset($options['minified']) ? $options['minified'] : FALSE; + $options['minified'] = $options['minified'] ?? FALSE; } $library[$type][] = $options; diff --git a/core/lib/Drupal/Core/Authentication/AuthenticationCollector.php b/core/lib/Drupal/Core/Authentication/AuthenticationCollector.php index 616e936b55..de6edae006 100644 --- a/core/lib/Drupal/Core/Authentication/AuthenticationCollector.php +++ b/core/lib/Drupal/Core/Authentication/AuthenticationCollector.php @@ -60,7 +60,7 @@ public function isGlobal($provider_id) { * {@inheritdoc} */ public function getProvider($provider_id) { - return isset($this->providers[$provider_id]) ? $this->providers[$provider_id] : NULL; + return $this->providers[$provider_id] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Cache/ApcuBackend.php b/core/lib/Drupal/Core/Cache/ApcuBackend.php index 6014fb8bff..fc6fab38bf 100644 --- a/core/lib/Drupal/Core/Cache/ApcuBackend.php +++ b/core/lib/Drupal/Core/Cache/ApcuBackend.php @@ -184,7 +184,7 @@ public function set($cid, $data, $expire = CacheBackendInterface::CACHE_PERMANEN */ public function setMultiple(array $items = []) { foreach ($items as $cid => $item) { - $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : []); + $this->set($cid, $item['data'], $item['expire'] ?? CacheBackendInterface::CACHE_PERMANENT, $item['tags'] ?? []); } } diff --git a/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php b/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php index b04ee5c55c..789b7274aa 100644 --- a/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php +++ b/core/lib/Drupal/Core/Cache/ChainedFastBackendFactory.php @@ -48,7 +48,7 @@ public function __construct(Settings $settings = NULL, $consistent_service_name // Default the consistent backend to the site's default backend. if (!isset($consistent_service_name)) { $cache_settings = isset($settings) ? $settings->get('cache') : []; - $consistent_service_name = isset($cache_settings['default']) ? $cache_settings['default'] : 'cache.backend.database'; + $consistent_service_name = $cache_settings['default'] ?? 'cache.backend.database'; } // Default the fast backend to APCu if it's available. diff --git a/core/lib/Drupal/Core/Cache/MemoryBackend.php b/core/lib/Drupal/Core/Cache/MemoryBackend.php index d402d70b54..18e3658d32 100644 --- a/core/lib/Drupal/Core/Cache/MemoryBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryBackend.php @@ -118,7 +118,7 @@ public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) { */ public function setMultiple(array $items = []) { foreach ($items as $cid => $item) { - $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : []); + $this->set($cid, $item['data'], $item['expire'] ?? CacheBackendInterface::CACHE_PERMANENT, $item['tags'] ?? []); } } diff --git a/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php b/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php index 63d20076c6..634120133d 100644 --- a/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php +++ b/core/lib/Drupal/Core/Cache/MemoryCounterBackend.php @@ -73,10 +73,10 @@ protected function increaseCounter($function, $cid) { */ public function getCounter($method = NULL, $cid = NULL) { if ($method && $cid) { - return isset($this->counter[$method][$cid]) ? $this->counter[$method][$cid] : 0; + return $this->counter[$method][$cid] ?? 0; } elseif ($method) { - return isset($this->counter[$method]) ? $this->counter[$method] : []; + return $this->counter[$method] ?? []; } else { return $this->counter; diff --git a/core/lib/Drupal/Core/Cache/PhpBackend.php b/core/lib/Drupal/Core/Cache/PhpBackend.php index 96a2b834bd..85935b0b61 100644 --- a/core/lib/Drupal/Core/Cache/PhpBackend.php +++ b/core/lib/Drupal/Core/Cache/PhpBackend.php @@ -84,7 +84,7 @@ protected function getByHash($cidhash, $allow_invalid = FALSE) { */ public function setMultiple(array $items) { foreach ($items as $cid => $item) { - $this->set($cid, $item['data'], isset($item['expire']) ? $item['expire'] : CacheBackendInterface::CACHE_PERMANENT, isset($item['tags']) ? $item['tags'] : []); + $this->set($cid, $item['data'], $item['expire'] ?? CacheBackendInterface::CACHE_PERMANENT, $item['tags'] ?? []); } } diff --git a/core/lib/Drupal/Core/Command/DbDumpCommand.php b/core/lib/Drupal/Core/Command/DbDumpCommand.php index ac544d068b..ae0e3617f1 100644 --- a/core/lib/Drupal/Core/Command/DbDumpCommand.php +++ b/core/lib/Drupal/Core/Command/DbDumpCommand.php @@ -183,7 +183,7 @@ protected function getTableSchema(Connection $connection, $table) { elseif (!isset($definition['fields'][$name]['size'])) { // Try use the provided length, if it doesn't exist default to 100. It's // not great but good enough for our dumps at this point. - $definition['fields'][$name]['length'] = isset($matches[2]) ? $matches[2] : 100; + $definition['fields'][$name]['length'] = $matches[2] ?? 100; } if (isset($row['Default'])) { diff --git a/core/lib/Drupal/Core/Command/InstallCommand.php b/core/lib/Drupal/Core/Command/InstallCommand.php index 5736bd1f5a..4b76025c11 100644 --- a/core/lib/Drupal/Core/Command/InstallCommand.php +++ b/core/lib/Drupal/Core/Command/InstallCommand.php @@ -328,8 +328,8 @@ protected function getProfiles($include_hidden = FALSE, $auto_select_distributio } // Determine the name of the profile; default to the internal name if none // is specified. - $name = isset($details['name']) ? $details['name'] : $profile->getName(); - $description = isset($details['description']) ? $details['description'] : $name; + $name = $details['name'] ?? $profile->getName(); + $description = $details['description'] ?? $name; $profiles[$profile->getName()] = $description; if ($auto_select_distributions && !empty($details['distribution'])) { diff --git a/core/lib/Drupal/Core/Config/CachedStorage.php b/core/lib/Drupal/Core/Config/CachedStorage.php index f43ede2a63..c1633dbcb5 100644 --- a/core/lib/Drupal/Core/Config/CachedStorage.php +++ b/core/lib/Drupal/Core/Config/CachedStorage.php @@ -97,7 +97,7 @@ public function readMultiple(array $names) { // missing configuration objects as an explicit FALSE. $items = []; foreach ($names_to_get as $name) { - $data = isset($list[$name]) ? $list[$name] : FALSE; + $data = $list[$name] ?? FALSE; $data_to_return[$name] = $data; $items[$cache_keys_map[$name]] = ['data' => $data]; } diff --git a/core/lib/Drupal/Core/Config/Config.php b/core/lib/Drupal/Core/Config/Config.php index 38bb3d5db7..08c9bf118f 100644 --- a/core/lib/Drupal/Core/Config/Config.php +++ b/core/lib/Drupal/Core/Config/Config.php @@ -91,7 +91,7 @@ public function get($key = '') { else { $parts = explode('.', $key); if (count($parts) == 1) { - return isset($this->overriddenData[$key]) ? $this->overriddenData[$key] : NULL; + return $this->overriddenData[$key] ?? NULL; } else { $value = NestedArray::getValue($this->overriddenData, $parts, $key_exists); @@ -295,7 +295,7 @@ public function getOriginal($key = '', $apply_overrides = TRUE) { else { $parts = explode('.', $key); if (count($parts) == 1) { - return isset($original_data[$key]) ? $original_data[$key] : NULL; + return $original_data[$key] ?? NULL; } else { $value = NestedArray::getValue($original_data, $parts, $key_exists); diff --git a/core/lib/Drupal/Core/Config/ConfigBase.php b/core/lib/Drupal/Core/Config/ConfigBase.php index 4f445ea21c..0bf960e93e 100644 --- a/core/lib/Drupal/Core/Config/ConfigBase.php +++ b/core/lib/Drupal/Core/Config/ConfigBase.php @@ -135,7 +135,7 @@ public function get($key = '') { else { $parts = explode('.', $key); if (count($parts) == 1) { - return isset($this->data[$key]) ? $this->data[$key] : NULL; + return $this->data[$key] ?? NULL; } else { $value = NestedArray::getValue($this->data, $parts, $key_exists); diff --git a/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php b/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php index 35fe0284e3..c68ac7255e 100644 --- a/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php +++ b/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php @@ -68,7 +68,7 @@ public function getCollectionNames($include_default = TRUE) { * if not. */ public function getOverrideService($collection) { - return isset($this->collections[$collection]) ? $this->collections[$collection] : NULL; + return $this->collections[$collection] ?? NULL; } } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 69a568bda0..1cbc336177 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -150,7 +150,7 @@ public function isNew() { * {@inheritdoc} */ public function get($property_name) { - return isset($this->{$property_name}) ? $this->{$property_name} : NULL; + return $this->{$property_name} ?? NULL; } /** @@ -228,8 +228,8 @@ public function createDuplicate() { * Helper callback for uasort() to sort configuration entities by weight and label. */ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) { - $a_weight = isset($a->weight) ? $a->weight : 0; - $b_weight = isset($b->weight) ? $b->weight : 0; + $a_weight = $a->weight ?? 0; + $b_weight = $b->weight ?? 0; if ($a_weight == $b_weight) { $a_label = $a->label(); $b_label = $b->label(); @@ -506,7 +506,7 @@ public function getThirdPartySetting($module, $key, $default = NULL) { * {@inheritdoc} */ public function getThirdPartySettings($module) { - return isset($this->third_party_settings[$module]) ? $this->third_party_settings[$module] : []; + return $this->third_party_settings[$module] ?? []; } /** diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php index 9dcec1835b..a56a6f7fbe 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php @@ -470,7 +470,7 @@ public function updateFromStorageRecord(ConfigEntityInterface $entity, array $va */ public function loadOverrideFree($id) { $entities = $this->loadMultipleOverrideFree([$id]); - return isset($entities[$id]) ? $entities[$id] : NULL; + return $entities[$id] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Config/Entity/Query/Query.php b/core/lib/Drupal/Core/Config/Entity/Query/Query.php index 757ce8ba6f..a18968873c 100644 --- a/core/lib/Drupal/Core/Config/Entity/Query/Query.php +++ b/core/lib/Drupal/Core/Config/Entity/Query/Query.php @@ -92,8 +92,8 @@ public function execute() { $properties = explode('.', $field); foreach ($properties as $property) { if (isset($a[$property]) || isset($b[$property])) { - $a = isset($a[$property]) ? $a[$property] : NULL; - $b = isset($b[$property]) ? $b[$property] : NULL; + $a = $a[$property] ?? NULL; + $b = $b[$property] ?? NULL; } } return ($a <= $b) ? $direction : -$direction; diff --git a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php index b16cee0aea..b77c107b7c 100644 --- a/core/lib/Drupal/Core/Config/Schema/ArrayElement.php +++ b/core/lib/Drupal/Core/Config/Schema/ArrayElement.php @@ -33,7 +33,7 @@ protected function getAllKeys() { protected function parse() { $elements = []; foreach ($this->getAllKeys() as $key) { - $value = isset($this->value[$key]) ? $this->value[$key] : NULL; + $value = $this->value[$key] ?? NULL; $definition = $this->getElementDefinition($key); $elements[$key] = $this->createElement($definition, $value, $key); } @@ -98,7 +98,7 @@ public function isEmpty() { * {@inheritdoc} */ public function toArray() { - return isset($this->value) ? $this->value : []; + return $this->value ?? []; } /** diff --git a/core/lib/Drupal/Core/Config/Schema/Mapping.php b/core/lib/Drupal/Core/Config/Schema/Mapping.php index 220a350490..3fa470be17 100644 --- a/core/lib/Drupal/Core/Config/Schema/Mapping.php +++ b/core/lib/Drupal/Core/Config/Schema/Mapping.php @@ -21,8 +21,8 @@ class Mapping extends ArrayElement { * {@inheritdoc} */ protected function getElementDefinition($key) { - $value = isset($this->value[$key]) ? $this->value[$key] : NULL; - $definition = isset($this->definition['mapping'][$key]) ? $this->definition['mapping'][$key] : []; + $value = $this->value[$key] ?? NULL; + $definition = $this->definition['mapping'][$key] ?? []; return $this->buildDataDefinition($definition, $value, $key); } diff --git a/core/lib/Drupal/Core/Config/Schema/Sequence.php b/core/lib/Drupal/Core/Config/Schema/Sequence.php index 547969bbcc..8e715baf67 100644 --- a/core/lib/Drupal/Core/Config/Schema/Sequence.php +++ b/core/lib/Drupal/Core/Config/Schema/Sequence.php @@ -23,7 +23,7 @@ class Sequence extends ArrayElement { * {@inheritdoc} */ protected function getElementDefinition($key) { - $value = isset($this->value[$key]) ? $this->value[$key] : NULL; + $value = $this->value[$key] ?? NULL; // @todo: Remove BC layer for sequence with hyphen in front. https://www.drupal.org/node/2444979 $definition = []; if (isset($this->definition['sequence'][0])) { diff --git a/core/lib/Drupal/Core/Config/Schema/SequenceDataDefinition.php b/core/lib/Drupal/Core/Config/Schema/SequenceDataDefinition.php index c317e29e02..c616741a5c 100644 --- a/core/lib/Drupal/Core/Config/Schema/SequenceDataDefinition.php +++ b/core/lib/Drupal/Core/Config/Schema/SequenceDataDefinition.php @@ -22,7 +22,7 @@ class SequenceDataDefinition extends ListDataDefinition { * be sorted). */ public function getOrderBy() { - return isset($this->definition['orderby']) ? $this->definition['orderby'] : NULL; + return $this->definition['orderby'] ?? NULL; } } diff --git a/core/lib/Drupal/Core/Cron.php b/core/lib/Drupal/Core/Cron.php index 59e0a67ae6..c45dfbd287 100644 --- a/core/lib/Drupal/Core/Cron.php +++ b/core/lib/Drupal/Core/Cron.php @@ -174,7 +174,7 @@ protected function processQueues() { $this->queueFactory->get($queue_name)->createQueue(); $queue_worker = $this->queueManager->createInstance($queue_name); - $end = time() + (isset($info['cron']['time']) ? $info['cron']['time'] : 15); + $end = time() + ($info['cron']['time'] ?? 15); $queue = $this->queueFactory->get($queue_name); $lease_time = isset($info['cron']['time']) ?: NULL; while (time() < $end && ($item = $queue->claimItem($lease_time))) { diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index a486a14192..5ffac809a7 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -250,7 +250,7 @@ public function __construct(\PDO $connection, array $connection_options) { } // Initialize and prepare the connection prefix. - $this->setPrefix(isset($connection_options['prefix']) ? $connection_options['prefix'] : ''); + $this->setPrefix($connection_options['prefix'] ?? ''); // Set a Statement class, unless the driver opted out. // @todo remove this in Drupal 10 https://www.drupal.org/node/3177490 @@ -898,7 +898,7 @@ public function query($query, array $args = [], $options = []) { return $stmt->rowCount(); case Database::RETURN_INSERT_ID: - $sequence_name = isset($options['sequence_name']) ? $options['sequence_name'] : NULL; + $sequence_name = $options['sequence_name'] ?? NULL; return $this->connection->lastInsertId($sequence_name); case Database::RETURN_NULL: diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php index e05f10c86e..283035b835 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php @@ -313,7 +313,7 @@ protected function createKeysSql($spec) { * Thrown if field specification is missing. */ protected function getNormalizedIndexes(array $spec) { - $indexes = isset($spec['indexes']) ? $spec['indexes'] : []; + $indexes = $spec['indexes'] ?? []; foreach ($indexes as $index_name => $index_fields) { foreach ($index_fields as $index_key => $index_field) { // Get the name of the field from the index specification. diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php index a5b6ae3296..9154a0188a 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php @@ -263,7 +263,7 @@ public function createDatabase($database) { } public function mapConditionOperator($operator) { - return isset(static::$postgresqlConditionOperatorMap[$operator]) ? static::$postgresqlConditionOperatorMap[$operator] : NULL; + return static::$postgresqlConditionOperatorMap[$operator] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php index 4a43d11aa5..af6c9d8acc 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php @@ -424,7 +424,7 @@ public function createDatabase($database) { } public function mapConditionOperator($operator) { - return isset(static::$sqliteConditionOperatorMap[$operator]) ? static::$sqliteConditionOperatorMap[$operator] : NULL; + return static::$sqliteConditionOperatorMap[$operator] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Database/Query/Condition.php b/core/lib/Drupal/Core/Database/Query/Condition.php index 8c5f207f94..b2fb78edd5 100644 --- a/core/lib/Drupal/Core/Database/Query/Condition.php +++ b/core/lib/Drupal/Core/Database/Query/Condition.php @@ -398,7 +398,7 @@ protected function mapConditionOperator($operator) { // do not need the more expensive mb_strtoupper() because SQL statements // are ASCII. $operator = strtoupper($operator); - $return = isset(static::$conditionOperatorMap[$operator]) ? static::$conditionOperatorMap[$operator] : []; + $return = static::$conditionOperatorMap[$operator] ?? []; } $return += ['operator' => $operator]; diff --git a/core/lib/Drupal/Core/Database/Query/Merge.php b/core/lib/Drupal/Core/Database/Query/Merge.php index efad9b59da..6109a556b4 100644 --- a/core/lib/Drupal/Core/Database/Query/Merge.php +++ b/core/lib/Drupal/Core/Database/Query/Merge.php @@ -331,7 +331,7 @@ public function keys(array $fields, array $values = []) { public function key($field, $value = NULL) { // @todo D9: Remove this backwards-compatibility shim. if (is_array($field)) { - $this->keys($field, isset($value) ? $value : []); + $this->keys($field, $value ?? []); } else { $this->keys([$field => $value]); diff --git a/core/lib/Drupal/Core/Database/Query/Select.php b/core/lib/Drupal/Core/Database/Query/Select.php index 8a86723675..5da3848166 100644 --- a/core/lib/Drupal/Core/Database/Query/Select.php +++ b/core/lib/Drupal/Core/Database/Query/Select.php @@ -133,7 +133,7 @@ class Select extends Query implements SelectInterface { public function __construct(Connection $connection, $table, $alias = NULL, $options = []) { $options['return'] = Database::RETURN_STATEMENT; parent::__construct($connection, $options); - $conjunction = isset($options['conjunction']) ? $options['conjunction'] : 'AND'; + $conjunction = $options['conjunction'] ?? 'AND'; $this->condition = $this->connection->condition($conjunction); $this->having = $this->connection->condition($conjunction); $this->addJoin(NULL, $table, $alias); @@ -180,7 +180,7 @@ public function addMetaData($key, $object) { * {@inheritdoc} */ public function getMetaData($key) { - return isset($this->alterMetaData[$key]) ? $this->alterMetaData[$key] : NULL; + return $this->alterMetaData[$key] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Database/StatementPrefetch.php b/core/lib/Drupal/Core/Database/StatementPrefetch.php index 1f2f1709cb..086ffc43ea 100644 --- a/core/lib/Drupal/Core/Database/StatementPrefetch.php +++ b/core/lib/Drupal/Core/Database/StatementPrefetch.php @@ -430,7 +430,7 @@ public function rowCount() { public function fetch($fetch_style = NULL, $cursor_orientation = \PDO::FETCH_ORI_NEXT, $cursor_offset = NULL) { if (isset($this->currentRow)) { // Set the fetch parameter. - $this->fetchStyle = isset($fetch_style) ? $fetch_style : $this->defaultFetchStyle; + $this->fetchStyle = $fetch_style ?? $this->defaultFetchStyle; $this->fetchOptions = $this->defaultFetchOptions; // Grab the row in the format specified above. @@ -516,7 +516,7 @@ public function fetchAssoc() { * {@inheritdoc} */ public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) { - $this->fetchStyle = isset($mode) ? $mode : $this->defaultFetchStyle; + $this->fetchStyle = $mode ?? $this->defaultFetchStyle; $this->fetchOptions = $this->defaultFetchOptions; if (isset($column_index)) { $this->fetchOptions['column'] = $column_index; @@ -581,7 +581,7 @@ public function fetchAllKeyed($key_index = 0, $value_index = 1) { * {@inheritdoc} */ public function fetchAllAssoc($key, $fetch_style = NULL) { - $this->fetchStyle = isset($fetch_style) ? $fetch_style : $this->defaultFetchStyle; + $this->fetchStyle = $fetch_style ?? $this->defaultFetchStyle; $this->fetchOptions = $this->defaultFetchOptions; $result = []; diff --git a/core/lib/Drupal/Core/Datetime/Element/Datetime.php b/core/lib/Drupal/Core/Datetime/Element/Datetime.php index e3bfa9c59a..e1d0aea472 100644 --- a/core/lib/Drupal/Core/Datetime/Element/Datetime.php +++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php @@ -105,7 +105,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form ]; } else { - $date = isset($element['#default_value']) ? $element['#default_value'] : NULL; + $date = $element['#default_value'] ?? NULL; if ($date instanceof DrupalDateTime && !$date->hasErrors()) { $date->setTimezone(new \DateTimeZone($element['#date_timezone'])); $input = [ diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/MimeTypePass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/MimeTypePass.php index 87294d933a..5daa81a655 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/MimeTypePass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/MimeTypePass.php @@ -42,7 +42,7 @@ public function process(ContainerBuilder $container) { throw new LogicException("Service '$id' does not implement $interface."); } } - $handlers[$id] = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $handlers[$id] = $attributes[0]['priority'] ?? 0; $interfaces[$id] = $handler->getClass(); } if (empty($handlers)) { diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterEventSubscribersPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterEventSubscribersPass.php index aa943c7246..c2c28b38e7 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterEventSubscribersPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterEventSubscribersPass.php @@ -40,12 +40,12 @@ public function process(ContainerBuilder $container) { $event_subscriber_info[$event_name][$priority][] = ['service' => [$id, $params]]; } elseif (is_string($params[0])) { - $priority = isset($params[1]) ? $params[1] : 0; + $priority = $params[1] ?? 0; $event_subscriber_info[$event_name][$priority][] = ['service' => [$id, $params[0]]]; } else { foreach ($params as $listener) { - $priority = isset($listener[1]) ? $listener[1] : 0; + $priority = $listener[1] ?? 0; $event_subscriber_info[$event_name][$priority][] = ['service' => [$id, $listener[0]]]; } } diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/StackedKernelPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/StackedKernelPass.php index a6f79c6820..21f77dd55d 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/StackedKernelPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/StackedKernelPass.php @@ -68,7 +68,7 @@ public function process(ContainerBuilder $container) { $responders = []; foreach ($container->findTaggedServiceIds('http_middleware') as $id => $attributes) { - $priorities[$id] = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $priorities[$id] = $attributes[0]['priority'] ?? 0; $middlewares[$id] = $container->getDefinition($id); $responders[$id] = !empty($attributes[0]['responder']); } diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/StackedSessionHandlerPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/StackedSessionHandlerPass.php index cf535dfc8b..6862cc465f 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/StackedSessionHandlerPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/StackedSessionHandlerPass.php @@ -24,7 +24,7 @@ public function process(ContainerBuilder $container) { $priorities = []; foreach ($container->findTaggedServiceIds('session_handler_proxy') as $id => $attributes) { - $priorities[$id] = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $priorities[$id] = $attributes[0]['priority'] ?? 0; $session_handler_proxies[$id] = $container->getDefinition($id); } diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php index e00193eacc..9cbfdb660d 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php @@ -127,9 +127,9 @@ public function process(ContainerBuilder $container) { * The service container. */ protected function processServiceCollectorPass(array $pass, $consumer_id, ContainerBuilder $container) { - $tag = isset($pass['tag']) ? $pass['tag'] : $consumer_id; - $method_name = isset($pass['call']) ? $pass['call'] : 'addHandler'; - $required = isset($pass['required']) ? $pass['required'] : FALSE; + $tag = $pass['tag'] ?? $consumer_id; + $method_name = $pass['call'] ?? 'addHandler'; + $required = $pass['required'] ?? FALSE; // Determine parameters. $consumer = $container->getDefinition($consumer_id); @@ -174,10 +174,10 @@ protected function processServiceCollectorPass(array $pass, $consumer_id, Contai if (!is_subclass_of($handler->getClass(), $interface)) { throw new LogicException("Service '$id' for consumer '$consumer_id' does not implement $interface."); } - $handlers[$id] = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $handlers[$id] = $attributes[0]['priority'] ?? 0; // Keep track of other tagged handlers arguments. foreach ($extra_params as $name => $pos) { - $extra_arguments[$id][$pos] = isset($attributes[0][$name]) ? $attributes[0][$name] : $params[$pos]->getDefaultValue(); + $extra_arguments[$id][$pos] = $attributes[0][$name] ?? $params[$pos]->getDefaultValue(); } } @@ -221,15 +221,15 @@ protected function processServiceCollectorPass(array $pass, $consumer_id, Contai * The service container. */ protected function processServiceIdCollectorPass(array $pass, $consumer_id, ContainerBuilder $container) { - $tag = isset($pass['tag']) ? $pass['tag'] : $consumer_id; - $required = isset($pass['required']) ? $pass['required'] : FALSE; + $tag = $pass['tag'] ?? $consumer_id; + $required = $pass['required'] ?? FALSE; $consumer = $container->getDefinition($consumer_id); // Find all tagged handlers. $handlers = []; foreach ($this->tagCache[$tag] ?? [] as $id => $attributes) { - $handlers[$id] = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $handlers[$id] = $attributes[0]['priority'] ?? 0; } if ($required && empty($handlers)) { diff --git a/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php b/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php index 55cd154e05..39d92501c7 100644 --- a/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php +++ b/core/lib/Drupal/Core/DependencyInjection/YamlFileLoader.php @@ -311,8 +311,8 @@ private function parseDefinition($id, $service, $file) } if (isset($service['decorates'])) { - $renameId = isset($service['decoration_inner_name']) ? $service['decoration_inner_name'] : null; - $priority = isset($service['decoration_priority']) ? $service['decoration_priority'] : 0; + $renameId = $service['decoration_inner_name'] ?? NULL; + $priority = $service['decoration_priority'] ?? 0; $definition->setDecoratedService($service['decorates'], $renameId, $priority); } diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index c8d7603062..d5887e19a6 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -635,7 +635,7 @@ public function discoverServiceProviders() { $this->containerNeedsDumping = FALSE; $GLOBALS['conf']['container_service_providers']['InstallerServiceProvider'] = 'Drupal\Core\Installer\InstallerServiceProvider'; } - $this->moduleList = isset($extensions['module']) ? $extensions['module'] : []; + $this->moduleList = $extensions['module'] ?? []; } $module_filenames = $this->getModuleFileNames(); $this->classLoaderAddMultiplePsr4($this->getModuleNamespacesPsr4($module_filenames)); @@ -786,7 +786,7 @@ protected function moduleData($module) { // Now find modules. $this->moduleData = $profiles + $listing->scan('module'); } - return isset($this->moduleData[$module]) ? $this->moduleData[$module] : FALSE; + return $this->moduleData[$module] ?? FALSE; } /** diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 3e82c6f95f..1bbf966d8a 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -606,7 +606,7 @@ protected function getTranslatedField($name, $langcode) { // $this->defaultLangcode might not be set if we are initializing the // default language code cache, in which case there is no valid // langcode to assign. - $field_langcode = isset($this->defaultLangcode) ? $this->defaultLangcode : LanguageInterface::LANGCODE_NOT_SPECIFIED; + $field_langcode = $this->defaultLangcode ?? LanguageInterface::LANGCODE_NOT_SPECIFIED; } else { $field_langcode = $langcode; diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index b69958d8e8..b8833c9703 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -539,7 +539,7 @@ protected function preLoad(array &$ids = NULL) { public function loadRevision($revision_id) { $revisions = $this->loadMultipleRevisions([$revision_id]); - return isset($revisions[$revision_id]) ? $revisions[$revision_id] : NULL; + return $revisions[$revision_id] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Entity/ContentEntityType.php b/core/lib/Drupal/Core/Entity/ContentEntityType.php index 5904851dab..73f07bf091 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityType.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityType.php @@ -65,7 +65,7 @@ public function getRevisionMetadataKeys() { */ public function getRevisionMetadataKey($key) { $keys = $this->getRevisionMetadataKeys(); - return isset($keys[$key]) ? $keys[$key] : FALSE; + return $keys[$key] ?? FALSE; } /** diff --git a/core/lib/Drupal/Core/Entity/Controller/EntityController.php b/core/lib/Drupal/Core/Entity/Controller/EntityController.php index 5d8f25698b..4dd93475fb 100644 --- a/core/lib/Drupal/Core/Entity/Controller/EntityController.php +++ b/core/lib/Drupal/Core/Entity/Controller/EntityController.php @@ -183,7 +183,7 @@ public function addPage($entity_type_id) { foreach ($bundles as $bundle_name => $bundle_info) { $build['#bundles'][$bundle_name] = [ 'label' => $bundle_info['label'], - 'description' => isset($bundle_info['description']) ? $bundle_info['description'] : '', + 'description' => $bundle_info['description'] ?? '', 'add_link' => Link::createFromRoute($bundle_info['label'], $form_route_name, [$bundle_argument => $bundle_name]), ]; } diff --git a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php index 1083f1127a..083de1d639 100644 --- a/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php +++ b/core/lib/Drupal/Core/Entity/Element/EntityAutocomplete.php @@ -167,12 +167,12 @@ public static function processEntityAutocomplete(array &$element, FormStateInter throw new \InvalidArgumentException("Missing required #autocreate['bundle'] parameter."); } // Default the autocreate user ID to the current user. - $element['#autocreate']['uid'] = isset($element['#autocreate']['uid']) ? $element['#autocreate']['uid'] : \Drupal::currentUser()->id(); + $element['#autocreate']['uid'] = $element['#autocreate']['uid'] ?? \Drupal::currentUser()->id(); } // Store the selection settings in the key/value store and pass a hashed key // in the route parameters. - $selection_settings = isset($element['#selection_settings']) ? $element['#selection_settings'] : []; + $selection_settings = $element['#selection_settings'] ?? []; $data = serialize($selection_settings) . $element['#target_type'] . $element['#selection_handler']; $selection_settings_key = Crypt::hmacBase64($data, Settings::getHashSalt()); @@ -287,7 +287,7 @@ public static function validateEntityAutocomplete(array &$element, FormStateInte // matches (tags). if (!$element['#tags'] && !empty($value)) { $last_value = $value[count($value) - 1]; - $value = isset($last_value['target_id']) ? $last_value['target_id'] : $last_value; + $value = $last_value['target_id'] ?? $last_value; } } diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php index dfa011ed55..3dcffd2cfa 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php @@ -216,7 +216,7 @@ public function processForm($element, FormStateInterface $form_state, $form) { // Hide extra fields. $extra_fields = \Drupal::service('entity_field.manager')->getExtraFields($this->targetEntityType, $this->bundle); - $extra_fields = isset($extra_fields['form']) ? $extra_fields['form'] : []; + $extra_fields = $extra_fields['form'] ?? []; foreach ($extra_fields as $extra_field => $info) { if (!$this->getComponent($extra_field)) { $element[$extra_field]['#access'] = FALSE; diff --git a/core/lib/Drupal/Core/Entity/EntityBase.php b/core/lib/Drupal/Core/Entity/EntityBase.php index 19a2a0ee4f..011bdfd03f 100644 --- a/core/lib/Drupal/Core/Entity/EntityBase.php +++ b/core/lib/Drupal/Core/Entity/EntityBase.php @@ -104,14 +104,14 @@ protected function uuidGenerator() { * {@inheritdoc} */ public function id() { - return isset($this->id) ? $this->id : NULL; + return $this->id ?? NULL; } /** * {@inheritdoc} */ public function uuid() { - return isset($this->uuid) ? $this->uuid : NULL; + return $this->uuid ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index c2b6786930..7dce1ff3c3 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -158,7 +158,7 @@ protected function init() { // Fill in defaults for extra fields. $context = $this->displayContext == 'view' ? 'display' : $this->displayContext; $extra_fields = \Drupal::service('entity_field.manager')->getExtraFields($this->targetEntityType, $this->bundle); - $extra_fields = isset($extra_fields[$context]) ? $extra_fields[$context] : []; + $extra_fields = $extra_fields[$context] ?? []; foreach ($extra_fields as $name => $definition) { if (!isset($this->content[$name]) && !isset($this->hidden[$name])) { // Extra fields are visible by default unless they explicitly say so. @@ -328,7 +328,7 @@ public function getComponents() { * {@inheritdoc} */ public function getComponent($name) { - return isset($this->content[$name]) ? $this->content[$name] : NULL; + return $this->content[$name] ?? NULL; } /** @@ -391,7 +391,7 @@ public function getHighestWeight() { */ protected function getFieldDefinition($field_name) { $definitions = $this->getFieldDefinitions(); - return isset($definitions[$field_name]) ? $definitions[$field_name] : NULL; + return $definitions[$field_name] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Entity/EntityFieldManager.php b/core/lib/Drupal/Core/Entity/EntityFieldManager.php index c845942612..4b1b9b1d7f 100644 --- a/core/lib/Drupal/Core/Entity/EntityFieldManager.php +++ b/core/lib/Drupal/Core/Entity/EntityFieldManager.php @@ -656,7 +656,7 @@ public function getExtraFields($entity_type_id, $bundle) { $extra = $this->moduleHandler->invokeAll('entity_extra_field_info'); $this->moduleHandler->alter('entity_extra_field_info', $extra); - $info = isset($extra[$entity_type_id][$bundle]) ? $extra[$entity_type_id][$bundle] : []; + $info = $extra[$entity_type_id][$bundle] ?? []; $info += [ 'form' => [], 'display' => [], diff --git a/core/lib/Drupal/Core/Entity/EntityStorageBase.php b/core/lib/Drupal/Core/Entity/EntityStorageBase.php index 8b78be167a..9d3fd912f6 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageBase.php @@ -243,7 +243,7 @@ protected function doCreate(array $values) { public function load($id) { assert(!is_null($id), sprintf('Cannot load the "%s" entity with NULL ID.', $this->entityTypeId)); $entities = $this->loadMultiple([$id]); - return isset($entities[$id]) ? $entities[$id] : NULL; + return $entities[$id] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index 4b8abf1e1d..527930c067 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -332,10 +332,10 @@ public function __construct($definition) { */ public function get($property) { if (property_exists($this, $property)) { - $value = isset($this->{$property}) ? $this->{$property} : NULL; + $value = $this->{$property} ?? NULL; } else { - $value = isset($this->additional[$property]) ? $this->additional[$property] : NULL; + $value = $this->additional[$property] ?? NULL; } return $value; } @@ -393,7 +393,7 @@ public function getKeys() { */ public function getKey($key) { $keys = $this->getKeys(); - return isset($keys[$key]) ? $keys[$key] : FALSE; + return $keys[$key] ?? FALSE; } /** @@ -627,7 +627,7 @@ public function getLinkTemplates() { */ public function getLinkTemplate($key) { $links = $this->getLinkTemplates(); - return isset($links[$key]) ? $links[$key] : FALSE; + return $links[$key] ?? FALSE; } /** diff --git a/core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php b/core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php index aa917c845c..8aef5ee039 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeBundleInfo.php @@ -78,7 +78,7 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Lan */ public function getBundleInfo($entity_type_id) { $bundle_info = $this->getAllBundleInfo(); - return isset($bundle_info[$entity_type_id]) ? $bundle_info[$entity_type_id] : []; + return $bundle_info[$entity_type_id] ?? []; } /** diff --git a/core/lib/Drupal/Core/Entity/EntityTypeManager.php b/core/lib/Drupal/Core/Entity/EntityTypeManager.php index fae1395957..8b7daa354f 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeManager.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeManager.php @@ -232,7 +232,7 @@ public function getRouteProviders($entity_type_id) { } } - return isset($this->handlers['route_provider'][$entity_type_id]) ? $this->handlers['route_provider'][$entity_type_id] : []; + return $this->handlers['route_provider'][$entity_type_id] ?? []; } /** diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php index 9ac0a6f557..ae1aab79dc 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -482,7 +482,7 @@ public function viewFieldItem(FieldItemInterface $item, $display = []) { $elements = $this->viewField($clone->{$field_name}, $display); // Extract the part of the render array we need. - $output = isset($elements[0]) ? $elements[0] : []; + $output = $elements[0] ?? []; if (isset($elements['#access'])) { $output['#access'] = $elements['#access']; } diff --git a/core/lib/Drupal/Core/Entity/Query/QueryBase.php b/core/lib/Drupal/Core/Entity/Query/QueryBase.php index da5c76031b..85878aa75c 100644 --- a/core/lib/Drupal/Core/Entity/Query/QueryBase.php +++ b/core/lib/Drupal/Core/Entity/Query/QueryBase.php @@ -330,7 +330,7 @@ public function tableSort(&$headers) { $direction = TableSort::getSort($headers, \Drupal::request()); foreach ($headers as $header) { if (is_array($header) && ($header['data'] == $order['name'])) { - $this->sort($header['specifier'], $direction, isset($header['langcode']) ? $header['langcode'] : NULL); + $this->sort($header['specifier'], $direction, $header['langcode'] ?? NULL); } } @@ -385,7 +385,7 @@ public function addMetaData($key, $object) { * {@inheritdoc} */ public function getMetaData($key) { - return isset($this->alterMetaData[$key]) ? $this->alterMetaData[$key] : NULL; + return $this->alterMetaData[$key] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php index c2699dd4c9..ad66a42972 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php @@ -250,7 +250,7 @@ protected function finish() { $this->sqlQuery->groupBy($field); } foreach ($this->sqlFields as $field) { - $this->sqlQuery->addField($field[0], $field[1], isset($field[2]) ? $field[2] : NULL); + $this->sqlQuery->addField($field[0], $field[1], $field[2] ?? NULL); } return $this; } diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index ba319da7a1..04d0e3ff9b 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -1047,7 +1047,7 @@ protected function mapToStorageRecord(ContentEntityInterface $entity, $table_nam $value = ($item = $entity->$field_name->first()) ? $item->getValue() : []; } else { - $value = isset($entity->$field_name->$column_name) ? $entity->$field_name->$column_name : NULL; + $value = $entity->$field_name->$column_name ?? NULL; } if (!empty($definition->getSchema()['columns'][$column_name]['serialize'])) { $value = serialize($value); diff --git a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php index 3e362317b5..0fc97a87b4 100644 --- a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php +++ b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php @@ -61,8 +61,8 @@ public static function createFromDataType($data_type) { throw new \InvalidArgumentException('Data type must be in the form of "entity:ENTITY_TYPE:BUNDLE."'); } return static::create( - isset($parts[1]) ? $parts[1] : NULL, - isset($parts[2]) ? $parts[2] : NULL + $parts[1] ?? NULL, + $parts[2] ?? NULL ); } @@ -120,7 +120,7 @@ public function getDataType() { * {@inheritdoc} */ public function getEntityTypeId() { - return isset($this->definition['constraints']['EntityType']) ? $this->definition['constraints']['EntityType'] : NULL; + return $this->definition['constraints']['EntityType'] ?? NULL; } /** @@ -134,7 +134,7 @@ public function setEntityTypeId($entity_type_id) { * {@inheritdoc} */ public function getBundles() { - $bundle = isset($this->definition['constraints']['Bundle']) ? $this->definition['constraints']['Bundle'] : NULL; + $bundle = $this->definition['constraints']['Bundle'] ?? NULL; return is_string($bundle) ? [$bundle] : $bundle; } diff --git a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php index dd0b355c79..906dab45de 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ConfigImportSubscriber.php @@ -92,7 +92,7 @@ protected function validateModules(ConfigImporter $config_importer) { // Get the install profile from the site's configuration. $current_core_extension = $config_importer->getStorageComparer()->getTargetStorage()->read('core.extension'); - $install_profile = isset($current_core_extension['profile']) ? $current_core_extension['profile'] : NULL; + $install_profile = $current_core_extension['profile'] ?? NULL; // Ensure the profile is not changing. if ($install_profile !== $core_extension['profile']) { diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index 9779f39c8e..23d5b274bc 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -102,7 +102,7 @@ public function parse($filename) { // Determine if the extension is compatible with the current version of // Drupal core. - $core_version_constraint = isset($parsed_info['core_version_requirement']) ? $parsed_info['core_version_requirement'] : $parsed_info['core']; + $core_version_constraint = $parsed_info['core_version_requirement'] ?? $parsed_info['core']; $parsed_info['core_incompatible'] = !Semver::satisfies(\Drupal::VERSION, $core_version_constraint); if (isset($parsed_info['version']) && $parsed_info['version'] === 'VERSION') { $parsed_info['version'] = \Drupal::VERSION; diff --git a/core/lib/Drupal/Core/Extension/ModuleExtensionList.php b/core/lib/Drupal/Core/Extension/ModuleExtensionList.php index ab4be38698..5aed60c0b0 100644 --- a/core/lib/Drupal/Core/Extension/ModuleExtensionList.php +++ b/core/lib/Drupal/Core/Extension/ModuleExtensionList.php @@ -162,7 +162,7 @@ protected function doList() { // Add status, weight, and schema version. $installed_modules = $this->configFactory->get('core.extension')->get('module') ?: []; foreach ($extensions as $name => $module) { - $module->weight = isset($installed_modules[$name]) ? $installed_modules[$name] : 0; + $module->weight = $installed_modules[$name] ?? 0; $module->status = (int) isset($installed_modules[$name]); $module->schema_version = UpdateHookRegistry::SCHEMA_UNINSTALLED; } diff --git a/core/lib/Drupal/Core/Extension/ModuleHandler.php b/core/lib/Drupal/Core/Extension/ModuleHandler.php index 74b0834ab3..1b22117ae2 100644 --- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -233,8 +233,8 @@ public function buildModuleDependencies(array $modules) { $graph_object = new Graph($graph); $graph = $graph_object->searchAndSort(); foreach ($graph as $module_name => $data) { - $modules[$module_name]->required_by = isset($data['reverse_paths']) ? $data['reverse_paths'] : []; - $modules[$module_name]->requires = isset($data['paths']) ? $data['paths'] : []; + $modules[$module_name]->required_by = $data['reverse_paths'] ?? []; + $modules[$module_name]->requires = $data['paths'] ?? []; $modules[$module_name]->sort = $data['weight']; } return $modules; diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php index 4d2290c35e..35ef9f28eb 100644 --- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php +++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php @@ -583,9 +583,9 @@ protected function removeCacheBins($module) { $definitions = Yaml::decode(file_get_contents($service_yaml_file)); $cache_bin_services = array_filter( - isset($definitions['services']) ? $definitions['services'] : [], + $definitions['services'] ?? [], function ($definition) { - $tags = isset($definition['tags']) ? $definition['tags'] : []; + $tags = $definition['tags'] ?? []; foreach ($tags as $tag) { if (isset($tag['name']) && ($tag['name'] == 'cache.bin')) { return TRUE; diff --git a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php index 7cd56e2578..4a0b53d2f0 100644 --- a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php +++ b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php @@ -192,7 +192,7 @@ public function setSetting($setting_name, $value) { * {@inheritdoc} */ public function getProvider() { - return isset($this->definition['provider']) ? $this->definition['provider'] : NULL; + return $this->definition['provider'] ?? NULL; } /** @@ -257,7 +257,7 @@ public function setRevisionable($revisionable) { */ public function getCardinality() { // @todo: Allow to control this. - return isset($this->definition['cardinality']) ? $this->definition['cardinality'] : 1; + return $this->definition['cardinality'] ?? 1; } /** @@ -408,28 +408,28 @@ public function setDisplayConfigurable($display_context, $configurable) { * {@inheritdoc} */ public function getDisplayOptions($display_context) { - return isset($this->definition['display'][$display_context]['options']) ? $this->definition['display'][$display_context]['options'] : NULL; + return $this->definition['display'][$display_context]['options'] ?? NULL; } /** * {@inheritdoc} */ public function isDisplayConfigurable($display_context) { - return isset($this->definition['display'][$display_context]['configurable']) ? $this->definition['display'][$display_context]['configurable'] : FALSE; + return $this->definition['display'][$display_context]['configurable'] ?? FALSE; } /** * {@inheritdoc} */ public function getDefaultValueLiteral() { - return isset($this->definition['default_value']) ? $this->definition['default_value'] : []; + return $this->definition['default_value'] ?? []; } /** * {@inheritdoc} */ public function getDefaultValueCallback() { - return isset($this->definition['default_value_callback']) ? $this->definition['default_value_callback'] : NULL; + return $this->definition['default_value_callback'] ?? NULL; } /** @@ -524,7 +524,7 @@ public function setInitialValue($value) { * The field name. */ public function getInitialValueFromField() { - return isset($this->definition['initial_value_from_field']) ? $this->definition['initial_value_from_field'] : NULL; + return $this->definition['initial_value_from_field'] ?? NULL; } /** @@ -620,7 +620,7 @@ public function __sleep() { * {@inheritdoc} */ public function getTargetEntityTypeId() { - return isset($this->definition['entity_type']) ? $this->definition['entity_type'] : NULL; + return $this->definition['entity_type'] ?? NULL; } /** @@ -640,7 +640,7 @@ public function setTargetEntityTypeId($entity_type_id) { * {@inheritdoc} */ public function getTargetBundle() { - return isset($this->definition['bundle']) ? $this->definition['bundle'] : NULL; + return $this->definition['bundle'] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php index 4f3bdf99b7..3f4fc4ea5d 100644 --- a/core/lib/Drupal/Core/Field/FieldConfigBase.php +++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php @@ -505,7 +505,7 @@ public function getConstraints() { */ public function getConstraint($constraint_name) { $constraints = $this->getConstraints(); - return isset($constraints[$constraint_name]) ? $constraints[$constraint_name] : NULL; + return $constraints[$constraint_name] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Field/FieldDefinition.php b/core/lib/Drupal/Core/Field/FieldDefinition.php index 80bb222d9d..9fbc65937a 100644 --- a/core/lib/Drupal/Core/Field/FieldDefinition.php +++ b/core/lib/Drupal/Core/Field/FieldDefinition.php @@ -124,7 +124,7 @@ public function setDisplayConfigurable($display_context, $configurable) { * {@inheritdoc} */ public function isDisplayConfigurable($display_context) { - return isset($this->definition['display'][$display_context]['configurable']) ? $this->definition['display'][$display_context]['configurable'] : FALSE; + return $this->definition['display'][$display_context]['configurable'] ?? FALSE; } /** @@ -157,14 +157,14 @@ public function setDisplayOptions($display_context, array $options) { * {@inheritdoc} */ public function getDisplayOptions($display_context) { - return isset($this->definition['display'][$display_context]['options']) ? $this->definition['display'][$display_context]['options'] : NULL; + return $this->definition['display'][$display_context]['options'] ?? NULL; } /** * {@inheritdoc} */ public function getDefaultValueLiteral() { - return isset($this->definition['default_value']) ? $this->definition['default_value'] : []; + return $this->definition['default_value'] ?? []; } /** @@ -187,7 +187,7 @@ public function setDefaultValueCallback($callback) { * {@inheritdoc} */ public function getDefaultValueCallback() { - return isset($this->definition['default_value_callback']) ? $this->definition['default_value_callback'] : NULL; + return $this->definition['default_value_callback'] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php index efdc92eddf..d337350983 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php @@ -146,7 +146,7 @@ public function settingsSummary() { $view_modes = $this->entityDisplayRepository->getViewModeOptions($this->getFieldSetting('target_type')); $view_mode = $this->getSetting('view_mode'); - $summary[] = t('Rendered as @mode', ['@mode' => isset($view_modes[$view_mode]) ? $view_modes[$view_mode] : $view_mode]); + $summary[] = t('Rendered as @mode', ['@mode' => $view_modes[$view_mode] ?? $view_mode]); return $summary; } diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php index d9f5b581f3..2ce3912d8b 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EntityReferenceAutocompleteWidget.php @@ -112,7 +112,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // the 'ValidReference' constraint. '#validate_reference' => FALSE, '#maxlength' => 1024, - '#default_value' => isset($referenced_entities[$delta]) ? $referenced_entities[$delta] : NULL, + '#default_value' => $referenced_entities[$delta] ?? NULL, '#size' => $this->getSetting('size'), '#placeholder' => $this->getSetting('placeholder'), ]; @@ -196,7 +196,7 @@ protected function getAutocreateBundle() { */ protected function getSelectionHandlerSetting($setting_name) { $settings = $this->getFieldSetting('handler_settings'); - return isset($settings[$setting_name]) ? $settings[$setting_name] : NULL; + return $settings[$setting_name] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Field/PluginSettingsBase.php b/core/lib/Drupal/Core/Field/PluginSettingsBase.php index 4e38e755f1..528d7d507c 100644 --- a/core/lib/Drupal/Core/Field/PluginSettingsBase.php +++ b/core/lib/Drupal/Core/Field/PluginSettingsBase.php @@ -61,7 +61,7 @@ public function getSetting($key) { if (!$this->defaultSettingsMerged && !array_key_exists($key, $this->settings)) { $this->mergeDefaults(); } - return isset($this->settings[$key]) ? $this->settings[$key] : NULL; + return $this->settings[$key] ?? NULL; } /** @@ -94,7 +94,7 @@ public function setSetting($key, $value) { */ public function getThirdPartySettings($module = NULL) { if ($module) { - return isset($this->thirdPartySettings[$module]) ? $this->thirdPartySettings[$module] : []; + return $this->thirdPartySettings[$module] ?? []; } return $this->thirdPartySettings; } @@ -103,7 +103,7 @@ public function getThirdPartySettings($module = NULL) { * {@inheritdoc} */ public function getThirdPartySetting($module, $key, $default = NULL) { - return isset($this->thirdPartySettings[$module][$key]) ? $this->thirdPartySettings[$module][$key] : $default; + return $this->thirdPartySettings[$module][$key] ?? $default; } /** diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php index 40ae20f569..d5097aa043 100644 --- a/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -84,7 +84,7 @@ public function form(FieldItemListInterface $items, array &$form, FormStateInter // displaying an individual element, just get a single form element and make // it the $delta value. if ($this->handlesMultipleValues() || isset($get_delta)) { - $delta = isset($get_delta) ? $get_delta : 0; + $delta = $get_delta ?? 0; $element = [ '#title' => $this->fieldDefinition->getLabel(), '#description' => $this->getFilteredDescription(), @@ -332,8 +332,8 @@ public static function addMoreAjax(array $form, FormStateInterface $form_state) // Add a DIV around the delta receiving the Ajax effect. $delta = $element['#max_delta']; - $element[$delta]['#prefix'] = '
' . (isset($element[$delta]['#prefix']) ? $element[$delta]['#prefix'] : ''); - $element[$delta]['#suffix'] = (isset($element[$delta]['#suffix']) ? $element[$delta]['#suffix'] : '') . '
'; + $element[$delta]['#prefix'] = '
' . ($element[$delta]['#prefix'] ?? ''); + $element[$delta]['#suffix'] = ($element[$delta]['#suffix'] ?? '') . '
'; return $element; } @@ -406,7 +406,7 @@ public function extractFormValues(FieldItemListInterface $items, array $form, Fo // Put delta mapping in $form_state, so that flagErrors() can use it. $field_state = static::getWidgetState($form['#parents'], $field_name, $form_state); foreach ($items as $delta => $item) { - $field_state['original_deltas'][$delta] = isset($item->_original_delta) ? $item->_original_delta : $delta; + $field_state['original_deltas'][$delta] = $item->_original_delta ?? $delta; unset($item->_original_delta, $item->_weight); } static::setWidgetState($form['#parents'], $field_name, $form_state, $field_state); diff --git a/core/lib/Drupal/Core/Field/WidgetPluginManager.php b/core/lib/Drupal/Core/Field/WidgetPluginManager.php index 80e9718769..e5afb21e5f 100644 --- a/core/lib/Drupal/Core/Field/WidgetPluginManager.php +++ b/core/lib/Drupal/Core/Field/WidgetPluginManager.php @@ -145,7 +145,7 @@ public function prepareConfiguration($field_type, array $configuration) { // If no widget is specified, use the default widget. if (!isset($configuration['type'])) { $field_type = $this->fieldTypeManager->getDefinition($field_type); - $configuration['type'] = isset($field_type['default_widget']) ? $field_type['default_widget'] : NULL; + $configuration['type'] = $field_type['default_widget'] ?? NULL; } // Filter out unknown settings, and fill in defaults for missing settings. $default_settings = $this->getDefaultSettings($configuration['type']); diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index 8acb6321b9..6388b857c7 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -1280,7 +1280,7 @@ protected function handleInputElement($form_id, &$element, FormStateInterface &$ // value. Avoid image buttons (which come with garbage value), so we // only get value for the button actually clicked. if (!isset($element['#value']) && empty($element['#has_garbage_value'])) { - $element['#value'] = isset($element['#default_value']) ? $element['#default_value'] : ''; + $element['#value'] = $element['#default_value'] ?? ''; } } } diff --git a/core/lib/Drupal/Core/Http/LinkRelationType.php b/core/lib/Drupal/Core/Http/LinkRelationType.php index b0366e5ef6..8c2af13bb0 100644 --- a/core/lib/Drupal/Core/Http/LinkRelationType.php +++ b/core/lib/Drupal/Core/Http/LinkRelationType.php @@ -41,21 +41,21 @@ public function getExtensionUri() { * {@inheritdoc} */ public function getDescription() { - return isset($this->pluginDefinition['description']) ? $this->pluginDefinition['description'] : ''; + return $this->pluginDefinition['description'] ?? ''; } /** * {@inheritdoc} */ public function getReference() { - return isset($this->pluginDefinition['reference']) ? $this->pluginDefinition['reference'] : ''; + return $this->pluginDefinition['reference'] ?? ''; } /** * {@inheritdoc} */ public function getNotes() { - return isset($this->pluginDefinition['notes']) ? $this->pluginDefinition['notes'] : ''; + return $this->pluginDefinition['notes'] ?? ''; } } diff --git a/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php b/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php index c37150c779..82b7d3c9e2 100644 --- a/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php +++ b/core/lib/Drupal/Core/Installer/Form/SelectProfileForm.php @@ -48,7 +48,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $install_ // Determine the name of the profile; default to file name if defined name // is unspecified. - $name = isset($details['name']) ? $details['name'] : $profile->getName(); + $name = $details['name'] ?? $profile->getName(); $names[$profile->getName()] = $name; } diff --git a/core/lib/Drupal/Core/KeyValueStore/StorageBase.php b/core/lib/Drupal/Core/KeyValueStore/StorageBase.php index ad5e3b4a56..ead499c70c 100644 --- a/core/lib/Drupal/Core/KeyValueStore/StorageBase.php +++ b/core/lib/Drupal/Core/KeyValueStore/StorageBase.php @@ -33,7 +33,7 @@ public function getCollectionName() { */ public function get($key, $default = NULL) { $values = $this->getMultiple([$key]); - return isset($values[$key]) ? $values[$key] : $default; + return $values[$key] ?? $default; } /** diff --git a/core/lib/Drupal/Core/Language/LanguageManager.php b/core/lib/Drupal/Core/Language/LanguageManager.php index eb5295cdbe..dd1687d56b 100644 --- a/core/lib/Drupal/Core/Language/LanguageManager.php +++ b/core/lib/Drupal/Core/Language/LanguageManager.php @@ -149,7 +149,7 @@ public function getNativeLanguages() { */ public function getLanguage($langcode) { $languages = $this->getLanguages(LanguageInterface::STATE_ALL); - return isset($languages[$langcode]) ? $languages[$langcode] : NULL; + return $languages[$langcode] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Layout/LayoutDefinition.php b/core/lib/Drupal/Core/Layout/LayoutDefinition.php index 033175188a..d80a8720ca 100644 --- a/core/lib/Drupal/Core/Layout/LayoutDefinition.php +++ b/core/lib/Drupal/Core/Layout/LayoutDefinition.php @@ -158,10 +158,10 @@ public function __construct(array $definition) { */ public function get($property) { if (property_exists($this, $property)) { - $value = isset($this->{$property}) ? $this->{$property} : NULL; + $value = $this->{$property} ?? NULL; } else { - $value = isset($this->additional[$property]) ? $this->additional[$property] : NULL; + $value = $this->additional[$property] ?? NULL; } return $value; } diff --git a/core/lib/Drupal/Core/Layout/LayoutPluginManager.php b/core/lib/Drupal/Core/Layout/LayoutPluginManager.php index 2cd0c68957..12d7403509 100644 --- a/core/lib/Drupal/Core/Layout/LayoutPluginManager.php +++ b/core/lib/Drupal/Core/Layout/LayoutPluginManager.php @@ -198,7 +198,7 @@ public function getCategories() { */ public function getSortedDefinitions(array $definitions = NULL, $label_key = 'label') { // Sort the plugins first by category, then by label. - $definitions = isset($definitions) ? $definitions : $this->getDefinitions(); + $definitions = $definitions ?? $this->getDefinitions(); // Suppress errors because PHPUnit will indirectly modify the contents, // triggering https://bugs.php.net/bug.php?id=50688. @uasort($definitions, function (LayoutDefinition $a, LayoutDefinition $b) { @@ -216,7 +216,7 @@ public function getSortedDefinitions(array $definitions = NULL, $label_key = 'la * @return \Drupal\Core\Layout\LayoutDefinition[][] */ public function getGroupedDefinitions(array $definitions = NULL, $label_key = 'label') { - $definitions = $this->getSortedDefinitions(isset($definitions) ? $definitions : $this->getDefinitions(), $label_key); + $definitions = $this->getSortedDefinitions($definitions ?? $this->getDefinitions(), $label_key); $grouped_definitions = []; foreach ($definitions as $id => $definition) { $grouped_definitions[(string) $definition->getCategory()][$id] = $definition; diff --git a/core/lib/Drupal/Core/Menu/LocalActionDefault.php b/core/lib/Drupal/Core/Menu/LocalActionDefault.php index 5e161ec1de..f3c0962306 100644 --- a/core/lib/Drupal/Core/Menu/LocalActionDefault.php +++ b/core/lib/Drupal/Core/Menu/LocalActionDefault.php @@ -83,7 +83,7 @@ public function getWeight() { * {@inheritdoc} */ public function getRouteParameters(RouteMatchInterface $route_match) { - $route_parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : []; + $route_parameters = $this->pluginDefinition['route_parameters'] ?? []; $route = $this->routeProvider->getRouteByName($this->getRouteName()); $variables = $route->compile()->getVariables(); diff --git a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php index 49a7a2cc68..edc09131db 100644 --- a/core/lib/Drupal/Core/Menu/LocalTaskDefault.php +++ b/core/lib/Drupal/Core/Menu/LocalTaskDefault.php @@ -41,7 +41,7 @@ public function getRouteName() { * {@inheritdoc} */ public function getRouteParameters(RouteMatchInterface $route_match) { - $route_parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : []; + $route_parameters = $this->pluginDefinition['route_parameters'] ?? []; $route = $this->routeProvider()->getRouteByName($this->getRouteName()); $variables = $route->compile()->getVariables(); diff --git a/core/lib/Drupal/Core/Menu/MenuLinkBase.php b/core/lib/Drupal/Core/Menu/MenuLinkBase.php index c61b5db0aa..22d5bbaf02 100644 --- a/core/lib/Drupal/Core/Menu/MenuLinkBase.php +++ b/core/lib/Drupal/Core/Menu/MenuLinkBase.php @@ -106,14 +106,14 @@ public function getMetaData() { * {@inheritdoc} */ public function getRouteName() { - return isset($this->pluginDefinition['route_name']) ? $this->pluginDefinition['route_name'] : ''; + return $this->pluginDefinition['route_name'] ?? ''; } /** * {@inheritdoc} */ public function getRouteParameters() { - return isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : []; + return $this->pluginDefinition['route_parameters'] ?? []; } /** diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index 34059a3350..59bbd2f728 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -729,7 +729,7 @@ public function load($id) { return $this->definitions[$id]; } $loaded = $this->loadMultiple([$id]); - return isset($loaded[$id]) ? $loaded[$id] : FALSE; + return $loaded[$id] ?? FALSE; } /** @@ -743,7 +743,7 @@ public function load($id) { */ protected function loadFull($id) { $loaded = $this->loadFullMultiple([$id]); - return isset($loaded[$id]) ? $loaded[$id] : []; + return $loaded[$id] ?? []; } /** diff --git a/core/lib/Drupal/Core/Pager/PagerManager.php b/core/lib/Drupal/Core/Pager/PagerManager.php index 6a9cb7c9b8..1fad49ce79 100644 --- a/core/lib/Drupal/Core/Pager/PagerManager.php +++ b/core/lib/Drupal/Core/Pager/PagerManager.php @@ -63,7 +63,7 @@ public function createPager($total, $limit, $element = 0) { * {@inheritdoc} */ public function getPager($element = 0) { - return isset($this->pagers[$element]) ? $this->pagers[$element] : NULL; + return $this->pagers[$element] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php b/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php index 87e78d868c..85ca11bb63 100644 --- a/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php +++ b/core/lib/Drupal/Core/PhpStorage/PhpStorageFactory.php @@ -38,7 +38,7 @@ public static function get($name) { $configuration = $overrides['default']; } // Make sure all the necessary configuration values are set. - $class = isset($configuration['class']) ? $configuration['class'] : 'Drupal\Component\PhpStorage\MTimeProtectedFileStorage'; + $class = $configuration['class'] ?? 'Drupal\Component\PhpStorage\MTimeProtectedFileStorage'; if (!isset($configuration['secret'])) { $configuration['secret'] = Settings::getHashSalt(); } diff --git a/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php b/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php index 52d153c3ed..7f8ae617a4 100644 --- a/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php +++ b/core/lib/Drupal/Core/Plugin/CategorizingPluginManagerTrait.php @@ -89,7 +89,7 @@ public function getCategories() { public function getSortedDefinitions(array $definitions = NULL, $label_key = 'label') { // Sort the plugins first by category, then by label. /** @var \Drupal\Core\Plugin\CategorizingPluginManagerTrait|\Drupal\Component\Plugin\PluginManagerInterface $this */ - $definitions = isset($definitions) ? $definitions : $this->getDefinitions(); + $definitions = $definitions ?? $this->getDefinitions(); uasort($definitions, function ($a, $b) use ($label_key) { if ($a['category'] != $b['category']) { return strnatcasecmp($a['category'], $b['category']); @@ -104,7 +104,7 @@ public function getSortedDefinitions(array $definitions = NULL, $label_key = 'la */ public function getGroupedDefinitions(array $definitions = NULL, $label_key = 'label') { /** @var \Drupal\Core\Plugin\CategorizingPluginManagerTrait|\Drupal\Component\Plugin\PluginManagerInterface $this */ - $definitions = $this->getSortedDefinitions(isset($definitions) ? $definitions : $this->getDefinitions(), $label_key); + $definitions = $this->getSortedDefinitions($definitions ?? $this->getDefinitions(), $label_key); $grouped_definitions = []; foreach ($definitions as $id => $definition) { $grouped_definitions[(string) $definition['category']][$id] = $definition; diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php b/core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php index 05887d3da1..895650c89c 100644 --- a/core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php +++ b/core/lib/Drupal/Core/Plugin/Context/ContextDefinition.php @@ -218,7 +218,7 @@ public function getConstraints() { */ public function getConstraint($constraint_name) { $constraints = $this->getConstraints(); - return isset($constraints[$constraint_name]) ? $constraints[$constraint_name] : NULL; + return $constraints[$constraint_name] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php index d07556bc18..248cf7adbf 100644 --- a/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php +++ b/core/lib/Drupal/Core/Plugin/Context/ContextHandler.php @@ -89,7 +89,7 @@ public function applyContextMapping(ContextAwarePluginInterface $plugin, $contex foreach ($plugin->getContextDefinitions() as $plugin_context_id => $plugin_context_definition) { // If this context was given a specific name, use that. - $context_id = isset($mappings[$plugin_context_id]) ? $mappings[$plugin_context_id] : $plugin_context_id; + $context_id = $mappings[$plugin_context_id] ?? $plugin_context_id; if (!empty($contexts[$context_id])) { // This assignment has been used, remove it. unset($mappings[$plugin_context_id]); diff --git a/core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php b/core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php index a6060b710f..444f8654d7 100644 --- a/core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php +++ b/core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php @@ -129,7 +129,7 @@ public function setContextValue($name, $value) { */ public function getContextMapping() { $configuration = $this instanceof ConfigurableInterface ? $this->getConfiguration() : $this->configuration; - return isset($configuration['context_mapping']) ? $configuration['context_mapping'] : []; + return $configuration['context_mapping'] ?? []; } /** diff --git a/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php b/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php index 071a5648b0..c3fa2ee5bb 100644 --- a/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php +++ b/core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php @@ -74,7 +74,7 @@ public function __construct(PluginManagerInterface $manager, array $configuratio * {@inheritdoc} */ protected function initializePlugin($instance_id) { - $configuration = isset($this->configurations[$instance_id]) ? $this->configurations[$instance_id] : []; + $configuration = $this->configurations[$instance_id] ?? []; if (!isset($configuration[$this->pluginKey])) { throw new PluginNotFoundException($instance_id); } diff --git a/core/lib/Drupal/Core/Render/Element/Checkbox.php b/core/lib/Drupal/Core/Render/Element/Checkbox.php index c1e657b167..f2e1501253 100644 --- a/core/lib/Drupal/Core/Render/Element/Checkbox.php +++ b/core/lib/Drupal/Core/Render/Element/Checkbox.php @@ -57,7 +57,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form // NULL to 0, because FormBuilder::handleInputElement() would otherwise // replace NULL with empty string, but an empty string is a potentially // valid value for a checked checkbox. - return isset($element['#default_value']) ? $element['#default_value'] : 0; + return $element['#default_value'] ?? 0; } else { // Checked checkboxes are submitted with a value (possibly '0' or ''): diff --git a/core/lib/Drupal/Core/Render/Element/Checkboxes.php b/core/lib/Drupal/Core/Render/Element/Checkboxes.php index 0d25f75c69..cdf0554873 100644 --- a/core/lib/Drupal/Core/Render/Element/Checkboxes.php +++ b/core/lib/Drupal/Core/Render/Element/Checkboxes.php @@ -80,7 +80,7 @@ public static function processCheckboxes(&$element, FormStateInterface $form_sta '#return_value' => $key, '#default_value' => isset($value[$key]) ? $key : NULL, '#attributes' => $element['#attributes'], - '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL, + '#ajax' => $element['#ajax'] ?? NULL, // Errors should only be shown on the parent checkboxes element. '#error_no_message' => TRUE, '#weight' => $weight, diff --git a/core/lib/Drupal/Core/Render/Element/FormElement.php b/core/lib/Drupal/Core/Render/Element/FormElement.php index 62fe3c1112..f911d72e85 100644 --- a/core/lib/Drupal/Core/Render/Element/FormElement.php +++ b/core/lib/Drupal/Core/Render/Element/FormElement.php @@ -184,7 +184,7 @@ public static function processAutocomplete(&$element, FormStateInterface $form_s $access = FALSE; if (!empty($element['#autocomplete_route_name'])) { - $parameters = isset($element['#autocomplete_route_parameters']) ? $element['#autocomplete_route_parameters'] : []; + $parameters = $element['#autocomplete_route_parameters'] ?? []; $url = Url::fromRoute($element['#autocomplete_route_name'], $parameters)->toString(TRUE); /** @var \Drupal\Core\Access\AccessManagerInterface $access_manager */ $access_manager = \Drupal::service('access_manager'); diff --git a/core/lib/Drupal/Core/Render/Element/HtmlTag.php b/core/lib/Drupal/Core/Render/Element/HtmlTag.php index 94a7ef18ce..8034abe98e 100644 --- a/core/lib/Drupal/Core/Render/Element/HtmlTag.php +++ b/core/lib/Drupal/Core/Render/Element/HtmlTag.php @@ -139,7 +139,7 @@ public static function preRenderHtmlTag($element) { * added to '#prefix' and '#suffix'. */ public static function preRenderConditionalComments($element) { - $browsers = isset($element['#browsers']) ? $element['#browsers'] : []; + $browsers = $element['#browsers'] ?? []; $browsers += [ 'IE' => TRUE, '!IE' => TRUE, @@ -174,11 +174,11 @@ public static function preRenderConditionalComments($element) { // Ensure what we are dealing with is safe. // This would be done later anyway in drupal_render(). - $prefix = isset($element['#prefix']) ? $element['#prefix'] : ''; + $prefix = $element['#prefix'] ?? ''; if ($prefix && !($prefix instanceof MarkupInterface)) { $prefix = Xss::filterAdmin($prefix); } - $suffix = isset($element['#suffix']) ? $element['#suffix'] : ''; + $suffix = $element['#suffix'] ?? ''; if ($suffix && !($suffix instanceof MarkupInterface)) { $suffix = Xss::filterAdmin($suffix); } diff --git a/core/lib/Drupal/Core/Render/Element/Number.php b/core/lib/Drupal/Core/Render/Element/Number.php index 36abb32b18..8f7efca552 100644 --- a/core/lib/Drupal/Core/Render/Element/Number.php +++ b/core/lib/Drupal/Core/Render/Element/Number.php @@ -86,7 +86,7 @@ public static function validateNumber(&$element, FormStateInterface $form_state, if (isset($element['#step']) && strtolower($element['#step']) != 'any') { // Check that the input is an allowed multiple of #step (offset by #min if // #min is set). - $offset = isset($element['#min']) ? $element['#min'] : 0.0; + $offset = $element['#min'] ?? 0.0; if (!NumberUtility::validStep($value, $element['#step'], $offset)) { $form_state->setError($element, t('%name is not a valid number.', ['%name' => $name])); diff --git a/core/lib/Drupal/Core/Render/Element/Radios.php b/core/lib/Drupal/Core/Render/Element/Radios.php index a64312ff63..38a043e5f9 100644 --- a/core/lib/Drupal/Core/Render/Element/Radios.php +++ b/core/lib/Drupal/Core/Render/Element/Radios.php @@ -73,11 +73,11 @@ public static function processRadios(&$element, FormStateInterface $form_state, '#return_value' => $key, // Use default or FALSE. A value of FALSE means that the radio button is // not 'checked'. - '#default_value' => isset($element['#default_value']) ? $element['#default_value'] : FALSE, + '#default_value' => $element['#default_value'] ?? FALSE, '#attributes' => $element['#attributes'], '#parents' => $element['#parents'], '#id' => HtmlUtility::getUniqueId('edit-' . implode('-', $parents_for_id)), - '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL, + '#ajax' => $element['#ajax'] ?? NULL, // Errors should only be shown on the parent radios element. '#error_no_message' => TRUE, '#weight' => $weight, @@ -108,7 +108,7 @@ public static function valueCallback(&$element, $input, FormStateInterface $form // FormBuilder::handleInputElement() converting the NULL to an empty // string, so that code can distinguish between nothing selected and the // selection of a radio button whose value is an empty string. - $value = isset($element['#default_value']) ? $element['#default_value'] : NULL; + $value = $element['#default_value'] ?? NULL; if (!isset($value)) { $element['#has_garbage_value'] = TRUE; } diff --git a/core/lib/Drupal/Core/Render/Element/Tableselect.php b/core/lib/Drupal/Core/Render/Element/Tableselect.php index a8a7a36d91..908e66044a 100644 --- a/core/lib/Drupal/Core/Render/Element/Tableselect.php +++ b/core/lib/Drupal/Core/Render/Element/Tableselect.php @@ -254,7 +254,7 @@ public static function processTableselect(&$element, FormStateInterface $form_st '#return_value' => $key, '#default_value' => isset($value[$key]) ? $key : NULL, '#attributes' => $element['#attributes'], - '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL, + '#ajax' => $element['#ajax'] ?? NULL, ]; } else { @@ -269,7 +269,7 @@ public static function processTableselect(&$element, FormStateInterface $form_st '#attributes' => $element['#attributes'], '#parents' => $element['#parents'], '#id' => HtmlUtility::getUniqueId('edit-' . implode('-', $parents_for_id)), - '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL, + '#ajax' => $element['#ajax'] ?? NULL, ]; } if (isset($element['#options'][$key]['#weight'])) { diff --git a/core/lib/Drupal/Core/Render/ElementInfoManager.php b/core/lib/Drupal/Core/Render/ElementInfoManager.php index 1de1f4c61c..ed92765263 100644 --- a/core/lib/Drupal/Core/Render/ElementInfoManager.php +++ b/core/lib/Drupal/Core/Render/ElementInfoManager.php @@ -76,7 +76,7 @@ public function getInfo($type) { if (!isset($this->elementInfo[$theme_name])) { $this->elementInfo[$theme_name] = $this->buildInfo($theme_name); } - $info = isset($this->elementInfo[$theme_name][$type]) ? $this->elementInfo[$theme_name][$type] : []; + $info = $this->elementInfo[$theme_name][$type] ?? []; $info['#defaults_loaded'] = TRUE; return $info; } @@ -87,7 +87,7 @@ public function getInfo($type) { public function getInfoProperty($type, $property_name, $default = NULL) { $info = $this->getInfo($type); - return isset($info[$property_name]) ? $info[$property_name] : $default; + return $info[$property_name] ?? $default; } /** diff --git a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php index 36042c3c7c..9d0ca3709e 100644 --- a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php +++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php @@ -432,7 +432,7 @@ protected function processHtmlHeadLink(array $html_head_link) { foreach ($html_head_link as $item) { $attributes = $item[0]; - $should_add_header = isset($item[1]) ? $item[1] : FALSE; + $should_add_header = $item[1] ?? FALSE; $element = [ '#tag' => 'link', diff --git a/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php b/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php index c445d8507c..e9dd1ed175 100644 --- a/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php @@ -58,7 +58,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch // Determine the title: use the title provided by the main content if any, // otherwise get it from the routing information. - $title = isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject()); + $title = $main_content['#title'] ?? $this->titleResolver->getTitle($request, $route_match->getRouteObject()); // Determine the dialog options and the target for the OpenDialogCommand. $options = $request->request->get('dialogOptions', []); diff --git a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php index 46992d8f68..fe1890f57d 100644 --- a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php @@ -205,7 +205,7 @@ protected function prepare(array $main_content, Request $request, RouteMatchInte // Determine the title: use the title provided by the main content if any, // otherwise get it from the routing information. $get_title = function (array $main_content) use ($request, $route_match) { - return isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject()); + return $main_content['#title'] ?? $this->titleResolver->getTitle($request, $route_match->getRouteObject()); }; // If the _controller result already is #type => page, @@ -241,7 +241,7 @@ protected function prepare(array $main_content, Request $request, RouteMatchInte return $this->renderer->render($main_content, FALSE); }); $main_content = $this->renderCache->getCacheableRenderArray($main_content) + [ - '#title' => isset($main_content['#title']) ? $main_content['#title'] : NULL, + '#title' => $main_content['#title'] ?? NULL, ]; } diff --git a/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php b/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php index d250d57329..d903acf88d 100644 --- a/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php @@ -27,7 +27,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch $response->setAttachments($main_content['#attached']); // If the main content doesn't provide a title, use the title resolver. - $title = isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject()); + $title = $main_content['#title'] ?? $this->titleResolver->getTitle($request, $route_match->getRouteObject()); // Determine the title: use the title provided by the main content if any, // otherwise get it from the routing information. diff --git a/core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php b/core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php index 086e84f929..6c598ccb0a 100644 --- a/core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php @@ -60,7 +60,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch $response->setAttachments($main_content['#attached']); // If the main content doesn't provide a title, use the title resolver. - $title = isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject()); + $title = $main_content['#title'] ?? $this->titleResolver->getTitle($request, $route_match->getRouteObject()); // Determine the title: use the title provided by the main content if any, // otherwise get it from the routing information. diff --git a/core/lib/Drupal/Core/Render/RenderCache.php b/core/lib/Drupal/Core/Render/RenderCache.php index 385d317f4a..674c00e28f 100644 --- a/core/lib/Drupal/Core/Render/RenderCache.php +++ b/core/lib/Drupal/Core/Render/RenderCache.php @@ -66,7 +66,7 @@ public function get(array $elements) { if (!$this->requestStack->getCurrentRequest()->isMethodCacheable() || !$cid = $this->createCacheID($elements)) { return FALSE; } - $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'render'; + $bin = $elements['#cache']['bin'] ?? 'render'; if (!empty($cid) && ($cache_bin = $this->cacheFactory->get($bin)) && $cache = $cache_bin->get($cid)) { $cached_element = $cache->data; @@ -96,7 +96,7 @@ public function set(array &$elements, array $pre_bubbling_elements) { $data = $this->getCacheableRenderArray($elements); - $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'render'; + $bin = $elements['#cache']['bin'] ?? 'render'; $cache = $this->cacheFactory->get($bin); // Calculate the pre-bubbling CID. diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php index 25b294c665..b99b2ccfc4 100644 --- a/core/lib/Drupal/Core/Render/Renderer.php +++ b/core/lib/Drupal/Core/Render/Renderer.php @@ -384,9 +384,9 @@ protected function doRender(&$elements, $is_root_call = FALSE) { } // Defaults for bubbleable rendering metadata. - $elements['#cache']['tags'] = isset($elements['#cache']['tags']) ? $elements['#cache']['tags'] : []; - $elements['#cache']['max-age'] = isset($elements['#cache']['max-age']) ? $elements['#cache']['max-age'] : Cache::PERMANENT; - $elements['#attached'] = isset($elements['#attached']) ? $elements['#attached'] : []; + $elements['#cache']['tags'] = $elements['#cache']['tags'] ?? []; + $elements['#cache']['max-age'] = $elements['#cache']['max-age'] ?? Cache::PERMANENT; + $elements['#attached'] = $elements['#attached'] ?? []; // Allow #pre_render to abort rendering. if (!empty($elements['#printed'])) { @@ -595,7 +595,7 @@ public function executeInRenderContext(RenderContext $context, callable $callabl */ protected function getCurrentRenderContext() { $request = $this->requestStack->getCurrentRequest(); - return isset(static::$contextCollection[$request]) ? static::$contextCollection[$request] : NULL; + return static::$contextCollection[$request] ?? NULL; } /** @@ -745,7 +745,7 @@ protected function ensureMarkupIsSafe(array $elements) { } elseif (!($elements['#markup'] instanceof MarkupInterface)) { // The default behavior is to XSS filter using the admin tag list. - $tags = isset($elements['#allowed_tags']) ? $elements['#allowed_tags'] : Xss::getAdminTagList(); + $tags = $elements['#allowed_tags'] ?? Xss::getAdminTagList(); $elements['#markup'] = Markup::create(Xss::filter($elements['#markup'], $tags)); } diff --git a/core/lib/Drupal/Core/Site/Settings.php b/core/lib/Drupal/Core/Site/Settings.php index dac9714d1f..31b2b8f0af 100644 --- a/core/lib/Drupal/Core/Site/Settings.php +++ b/core/lib/Drupal/Core/Site/Settings.php @@ -119,7 +119,7 @@ public static function get($name, $default = NULL) { if (isset(self::$deprecatedSettings[$name])) { @trigger_error(self::$deprecatedSettings[$name]['message'], E_USER_DEPRECATED); } - return isset(self::$instance->storage[$name]) ? self::$instance->storage[$name] : $default; + return self::$instance->storage[$name] ?? $default; } /** diff --git a/core/lib/Drupal/Core/State/State.php b/core/lib/Drupal/Core/State/State.php index f35c954596..a71e5b2752 100644 --- a/core/lib/Drupal/Core/State/State.php +++ b/core/lib/Drupal/Core/State/State.php @@ -38,7 +38,7 @@ public function __construct(KeyValueFactoryInterface $key_value_factory) { */ public function get($key, $default = NULL) { $values = $this->getMultiple([$key]); - return isset($values[$key]) ? $values[$key] : $default; + return $values[$key] ?? $default; } /** diff --git a/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php b/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php index dcff3fc3b2..22225f6d8b 100644 --- a/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php +++ b/core/lib/Drupal/Core/StringTranslation/TranslatableMarkup.php @@ -156,7 +156,7 @@ public function getUntranslatedString() { * The value of this option or empty string of option is not set. */ public function getOption($name) { - return isset($this->options[$name]) ? $this->options[$name] : ''; + return $this->options[$name] ?? ''; } /** diff --git a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php index 231c4b5d9a..ecca21a0f4 100644 --- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php +++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php @@ -540,8 +540,8 @@ protected function installParameters() { 'name' => $this->rootUser->name, 'mail' => $this->rootUser->getEmail(), 'pass' => [ - 'pass1' => isset($this->rootUser->pass_raw) ? $this->rootUser->pass_raw : $this->rootUser->passRaw, - 'pass2' => isset($this->rootUser->pass_raw) ? $this->rootUser->pass_raw : $this->rootUser->passRaw, + 'pass1' => $this->rootUser->pass_raw ?? $this->rootUser->passRaw, + 'pass2' => $this->rootUser->pass_raw ?? $this->rootUser->passRaw, ], ], // form_type_checkboxes_value() requires NULL instead of FALSE values @@ -582,7 +582,7 @@ protected function setupBaseUrl() { $parsed_url = parse_url($base_url); $host = $parsed_url['host'] . (isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''); $path = isset($parsed_url['path']) ? rtrim(rtrim($parsed_url['path']), '/') : ''; - $port = isset($parsed_url['port']) ? $parsed_url['port'] : 80; + $port = $parsed_url['port'] ?? 80; $valid_url_schemes = ['http', 'https']; if (!in_array(strtolower($parsed_url['scheme']), $valid_url_schemes, TRUE)) { diff --git a/core/lib/Drupal/Core/Test/TestSetupTrait.php b/core/lib/Drupal/Core/Test/TestSetupTrait.php index f78455ca55..7a52811183 100644 --- a/core/lib/Drupal/Core/Test/TestSetupTrait.php +++ b/core/lib/Drupal/Core/Test/TestSetupTrait.php @@ -153,7 +153,7 @@ protected function changeDatabasePrefix() { // Ensure no existing database gets in the way. If a default database // exists already it must be removed. Database::removeConnection('default'); - $database = Database::convertDbUrlToConnectionInfo($db_url, isset($this->root) ? $this->root : DRUPAL_ROOT); + $database = Database::convertDbUrlToConnectionInfo($db_url, $this->root ?? DRUPAL_ROOT); Database::addConnectionInfo('default', 'default', $database); } diff --git a/core/lib/Drupal/Core/Theme/Registry.php b/core/lib/Drupal/Core/Theme/Registry.php index 094780a10e..4545d1fb86 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -485,7 +485,7 @@ protected function processExtension(array &$cache, $name, $type, $theme, $path) // system.module to declare theme functions on behalf of core .include // files. if (isset($info['file'])) { - $include_file = isset($info['path']) ? $info['path'] : $path; + $include_file = $info['path'] ?? $path; $include_file .= '/' . $info['file']; include_once $this->root . '/' . $include_file; $result[$hook]['includes'][] = $include_file; diff --git a/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/core/lib/Drupal/Core/Theme/ThemeInitialization.php index 34b95e955c..c242892672 100644 --- a/core/lib/Drupal/Core/Theme/ThemeInitialization.php +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php @@ -254,8 +254,8 @@ public function getActiveTheme(Extension $theme, array $base_themes = []) { } } - $values['engine'] = isset($theme->engine) ? $theme->engine : NULL; - $values['owner'] = isset($theme->owner) ? $theme->owner : NULL; + $values['engine'] = $theme->engine ?? NULL; + $values['owner'] = $theme->owner ?? NULL; $values['extension'] = $theme; $base_active_themes = []; diff --git a/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php b/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php index f6660c4cca..7fe8859d5d 100644 --- a/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php +++ b/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php @@ -80,7 +80,7 @@ public function get($index) { // @see \Drupal\Core\TypedData\Plugin\DataType\ItemList::get(). $this->ensureComputedValue(); - return isset($this->list[$index]) ? $this->list[$index] : NULL; + return $this->list[$index] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/TypedData/DataDefinition.php b/core/lib/Drupal/Core/TypedData/DataDefinition.php index 47010835c8..7ea5d84d48 100644 --- a/core/lib/Drupal/Core/TypedData/DataDefinition.php +++ b/core/lib/Drupal/Core/TypedData/DataDefinition.php @@ -72,7 +72,7 @@ public function setDataType($type) { * {@inheritdoc} */ public function getLabel() { - return isset($this->definition['label']) ? $this->definition['label'] : NULL; + return $this->definition['label'] ?? NULL; } /** @@ -93,7 +93,7 @@ public function setLabel($label) { * {@inheritdoc} */ public function getDescription() { - return isset($this->definition['description']) ? $this->definition['description'] : NULL; + return $this->definition['description'] ?? NULL; } /** @@ -215,7 +215,7 @@ public function setClass($class) { * {@inheritdoc} */ public function getSettings() { - return isset($this->definition['settings']) ? $this->definition['settings'] : []; + return $this->definition['settings'] ?? []; } /** @@ -236,7 +236,7 @@ public function setSettings(array $settings) { * {@inheritdoc} */ public function getSetting($setting_name) { - return isset($this->definition['settings'][$setting_name]) ? $this->definition['settings'][$setting_name] : NULL; + return $this->definition['settings'][$setting_name] ?? NULL; } /** @@ -259,7 +259,7 @@ public function setSetting($setting_name, $value) { * {@inheritdoc} */ public function getConstraints() { - $constraints = isset($this->definition['constraints']) ? $this->definition['constraints'] : []; + $constraints = $this->definition['constraints'] ?? []; $constraints += $this->getTypedDataManager()->getDefaultConstraints($this); return $constraints; } @@ -269,7 +269,7 @@ public function getConstraints() { */ public function getConstraint($constraint_name) { $constraints = $this->getConstraints(); - return isset($constraints[$constraint_name]) ? $constraints[$constraint_name] : NULL; + return $constraints[$constraint_name] ?? NULL; } /** diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php index 733a4e86d2..49afa8a76a 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php @@ -100,7 +100,7 @@ public function get($index) { if (!is_numeric($index)) { throw new \InvalidArgumentException('Unable to get a value with a non-numeric delta in a list.'); } - return isset($this->list[$index]) ? $this->list[$index] : NULL; + return $this->list[$index] ?? NULL; } /** @@ -120,7 +120,7 @@ public function set($index, $value) { $value = $value->getValue(); } // If needed, create the item at the next position. - $item = isset($this->list[$index]) ? $this->list[$index] : $this->appendItem(); + $item = $this->list[$index] ?? $this->appendItem(); $item->setValue($value); return $this; } diff --git a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php index cadebd7d2a..67ada2a180 100644 --- a/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php +++ b/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php @@ -83,7 +83,7 @@ public function setValue($values, $notify = TRUE) { // Update any existing property objects. foreach ($this->properties as $name => $property) { - $value = isset($values[$name]) ? $values[$name] : NULL; + $value = $values[$name] ?? NULL; $property->setValue($value, FALSE); // Remove the value from $this->values to ensure it does not contain any // value for computed properties. diff --git a/core/lib/Drupal/Core/Validation/DrupalTranslator.php b/core/lib/Drupal/Core/Validation/DrupalTranslator.php index 4025feda37..90542fd98d 100644 --- a/core/lib/Drupal/Core/Validation/DrupalTranslator.php +++ b/core/lib/Drupal/Core/Validation/DrupalTranslator.php @@ -105,7 +105,7 @@ protected function getOptions($domain = NULL, $locale = NULL) { // We do not support domains, so we ignore this parameter. // If locale is left NULL, TranslatableMarkup will default to the interface // language. - $locale = isset($locale) ? $locale : $this->locale; + $locale = $locale ?? $this->locale; return ['langcode' => $locale]; } diff --git a/core/modules/big_pipe/src/Render/BigPipe.php b/core/modules/big_pipe/src/Render/BigPipe.php index 3067673e76..e16668ea39 100644 --- a/core/modules/big_pipe/src/Render/BigPipe.php +++ b/core/modules/big_pipe/src/Render/BigPipe.php @@ -282,8 +282,8 @@ public function sendContent(BigPipeResponse $response) { $attachments = $response->getAttachments(); // First, gather the BigPipe placeholders that must be replaced. - $placeholders = isset($attachments['big_pipe_placeholders']) ? $attachments['big_pipe_placeholders'] : []; - $nojs_placeholders = isset($attachments['big_pipe_nojs_placeholders']) ? $attachments['big_pipe_nojs_placeholders'] : []; + $placeholders = $attachments['big_pipe_placeholders'] ?? []; + $nojs_placeholders = $attachments['big_pipe_nojs_placeholders'] ?? []; // BigPipe sends responses using "Transfer-Encoding: chunked". To avoid // sending already-sent assets, it is necessary to track cumulative assets diff --git a/core/modules/block/src/BlockForm.php b/core/modules/block/src/BlockForm.php index f5d476700b..16801c8fea 100644 --- a/core/modules/block/src/BlockForm.php +++ b/core/modules/block/src/BlockForm.php @@ -238,7 +238,7 @@ protected function buildVisibilityInterface(array $form, FormStateInterface $for continue; } /** @var \Drupal\Core\Condition\ConditionInterface $condition */ - $condition = $this->manager->createInstance($condition_id, isset($visibility[$condition_id]) ? $visibility[$condition_id] : []); + $condition = $this->manager->createInstance($condition_id, $visibility[$condition_id] ?? []); $form_state->set(['conditions', $condition_id], $condition); $condition_form = $condition->buildConfigurationForm([], $form_state); $condition_form['#type'] = 'details'; diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index b0cb597630..d6d64f4da1 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -514,7 +514,7 @@ public function bookTreeAllData($bid, $link = NULL, $max_depth = NULL) { // Use $nid as a flag for whether the data being loaded is for the whole // tree. - $nid = isset($link['nid']) ? $link['nid'] : 0; + $nid = $link['nid'] ?? 0; // Generate a cache ID (cid) specific for this $bid, $link, language, and // depth. $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); @@ -721,7 +721,7 @@ protected function doBookTreeBuild($bid, array $parameters = []) { } if (!isset($trees[$tree_cid])) { - $min_depth = (isset($parameters['min_depth']) ? $parameters['min_depth'] : 1); + $min_depth = ($parameters['min_depth'] ?? 1); $result = $this->bookOutlineStorage->getBookMenuTree($bid, $parameters, $min_depth, static::BOOK_MAX_DEPTH); // Build an ordered array of links using the query result object. @@ -730,7 +730,7 @@ protected function doBookTreeBuild($bid, array $parameters = []) { $link = (array) $link; $links[$link['nid']] = $link; } - $active_trail = (isset($parameters['active_trail']) ? $parameters['active_trail'] : []); + $active_trail = ($parameters['active_trail'] ?? []); $data['tree'] = $this->buildBookOutlineData($links, $active_trail, $min_depth); $data['node_links'] = []; $this->bookTreeCollectNodeLinks($data['tree'], $data['node_links']); @@ -797,7 +797,7 @@ protected function flatBookTree(array $tree, array &$flat) { */ public function loadBookLink($nid, $translate = TRUE) { $links = $this->loadBookLinks([$nid], $translate); - return isset($links[$nid]) ? $links[$nid] : FALSE; + return $links[$nid] ?? FALSE; } /** diff --git a/core/modules/ckeditor/ckeditor.admin.inc b/core/modules/ckeditor/ckeditor.admin.inc index f9316c6a58..b344edff9d 100644 --- a/core/modules/ckeditor/ckeditor.admin.inc +++ b/core/modules/ckeditor/ckeditor.admin.inc @@ -77,7 +77,7 @@ function template_preprocess_ckeditor_settings_toolbar(&$variables) { elseif (isset($button['image']) || isset($button['image' . $rtl])) { $value = [ '#theme' => 'image', - '#uri' => isset($button['image' . $rtl]) ? $button['image' . $rtl] : $button['image'], + '#uri' => $button['image' . $rtl] ?? $button['image'], '#title' => $button['label'], '#prefix' => '', '#suffix' => '', diff --git a/core/modules/comment/src/CommentManager.php b/core/modules/comment/src/CommentManager.php index 815a391b18..565df434b8 100644 --- a/core/modules/comment/src/CommentManager.php +++ b/core/modules/comment/src/CommentManager.php @@ -112,7 +112,7 @@ public function getFields($entity_type_id) { } $map = $this->entityFieldManager->getFieldMapByFieldType('comment'); - return isset($map[$entity_type_id]) ? $map[$entity_type_id] : []; + return $map[$entity_type_id] ?? []; } /** diff --git a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index 35ce99b7eb..4e918ed5a8 100644 --- a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -251,7 +251,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { public function settingsSummary() { $view_mode = $this->getSetting('view_mode'); $view_modes = $this->getViewModes(); - $view_mode_label = isset($view_modes[$view_mode]) ? $view_modes[$view_mode] : 'default'; + $view_mode_label = $view_modes[$view_mode] ?? 'default'; $summary = [$this->t('Comment view mode: @mode', ['@mode' => $view_mode_label])]; if ($pager_id = $this->getSetting('pager_id')) { $summary[] = $this->t('Pager ID: @id', ['@id' => $pager_id]); diff --git a/core/modules/config_translation/src/FormElement/ListElement.php b/core/modules/config_translation/src/FormElement/ListElement.php index 1ea452362b..612b0f1bc3 100644 --- a/core/modules/config_translation/src/FormElement/ListElement.php +++ b/core/modules/config_translation/src/FormElement/ListElement.php @@ -85,7 +85,7 @@ public function setConfig(Config $base_config, LanguageConfigOverride $config_tr $element_key = isset($base_key) ? "$base_key.$key" : $key; if ($form_element = ConfigTranslationFormBase::createFormElement($element)) { // Traverse into the next level of the configuration. - $value = isset($config_values[$key]) ? $config_values[$key] : NULL; + $value = $config_values[$key] ?? NULL; $form_element->setConfig($base_config, $config_translation, $value, $element_key); } } diff --git a/core/modules/config_translation/src/FormElement/PluralVariants.php b/core/modules/config_translation/src/FormElement/PluralVariants.php index 42754e2c9b..c659531b13 100644 --- a/core/modules/config_translation/src/FormElement/PluralVariants.php +++ b/core/modules/config_translation/src/FormElement/PluralVariants.php @@ -35,7 +35,7 @@ protected function getSourceElement(LanguageInterface $source_language, $source_ '#title' => $i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form'), '#markup' => new FormattableMarkup('@value', [ '@langcode' => $source_language->getId(), - '@value' => isset($values[$i]) ? $values[$i] : $this->t('(Empty)'), + '@value' => $values[$i] ?? $this->t('(Empty)'), ]), ]; } @@ -62,7 +62,7 @@ protected function getTranslationElement(LanguageInterface $translation_language '#type' => 'textfield', // @todo Should use better labels https://www.drupal.org/node/2499639 '#title' => $i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form'), - '#default_value' => isset($values[$i]) ? $values[$i] : '', + '#default_value' => $values[$i] ?? '', '#attributes' => ['lang' => $translation_language->getId()], ]; } diff --git a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php index fade477e22..9427b803d6 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php @@ -668,7 +668,7 @@ class TestConfigNamesMapper extends ConfigNamesMapper { * The language code of this mapper if it is set; NULL otherwise. */ public function getInternalLangcode() { - return isset($this->langcode) ? $this->langcode : NULL; + return $this->langcode ?? NULL; } /** diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 8a2930278b..afaedd537c 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -191,7 +191,7 @@ function contact_form_user_form_alter(&$form, FormStateInterface $form_state) { $form['contact']['contact'] = [ '#type' => 'checkbox', '#title' => t('Personal contact form'), - '#default_value' => isset($account_data) ? $account_data : \Drupal::config('contact.settings')->get('user_default_enabled'), + '#default_value' => $account_data ?? \Drupal::config('contact.settings')->get('user_default_enabled'), '#description' => t('Allow other users to contact you via a personal contact form which keeps your email address hidden. Note that some privileged users such as site administrators are still able to contact you even if you choose to disable this feature.'), ]; $form['actions']['submit']['#submit'][] = 'contact_user_profile_form_submit'; diff --git a/core/modules/content_moderation/src/Form/ContentModerationConfigureForm.php b/core/modules/content_moderation/src/Form/ContentModerationConfigureForm.php index f43451ec63..99c30c3600 100644 --- a/core/modules/content_moderation/src/Form/ContentModerationConfigureForm.php +++ b/core/modules/content_moderation/src/Form/ContentModerationConfigureForm.php @@ -142,7 +142,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#required' => TRUE, '#options' => array_map([State::class, 'labelCallback'], $this->workflowType->getStates()), '#description' => $this->t('Select the state that new content will be assigned. This state will appear as the default in content forms and the available target states will be based on the transitions available from this state.'), - '#default_value' => isset($workflow_type_configuration['default_moderation_state']) ? $workflow_type_configuration['default_moderation_state'] : 'draft', + '#default_value' => $workflow_type_configuration['default_moderation_state'] ?? 'draft', ]; return $form; } diff --git a/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php b/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php index b585961d2d..d967f717e4 100644 --- a/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php +++ b/core/modules/content_moderation/src/Plugin/WorkflowType/ContentModeration.php @@ -147,7 +147,7 @@ public function getEntityTypes() { * {@inheritdoc} */ public function getBundlesForEntityType($entity_type_id) { - return isset($this->configuration['entity_types'][$entity_type_id]) ? $this->configuration['entity_types'][$entity_type_id] : []; + return $this->configuration['entity_types'][$entity_type_id] ?? []; } /** diff --git a/core/modules/content_translation/src/ContentTranslationPermissions.php b/core/modules/content_translation/src/ContentTranslationPermissions.php index ce1c71e9b8..968cffe364 100644 --- a/core/modules/content_translation/src/ContentTranslationPermissions.php +++ b/core/modules/content_translation/src/ContentTranslationPermissions.php @@ -80,7 +80,7 @@ public function contentPermissions() { case 'bundle': foreach ($this->entityTypeBundleInfo->getBundleInfo($entity_type_id) as $bundle => $bundle_info) { if ($this->contentTranslationManager->isEnabled($entity_type_id, $bundle)) { - $t_args['%bundle_label'] = isset($bundle_info['label']) ? $bundle_info['label'] : $bundle; + $t_args['%bundle_label'] = $bundle_info['label'] ?? $bundle; $permission["translate $bundle $entity_type_id"] = [ 'title' => $this->t('Translate %bundle_label @entity_label', $t_args), ]; diff --git a/core/modules/content_translation/src/FieldTranslationSynchronizer.php b/core/modules/content_translation/src/FieldTranslationSynchronizer.php index 4c4aaaf93b..336909d2a7 100644 --- a/core/modules/content_translation/src/FieldTranslationSynchronizer.php +++ b/core/modules/content_translation/src/FieldTranslationSynchronizer.php @@ -155,7 +155,7 @@ public function synchronizeFields(ContentEntityInterface $entity, $sync_langcode foreach ($groups as $group) { $info = $column_groups[$group]; // A missing 'columns' key indicates we have a single-column group. - $columns = array_merge($columns, isset($info['columns']) ? $info['columns'] : [$group]); + $columns = array_merge($columns, $info['columns'] ?? [$group]); } if (!empty($columns)) { $values = []; @@ -285,7 +285,7 @@ public function synchronizeItems(array &$values, array $unchanged_items, $sync_l // the new values are at least propagated to all the translations. // If the value has only been reordered we just move the old one in // the new position. - $item = isset($original_field_values[$langcode][$old_delta]) ? $original_field_values[$langcode][$old_delta] : $source_items[$new_delta]; + $item = $original_field_values[$langcode][$old_delta] ?? $source_items[$new_delta]; // When saving a default revision starting from a pending revision, // we may have desynchronized field values, so we make sure that // untranslatable properties are synchronized, even if in any other diff --git a/core/modules/content_translation/src/Plugin/migrate/source/d7/EntityTranslationSettings.php b/core/modules/content_translation/src/Plugin/migrate/source/d7/EntityTranslationSettings.php index f01146159f..ba35c90f07 100644 --- a/core/modules/content_translation/src/Plugin/migrate/source/d7/EntityTranslationSettings.php +++ b/core/modules/content_translation/src/Plugin/migrate/source/d7/EntityTranslationSettings.php @@ -80,12 +80,12 @@ protected function initializeIterator() { // settings variable exists for that node type, otherwise use default // values. foreach ($node_types as $node_type) { - $settings = isset($results['entity_translation_settings_node__' . $node_type]) ? $results['entity_translation_settings_node__' . $node_type] : []; + $settings = $results['entity_translation_settings_node__' . $node_type] ?? []; $rows[] = [ 'id' => 'node.' . $node_type, 'target_entity_type_id' => 'node', 'target_bundle' => $node_type, - 'default_langcode' => isset($settings['default_language']) ? $settings['default_language'] : 'und', + 'default_langcode' => $settings['default_language'] ?? 'und', // The Drupal 7 'hide_language_selector' configuration has become // 'language_alterable' in Drupal 8 so we need to negate the value we // receive from the source. The Drupal 7 'hide_language_selector' @@ -104,7 +104,7 @@ protected function initializeIterator() { // if a settings variable exists for that comment type, otherwise use // default values. foreach ($node_types as $node_type) { - $settings = isset($results['entity_translation_settings_comment__comment_node_' . $node_type]) ? $results['entity_translation_settings_comment__comment_node_' . $node_type] : []; + $settings = $results['entity_translation_settings_comment__comment_node_' . $node_type] ?? []; // Forum uses a hardcoded comment type name, so make sure we use it // when we're dealing with forum comment type. $bundle = $node_type == 'forum' ? 'comment_forum' : 'comment_node_' . $node_type; @@ -112,7 +112,7 @@ protected function initializeIterator() { 'id' => 'comment.' . $bundle, 'target_entity_type_id' => 'comment', 'target_bundle' => $bundle, - 'default_langcode' => isset($settings['default_language']) ? $settings['default_language'] : 'xx-et-current', + 'default_langcode' => $settings['default_language'] ?? 'xx-et-current', // The Drupal 7 'hide_language_selector' configuration has become // 'language_alterable' in Drupal 8 so we need to negate the value we // receive from the source. The Drupal 7 'hide_language_selector' @@ -129,12 +129,12 @@ protected function initializeIterator() { // settings variable exists for that vocabulary, otherwise use default // values. foreach ($vocabularies as $vocabulary) { - $settings = isset($results['entity_translation_settings_taxonomy_term__' . $vocabulary]) ? $results['entity_translation_settings_taxonomy_term__' . $vocabulary] : []; + $settings = $results['entity_translation_settings_taxonomy_term__' . $vocabulary] ?? []; $rows[] = [ 'id' => 'taxonomy_term.' . $vocabulary, 'target_entity_type_id' => 'taxonomy_term', 'target_bundle' => $vocabulary, - 'default_langcode' => isset($settings['default_language']) ? $settings['default_language'] : 'xx-et-default', + 'default_langcode' => $settings['default_language'] ?? 'xx-et-default', // The Drupal 7 'hide_language_selector' configuration has become // 'language_alterable' in Drupal 8 so we need to negate the value we // receive from the source. The Drupal 7 'hide_language_selector' @@ -149,12 +149,12 @@ protected function initializeIterator() { if (in_array('user', $entity_types, TRUE)) { // User entity type is not bundleable. Check if a settings variable // exists, otherwise use default values. - $settings = isset($results['entity_translation_settings_user__user']) ? $results['entity_translation_settings_user__user'] : []; + $settings = $results['entity_translation_settings_user__user'] ?? []; $rows[] = [ 'id' => 'user.user', 'target_entity_type_id' => 'user', 'target_bundle' => 'user', - 'default_langcode' => isset($settings['default_language']) ? $settings['default_language'] : 'xx-et-default', + 'default_langcode' => $settings['default_language'] ?? 'xx-et-default', // The Drupal 7 'hide_language_selector' configuration has become // 'language_alterable' in Drupal 8 so we need to negate the value we // receive from the source. The Drupal 7 'hide_language_selector' diff --git a/core/modules/contextual/src/Element/ContextualLinks.php b/core/modules/contextual/src/Element/ContextualLinks.php index 4e43de8e40..ba7c073619 100644 --- a/core/modules/contextual/src/Element/ContextualLinks.php +++ b/core/modules/contextual/src/Element/ContextualLinks.php @@ -78,7 +78,7 @@ public static function preRenderLinks(array $element) { $class = Html::getClass($class); $links[$class] = [ 'title' => $item['title'], - 'url' => Url::fromRoute(isset($item['route_name']) ? $item['route_name'] : '', isset($item['route_parameters']) ? $item['route_parameters'] : [], $item['localized_options']), + 'url' => Url::fromRoute($item['route_name'] ?? '', $item['route_parameters'] ?? [], $item['localized_options']), ]; } $element['#links'] = $links; diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php index 203f15d0bd..5f77efcd6c 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php @@ -36,7 +36,7 @@ public function defaultValuesForm(array &$form, FormStateInterface $form_state) '#type' => 'select', '#title' => t('Default date'), '#description' => t('Set a default value for this date.'), - '#default_value' => isset($default_value[0]['default_date_type']) ? $default_value[0]['default_date_type'] : '', + '#default_value' => $default_value[0]['default_date_type'] ?? '', '#options' => [ static::DEFAULT_VALUE_NOW => t('Current date'), static::DEFAULT_VALUE_CUSTOM => t('Relative date'), diff --git a/core/modules/datetime_range/src/Plugin/Field/FieldType/DateRangeFieldItemList.php b/core/modules/datetime_range/src/Plugin/Field/FieldType/DateRangeFieldItemList.php index f4ca8b8feb..bf2e578fef 100644 --- a/core/modules/datetime_range/src/Plugin/Field/FieldType/DateRangeFieldItemList.php +++ b/core/modules/datetime_range/src/Plugin/Field/FieldType/DateRangeFieldItemList.php @@ -31,7 +31,7 @@ public function defaultValuesForm(array &$form, FormStateInterface $form_state) '#type' => 'select', '#title' => $this->t('Default end date'), '#description' => $this->t('Set a default value for the end date.'), - '#default_value' => isset($default_value[0]['default_end_date_type']) ? $default_value[0]['default_end_date_type'] : '', + '#default_value' => $default_value[0]['default_end_date_type'] ?? '', '#options' => [ static::DEFAULT_VALUE_NOW => $this->t('Current date'), static::DEFAULT_VALUE_CUSTOM => $this->t('Relative date'), diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 2dd2ed9760..ab1529b5a5 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -282,7 +282,7 @@ function editor_load($format_id) { // formats for administrators). Loading a small number of editors all at once // is more efficient than loading multiple editors individually. $editors = Editor::loadMultiple(); - return isset($editors[$format_id]) ? $editors[$format_id] : NULL; + return $editors[$format_id] ?? NULL; } /** diff --git a/core/modules/editor/src/Form/EditorImageDialog.php b/core/modules/editor/src/Form/EditorImageDialog.php index 6308aea773..a1ced5747b 100644 --- a/core/modules/editor/src/Form/EditorImageDialog.php +++ b/core/modules/editor/src/Form/EditorImageDialog.php @@ -116,7 +116,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Editor $e $form['attributes']['src'] = [ '#title' => $this->t('URL'), '#type' => 'textfield', - '#default_value' => isset($image_element['src']) ? $image_element['src'] : '', + '#default_value' => $image_element['src'] ?? '', '#maxlength' => 2048, '#required' => TRUE, ]; @@ -139,7 +139,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Editor $e // an existing image (which means the src attribute is set) and its alt // attribute is empty, then we show that as two double quotes in the dialog. // @see https://www.drupal.org/node/2307647 - $alt = isset($image_element['alt']) ? $image_element['alt'] : ''; + $alt = $image_element['alt'] ?? ''; if ($alt === '' && !empty($image_element['src'])) { $alt = '""'; } diff --git a/core/modules/editor/src/Form/EditorLinkDialog.php b/core/modules/editor/src/Form/EditorLinkDialog.php index 1b1735a2e7..df0bcfef69 100644 --- a/core/modules/editor/src/Form/EditorLinkDialog.php +++ b/core/modules/editor/src/Form/EditorLinkDialog.php @@ -40,7 +40,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Editor $e // The default values are set directly from \Drupal::request()->request, // provided by the editor plugin opening the dialog. $user_input = $form_state->getUserInput(); - $input = isset($user_input['editor_object']) ? $user_input['editor_object'] : []; + $input = $user_input['editor_object'] ?? []; $form['#tree'] = TRUE; $form['#attached']['library'][] = 'editor/drupal.editor.dialog'; @@ -52,7 +52,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Editor $e $form['attributes']['href'] = [ '#title' => $this->t('URL'), '#type' => 'textfield', - '#default_value' => isset($input['href']) ? $input['href'] : '', + '#default_value' => $input['href'] ?? '', '#maxlength' => 2048, ]; diff --git a/core/modules/field/src/FieldConfigStorage.php b/core/modules/field/src/FieldConfigStorage.php index 7d5389778c..3f18a0fed7 100644 --- a/core/modules/field/src/FieldConfigStorage.php +++ b/core/modules/field/src/FieldConfigStorage.php @@ -101,7 +101,7 @@ public function importDelete($name, Config $new_config, Config $old_config) { */ public function loadByProperties(array $conditions = []) { // Include deleted fields if specified in the $conditions parameters. - $include_deleted = isset($conditions['include_deleted']) ? $conditions['include_deleted'] : FALSE; + $include_deleted = $conditions['include_deleted'] ?? FALSE; unset($conditions['include_deleted']); $fields = []; diff --git a/core/modules/field/src/FieldStorageConfigStorage.php b/core/modules/field/src/FieldStorageConfigStorage.php index 1125ab97ec..dee08eb58d 100644 --- a/core/modules/field/src/FieldStorageConfigStorage.php +++ b/core/modules/field/src/FieldStorageConfigStorage.php @@ -101,7 +101,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI */ public function loadByProperties(array $conditions = []) { // Include deleted fields if specified in the $conditions parameters. - $include_deleted = isset($conditions['include_deleted']) ? $conditions['include_deleted'] : FALSE; + $include_deleted = $conditions['include_deleted'] ?? FALSE; unset($conditions['include_deleted']); /** @var \Drupal\field\FieldStorageConfigInterface[] $storages */ diff --git a/core/modules/field/src/Plugin/migrate/process/d6/FieldFormatterSettingsDefaults.php b/core/modules/field/src/Plugin/migrate/process/d6/FieldFormatterSettingsDefaults.php index 9a8e86abb7..1e9c82cd3a 100644 --- a/core/modules/field/src/Plugin/migrate/process/d6/FieldFormatterSettingsDefaults.php +++ b/core/modules/field/src/Plugin/migrate/process/d6/FieldFormatterSettingsDefaults.php @@ -126,7 +126,7 @@ protected function numberSettings($type, $format) { ], ]; - return isset($map[$type][$format]) ? $map[$type][$format] : []; + return $map[$type][$format] ?? []; } } diff --git a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceOptionTranslation.php b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceOptionTranslation.php index 72e954bf0c..4b612bffaa 100644 --- a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceOptionTranslation.php +++ b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceOptionTranslation.php @@ -34,7 +34,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable for ($i = 0; $i < 2; $i++) { $value = $list[$i]; $tmp = explode("|", $value); - $original_option_key = isset($tmp[0]) ? $tmp[0] : NULL; + $original_option_key = $tmp[0] ?? NULL; $option_key = ($i === 0) ? 'off_label' : 'on_label'; // Find property with name matching the original option. if ($option == $original_option_key) { diff --git a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceWidgetSettings.php b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceWidgetSettings.php index 6b04de2667..895c412598 100644 --- a/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceWidgetSettings.php +++ b/core/modules/field/src/Plugin/migrate/process/d6/FieldInstanceWidgetSettings.php @@ -39,9 +39,9 @@ public function transform($value, MigrateExecutableInterface $migrate_executable * A valid array of settings. */ public function getSettings($widget_type, $widget_settings) { - $progress = isset($widget_settings['progress_indicator']) ? $widget_settings['progress_indicator'] : 'throbber'; - $size = isset($widget_settings['size']) ? $widget_settings['size'] : 60; - $rows = isset($widget_settings['rows']) ? $widget_settings['rows'] : 5; + $progress = $widget_settings['progress_indicator'] ?? 'throbber'; + $size = $widget_settings['size'] ?? 60; + $rows = $widget_settings['rows'] ?? 5; $settings = [ 'text_textfield' => [ @@ -77,7 +77,7 @@ public function getSettings($widget_type, $widget_settings) { ], ]; - return isset($settings[$widget_type]) ? $settings[$widget_type] : []; + return $settings[$widget_type] ?? []; } } diff --git a/core/modules/field/src/Plugin/migrate/process/d6/FieldSettings.php b/core/modules/field/src/Plugin/migrate/process/d6/FieldSettings.php index e8cf7f5fa6..967b4cbd79 100644 --- a/core/modules/field/src/Plugin/migrate/process/d6/FieldSettings.php +++ b/core/modules/field/src/Plugin/migrate/process/d6/FieldSettings.php @@ -44,7 +44,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable * A valid array of settings. */ public function getSettings($field_type, $global_settings, $original_field_type = NULL) { - $max_length = isset($global_settings['max_length']) ? $global_settings['max_length'] : ''; + $max_length = $global_settings['max_length'] ?? ''; $max_length = empty($max_length) ? 255 : $max_length; $allowed_values = []; if (isset($global_settings['allowed_values'])) { @@ -57,7 +57,7 @@ public function getSettings($field_type, $global_settings, $original_field_type case 'list_float': foreach ($list as $value) { $value = explode("|", $value); - $allowed_values[$value[0]] = isset($value[1]) ? $value[1] : $value[0]; + $allowed_values[$value[0]] = $value[1] ?? $value[0]; } break; @@ -89,7 +89,7 @@ public function getSettings($field_type, $global_settings, $original_field_type return ['target_type' => 'user']; } else { - return isset($settings[$field_type]) ? $settings[$field_type] : []; + return $settings[$field_type] ?? []; } } diff --git a/core/modules/field_ui/src/Element/FieldUiTable.php b/core/modules/field_ui/src/Element/FieldUiTable.php index 839a0ed5f4..8dee40d733 100644 --- a/core/modules/field_ui/src/Element/FieldUiTable.php +++ b/core/modules/field_ui/src/Element/FieldUiTable.php @@ -83,7 +83,7 @@ public static function tablePreRender($elements) { $indentation = [ '#theme' => 'indentation', '#size' => $depth, - '#suffix' => isset($row[$cell]['#prefix']) ? $row[$cell]['#prefix'] : '', + '#suffix' => $row[$cell]['#prefix'] ?? '', ]; $row[$cell]['#prefix'] = \Drupal::service('renderer')->render($indentation); } diff --git a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php index 97d234aad4..8f39914409 100644 --- a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php +++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php @@ -604,7 +604,7 @@ protected function copyFormValuesToEntity(EntityInterface $entity, array $form, // Only store settings actually used by the selected plugin. $default_settings = $this->pluginManager->getDefaultSettings($options['type']); $options['settings'] = isset($values['settings_edit_form']['settings']) ? array_intersect_key($values['settings_edit_form']['settings'], $default_settings) : []; - $options['third_party_settings'] = isset($values['settings_edit_form']['third_party_settings']) ? $values['settings_edit_form']['third_party_settings'] : []; + $options['third_party_settings'] = $values['settings_edit_form']['third_party_settings'] ?? []; $form_state->set('plugin_settings_update', NULL); } @@ -704,8 +704,8 @@ public function multistepAjax($form, FormStateInterface $form_state) { foreach ($updated_rows as $name) { foreach ($updated_columns as $key) { $element = &$form['fields'][$name][$key]; - $element['#prefix'] = '
' . (isset($element['#prefix']) ? $element['#prefix'] : ''); - $element['#suffix'] = (isset($element['#suffix']) ? $element['#suffix'] : '') . '
'; + $element['#prefix'] = '
' . ($element['#prefix'] ?? ''); + $element['#suffix'] = ($element['#suffix'] ?? '') . '
'; } } @@ -724,7 +724,7 @@ public function multistepAjax($form, FormStateInterface $form_state) { protected function getExtraFields() { $context = $this->displayContext == 'view' ? 'display' : $this->displayContext; $extra_fields = $this->entityFieldManager->getExtraFields($this->entity->getTargetEntityTypeId(), $this->entity->getTargetBundle()); - return isset($extra_fields[$context]) ? $extra_fields[$context] : []; + return $extra_fields[$context] ?? []; } /** diff --git a/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php b/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php index 5442d7fa7e..6ee46132f2 100644 --- a/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php +++ b/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php @@ -62,7 +62,7 @@ protected function getEntityDisplay($entity_type_id, $bundle, $mode) { * {@inheritdoc} */ protected function getDefaultPlugin($field_type) { - return isset($this->fieldTypes[$field_type]['default_widget']) ? $this->fieldTypes[$field_type]['default_widget'] : NULL; + return $this->fieldTypes[$field_type]['default_widget'] ?? NULL; } /** diff --git a/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php b/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php index eeb54fcb44..73ed8b4395 100644 --- a/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php +++ b/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php @@ -95,7 +95,7 @@ protected function getEntityDisplay($entity_type_id, $bundle, $mode) { * {@inheritdoc} */ protected function getDefaultPlugin($field_type) { - return isset($this->fieldTypes[$field_type]['default_formatter']) ? $this->fieldTypes[$field_type]['default_formatter'] : NULL; + return $this->fieldTypes[$field_type]['default_formatter'] ?? NULL; } /** diff --git a/core/modules/field_ui/src/Form/FieldStorageAddForm.php b/core/modules/field_ui/src/Form/FieldStorageAddForm.php index c4af96099c..8a1139b0df 100644 --- a/core/modules/field_ui/src/Form/FieldStorageAddForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageAddForm.php @@ -363,10 +363,10 @@ public function submitForm(array &$form, FormStateInterface $form_state) { } } - $widget_id = isset($field_options['entity_form_display']['type']) ? $field_options['entity_form_display']['type'] : NULL; - $widget_settings = isset($field_options['entity_form_display']['settings']) ? $field_options['entity_form_display']['settings'] : []; - $formatter_id = isset($field_options['entity_view_display']['type']) ? $field_options['entity_view_display']['type'] : NULL; - $formatter_settings = isset($field_options['entity_view_display']['settings']) ? $field_options['entity_view_display']['settings'] : []; + $widget_id = $field_options['entity_form_display']['type'] ?? NULL; + $widget_settings = $field_options['entity_form_display']['settings'] ?? []; + $formatter_id = $field_options['entity_view_display']['type'] ?? NULL; + $formatter_settings = $field_options['entity_view_display']['settings'] ?? []; } // Create the field storage and field. diff --git a/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php index bf1994c1f9..d70c0aadd4 100644 --- a/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageConfigEditForm.php @@ -254,7 +254,7 @@ protected function getEnforcedCardinality() { /** @var \Drupal\Core\Field\FieldTypePluginManager $field_type_manager */ $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); $definition = $field_type_manager->getDefinition($this->entity->getType()); - return isset($definition['cardinality']) ? $definition['cardinality'] : NULL; + return $definition['cardinality'] ?? NULL; } } diff --git a/core/modules/file/file.module b/core/modules/file/file.module index fb2f3484b7..f4d6a40773 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -770,9 +770,9 @@ function _file_save_upload_from_form(array $element, FormStateInterface $form_st // from $_SESSION. $errors_before = \Drupal::messenger()->deleteByType(MessengerInterface::TYPE_ERROR); - $upload_location = isset($element['#upload_location']) ? $element['#upload_location'] : FALSE; + $upload_location = $element['#upload_location'] ?? FALSE; $upload_name = implode('_', $element['#parents']); - $upload_validators = isset($element['#upload_validators']) ? $element['#upload_validators'] : []; + $upload_validators = $element['#upload_validators'] ?? []; $result = file_save_upload($upload_name, $upload_validators, $upload_location, $delta, $replace); @@ -1409,7 +1409,7 @@ function file_managed_file_save_upload($element, FormStateInterface $form_state) } $file_upload = $all_files[$upload_name]; - $destination = isset($element['#upload_location']) ? $element['#upload_location'] : NULL; + $destination = $element['#upload_location'] ?? NULL; if (isset($destination) && !\Drupal::service('file_system')->prepareDirectory($destination, FileSystemInterface::CREATE_DIRECTORY)) { \Drupal::logger('file')->notice('The upload directory %directory for the file field %name could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled.', ['%directory' => $destination, '%name' => $element['#field_name']]); $form_state->setError($element, t('The file could not be uploaded.')); @@ -1707,7 +1707,7 @@ function file_get_file_references(FileInterface $file, FieldDefinitionInterface if (!isset($references[$file->id()][$age])) { $references[$file->id()][$age] = []; $usage_list = \Drupal::service('file.usage')->listUsage($file); - $file_usage_list = isset($usage_list['file']) ? $usage_list['file'] : []; + $file_usage_list = $usage_list['file'] ?? []; foreach ($file_usage_list as $entity_type_id => $entity_ids) { $entities = \Drupal::entityTypeManager() ->getStorage($entity_type_id)->loadMultiple(array_keys($entity_ids)); @@ -1783,7 +1783,7 @@ function _views_file_status($choice = NULL) { ]; if (isset($choice)) { - return isset($status[$choice]) ? $status[$choice] : t('Unknown'); + return $status[$choice] ?? t('Unknown'); } return $status; diff --git a/core/modules/file/src/Element/ManagedFile.php b/core/modules/file/src/Element/ManagedFile.php index 746d1c0392..5ee3f9b6fb 100644 --- a/core/modules/file/src/Element/ManagedFile.php +++ b/core/modules/file/src/Element/ManagedFile.php @@ -134,11 +134,11 @@ public static function valueCallback(&$element, $input, FormStateInterface $form // default value. if ($input === FALSE || $force_default) { if ($element['#extended']) { - $default_fids = isset($element['#default_value']['fids']) ? $element['#default_value']['fids'] : []; - $return = isset($element['#default_value']) ? $element['#default_value'] : ['fids' => []]; + $default_fids = $element['#default_value']['fids'] ?? []; + $return = $element['#default_value'] ?? ['fids' => []]; } else { - $default_fids = isset($element['#default_value']) ? $element['#default_value'] : []; + $default_fids = $element['#default_value'] ?? []; $return = ['fids' => []]; } @@ -218,7 +218,7 @@ public static function processManagedFile(&$element, FormStateInterface $form_st // This is used sometimes so let's implode it just once. $parents_prefix = implode('_', $element['#parents']); - $fids = isset($element['#value']['fids']) ? $element['#value']['fids'] : []; + $fids = $element['#value']['fids'] ?? []; // Set some default element properties. $element['#progress_indicator'] = empty($element['#progress_indicator']) ? 'none' : $element['#progress_indicator']; diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php index 99bfae4b27..a67852a8f9 100644 --- a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php +++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php @@ -188,7 +188,7 @@ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { $element['description_field'] = [ '#type' => 'checkbox', '#title' => t('Enable Description field'), - '#default_value' => isset($settings['description_field']) ? $settings['description_field'] : '', + '#default_value' => $settings['description_field'] ?? '', '#description' => t('The description field allows users to enter a description about the uploaded file.'), '#weight' => 11, ]; diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php index da7c22e8d7..8892797888 100644 --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -409,7 +409,7 @@ public static function process($element, FormStateInterface $form_state, $form) $element['description'] = [ '#type' => $config->get('description.type'), '#title' => t('Description'), - '#value' => isset($item['description']) ? $item['description'] : '', + '#value' => $item['description'] ?? '', '#maxlength' => $config->get('description.length'), '#description' => t('The description may be used as the label of the link to the file.'), ]; diff --git a/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php b/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php index 9a0c93f610..86987453de 100644 --- a/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php +++ b/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php @@ -74,9 +74,9 @@ public function transform($value, MigrateExecutableInterface $migrate_executable return [ 'target_id' => $lookup_result[0]['fid'], 'display' => $value['list'], - 'description' => isset($options['description']) ? $options['description'] : '', - 'alt' => isset($options['alt']) ? $options['alt'] : '', - 'title' => isset($options['title']) ? $options['title'] : '', + 'description' => $options['description'] ?? '', + 'alt' => $options['alt'] ?? '', + 'title' => $options['title'] ?? '', ]; } else { diff --git a/core/modules/file/src/Plugin/migrate/source/d6/File.php b/core/modules/file/src/Plugin/migrate/source/d6/File.php index 7b7b2df311..1332a0c9cf 100644 --- a/core/modules/file/src/Plugin/migrate/source/d6/File.php +++ b/core/modules/file/src/Plugin/migrate/source/d6/File.php @@ -54,7 +54,7 @@ public function query() { * {@inheritdoc} */ protected function initializeIterator() { - $site_path = isset($this->configuration['site_path']) ? $this->configuration['site_path'] : 'sites/default'; + $site_path = $this->configuration['site_path'] ?? 'sites/default'; $this->filePath = $this->variableGet('file_directory_path', $site_path . '/files') . '/'; $this->tempFilePath = $this->variableGet('file_directory_temp', '/tmp') . '/'; diff --git a/core/modules/file/tests/src/Functional/FileFieldTestBase.php b/core/modules/file/tests/src/Functional/FileFieldTestBase.php index cdb0e3da31..cbfe67fa3c 100644 --- a/core/modules/file/tests/src/Functional/FileFieldTestBase.php +++ b/core/modules/file/tests/src/Functional/FileFieldTestBase.php @@ -222,7 +222,7 @@ public function replaceNodeFile($file, $field_name, $nid, $new_revision = TRUE) public function assertFileEntryExists($file, $message = NULL) { $this->container->get('entity_type.manager')->getStorage('file')->resetCache(); $db_file = File::load($file->id()); - $message = isset($message) ? $message : new FormattableMarkup('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]); + $message = $message ?? new FormattableMarkup('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]); $this->assertEquals($file->getFileUri(), $db_file->getFileUri(), $message); } @@ -231,7 +231,7 @@ public function assertFileEntryExists($file, $message = NULL) { */ public function assertFileEntryNotExists($file, $message) { $this->container->get('entity_type.manager')->getStorage('file')->resetCache(); - $message = isset($message) ? $message : new FormattableMarkup('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]); + $message = $message ?? new FormattableMarkup('File %file exists in database at the correct path.', ['%file' => $file->getFileUri()]); $this->assertNull(File::load($file->id()), $message); } @@ -239,7 +239,7 @@ public function assertFileEntryNotExists($file, $message) { * Asserts that a file's status is set to permanent in the database. */ public function assertFileIsPermanent(FileInterface $file, $message = NULL) { - $message = isset($message) ? $message : new FormattableMarkup('File %file is permanent.', ['%file' => $file->getFileUri()]); + $message = $message ?? new FormattableMarkup('File %file is permanent.', ['%file' => $file->getFileUri()]); $this->assertTrue($file->isPermanent(), $message); } diff --git a/core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php b/core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php index db17056c17..2e688aa71f 100644 --- a/core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php +++ b/core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php @@ -67,7 +67,7 @@ public static function create(ContainerInterface $container, array $configuratio */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $rid = $row->getSourceProperty('rid'); - $migration = isset($this->configuration['migration']) ? $this->configuration['migration'] : 'd6_filter_format'; + $migration = $this->configuration['migration'] ?? 'd6_filter_format'; if ($formats = $row->getSourceProperty("filter_permissions:$rid")) { foreach ($formats as $format) { $lookup_result = $this->migrateLookup->lookup($migration, [$format]); diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 8bf800e11a..c11ec858f8 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -465,7 +465,7 @@ function template_preprocess_forums(&$variables) { $variables['topics'][$id]->submitted = \Drupal::service('renderer')->render($forum_submitted); $forum_submitted = [ '#theme' => 'forum_submitted', - '#topic' => isset($topic->last_reply) ? $topic->last_reply : NULL, + '#topic' => $topic->last_reply ?? NULL, ]; $variables['topics'][$id]->last_reply = \Drupal::service('renderer')->render($forum_submitted); diff --git a/core/modules/forum/src/ForumManager.php b/core/modules/forum/src/ForumManager.php index 3a5ec47c74..3e9a16e9a6 100644 --- a/core/modules/forum/src/ForumManager.php +++ b/core/modules/forum/src/ForumManager.php @@ -329,7 +329,7 @@ protected function lastVisit($nid, AccountInterface $account) { $this->history[$t->nid] = $t->timestamp > HISTORY_READ_LIMIT ? $t->timestamp : HISTORY_READ_LIMIT; } } - return isset($this->history[$nid]) ? $this->history[$nid] : HISTORY_READ_LIMIT; + return $this->history[$nid] ?? HISTORY_READ_LIMIT; } /** diff --git a/core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php b/core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php index 50315dc30a..d078cf154a 100644 --- a/core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php +++ b/core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php @@ -76,7 +76,7 @@ public function normalize($field_item, $format = NULL, array $context = []) { // If the parent entity passed in a langcode, unset it before normalizing // the target entity. Otherwise, untranslatable fields of the target entity // will include the langcode. - $langcode = isset($context['langcode']) ? $context['langcode'] : NULL; + $langcode = $context['langcode'] ?? NULL; unset($context['langcode']); $context['included_fields'] = ['uuid']; diff --git a/core/modules/image/src/Form/ImageStyleEditForm.php b/core/modules/image/src/Form/ImageStyleEditForm.php index 5f075b3bbf..5a7ad036f8 100644 --- a/core/modules/image/src/Form/ImageStyleEditForm.php +++ b/core/modules/image/src/Form/ImageStyleEditForm.php @@ -153,7 +153,7 @@ public function form(array $form, FormStateInterface $form_state) { } $form['effects']['new'] = [ '#tree' => FALSE, - '#weight' => isset($user_input['weight']) ? $user_input['weight'] : NULL, + '#weight' => $user_input['weight'] ?? NULL, '#attributes' => ['class' => ['draggable']], ]; $form['effects']['new']['effect'] = [ diff --git a/core/modules/image/src/ImageStyleStorage.php b/core/modules/image/src/ImageStyleStorage.php index 69b7a513e4..1a629dd0a4 100644 --- a/core/modules/image/src/ImageStyleStorage.php +++ b/core/modules/image/src/ImageStyleStorage.php @@ -33,7 +33,7 @@ public function setReplacementId($name, $replacement) { * {@inheritdoc} */ public function getReplacementId($name) { - return isset($this->replacement[$name]) ? $this->replacement[$name] : NULL; + return $this->replacement[$name] ?? NULL; } /** diff --git a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php index 17360160a3..5a602339a2 100644 --- a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php +++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php @@ -258,7 +258,7 @@ public static function process($element, FormStateInterface $form_state, $form) $element['alt'] = [ '#title' => t('Alternative text'), '#type' => 'textfield', - '#default_value' => isset($item['alt']) ? $item['alt'] : '', + '#default_value' => $item['alt'] ?? '', '#description' => t('Short description of the image used by screen readers and displayed when the image is not loaded. This is important for accessibility.'), // @see https://www.drupal.org/node/465106#alt-text '#maxlength' => 512, @@ -270,7 +270,7 @@ public static function process($element, FormStateInterface $form_state, $form) $element['title'] = [ '#type' => 'textfield', '#title' => t('Title'), - '#default_value' => isset($item['title']) ? $item['title'] : '', + '#default_value' => $item['title'] ?? '', '#description' => t('The title is used as a tool tip when the user hovers the mouse over the image.'), '#maxlength' => 1024, '#weight' => -11, diff --git a/core/modules/image/tests/src/Functional/ImageFieldTestBase.php b/core/modules/image/tests/src/Functional/ImageFieldTestBase.php index d4a03267bb..82cef6e775 100644 --- a/core/modules/image/tests/src/Functional/ImageFieldTestBase.php +++ b/core/modules/image/tests/src/Functional/ImageFieldTestBase.php @@ -116,7 +116,7 @@ public function uploadNodeImage($image, $field_name, $type, $alt = '') { // Retrieve ID of the newly created node from the current URL. $matches = []; preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches); - return isset($matches[1]) ? $matches[1] : FALSE; + return $matches[1] ?? FALSE; } /** diff --git a/core/modules/jsonapi/src/Access/TemporaryQueryGuard.php b/core/modules/jsonapi/src/Access/TemporaryQueryGuard.php index 7a7991f158..1c5c34db16 100644 --- a/core/modules/jsonapi/src/Access/TemporaryQueryGuard.php +++ b/core/modules/jsonapi/src/Access/TemporaryQueryGuard.php @@ -588,7 +588,7 @@ protected static function buildTree(array $paths) { // This complex expression is needed to handle the string, "0", which // would be evaluated as FALSE. if (!is_null(($field_name = array_shift($parts)))) { - $previous = isset($merged[$field_name]) ? $merged[$field_name] : []; + $previous = $merged[$field_name] ?? []; $merged[$field_name] = array_merge($previous, [$parts]); } } diff --git a/core/modules/jsonapi/src/Controller/EntityResource.php b/core/modules/jsonapi/src/Controller/EntityResource.php index 47bc9c056d..7200d2f608 100644 --- a/core/modules/jsonapi/src/Controller/EntityResource.php +++ b/core/modules/jsonapi/src/Controller/EntityResource.php @@ -883,8 +883,8 @@ protected function getCollectionQuery(ResourceType $resource_type, array $params if (isset($params[Sort::KEY_NAME]) && $sort = $params[Sort::KEY_NAME]) { foreach ($sort->fields() as $field) { $path = $this->fieldResolver->resolveInternalEntityQueryPath($resource_type, $field[Sort::PATH_KEY]); - $direction = isset($field[Sort::DIRECTION_KEY]) ? $field[Sort::DIRECTION_KEY] : 'ASC'; - $langcode = isset($field[Sort::LANGUAGE_KEY]) ? $field[Sort::LANGUAGE_KEY] : NULL; + $direction = $field[Sort::DIRECTION_KEY] ?? 'ASC'; + $langcode = $field[Sort::LANGUAGE_KEY] ?? NULL; $query->sort($path, $direction, $langcode); } } diff --git a/core/modules/jsonapi/src/DependencyInjection/Compiler/RegisterSerializationClassesCompilerPass.php b/core/modules/jsonapi/src/DependencyInjection/Compiler/RegisterSerializationClassesCompilerPass.php index 7587cb3242..a0a33b69bf 100644 --- a/core/modules/jsonapi/src/DependencyInjection/Compiler/RegisterSerializationClassesCompilerPass.php +++ b/core/modules/jsonapi/src/DependencyInjection/Compiler/RegisterSerializationClassesCompilerPass.php @@ -70,14 +70,14 @@ public function process(ContainerBuilder $container) { // Normalizers are not an API: mark private. $container->getDefinition($id)->setPublic(FALSE); - $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $priority = $attributes[0]['priority'] ?? 0; $normalizers[$priority][] = new Reference($id); } foreach ($container->findTaggedServiceIds(static::OVERRIDDEN_SERVICE_ENCODER_TAG) as $id => $attributes) { // Encoders are not an API: mark private. $container->getDefinition($id)->setPublic(FALSE); - $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $priority = $attributes[0]['priority'] ?? 0; $encoders[$priority][] = new Reference($id); } diff --git a/core/modules/jsonapi/src/IncludeResolver.php b/core/modules/jsonapi/src/IncludeResolver.php index af055b1c16..2aad83386f 100644 --- a/core/modules/jsonapi/src/IncludeResolver.php +++ b/core/modules/jsonapi/src/IncludeResolver.php @@ -249,7 +249,7 @@ protected static function buildTree(array $paths) { if (!$field_name = array_shift($parts)) { continue; } - $previous = isset($merged[$field_name]) ? $merged[$field_name] : []; + $previous = $merged[$field_name] ?? []; $merged[$field_name] = array_merge($previous, [$parts]); } return !empty($merged) ? array_map([static::class, __FUNCTION__], $merged) : $merged; diff --git a/core/modules/jsonapi/src/Normalizer/EntityAccessDeniedHttpExceptionNormalizer.php b/core/modules/jsonapi/src/Normalizer/EntityAccessDeniedHttpExceptionNormalizer.php index 1e0930eea9..a731340694 100644 --- a/core/modules/jsonapi/src/Normalizer/EntityAccessDeniedHttpExceptionNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/EntityAccessDeniedHttpExceptionNormalizer.php @@ -40,9 +40,7 @@ protected function buildErrorObjects(HttpException $exception) { $entity = $error['entity']; $pointer = $error['pointer']; $reason = $error['reason']; - $relationship_field = isset($error['relationship_field']) - ? $error['relationship_field'] - : NULL; + $relationship_field = $error['relationship_field'] ?? NULL; if (isset($entity)) { $entity_type_id = $entity->getEntityTypeId(); diff --git a/core/modules/jsonapi/src/Normalizer/ResourceIdentifierNormalizer.php b/core/modules/jsonapi/src/Normalizer/ResourceIdentifierNormalizer.php index c428b3c788..8e65b7789c 100644 --- a/core/modules/jsonapi/src/Normalizer/ResourceIdentifierNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/ResourceIdentifierNormalizer.php @@ -97,7 +97,7 @@ public function denormalize($data, $class, $format = NULL, array $context = []) implode(', ', $target_resource_type_names) )); } - return new ResourceIdentifier($value['type'], $value['id'], isset($value['meta']) ? $value['meta'] : []); + return new ResourceIdentifier($value['type'], $value['id'], $value['meta'] ?? []); }, $data['data']); if (!ResourceIdentifier::areResourceIdentifiersUnique($resource_identifiers)) { throw new BadRequestHttpException('Duplicate relationships are not permitted. Use `meta.arity` to distinguish resource identifiers with matching `type` and `id` values.'); index 8a21f42020..838ff21ad9 --- a/core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php @@ -122,11 +122,9 @@ protected function getNormalization(array $field_names, ResourceObject $object, } // Add links if missing. $base = &$normalizer_values[ResourceObjectNormalizationCacher::RESOURCE_CACHE_SUBSET_BASE]; - $base['links'] = isset($base['links']) - ? $base['links'] - : $this->serializer - ->normalize($object->getLinks(), $format, $context) - ->omitIfEmpty(); + $base['links'] = $base['links'] ?? $this->serializer + ->normalize($object->getLinks(), $format, $context) + ->omitIfEmpty(); if (!empty($non_cached_requested_fields)) { $this->cacher->saveOnTerminate($object, $normalizer_values); diff --git a/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php b/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php index aeadd2741a..6e749ee352 100644 --- a/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php +++ b/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php @@ -188,7 +188,7 @@ public function get($entity_type_id, $bundle) { */ public function getByTypeName($type_name) { $resource_types = $this->all(); - return isset($resource_types[$type_name]) ? $resource_types[$type_name] : NULL; + return $resource_types[$type_name] ?? NULL; } /** diff --git a/core/modules/jsonapi/src/Routing/Routes.php b/core/modules/jsonapi/src/Routing/Routes.php index 8a7586a262..609ed91312 100644 --- a/core/modules/jsonapi/src/Routing/Routes.php +++ b/core/modules/jsonapi/src/Routing/Routes.php @@ -465,7 +465,7 @@ protected static function hasNonInternalFileTargetResourceTypes(array $resource_ */ public static function getResourceTypeNameFromParameters(array $parameters) { if (isset($parameters[static::JSON_API_ROUTE_FLAG_KEY]) && $parameters[static::JSON_API_ROUTE_FLAG_KEY]) { - return isset($parameters[static::RESOURCE_TYPE_KEY]) ? $parameters[static::RESOURCE_TYPE_KEY] : NULL; + return $parameters[static::RESOURCE_TYPE_KEY] ?? NULL; } return NULL; } diff --git a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php index e0d9048f42..41999f594a 100644 --- a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php +++ b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php @@ -1696,7 +1696,7 @@ protected function getExpectedGetRelationshipResponse($relationship_field_name, ]) ->addCacheableDependency($entity) ->addCacheableDependency($access); - $status_code = isset($expected_document['errors'][0]['status']) ? $expected_document['errors'][0]['status'] : 200; + $status_code = $expected_document['errors'][0]['status'] ?? 200; $resource_response = new CacheableResourceResponse($expected_document, $status_code); $resource_response->addCacheableDependency($expected_cacheability); return $resource_response; diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc index a55e65a23c..7a5c4fa1d1 100644 --- a/core/modules/language/language.admin.inc +++ b/core/modules/language/language.admin.inc @@ -74,7 +74,7 @@ function template_preprocess_language_negotiation_configure_form(&$variables) { } // Unset configurable to prevent rendering twice with children. - $configurable = isset($form[$type]['configurable']) ? $form[$type]['configurable'] : NULL; + $configurable = $form[$type]['configurable'] ?? NULL; unset($form[$type]['configurable']); $variables['language_types'][] = [ diff --git a/core/modules/language/src/Element/LanguageConfiguration.php b/core/modules/language/src/Element/LanguageConfiguration.php index 543e9a0e75..b6790da2b5 100644 --- a/core/modules/language/src/Element/LanguageConfiguration.php +++ b/core/modules/language/src/Element/LanguageConfiguration.php @@ -32,7 +32,7 @@ public function getInfo() { * Process handler for the language_configuration form element. */ public static function processLanguageConfiguration(&$element, FormStateInterface $form_state, &$form) { - $options = isset($element['#options']) ? $element['#options'] : []; + $options = $element['#options'] ?? []; // Avoid validation failure since we are moving the '#options' key in the // nested 'language' select element. unset($element['#options']); diff --git a/core/modules/language/src/Entity/ConfigurableLanguage.php b/core/modules/language/src/Entity/ConfigurableLanguage.php index f268cb65a3..5dbdeda0ef 100644 --- a/core/modules/language/src/Entity/ConfigurableLanguage.php +++ b/core/modules/language/src/Entity/ConfigurableLanguage.php @@ -284,7 +284,7 @@ public static function createFromLangcode($langcode) { return static::create([ 'id' => $langcode, 'label' => $standard_languages[$langcode][0], - 'direction' => isset($standard_languages[$langcode][2]) ? $standard_languages[$langcode][2] : static::DIRECTION_LTR, + 'direction' => $standard_languages[$langcode][2] ?? static::DIRECTION_LTR, ]); } } diff --git a/core/modules/language/src/Form/LanguageAddForm.php b/core/modules/language/src/Form/LanguageAddForm.php index 22d569f64e..4490044706 100644 --- a/core/modules/language/src/Form/LanguageAddForm.php +++ b/core/modules/language/src/Form/LanguageAddForm.php @@ -153,7 +153,7 @@ protected function copyFormValuesToEntity(EntityInterface $entity, array $form, else { $standard_languages = LanguageManager::getStandardLanguageList(); $label = $standard_languages[$langcode][0]; - $direction = isset($standard_languages[$langcode][2]) ? $standard_languages[$langcode][2] : ConfigurableLanguage::DIRECTION_LTR; + $direction = $standard_languages[$langcode][2] ?? ConfigurableLanguage::DIRECTION_LTR; } $entity->set('id', $langcode); $entity->set('label', $label); diff --git a/core/modules/language/src/Form/NegotiationConfigureForm.php b/core/modules/language/src/Form/NegotiationConfigureForm.php index 0679a563d2..6af8c14585 100644 --- a/core/modules/language/src/Form/NegotiationConfigureForm.php +++ b/core/modules/language/src/Form/NegotiationConfigureForm.php @@ -248,7 +248,7 @@ protected function configureFormTable(array &$form, $type) { // Add missing data to the methods lists. foreach ($negotiation_info as $method_id => $method) { if (!isset($methods_weight[$method_id])) { - $methods_weight[$method_id] = isset($method['weight']) ? $method['weight'] : 0; + $methods_weight[$method_id] = $method['weight'] ?? 0; } } @@ -267,7 +267,7 @@ protected function configureFormTable(array &$form, $type) { // List the method only if the current type is defined in its 'types' key. // If it is not defined default to all the configurable language types. - $types = array_flip(isset($method['types']) ? $method['types'] : $form['#language_types']); + $types = array_flip($method['types'] ?? $form['#language_types']); if (isset($types[$type])) { $table_form['#language_negotiation_info'][$method_id] = $method; diff --git a/core/modules/language/src/Form/NegotiationUrlForm.php b/core/modules/language/src/Form/NegotiationUrlForm.php index 707b5ebe9e..8f43315452 100644 --- a/core/modules/language/src/Form/NegotiationUrlForm.php +++ b/core/modules/language/src/Form/NegotiationUrlForm.php @@ -117,14 +117,14 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'textfield', '#title' => $language->isDefault() ? $this->t('%language (%langcode) path prefix (Default language)', $t_args) : $this->t('%language (%langcode) path prefix', $t_args), '#maxlength' => 64, - '#default_value' => isset($prefixes[$langcode]) ? $prefixes[$langcode] : '', + '#default_value' => $prefixes[$langcode] ?? '', '#field_prefix' => $base_url . '/', ]; $form['domain'][$langcode] = [ '#type' => 'textfield', '#title' => $this->t('%language (%langcode) domain', ['%language' => $language->getName(), '%langcode' => $language->getId()]), '#maxlength' => 128, - '#default_value' => isset($domains[$langcode]) ? $domains[$langcode] : '', + '#default_value' => $domains[$langcode] ?? '', ]; } diff --git a/core/modules/language/src/LanguageNegotiator.php b/core/modules/language/src/LanguageNegotiator.php index 40a0d0296d..c4e083ab1a 100644 --- a/core/modules/language/src/LanguageNegotiator.php +++ b/core/modules/language/src/LanguageNegotiator.php @@ -189,7 +189,7 @@ protected function negotiateLanguage($type, $method_id) { } $languages = $this->languageManager->getLanguages(); - return isset($languages[$langcode]) ? $languages[$langcode] : NULL; + return $languages[$langcode] ?? NULL; } /** diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php index b78dbb9e40..388184f623 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationContentEntity.php @@ -188,7 +188,7 @@ protected function hasLowerLanguageNegotiationWeight() { $max_weight = isset($content_method_weights[LanguageNegotiationUrl::METHOD_ID]) ? max($max_weight, $content_method_weights[LanguageNegotiationUrl::METHOD_ID]) : $max_weight; } else { - $max_weight = isset($content_method_weights[LanguageNegotiationUrl::METHOD_ID]) ? $content_method_weights[LanguageNegotiationUrl::METHOD_ID] : PHP_INT_MAX; + $max_weight = $content_method_weights[LanguageNegotiationUrl::METHOD_ID] ?? PHP_INT_MAX; } $this->hasLowerLanguageNegotiationWeightResult = $content_method_weights[static::METHOD_ID] < $max_weight; diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php index 971e907aae..eae9b6e6ef 100644 --- a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php +++ b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php @@ -127,7 +127,7 @@ public function getLanguageSwitchLinks(Request $request, $type, Url $url) { $links = []; $config = $this->config->get('language.negotiation')->get('session'); $param = $config['parameter']; - $language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : $this->languageManager->getCurrentLanguage($type)->getId(); + $language_query = $_SESSION[$param] ?? $this->languageManager->getCurrentLanguage($type)->getId(); $query = []; parse_str($request->getQueryString(), $query); diff --git a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php index f1f33104a4..7caf63500f 100644 --- a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php +++ b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php @@ -92,7 +92,7 @@ private function checkUrl(LanguageInterface $language, $message) { $rewritten_path = trim(str_replace($base_path, '', Url::fromRoute('', [], $options)->toString()), '/'); $segments = explode('/', $rewritten_path, 2); $prefix = $segments[0]; - $path = isset($segments[1]) ? $segments[1] : $prefix; + $path = $segments[1] ?? $prefix; // If the rewritten URL has not a language prefix we pick a random prefix so // we can always check the prefixed URL. diff --git a/core/modules/layout_builder/layout_builder.module b/core/modules/layout_builder/layout_builder.module index 4631de2547..0bad047228 100644 --- a/core/modules/layout_builder/layout_builder.module +++ b/core/modules/layout_builder/layout_builder.module @@ -144,7 +144,7 @@ function layout_builder_entity_view_alter(array &$build, EntityInterface $entity foreach ($extra_fields['display'] as $field_name => $extra_field) { // If the extra field is not set replace with an empty array to avoid // the placeholder text from being rendered. - $replacement = isset($build[$field_name]) ? $build[$field_name] : []; + $replacement = $build[$field_name] ?? []; ExtraFieldBlock::replaceFieldPlaceholder($build, $replacement, $field_name); // After the rendered field in $build has been copied over to the // ExtraFieldBlock block we must remove it from its original location or diff --git a/core/modules/layout_builder/src/Element/LayoutBuilder.php b/core/modules/layout_builder/src/Element/LayoutBuilder.php index 8bf656475b..5c91b1e392 100644 --- a/core/modules/layout_builder/src/Element/LayoutBuilder.php +++ b/core/modules/layout_builder/src/Element/LayoutBuilder.php @@ -310,7 +310,7 @@ protected function buildAdministrativeSection(SectionStorageInterface $section_s // Get weights of all children for use by the region label. $weights = array_map(function ($a) { - return isset($a['#weight']) ? $a['#weight'] : 0; + return $a['#weight'] ?? 0; }, $build[$region]); // The region label is made visible when the move block dialog is open. diff --git a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php index 6094889664..c0794f9e27 100644 --- a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php +++ b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php @@ -436,7 +436,7 @@ public function setComponent($name, array $options = []) { } $section = $this->getDefaultSection(); - $region = isset($options['region']) ? $options['region'] : $section->getDefaultRegion(); + $region = $options['region'] ?? $section->getDefaultRegion(); $new_component = (new SectionComponent(\Drupal::service('uuid')->generate(), $region, $configuration)); $section->appendComponent($new_component); } diff --git a/core/modules/layout_builder/src/Section.php b/core/modules/layout_builder/src/Section.php index cd27437cb2..7b986435ba 100644 --- a/core/modules/layout_builder/src/Section.php +++ b/core/modules/layout_builder/src/Section.php @@ -391,14 +391,14 @@ public function __clone() { * {@inheritdoc} */ public function getThirdPartySetting($provider, $key, $default = NULL) { - return isset($this->thirdPartySettings[$provider][$key]) ? $this->thirdPartySettings[$provider][$key] : $default; + return $this->thirdPartySettings[$provider][$key] ?? $default; } /** * {@inheritdoc} */ public function getThirdPartySettings($provider) { - return isset($this->thirdPartySettings[$provider]) ? $this->thirdPartySettings[$provider] : []; + return $this->thirdPartySettings[$provider] ?? []; } /** diff --git a/core/modules/layout_builder/src/SectionComponent.php b/core/modules/layout_builder/src/SectionComponent.php index b14fc6ae3d..10d278f320 100644 --- a/core/modules/layout_builder/src/SectionComponent.php +++ b/core/modules/layout_builder/src/SectionComponent.php @@ -104,10 +104,10 @@ public function toRenderArray(array $contexts = [], $in_preview = FALSE) { */ public function get($property) { if (property_exists($this, $property)) { - $value = isset($this->{$property}) ? $this->{$property} : NULL; + $value = $this->{$property} ?? NULL; } else { - $value = isset($this->additional[$property]) ? $this->additional[$property] : NULL; + $value = $this->additional[$property] ?? NULL; } return $value; } diff --git a/core/modules/layout_builder/src/SectionStorage/SectionStorageDefinition.php b/core/modules/layout_builder/src/SectionStorage/SectionStorageDefinition.php index eb9e5afc4f..c97584b39c 100644 --- a/core/modules/layout_builder/src/SectionStorage/SectionStorageDefinition.php +++ b/core/modules/layout_builder/src/SectionStorage/SectionStorageDefinition.php @@ -60,10 +60,10 @@ public function __construct(array $definition = []) { */ public function get($property) { if (property_exists($this, $property)) { - $value = isset($this->{$property}) ? $this->{$property} : NULL; + $value = $this->{$property} ?? NULL; } else { - $value = isset($this->additional[$property]) ? $this->additional[$property] : NULL; + $value = $this->additional[$property] ?? NULL; } return $value; } diff --git a/core/modules/layout_discovery/layout_discovery.module b/core/modules/layout_discovery/layout_discovery.module index 3eed9fe2f9..ce08617e02 100644 --- a/core/modules/layout_discovery/layout_discovery.module +++ b/core/modules/layout_discovery/layout_discovery.module @@ -37,8 +37,8 @@ function layout_discovery_theme() { * Properties used: #settings, #layout. */ function template_preprocess_layout(&$variables) { - $variables['settings'] = isset($variables['content']['#settings']) ? $variables['content']['#settings'] : []; - $variables['layout'] = isset($variables['content']['#layout']) ? $variables['content']['#layout'] : []; + $variables['settings'] = $variables['content']['#settings'] ?? []; + $variables['layout'] = $variables['content']['#layout'] ?? []; // Create an attributes variable for each region. foreach (Element::children($variables['content']) as $name) { diff --git a/core/modules/locale/locale.batch.inc b/core/modules/locale/locale.batch.inc index fcc284618f..8b3fe6ac43 100644 --- a/core/modules/locale/locale.batch.inc +++ b/core/modules/locale/locale.batch.inc @@ -63,7 +63,7 @@ function locale_translation_batch_status_check($project, $langcode, array $optio // Update the file object with the result data. In case of a redirect we // store the resulting uri. if (isset($result['last_modified'])) { - $remote_file->uri = isset($result['location']) ? $result['location'] : $remote_file->uri; + $remote_file->uri = $result['location'] ?? $remote_file->uri; $remote_file->timestamp = $result['last_modified']; locale_translation_status_save($source->name, $source->langcode, LOCALE_TRANSLATION_REMOTE, $remote_file); } diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index e67ad4edcf..dab2e350bf 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -484,7 +484,7 @@ function locale_translate_file_attach_properties($file, array $options = []) { if (isset($matches[5])) { $file->project = $matches[2] . $matches[3]; $file->version = $matches[4]; - $file->langcode = isset($options['langcode']) ? $options['langcode'] : $matches[5]; + $file->langcode = $options['langcode'] ?? $matches[5]; } else { $file->langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED; @@ -634,7 +634,7 @@ function locale_config_batch_refresh_name(array $names, array $langcodes, &$cont */ function locale_config_batch_finished($success, array $results) { if ($success) { - $configuration = isset($results['stats']['config']) ? $results['stats']['config'] : 0; + $configuration = $results['stats']['config'] ?? 0; if ($configuration) { \Drupal::messenger()->addStatus(t('The configuration was successfully updated. There are %number configuration objects updated.', ['%number' => $configuration])); \Drupal::logger('locale')->notice('The configuration was successfully updated. %number configuration objects updated.', ['%number' => $configuration]); diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc index 7321b55159..9a7f4544c2 100644 --- a/core/modules/locale/locale.compare.inc +++ b/core/modules/locale/locale.compare.inc @@ -69,7 +69,7 @@ function locale_translation_build_projects() { // For every project store information. $data += [ 'name' => $name, - 'version' => isset($data['info']['version']) ? $data['info']['version'] : '', + 'version' => $data['info']['version'] ?? '', 'core' => 'all', // A project can provide the path and filename pattern to download the // gettext file. Use the default if not. diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index e1ac093d62..c781ec0f46 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -298,7 +298,7 @@ function locale_get_plural($count, $langcode = NULL) { // modulo used but storing 0-99 is not enough because below 100 we often // find exceptions (1, 2, etc). $index = $count > 199 ? 100 + ($count % 100) : $count; - $plural_indexes[$langcode][$count] = isset($plural_formulas[$index]) ? $plural_formulas[$index] : $plural_formulas['default']; + $plural_indexes[$langcode][$count] = $plural_formulas[$index] ?? $plural_formulas['default']; } // In case there is no plural formula for English (no imported translation // for English), use a default formula. diff --git a/core/modules/locale/locale.translation.inc b/core/modules/locale/locale.translation.inc index 2672d5c38a..74667cf1fe 100644 --- a/core/modules/locale/locale.translation.inc +++ b/core/modules/locale/locale.translation.inc @@ -112,7 +112,7 @@ function locale_translation_load_sources(array $projects = NULL, array $langcode // Use only the selected projects and languages for update. foreach ($projects as $project) { foreach ($langcodes as $langcode) { - $sources[$project][$langcode] = isset($status[$project][$langcode]) ? $status[$project][$langcode] : NULL; + $sources[$project][$langcode] = $status[$project][$langcode] ?? NULL; } } return $sources; @@ -318,7 +318,7 @@ function locale_translation_build_server_pattern($project, $template) { '%project' => $project->name, '%version' => $project->version, '%core' => $project->core, - '%language' => isset($project->langcode) ? $project->langcode : '%language', + '%language' => $project->langcode ?? '%language', ]; return strtr($template, $variables); } diff --git a/core/modules/locale/src/Form/TranslateEditForm.php b/core/modules/locale/src/Form/TranslateEditForm.php index aa2f74bc4a..18b8f834b3 100644 --- a/core/modules/locale/src/Form/TranslateEditForm.php +++ b/core/modules/locale/src/Form/TranslateEditForm.php @@ -128,7 +128,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { // @todo Should use better labels https://www.drupal.org/node/2499639 '#title' => ($i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form')), '#rows' => $rows, - '#default_value' => isset($translation_array[$i]) ? $translation_array[$i] : '', + '#default_value' => $translation_array[$i] ?? '', '#attributes' => ['lang' => $langcode], '#prefix' => $i == 0 ? ('' . $this->t('Translated string (@language)', ['@language' => $langname]) . '') : '', ]; @@ -207,7 +207,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { if ($is_changed) { // Only update or insert if we have a value to use. - $target = isset($existing_translation_objects[$lid]) ? $existing_translation_objects[$lid] : $this->localeStorage->createTranslation(['lid' => $lid, 'language' => $langcode]); + $target = $existing_translation_objects[$lid] ?? $this->localeStorage->createTranslation(['lid' => $lid, 'language' => $langcode]); $target->setPlurals($new_translation['translations']) ->setCustomized() ->save(); diff --git a/core/modules/locale/src/Form/TranslateFilterForm.php b/core/modules/locale/src/Form/TranslateFilterForm.php index f7a3d20ec1..e293e3d871 100644 --- a/core/modules/locale/src/Form/TranslateFilterForm.php +++ b/core/modules/locale/src/Form/TranslateFilterForm.php @@ -43,7 +43,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ]; } else { - $empty_option = isset($filter['options'][$filter['default']]) ? $filter['options'][$filter['default']] : '- None -'; + $empty_option = $filter['options'][$filter['default']] ?? '- None -'; $form['filters']['status'][$key] = [ '#title' => $filter['title'], '#type' => 'select', diff --git a/core/modules/locale/src/Form/TranslationStatusForm.php b/core/modules/locale/src/Form/TranslationStatusForm.php index 4ac817c784..e354153dfd 100644 --- a/core/modules/locale/src/Form/TranslationStatusForm.php +++ b/core/modules/locale/src/Form/TranslationStatusForm.php @@ -207,8 +207,8 @@ protected function prepareUpdateData(array $status) { } // Translation update found for this project-language combination. elseif ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE) { - $local = isset($project_info->files[LOCALE_TRANSLATION_LOCAL]) ? $project_info->files[LOCALE_TRANSLATION_LOCAL] : NULL; - $remote = isset($project_info->files[LOCALE_TRANSLATION_REMOTE]) ? $project_info->files[LOCALE_TRANSLATION_REMOTE] : NULL; + $local = $project_info->files[LOCALE_TRANSLATION_LOCAL] ?? NULL; + $remote = $project_info->files[LOCALE_TRANSLATION_REMOTE] ?? NULL; $recent = _locale_translation_source_compare($local, $remote) == LOCALE_TRANSLATION_SOURCE_COMPARE_LT ? $remote : $local; $updates[$langcode]['updates'][] = [ 'name' => $project_info->name == 'drupal' ? $this->t('Drupal core') : $project_data[$project_info->name]->info['name'], @@ -237,8 +237,8 @@ protected function prepareUpdateData(array $status) { * The string which contains debug information. */ protected function createInfoString($project_info) { - $remote_path = isset($project_info->files['remote']->uri) ? $project_info->files['remote']->uri : FALSE; - $local_path = isset($project_info->files['local']->uri) ? $project_info->files['local']->uri : FALSE; + $remote_path = $project_info->files['remote']->uri ?? FALSE; + $local_path = $project_info->files['local']->uri ?? FALSE; if (locale_translation_use_remote_source() && $remote_path && $local_path) { return $this->t('File not found at %remote_path nor at %local_path', [ diff --git a/core/modules/locale/src/LocaleConfigSubscriber.php b/core/modules/locale/src/LocaleConfigSubscriber.php index 289e838e05..2817251a82 100644 --- a/core/modules/locale/src/LocaleConfigSubscriber.php +++ b/core/modules/locale/src/LocaleConfigSubscriber.php @@ -149,7 +149,7 @@ protected function processTranslatableData($name, array $config, array $translat continue; } if (is_array($item)) { - $reference_config_item = isset($reference_config[$key]) ? $reference_config[$key] : []; + $reference_config_item = $reference_config[$key] ?? []; $this->processTranslatableData($name, $config[$key], $item, $langcode, $reference_config_item); } else { diff --git a/core/modules/locale/src/LocaleProjectStorage.php b/core/modules/locale/src/LocaleProjectStorage.php index 05faa17db3..8147b4c0eb 100644 --- a/core/modules/locale/src/LocaleProjectStorage.php +++ b/core/modules/locale/src/LocaleProjectStorage.php @@ -45,7 +45,7 @@ public function __construct(KeyValueFactoryInterface $key_value_factory) { */ public function get($key, $default = NULL) { $values = $this->getMultiple([$key]); - return isset($values[$key]) ? $values[$key] : $default; + return $values[$key] ?? $default; } /** diff --git a/core/modules/locale/src/PluralFormula.php b/core/modules/locale/src/PluralFormula.php index 8f1920e649..0913a69cda 100644 --- a/core/modules/locale/src/PluralFormula.php +++ b/core/modules/locale/src/PluralFormula.php @@ -86,7 +86,7 @@ public function getNumberOfPlurals($langcode = NULL) { */ public function getFormula($langcode) { $this->loadFormulae(); - return isset($this->formulae[$langcode]['formula']) ? $this->formulae[$langcode]['formula'] : FALSE; + return $this->formulae[$langcode]['formula'] ?? FALSE; } /** diff --git a/core/modules/locale/src/SourceString.php b/core/modules/locale/src/SourceString.php index dd59954bf7..94cd6413a2 100644 --- a/core/modules/locale/src/SourceString.php +++ b/core/modules/locale/src/SourceString.php @@ -29,7 +29,7 @@ public function isTranslation() { * {@inheritdoc} */ public function getString() { - return isset($this->source) ? $this->source : ''; + return $this->source ?? ''; } /** diff --git a/core/modules/locale/src/StringBase.php b/core/modules/locale/src/StringBase.php index 55572d07d5..832d1965b0 100644 --- a/core/modules/locale/src/StringBase.php +++ b/core/modules/locale/src/StringBase.php @@ -67,7 +67,7 @@ public function __construct($values = []) { * {@inheritdoc} */ public function getId() { - return isset($this->lid) ? $this->lid : NULL; + return $this->lid ?? NULL; } /** @@ -82,7 +82,7 @@ public function setId($lid) { * {@inheritdoc} */ public function getVersion() { - return isset($this->version) ? $this->version : NULL; + return $this->version ?? NULL; } /** @@ -112,7 +112,7 @@ public function setPlurals($plurals) { * {@inheritdoc} */ public function getStorage() { - return isset($this->storage) ? $this->storage : NULL; + return $this->storage ?? NULL; } /** @@ -158,7 +158,7 @@ public function getLocations($check_only = FALSE) { $this->locations[$location->type][$location->name] = $location->lid; } } - return isset($this->locations) ? $this->locations : []; + return $this->locations ?? []; } /** diff --git a/core/modules/locale/src/TranslationString.php b/core/modules/locale/src/TranslationString.php index c32d23f2d2..ac8ef1440b 100644 --- a/core/modules/locale/src/TranslationString.php +++ b/core/modules/locale/src/TranslationString.php @@ -84,7 +84,7 @@ public function isTranslation() { * {@inheritdoc} */ public function getString() { - return isset($this->translation) ? $this->translation : ''; + return $this->translation ?? ''; } /** diff --git a/core/modules/media/media.module b/core/modules/media/media.module index 8c90b3bfff..577c1f842f 100644 --- a/core/modules/media/media.module +++ b/core/modules/media/media.module @@ -271,7 +271,7 @@ function media_field_widget_complete_form_alter(array &$field_widget_complete_fo // Use the title set on the element if it exists, otherwise fall back to the // field label. - $elements['#media_help']['#original_label'] = isset($elements['#title']) ? $elements['#title'] : $context['items']->getFieldDefinition()->getLabel(); + $elements['#media_help']['#original_label'] = $elements['#title'] ?? $context['items']->getFieldDefinition()->getLabel(); // Customize the label for the field widget. // @todo Research a better approach https://www.drupal.org/node/2943024. @@ -316,7 +316,7 @@ function media_preprocess_media_reference_help(&$variables) { $element = $variables['element']; Element::setAttributes($element, ['id']); RenderElement::setAttributes($element); - $variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : []; + $variables['attributes'] = $element['#attributes'] ?? []; $variables['legend_attributes'] = new Attribute(); $variables['header_attributes'] = new Attribute(); $variables['description']['attributes'] = new Attribute(); diff --git a/core/modules/media/src/Form/EditorMediaDialog.php b/core/modules/media/src/Form/EditorMediaDialog.php index ca8b7671a0..65f2d59865 100644 --- a/core/modules/media/src/Form/EditorMediaDialog.php +++ b/core/modules/media/src/Form/EditorMediaDialog.php @@ -135,7 +135,7 @@ public function buildForm(array $form, FormStateInterface $form_state, EditorInt $media = $media->getTranslation($editor_object['hostEntityLangcode']); } $settings = $media->{$image_field_name}->getItemDefinition()->getSettings(); - $alt = isset($media_embed_element['alt']) ? $media_embed_element['alt'] : NULL; + $alt = $media_embed_element['alt'] ?? NULL; $form['alt'] = [ '#type' => 'textfield', '#title' => $this->t('Alternate text'), diff --git a/core/modules/media/src/MediaSourceBase.php b/core/modules/media/src/MediaSourceBase.php index 5cc284835e..df21b94c38 100644 --- a/core/modules/media/src/MediaSourceBase.php +++ b/core/modules/media/src/MediaSourceBase.php @@ -258,7 +258,7 @@ protected function getSourceFieldStorage() { // Even if we do know the name of the source field, there's no // guarantee that it exists. $fields = $this->entityFieldManager->getFieldStorageDefinitions('media'); - return isset($fields[$field]) ? $fields[$field] : NULL; + return $fields[$field] ?? NULL; } return NULL; } @@ -273,7 +273,7 @@ public function getSourceFieldDefinition(MediaTypeInterface $type) { // Even if we do know the name of the source field, there is no // guarantee that it already exists. $fields = $this->entityFieldManager->getFieldDefinitions('media', $type->id()); - return isset($fields[$field]) ? $fields[$field] : NULL; + return $fields[$field] ?? NULL; } return NULL; } diff --git a/core/modules/media/src/MediaTypeForm.php b/core/modules/media/src/MediaTypeForm.php index 289fc8aad0..ded58b036c 100644 --- a/core/modules/media/src/MediaTypeForm.php +++ b/core/modules/media/src/MediaTypeForm.php @@ -188,7 +188,7 @@ public function form(array $form, FormStateInterface $form_state) { '#type' => 'select', '#title' => $metadata_attribute_label, '#options' => $options, - '#default_value' => isset($field_map[$metadata_attribute_name]) ? $field_map[$metadata_attribute_name] : MediaSourceInterface::METADATA_FIELD_EMPTY, + '#default_value' => $field_map[$metadata_attribute_name] ?? MediaSourceInterface::METADATA_FIELD_EMPTY, ]; } } diff --git a/core/modules/media_library/src/Form/AddFormBase.php b/core/modules/media_library/src/Form/AddFormBase.php index a63bc7dc87..83742a3a17 100644 --- a/core/modules/media_library/src/Form/AddFormBase.php +++ b/core/modules/media_library/src/Form/AddFormBase.php @@ -255,7 +255,7 @@ protected function buildEntityFormElement(MediaInterface $media, array $form, Fo // triggering element is not set correctly and the wrong media item is // removed. // @see ::removeButtonSubmit() - $parents = isset($form['#parents']) ? $form['#parents'] : []; + $parents = $form['#parents'] ?? []; $id_suffix = $parents ? '-' . implode('-', $parents) : ''; $element = [ diff --git a/core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php b/core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php index 0121dcd6bd..6eb543c1e9 100644 --- a/core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php +++ b/core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php @@ -138,7 +138,7 @@ protected function getAllowedMediaTypeIdsSorted() { $handler_settings = $this->getFieldSetting('handler_settings'); // The target bundles will be blank when saving field storage settings, // when first adding a media reference field. - $allowed_media_type_ids = isset($handler_settings['target_bundles']) ? $handler_settings['target_bundles'] : NULL; + $allowed_media_type_ids = $handler_settings['target_bundles'] ?? NULL; // When there are no allowed media types, return the empty array. if ($allowed_media_type_ids === []) { @@ -238,7 +238,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { */ public static function setMediaTypesValue(array &$element, $input, FormStateInterface $form_state) { if ($input === FALSE) { - return isset($element['#default_value']) ? $element['#default_value'] : []; + return $element['#default_value'] ?? []; } // Sort the media types by weight value and set the value in the form state. @@ -305,7 +305,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $element += [ '#type' => 'fieldset', '#cardinality' => $this->fieldDefinition->getFieldStorageDefinition()->getCardinality(), - '#target_bundles' => isset($settings['target_bundles']) ? $settings['target_bundles'] : FALSE, + '#target_bundles' => $settings['target_bundles'] ?? FALSE, '#attributes' => [ 'id' => $wrapper_id, 'class' => ['js-media-library-widget'], @@ -632,7 +632,7 @@ protected function getNoMediaTypesAvailableMessage() { * {@inheritdoc} */ public function errorElement(array $element, ConstraintViolationInterface $error, array $form, FormStateInterface $form_state) { - return isset($element['target_id']) ? $element['target_id'] : FALSE; + return $element['target_id'] ?? FALSE; } /** @@ -916,10 +916,10 @@ protected static function getFieldState(array $element, FormStateInterface $form // is used, the unvalidated user input is not added to the form state. // @see FormValidator::handleErrorsWithLimitedValidation() $values = NestedArray::getValue($form_state->getUserInput(), $path); - $selection = isset($values['selection']) ? $values['selection'] : []; + $selection = $values['selection'] ?? []; $widget_state = static::getWidgetState($element['#field_parents'], $element['#field_name'], $form_state); - $widget_state['items'] = isset($widget_state['items']) ? $widget_state['items'] : $selection; + $widget_state['items'] = $widget_state['items'] ?? $selection; return $widget_state; } diff --git a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php index 0aec98069c..83a2a086f2 100644 --- a/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php +++ b/core/modules/menu_link_content/src/Plugin/Menu/MenuLinkContent.php @@ -134,7 +134,7 @@ protected function getEntity() { // multiple IDs added earlier in each plugin's constructor. static::$entityIdsToLoad[$entity_id] = $entity_id; $entities = $storage->loadMultiple(array_values(static::$entityIdsToLoad)); - $entity = isset($entities[$entity_id]) ? $entities[$entity_id] : NULL; + $entity = $entities[$entity_id] ?? NULL; static::$entityIdsToLoad = []; } if (!$entity) { diff --git a/core/modules/menu_link_content/tests/src/Kernel/MenuLinksTest.php b/core/modules/menu_link_content/tests/src/Kernel/MenuLinksTest.php index afe0aee563..61279cb7a7 100644 --- a/core/modules/menu_link_content/tests/src/Kernel/MenuLinksTest.php +++ b/core/modules/menu_link_content/tests/src/Kernel/MenuLinksTest.php @@ -125,7 +125,7 @@ public function assertMenuLinkParents($links, $expected_hierarchy) { foreach ($expected_hierarchy as $id => $parent) { /** @var \Drupal\Core\Menu\MenuLinkInterface $menu_link_plugin */ $menu_link_plugin = $this->menuLinkManager->createInstance($links[$id]); - $expected_parent = isset($links[$parent]) ? $links[$parent] : ''; + $expected_parent = $links[$parent] ?? ''; $this->assertEquals($expected_parent, $menu_link_plugin->getParent(), new FormattableMarkup('Menu link %id has parent of %parent, expected %expected_parent.', ['%id' => $id, '%parent' => $menu_link_plugin->getParent(), '%expected_parent' => $expected_parent])); } diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module index 090567541e..aaa7406241 100644 --- a/core/modules/menu_ui/menu_ui.module +++ b/core/modules/menu_ui/menu_ui.module @@ -114,7 +114,7 @@ function _menu_ui_node_save(NodeInterface $node, array $values) { $entity->description->value = trim($values['description']); $entity->menu_name->value = $values['menu_name']; $entity->parent->value = $values['parent']; - $entity->weight->value = isset($values['weight']) ? $values['weight'] : 0; + $entity->weight->value = $values['weight'] ?? 0; $entity->isDefaultRevision($node->isDefaultRevision()); $entity->save(); } diff --git a/core/modules/migrate/src/MigrateMessage.php b/core/modules/migrate/src/MigrateMessage.php index 4cc166c81c..bcf73ad537 100644 --- a/core/modules/migrate/src/MigrateMessage.php +++ b/core/modules/migrate/src/MigrateMessage.php @@ -23,7 +23,7 @@ class MigrateMessage implements MigrateMessageInterface { * {@inheritdoc} */ public function display($message, $type = 'status') { - $type = isset($this->map[$type]) ? $this->map[$type] : RfcLogLevel::NOTICE; + $type = $this->map[$type] ?? RfcLogLevel::NOTICE; \Drupal::logger('migrate')->log($type, $message); } diff --git a/core/modules/migrate/src/Plugin/Migration.php b/core/modules/migrate/src/Plugin/Migration.php index abad25cd45..181c8f11d0 100644 --- a/core/modules/migrate/src/Plugin/Migration.php +++ b/core/modules/migrate/src/Plugin/Migration.php @@ -411,7 +411,7 @@ public function getDestinationPlugin($stub_being_requested = FALSE) { public function getIdMap() { if (!isset($this->idMapPlugin)) { $configuration = $this->idMap; - $plugin = isset($configuration['plugin']) ? $configuration['plugin'] : 'sql'; + $plugin = $configuration['plugin'] ?? 'sql'; $this->idMapPlugin = $this->idMapPluginManager->createInstance($plugin, $configuration, $this); } return $this->idMapPlugin; @@ -656,7 +656,7 @@ public function getPluginDefinition() { // While normal plugins do not change their definitions on the fly, this // one does so accommodate for that. foreach (parent::getPluginDefinition() as $key => $value) { - $definition[$key] = isset($this->$key) ? $this->$key : $value; + $definition[$key] = $this->$key ?? $value; } return $definition; } diff --git a/core/modules/migrate/src/Plugin/MigrationPluginManager.php b/core/modules/migrate/src/Plugin/MigrationPluginManager.php index bb4f6c0be8..6f53b87f50 100644 --- a/core/modules/migrate/src/Plugin/MigrationPluginManager.php +++ b/core/modules/migrate/src/Plugin/MigrationPluginManager.php @@ -108,7 +108,7 @@ public function createInstances($migration_id, array $configuration = []) { $instances = []; foreach ($plugin_ids as $plugin_id) { - $instances[$plugin_id] = $factory->createInstance($plugin_id, isset($configuration[$plugin_id]) ? $configuration[$plugin_id] : []); + $instances[$plugin_id] = $factory->createInstance($plugin_id, $configuration[$plugin_id] ?? []); } foreach ($instances as $migration) { @@ -226,7 +226,7 @@ public function buildDependencyMigration(array $migrations, array $dynamic_ids) * The dynamic ID mapping. */ protected function addDependency(array &$graph, $id, $dependency, $dynamic_ids) { - $dependencies = isset($dynamic_ids[$dependency]) ? $dynamic_ids[$dependency] : [$dependency]; + $dependencies = $dynamic_ids[$dependency] ?? [$dependency]; if (!isset($graph[$id]['edges'])) { $graph[$id]['edges'] = []; } @@ -237,7 +237,7 @@ protected function addDependency(array &$graph, $id, $dependency, $dynamic_ids) * {@inheritdoc} */ public function createStubMigration(array $definition) { - $id = isset($definition['id']) ? $definition['id'] : uniqid(); + $id = $definition['id'] ?? uniqid(); return Migration::create(\Drupal::getContainer(), [], $id, $definition); } diff --git a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php index d96bfab70d..0e9668b54f 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php @@ -129,7 +129,7 @@ public static function create(ContainerInterface $container, array $configuratio * The bundle for this row. */ public function getBundle(Row $row) { - $default_bundle = isset($this->configuration['default_bundle']) ? $this->configuration['default_bundle'] : ''; + $default_bundle = $this->configuration['default_bundle'] ?? ''; $bundle_key = $this->getKey('bundle'); return $row->getDestinationProperty($bundle_key) ?: $default_bundle; } diff --git a/core/modules/migrate/src/Plugin/migrate/process/Concat.php b/core/modules/migrate/src/Plugin/migrate/process/Concat.php index 3490ae81e3..801d65d6c4 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Concat.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Concat.php @@ -63,7 +63,7 @@ class Concat extends ProcessPluginBase { */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { if (is_array($value)) { - $delimiter = isset($this->configuration['delimiter']) ? $this->configuration['delimiter'] : ''; + $delimiter = $this->configuration['delimiter'] ?? ''; return implode($delimiter, $value); } else { diff --git a/core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php b/core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php index b6f3839df8..05229f03d1 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php +++ b/core/modules/migrate/src/Plugin/migrate/process/DefaultValue.php @@ -53,7 +53,7 @@ class DefaultValue extends ProcessPluginBase { */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { if (!empty($this->configuration['strict'])) { - return isset($value) ? $value : $this->configuration['default_value']; + return $value ?? $this->configuration['default_value']; } return $value ?: $this->configuration['default_value']; } diff --git a/core/modules/migrate/src/Plugin/migrate/process/Explode.php b/core/modules/migrate/src/Plugin/migrate/process/Explode.php index 536a9e1b0a..b2051c2a5b 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Explode.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Explode.php @@ -117,7 +117,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable } } - $limit = isset($this->configuration['limit']) ? $this->configuration['limit'] : PHP_INT_MAX; + $limit = $this->configuration['limit'] ?? PHP_INT_MAX; return explode($this->configuration['delimiter'], $value, $limit); } diff --git a/core/modules/migrate/src/Plugin/migrate/process/FormatDate.php b/core/modules/migrate/src/Plugin/migrate/process/FormatDate.php index 150d7c1143..3bd876c3ea 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/FormatDate.php +++ b/core/modules/migrate/src/Plugin/migrate/process/FormatDate.php @@ -112,9 +112,9 @@ public function transform($value, MigrateExecutableInterface $migrate_executable $toFormat = $this->configuration['to_format']; $system_timezone = date_default_timezone_get(); $default_timezone = !empty($system_timezone) ? $system_timezone : 'UTC'; - $from_timezone = isset($this->configuration['from_timezone']) ? $this->configuration['from_timezone'] : $default_timezone; - $to_timezone = isset($this->configuration['to_timezone']) ? $this->configuration['to_timezone'] : $default_timezone; - $settings = isset($this->configuration['settings']) ? $this->configuration['settings'] : []; + $from_timezone = $this->configuration['from_timezone'] ?? $default_timezone; + $to_timezone = $this->configuration['to_timezone'] ?? $default_timezone; + $settings = $this->configuration['settings'] ?? []; // Older versions of Drupal where omitting certain granularities (also known // as "collected date attributes") resulted in invalid timestamps getting diff --git a/core/modules/migrate/src/Plugin/migrate/process/MakeUniqueBase.php b/core/modules/migrate/src/Plugin/migrate/process/MakeUniqueBase.php index 861a6b6f88..ee421b0846 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/MakeUniqueBase.php +++ b/core/modules/migrate/src/Plugin/migrate/process/MakeUniqueBase.php @@ -45,12 +45,12 @@ abstract class MakeUniqueBase extends ProcessPluginBase { */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $i = 1; - $postfix = isset($this->configuration['postfix']) ? $this->configuration['postfix'] : ''; - $start = isset($this->configuration['start']) ? $this->configuration['start'] : 0; + $postfix = $this->configuration['postfix'] ?? ''; + $start = $this->configuration['start'] ?? 0; if (!is_int($start)) { throw new MigrateException('The start position configuration key should be an integer. Omit this key to capture from the beginning of the string.'); } - $length = isset($this->configuration['length']) ? $this->configuration['length'] : NULL; + $length = $this->configuration['length'] ?? NULL; if (!is_null($length) && !is_int($length)) { throw new MigrateException('The character length configuration key should be an integer. Omit this key to capture the entire string.'); } diff --git a/core/modules/migrate/src/Plugin/migrate/process/Substr.php b/core/modules/migrate/src/Plugin/migrate/process/Substr.php index aea79121cd..c4841d7b63 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Substr.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Substr.php @@ -72,11 +72,11 @@ class Substr extends ProcessPluginBase { * {@inheritdoc} */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { - $start = isset($this->configuration['start']) ? $this->configuration['start'] : 0; + $start = $this->configuration['start'] ?? 0; if (!is_int($start)) { throw new MigrateException('The start position configuration value should be an integer. Omit this key to capture from the beginning of the string.'); } - $length = isset($this->configuration['length']) ? $this->configuration['length'] : NULL; + $length = $this->configuration['length'] ?? NULL; if ($length !== NULL && !is_int($length)) { throw new MigrateException('The character length configuration value should be an integer. Omit this key to capture from the start position to the end of the string.'); } diff --git a/core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php b/core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php index 9b269d9bf3..f24cac1f4e 100644 --- a/core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php +++ b/core/modules/migrate/tests/src/Unit/process/MakeUniqueEntityFieldTest.php @@ -72,8 +72,8 @@ public function testMakeUniqueEntityField($count, $postfix = '', $start = NULL, if ($postfix) { $configuration['postfix'] = $postfix; } - $configuration['start'] = isset($start) ? $start : NULL; - $configuration['length'] = isset($length) ? $length : NULL; + $configuration['start'] = $start ?? NULL; + $configuration['length'] = $length ?? NULL; $plugin = new MakeUniqueEntityField($configuration, 'make_unique', [], $this->getMigration(), $this->entityTypeManager); $this->entityQueryExpects($count); $value = $this->randomMachineName(32); diff --git a/core/modules/migrate_drupal/src/FieldDiscovery.php b/core/modules/migrate_drupal/src/FieldDiscovery.php index 1769885324..f1c4745ece 100644 --- a/core/modules/migrate_drupal/src/FieldDiscovery.php +++ b/core/modules/migrate_drupal/src/FieldDiscovery.php @@ -143,7 +143,7 @@ public function addBundleFieldProcesses(MigrationInterface $migration, $entity_t foreach ($bundle_fields as $field_name => $field_info) { $plugin = $this->getFieldPlugin($field_info['type'], $migration); if ($plugin) { - $method = isset($plugin_definition['field_plugin_method']) ? $plugin_definition['field_plugin_method'] : 'defineValueProcessPipeline'; + $method = $plugin_definition['field_plugin_method'] ?? 'defineValueProcessPipeline'; call_user_func_array([ $plugin, 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 54cce94105..8a2678010e 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php @@ -132,7 +132,7 @@ public function checkRequirements() { */ protected function getModuleSchemaVersion($module) { $system_data = $this->getSystemData(); - return isset($system_data['module'][$module]['schema_version']) ? $system_data['module'][$module]['schema_version'] : FALSE; + return $system_data['module'][$module]['schema_version'] ?? FALSE; } /** 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 dbb5ed67d6..95feeed792 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 @@ -33,7 +33,7 @@ protected function getFields($entity_type, $bundle = NULL) { $query = $this->select('field_config_instance', 'fci') ->fields('fci') ->condition('fci.entity_type', $entity_type) - ->condition('fci.bundle', isset($bundle) ? $bundle : $entity_type) + ->condition('fci.bundle', $bundle ?? $entity_type) ->condition('fci.deleted', 0); // Join the 'field_config' table and add the 'translatable' setting to the diff --git a/core/modules/node/src/Entity/NodeType.php b/core/modules/node/src/Entity/NodeType.php index f30c995ea1..00f3431852 100644 --- a/core/modules/node/src/Entity/NodeType.php +++ b/core/modules/node/src/Entity/NodeType.php @@ -118,7 +118,7 @@ public function id() { */ public function isLocked() { $locked = \Drupal::state()->get('node.type.locked'); - return isset($locked[$this->id()]) ? $locked[$this->id()] : FALSE; + return $locked[$this->id()] ?? FALSE; } /** diff --git a/core/modules/node/src/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php index b23112ae31..5412541a49 100644 --- a/core/modules/node/src/Plugin/Search/NodeSearch.php +++ b/core/modules/node/src/Plugin/Search/NodeSearch.php @@ -446,7 +446,7 @@ protected function addNodeRankings(SelectExtender $query) { if (isset($values['join']) && !isset($tables[$values['join']['alias']])) { $query->addJoin($values['join']['type'], $values['join']['table'], $values['join']['alias'], $values['join']['on']); } - $arguments = isset($values['arguments']) ? $values['arguments'] : []; + $arguments = $values['arguments'] ?? []; $query->addScore($values['score'], $arguments, $node_rank); } } @@ -604,7 +604,7 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) { '#title' => t('Containing any of the words'), '#size' => 30, '#maxlength' => 255, - '#default_value' => isset($defaults['or']) ? $defaults['or'] : '', + '#default_value' => $defaults['or'] ?? '', ]; $form['advanced']['keywords-fieldset']['keywords']['phrase'] = [ @@ -612,7 +612,7 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) { '#title' => t('Containing the phrase'), '#size' => 30, '#maxlength' => 255, - '#default_value' => isset($defaults['phrase']) ? $defaults['phrase'] : '', + '#default_value' => $defaults['phrase'] ?? '', ]; $form['advanced']['keywords-fieldset']['keywords']['negative'] = [ @@ -620,7 +620,7 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) { '#title' => t('Containing none of the words'), '#size' => 30, '#maxlength' => 255, - '#default_value' => isset($defaults['negative']) ? $defaults['negative'] : '', + '#default_value' => $defaults['negative'] ?? '', ]; // Add node types. @@ -635,7 +635,7 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) { '#prefix' => '
', '#suffix' => '
', '#options' => $types, - '#default_value' => isset($defaults['type']) ? $defaults['type'] : [], + '#default_value' => $defaults['type'] ?? [], ]; $form['advanced']['submit'] = [ @@ -664,7 +664,7 @@ public function searchFormAlter(array &$form, FormStateInterface $form_state) { '#prefix' => '
', '#suffix' => '
', '#options' => $language_options, - '#default_value' => isset($defaults['language']) ? $defaults['language'] : [], + '#default_value' => $defaults['language'] ?? [], ]; } } @@ -847,7 +847,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#type' => 'select', '#options' => $options, '#attributes' => ['aria-label' => $this->t("Influence of '@title'", ['@title' => $values['title']])], - '#default_value' => isset($this->configuration['rankings'][$var]) ? $this->configuration['rankings'][$var] : 0, + '#default_value' => $this->configuration['rankings'][$var] ?? 0, ]; } return $form; diff --git a/core/modules/node/src/Plugin/migrate/source/d6/Node.php b/core/modules/node/src/Plugin/migrate/source/d6/Node.php index 4fe426d890..c5367d1406 100644 --- a/core/modules/node/src/Plugin/migrate/source/d6/Node.php +++ b/core/modules/node/src/Plugin/migrate/source/d6/Node.php @@ -255,7 +255,7 @@ protected function getFieldInfo($node_type) { } } - return isset($this->fieldInfo[$node_type]) ? $this->fieldInfo[$node_type] : []; + return $this->fieldInfo[$node_type] ?? []; } /** diff --git a/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php b/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php index 1238e0ee98..c741e2742f 100644 --- a/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php +++ b/core/modules/node/src/Plugin/migrate/source/d6/NodeType.php @@ -132,7 +132,7 @@ public function prepareRow(Row $row) { $options[$item] = in_array($item, $source_options); } $row->setSourceProperty('options', $options); - $submitted = isset($this->themeSettings['toggle_node_info_' . $type]) ? $this->themeSettings['toggle_node_info_' . $type] : FALSE; + $submitted = $this->themeSettings['toggle_node_info_' . $type] ?? FALSE; $row->setSourceProperty('display_submitted', $submitted); if ($default_node_menu = $this->variableGet('menu_default_node_menu', NULL)) { diff --git a/core/modules/node/src/Plugin/views/field/Node.php b/core/modules/node/src/Plugin/views/field/Node.php index ae35363e27..f81777e421 100644 --- a/core/modules/node/src/Plugin/views/field/Node.php +++ b/core/modules/node/src/Plugin/views/field/Node.php @@ -37,7 +37,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o */ protected function defineOptions() { $options = parent::defineOptions(); - $options['link_to_node'] = ['default' => isset($this->definition['link_to_node default']) ? $this->definition['link_to_node default'] : FALSE]; + $options['link_to_node'] = ['default' => $this->definition['link_to_node default'] ?? FALSE]; return $options; } diff --git a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php index 5ad9539d3e..2283520454 100644 --- a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php +++ b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php @@ -40,7 +40,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) { $value = $item->value; // If the stored value is in the current set of allowed values, display // the associated label, otherwise just display the raw value. - $output = isset($options[$value]) ? $options[$value] : $value; + $output = $options[$value] ?? $value; $elements[$delta] = [ '#markup' => $output, '#allowed_tags' => FieldFilteredMarkup::allowedTags(), diff --git a/core/modules/path/src/Plugin/migrate/process/PathSetTranslated.php b/core/modules/path/src/Plugin/migrate/process/PathSetTranslated.php index 74ed9652d9..b982d2b348 100644 --- a/core/modules/path/src/Plugin/migrate/process/PathSetTranslated.php +++ b/core/modules/path/src/Plugin/migrate/process/PathSetTranslated.php @@ -64,7 +64,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable throw new MigrateException("The input value should be an array."); } - $path = isset($value[0]) ? $value[0] : ''; + $path = $value[0] ?? ''; $nid = (is_array($value[1]) && isset($value[1][0])) ? $value[1][0] : FALSE; if (preg_match('/^\/node\/\d+$/', $path) && $nid) { return '/node/' . $nid; diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 1c003a5163..69b5f724eb 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -170,7 +170,7 @@ function rdf_rdfa_attributes($mapping, $data = NULL) { $attributes = []; // The type of mapping defaults to 'property'. - $type = isset($mapping['mapping_type']) ? $mapping['mapping_type'] : 'property'; + $type = $mapping['mapping_type'] ?? 'property'; switch ($type) { // The mapping expresses the relationship between two resources. @@ -187,7 +187,7 @@ function rdf_rdfa_attributes($mapping, $data = NULL) { // Convert $data to a specific format as per the callback function. if (isset($data) && !empty($mapping['datatype_callback'])) { $callback = $mapping['datatype_callback']['callable']; - $arguments = isset($mapping['datatype_callback']['arguments']) ? $mapping['datatype_callback']['arguments'] : NULL; + $arguments = $mapping['datatype_callback']['arguments'] ?? NULL; $attributes['content'] = call_user_func($callback, $data, $arguments); } if (isset($mapping['datatype'])) { diff --git a/core/modules/responsive_image/src/ResponsiveImageStyleForm.php b/core/modules/responsive_image/src/ResponsiveImageStyleForm.php index 17e00500c9..7bceff174e 100644 --- a/core/modules/responsive_image/src/ResponsiveImageStyleForm.php +++ b/core/modules/responsive_image/src/ResponsiveImageStyleForm.php @@ -141,7 +141,7 @@ public function form(array $form, FormStateInterface $form_state) { 'image_style' => $this->t('Select a single image style.'), '_none' => $this->t('Do not use this breakpoint.'), ], - '#default_value' => isset($image_style_mapping['image_mapping_type']) ? $image_style_mapping['image_mapping_type'] : '_none', + '#default_value' => $image_style_mapping['image_mapping_type'] ?? '_none', '#description' => $description, ]; $form['keyed_styles'][$breakpoint_id][$multiplier]['image_style'] = [ @@ -159,7 +159,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['keyed_styles'][$breakpoint_id][$multiplier]['sizes'] = [ '#type' => 'textarea', '#title' => $this->t('Sizes'), - '#default_value' => isset($image_style_mapping['image_mapping']['sizes']) ? $image_style_mapping['image_mapping']['sizes'] : '100vw', + '#default_value' => $image_style_mapping['image_mapping']['sizes'] ?? '100vw', '#description' => $this->t('Enter the value for the sizes attribute, for example: %example_sizes.', ['%example_sizes' => '(min-width:700px) 700px, 100vw']), '#states' => [ 'visible' => [ @@ -175,7 +175,7 @@ public function form(array $form, FormStateInterface $form_state) { '#type' => 'checkboxes', '#options' => array_diff_key($image_styles, ['' => '']), '#description' => $this->t('Select image styles with widths that range from the smallest amount of space this image will take up in the layout to the largest, bearing in mind that high resolution screens will need images 1.5x to 2x larger.'), - '#default_value' => isset($image_style_mapping['image_mapping']['sizes_image_styles']) ? $image_style_mapping['image_mapping']['sizes_image_styles'] : [], + '#default_value' => $image_style_mapping['image_mapping']['sizes_image_styles'] ?? [], '#states' => [ 'visible' => [ ':input[name="keyed_styles[' . $breakpoint_id . '][' . $multiplier . '][image_mapping_type]"]' => ['value' => 'sizes'], diff --git a/core/modules/rest/src/Plugin/ResourceBase.php b/core/modules/rest/src/Plugin/ResourceBase.php index b7c4ab41c0..0c64978df8 100644 --- a/core/modules/rest/src/Plugin/ResourceBase.php +++ b/core/modules/rest/src/Plugin/ResourceBase.php @@ -99,8 +99,8 @@ public function routes() { $collection = new RouteCollection(); $definition = $this->getPluginDefinition(); - $canonical_path = isset($definition['uri_paths']['canonical']) ? $definition['uri_paths']['canonical'] : '/' . strtr($this->pluginId, ':', '/') . '/{id}'; - $create_path = isset($definition['uri_paths']['create']) ? $definition['uri_paths']['create'] : '/' . strtr($this->pluginId, ':', '/'); + $canonical_path = $definition['uri_paths']['canonical'] ?? '/' . strtr($this->pluginId, ':', '/') . '/{id}'; + $create_path = $definition['uri_paths']['create'] ?? '/' . strtr($this->pluginId, ':', '/'); $route_name = strtr($this->pluginId, ':', '.'); diff --git a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php index 9b9e28573e..b328e452e0 100644 --- a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php +++ b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php @@ -94,14 +94,14 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('Alias for @id', ['@id' => $id]), '#title_display' => 'invisible', '#type' => 'textfield', - '#default_value' => isset($options[$id]['alias']) ? $options[$id]['alias'] : '', + '#default_value' => $options[$id]['alias'] ?? '', '#element_validate' => [[$this, 'validateAliasName']], ]; $form['field_options'][$id]['raw_output'] = [ '#title' => $this->t('Raw output for @id', ['@id' => $id]), '#title_display' => 'invisible', '#type' => 'checkbox', - '#default_value' => isset($options[$id]['raw_output']) ? $options[$id]['raw_output'] : '', + '#default_value' => $options[$id]['raw_output'] ?? '', ]; } } @@ -189,7 +189,7 @@ public function getFieldKeyAlias($id) { */ protected static function extractFromOptionsArray($key, $options) { return array_map(function ($item) use ($key) { - return isset($item[$key]) ? $item[$key] : NULL; + return $item[$key] ?? NULL; }, $options); } diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc index 8db7d159f2..a9e49ffc21 100644 --- a/core/modules/search/search.pages.inc +++ b/core/modules/search/search.pages.inc @@ -49,7 +49,7 @@ function template_preprocess_search_result(&$variables) { $info = array_merge($info, $result['extra']); } // Check for existence. User search does not include snippets. - $variables['snippet'] = isset($result['snippet']) ? $result['snippet'] : ''; + $variables['snippet'] = $result['snippet'] ?? ''; // Provide separated and grouped meta information.. $variables['info_split'] = $info; $variables['info'] = [ diff --git a/core/modules/serialization/src/Normalizer/DateTimeIso8601Normalizer.php b/core/modules/serialization/src/Normalizer/DateTimeIso8601Normalizer.php index c70c43d8bb..f4eaa03448 100644 --- a/core/modules/serialization/src/Normalizer/DateTimeIso8601Normalizer.php +++ b/core/modules/serialization/src/Normalizer/DateTimeIso8601Normalizer.php @@ -58,7 +58,7 @@ public function denormalize($data, $class, $format = NULL, array $context = []) // @todo Move the date-only handling out of here in https://www.drupal.org/project/drupal/issues/2958416. $field_definition = isset($context['target_instance']) ? $context['target_instance']->getFieldDefinition() - : (isset($context['field_definition']) ? $context['field_definition'] : NULL); + : ($context['field_definition'] ?? NULL); if ($field_definition === NULL) { throw new InvalidArgumentException('$context[\'target_instance\'] or $context[\'field_definition\'] must be set to denormalize with the DateTimeIso8601Normalizer'); } diff --git a/core/modules/serialization/src/Normalizer/DateTimeNormalizer.php b/core/modules/serialization/src/Normalizer/DateTimeNormalizer.php index b84e170d6b..42a715092b 100644 --- a/core/modules/serialization/src/Normalizer/DateTimeNormalizer.php +++ b/core/modules/serialization/src/Normalizer/DateTimeNormalizer.php @@ -96,9 +96,7 @@ public function denormalize($data, $class, $format = NULL, array $context = []) // input data if it matches the defined pattern. Since the formats are // unambiguous (i.e., they reference an absolute time with a defined time // zone), only one will ever match. - $allowed_formats = isset($context['datetime_allowed_formats']) - ? $context['datetime_allowed_formats'] - : $this->allowedFormats; + $allowed_formats = $context['datetime_allowed_formats'] ?? $this->allowedFormats; foreach ($allowed_formats as $format) { $date = \DateTime::createFromFormat($format, $data); $errors = \DateTime::getLastErrors(); diff --git a/core/modules/serialization/src/Normalizer/FieldableEntityNormalizerTrait.php b/core/modules/serialization/src/Normalizer/FieldableEntityNormalizerTrait.php index c35ed41add..379d0f9d8a 100644 --- a/core/modules/serialization/src/Normalizer/FieldableEntityNormalizerTrait.php +++ b/core/modules/serialization/src/Normalizer/FieldableEntityNormalizerTrait.php @@ -101,7 +101,7 @@ protected function extractBundleData(array &$data, EntityTypeInterface $entity_t $key_id = isset($base_field_definitions[$bundle_key]) ? $base_field_definitions[$bundle_key]->getFieldStorageDefinition()->getMainPropertyName() : 'value'; // Normalize the bundle if it is not explicitly set. - $bundle_value = isset($data[$bundle_key][0][$key_id]) ? $data[$bundle_key][0][$key_id] : (isset($data[$bundle_key]) ? $data[$bundle_key] : NULL); + $bundle_value = $data[$bundle_key][0][$key_id] ?? ($data[$bundle_key] ?? NULL); // Unset the bundle from the data. unset($data[$bundle_key]); diff --git a/core/modules/serialization/src/RegisterEntityResolversCompilerPass.php b/core/modules/serialization/src/RegisterEntityResolversCompilerPass.php index 483ad43efe..2e61158dda 100644 --- a/core/modules/serialization/src/RegisterEntityResolversCompilerPass.php +++ b/core/modules/serialization/src/RegisterEntityResolversCompilerPass.php @@ -23,7 +23,7 @@ public function process(ContainerBuilder $container) { // Retrieve registered Normalizers and Encoders from the container. foreach ($container->findTaggedServiceIds('entity_resolver') as $id => $attributes) { - $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $priority = $attributes[0]['priority'] ?? 0; $resolvers[$priority][] = new Reference($id); } diff --git a/core/modules/serialization/src/RegisterSerializationClassesCompilerPass.php b/core/modules/serialization/src/RegisterSerializationClassesCompilerPass.php index eba01ba918..3071c59d60 100644 --- a/core/modules/serialization/src/RegisterSerializationClassesCompilerPass.php +++ b/core/modules/serialization/src/RegisterSerializationClassesCompilerPass.php @@ -25,14 +25,14 @@ public function process(ContainerBuilder $container) { // The 'serializer' service is the public API: mark normalizers private. $container->getDefinition($id)->setPublic(FALSE); - $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $priority = $attributes[0]['priority'] ?? 0; $normalizers[$priority][] = new Reference($id); } foreach ($container->findTaggedServiceIds('encoder') as $id => $attributes) { // The 'serializer' service is the public API: mark encoders private. $container->getDefinition($id)->setPublic(FALSE); - $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + $priority = $attributes[0]['priority'] ?? 0; $encoders[$priority][] = new Reference($id); } diff --git a/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php b/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php index 636db2008c..bdec9903df 100644 --- a/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php +++ b/core/modules/shortcut/tests/src/Functional/ShortcutTestBase.php @@ -110,7 +110,7 @@ protected function setUp() { */ public function generateShortcutSet($label = '', $id = NULL) { $set = ShortcutSet::create([ - 'id' => isset($id) ? $id : strtolower($this->randomMachineName()), + 'id' => $id ?? strtolower($this->randomMachineName()), 'label' => empty($label) ? $this->randomString() : $label, ]); $set->save(); diff --git a/core/modules/system/src/Controller/BatchController.php b/core/modules/system/src/Controller/BatchController.php index 038b133301..761c32a08d 100644 --- a/core/modules/system/src/Controller/BatchController.php +++ b/core/modules/system/src/Controller/BatchController.php @@ -61,7 +61,7 @@ public function batchPage(Request $request) { return $output; } elseif (isset($output)) { - $title = isset($output['#title']) ? $output['#title'] : NULL; + $title = $output['#title'] ?? NULL; $page = [ '#type' => 'page', '#title' => $title, diff --git a/core/modules/system/src/Controller/DbUpdateController.php b/core/modules/system/src/Controller/DbUpdateController.php index 8111de2471..145e4a7723 100644 --- a/core/modules/system/src/Controller/DbUpdateController.php +++ b/core/modules/system/src/Controller/DbUpdateController.php @@ -191,7 +191,7 @@ public function handle($op, Request $request) { if ($output instanceof Response) { return $output; } - $title = isset($output['#title']) ? $output['#title'] : $this->t('Drupal database update'); + $title = $output['#title'] ?? $this->t('Drupal database update'); return $this->bareHtmlPageRenderer->renderBarePage($output, $title, 'maintenance_page', $regions); } diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php index cf84a71a2c..75a8005b21 100644 --- a/core/modules/system/src/Form/ModulesListForm.php +++ b/core/modules/system/src/Form/ModulesListForm.php @@ -275,7 +275,7 @@ protected function buildRow(array $modules, Extension $module, $distribution) { // Generate link for module's configuration page, if it has one. if ($module->status && isset($module->info['configure'])) { - $route_parameters = isset($module->info['configure_parameters']) ? $module->info['configure_parameters'] : []; + $route_parameters = $module->info['configure_parameters'] ?? []; if ($this->accessManager->checkNamedRoute($module->info['configure'], $route_parameters, $this->currentUser)) { $row['links']['configure'] = [ '#type' => 'link', @@ -319,7 +319,7 @@ protected function buildRow(array $modules, Extension $module, $distribution) { '@core_version' => \Drupal::VERSION, ]); $row['#requires']['core'] = $this->t('Drupal Core (@core_requirement) (incompatible with version @core_version)', [ - '@core_requirement' => isset($module->info['core_version_requirement']) ? $module->info['core_version_requirement'] : $module->info['core'], + '@core_requirement' => $module->info['core_version_requirement'] ?? $module->info['core'], '@core_version' => \Drupal::VERSION, ]); } diff --git a/core/modules/system/src/Form/ThemeExperimentalConfirmForm.php b/core/modules/system/src/Form/ThemeExperimentalConfirmForm.php index d83cd422ef..c9c9937751 100644 --- a/core/modules/system/src/Form/ThemeExperimentalConfirmForm.php +++ b/core/modules/system/src/Form/ThemeExperimentalConfirmForm.php @@ -134,8 +134,8 @@ public function buildForm(array $form, FormStateInterface $form_state) { */ public function submitForm(array &$form, FormStateInterface $form_state) { $args = $form_state->getBuildInfo()['args']; - $theme = isset($args[0]) ? $args[0] : NULL; - $set_default = isset($args[1]) ? $args[1] : FALSE; + $theme = $args[0] ?? NULL; + $set_default = $args[1] ?? FALSE; $themes = $this->themeList->getList(); $config = $this->configFactory()->getEditable('system.theme'); try { diff --git a/core/modules/system/src/Form/ThemeSettingsForm.php b/core/modules/system/src/Form/ThemeSettingsForm.php index 03e4a4a33c..5375abcfae 100644 --- a/core/modules/system/src/Form/ThemeSettingsForm.php +++ b/core/modules/system/src/Form/ThemeSettingsForm.php @@ -314,7 +314,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $theme = } $element['#description'] = $this->t('Examples: @implicit-public-file (for a file in the public filesystem), @explicit-file, or @local-file.', [ - '@implicit-public-file' => isset($friendly_path) ? $friendly_path : $default, + '@implicit-public-file' => $friendly_path ?? $default, '@explicit-file' => StreamWrapperManager::getScheme($original_path) !== FALSE ? $original_path : 'public://' . $default, '@local-file' => $local_file, ]); diff --git a/core/modules/system/src/PhpStorage/MockPhpStorage.php b/core/modules/system/src/PhpStorage/MockPhpStorage.php index faac373b9e..cb3c42f8a4 100644 --- a/core/modules/system/src/PhpStorage/MockPhpStorage.php +++ b/core/modules/system/src/PhpStorage/MockPhpStorage.php @@ -34,7 +34,7 @@ public function getConfiguration() { * Gets a single configuration key. */ public function getConfigurationValue($key) { - return isset($this->configuration[$key]) ? $this->configuration[$key] : NULL; + return $this->configuration[$key] ?? NULL; } } diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 9c577d0f98..f7f0eab37a 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -300,7 +300,7 @@ function template_preprocess_system_themes_page(&$variables) { $current_theme['attributes'] = new Attribute(); $current_theme['name'] = $theme->info['name']; - $current_theme['version'] = isset($theme->info['version']) ? $theme->info['version'] : ''; + $current_theme['version'] = $theme->info['version'] ?? ''; $current_theme['notes'] = $theme->notes; $current_theme['is_default'] = $theme->is_default; $current_theme['is_admin'] = $theme->is_admin; diff --git a/core/modules/system/system.module b/core/modules/system/system.module index f6481d8ff6..814a66edee 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -937,7 +937,7 @@ function system_system_info_alter(&$info, Extension $file, $type) { */ function system_default_region($theme) { $regions = array_keys(system_region_list($theme, REGIONS_VISIBLE)); - return isset($regions[0]) ? $regions[0] : ''; + return $regions[0] ?? ''; } /** diff --git a/core/modules/system/tests/modules/dialog_renderer_test/src/Render/MainContent/WideModalRenderer.php b/core/modules/system/tests/modules/dialog_renderer_test/src/Render/MainContent/WideModalRenderer.php index aecb4dd0de..88f304e2bd 100644 --- a/core/modules/system/tests/modules/dialog_renderer_test/src/Render/MainContent/WideModalRenderer.php +++ b/core/modules/system/tests/modules/dialog_renderer_test/src/Render/MainContent/WideModalRenderer.php @@ -56,7 +56,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch $response->setAttachments($main_content['#attached']); // If the main content doesn't provide a title, use the title resolver. - $title = isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject()); + $title = $main_content['#title'] ?? $this->titleResolver->getTitle($request, $route_match->getRouteObject()); // Determine the title: use the title provided by the main content if any, // otherwise get it from the routing information. diff --git a/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockUserLoginBlock.php b/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockUserLoginBlock.php index 6741eac964..f9354820a4 100644 --- a/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockUserLoginBlock.php +++ b/core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockUserLoginBlock.php @@ -20,7 +20,7 @@ class MockUserLoginBlock extends PluginBase { public function __construct(array $configuration, $plugin_id, $plugin_definition) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->title = isset($configuration['title']) ? $configuration['title'] : ''; + $this->title = $configuration['title'] ?? ''; } public function getTitle() { diff --git a/core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php b/core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php index 350d145302..206bf394b4 100644 --- a/core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php +++ b/core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php @@ -49,8 +49,8 @@ protected function applyEntityUpdates($entity_type_id = NULL) { $original_storage_definitions = \Drupal::service('entity.last_installed_schema.repository')->getLastInstalledFieldStorageDefinitions($entity_type_id); foreach ($change_list['field_storage_definitions'] as $field_name => $change) { - $storage_definition = isset($storage_definitions[$field_name]) ? $storage_definitions[$field_name] : NULL; - $original_storage_definition = isset($original_storage_definitions[$field_name]) ? $original_storage_definitions[$field_name] : NULL; + $storage_definition = $storage_definitions[$field_name] ?? NULL; + $original_storage_definition = $original_storage_definitions[$field_name] ?? NULL; $this->doFieldUpdate($change, $storage_definition, $original_storage_definition); } } diff --git a/core/modules/system/tests/src/Functional/Form/FormTest.php b/core/modules/system/tests/src/Functional/Form/FormTest.php index 74dd371a1e..4d3becca52 100644 --- a/core/modules/system/tests/src/Functional/Form/FormTest.php +++ b/core/modules/system/tests/src/Functional/Form/FormTest.php @@ -651,8 +651,8 @@ public function testNumber() { // Create placeholder array. $placeholders = [ '%name' => $form[$element]['#title'], - '%min' => isset($form[$element]['#min']) ? $form[$element]['#min'] : '0', - '%max' => isset($form[$element]['#max']) ? $form[$element]['#max'] : '0', + '%min' => $form[$element]['#min'] ?? '0', + '%max' => $form[$element]['#max'] ?? '0', ]; foreach ($error_messages as $id => $message) { @@ -860,7 +860,7 @@ public function testDisabledMarkup() { $element = $this->xpath($path, [ ':name' => Html::escape($name), ':div-class' => $class, - ':value' => isset($item['#value']) ? $item['#value'] : '', + ':value' => $item['#value'] ?? '', ]); $this->assertTrue(isset($element[0]), new FormattableMarkup('Disabled form element class found for #type %type.', ['%type' => $item['#type']])); } diff --git a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php index 720ff0850b..30575f2abe 100644 --- a/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php +++ b/core/modules/system/tests/src/Kernel/Block/SystemMenuBlockTest.php @@ -226,7 +226,7 @@ public function testConfigLevelDepth() { $no_active_trail_expectations['level_3_and_beyond'] = []; foreach ($blocks as $id => $block) { $block_build = $block->build(); - $items = isset($block_build['#items']) ? $block_build['#items'] : []; + $items = $block_build['#items'] ?? []; $this->assertSame($no_active_trail_expectations[$id], $this->convertBuiltMenuToIdTree($items), new FormattableMarkup('Menu block %id with no active trail renders the expected tree.', ['%id' => $id])); } @@ -278,7 +278,7 @@ public function testConfigLevelDepth() { $active_trail_expectations['level_3_and_beyond'] = $active_trail_expectations['level_3_only']; foreach ($blocks as $id => $block) { $block_build = $block->build(); - $items = isset($block_build['#items']) ? $block_build['#items'] : []; + $items = $block_build['#items'] ?? []; $this->assertSame($active_trail_expectations[$id], $this->convertBuiltMenuToIdTree($items), new FormattableMarkup('Menu block %id with an active trail renders the expected tree.', ['%id' => $id])); } } @@ -305,7 +305,7 @@ public function testConfigExpanded($active_route, $menu_block_level, $expected_i $this->container->get('request_stack')->push($request); $block_build = $block->build(); - $items = isset($block_build['#items']) ? $block_build['#items'] : []; + $items = $block_build['#items'] ?? []; $this->assertEquals($expected_items, $this->convertBuiltMenuToIdTree($items)); } diff --git a/core/modules/taxonomy/src/Form/OverviewTerms.php b/core/modules/taxonomy/src/Form/OverviewTerms.php index a7a38cbbcf..0b918bf731 100644 --- a/core/modules/taxonomy/src/Form/OverviewTerms.php +++ b/core/modules/taxonomy/src/Form/OverviewTerms.php @@ -192,7 +192,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Vocabular } } } - $back_step = isset($back_step) ? $back_step : 0; + $back_step = $back_step ?? 0; // Continue rendering the tree until we reach the a new root item. if ($page_entries >= $page_increment + $back_step + 1 && $term->depth == 0 && $root_entries > 1) { diff --git a/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepthModifier.php b/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepthModifier.php index b1822dedda..65af6623be 100644 --- a/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepthModifier.php +++ b/core/modules/taxonomy/src/Plugin/views/argument/IndexTidDepthModifier.php @@ -23,7 +23,7 @@ public function query($group_by = FALSE) {} public function preQuery() { // We don't know our argument yet, but it's based upon our position: - $argument = isset($this->view->args[$this->position]) ? $this->view->args[$this->position] : NULL; + $argument = $this->view->args[$this->position] ?? NULL; if (!is_numeric($argument)) { return; } diff --git a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php index 93d0ab3978..805f56b8c2 100644 --- a/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php +++ b/core/modules/taxonomy/src/Plugin/views/field/TaxonomyIndexTid.php @@ -170,7 +170,7 @@ protected function documentSelfTokens(&$tokens) { protected function addSelfTokens(&$tokens, $item) { foreach (['tid', 'name', 'vocabulary_vid', 'vocabulary'] as $token) { - $tokens['{{ ' . $this->options['id'] . '__' . $token . ' }}'] = isset($item[$token]) ? $item[$token] : ''; + $tokens['{{ ' . $this->options['id'] . '__' . $token . ' }}'] = $item[$token] ?? ''; } } diff --git a/core/modules/text/src/Plugin/migrate/field/d6/TextField.php b/core/modules/text/src/Plugin/migrate/field/d6/TextField.php index e279332a57..59c5ab57ed 100644 --- a/core/modules/text/src/Plugin/migrate/field/d6/TextField.php +++ b/core/modules/text/src/Plugin/migrate/field/d6/TextField.php @@ -47,7 +47,7 @@ public function getFieldFormatterMap() { * {@inheritdoc} */ public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $field_info) { - $widget_type = isset($field_info['widget_type']) ? $field_info['widget_type'] : $field_info['widget']['type']; + $widget_type = $field_info['widget_type'] ?? $field_info['widget']['type']; if ($widget_type == 'optionwidgets_onoff') { $process = [ diff --git a/core/modules/tour/src/Entity/Tour.php b/core/modules/tour/src/Entity/Tour.php index feca0585b0..1700682632 100644 --- a/core/modules/tour/src/Entity/Tour.php +++ b/core/modules/tour/src/Entity/Tour.php @@ -147,7 +147,7 @@ public function hasMatchingRoute($route_name, $route_params) { if (!isset($this->keyedRoutes)) { $this->keyedRoutes = []; foreach ($this->getRoutes() as $route) { - $this->keyedRoutes[$route['route_name']] = isset($route['route_params']) ? $route['route_params'] : []; + $this->keyedRoutes[$route['route_name']] = $route['route_params'] ?? []; } } if (!isset($this->keyedRoutes[$route_name])) { diff --git a/core/modules/tour/src/Plugin/HelpSection/TourHelpSection.php b/core/modules/tour/src/Plugin/HelpSection/TourHelpSection.php index ab9fc8e39f..4716af4271 100644 --- a/core/modules/tour/src/Plugin/HelpSection/TourHelpSection.php +++ b/core/modules/tour/src/Plugin/HelpSection/TourHelpSection.php @@ -99,7 +99,7 @@ public function listTopics() { // out with a missing parameter exception if the route leads to a set // of pages instead of a single page. try { - $params = isset($route['route_params']) ? $route['route_params'] : []; + $params = $route['route_params'] ?? []; $url = Url::fromRoute($route['route_name'], $params); // Skip this route if the current user cannot access it. if (!$url->access()) { diff --git a/core/modules/update/update.install b/core/modules/update/update.install index 4c4fdc1633..d811f3a9ed 100644 --- a/core/modules/update/update.install +++ b/core/modules/update/update.install @@ -155,7 +155,7 @@ function _update_requirement_check($project, $type) { case UpdateFetcherInterface::NOT_CHECKED: case UpdateFetcherInterface::NOT_FETCHED: case UpdateFetcherInterface::FETCH_PENDING: - $requirement_label = isset($project['reason']) ? $project['reason'] : t('Can not determine status'); + $requirement_label = $project['reason'] ?? t('Can not determine status'); $requirement['severity'] = REQUIREMENT_WARNING; break; diff --git a/core/modules/user/src/Controller/UserController.php b/core/modules/user/src/Controller/UserController.php index dd172448ac..9ab895972c 100644 --- a/core/modules/user/src/Controller/UserController.php +++ b/core/modules/user/src/Controller/UserController.php @@ -343,7 +343,7 @@ public function confirmCancel(UserInterface $user, $timestamp = 0, $hashed_pass // Validate expiration and hashed password/login. if ($timestamp <= $current && $current - $timestamp < $timeout && $user->id() && $timestamp >= $user->getLastLoginTime() && hash_equals($hashed_pass, user_pass_rehash($user, $timestamp))) { $edit = [ - 'user_cancel_notify' => isset($account_data['cancel_notify']) ? $account_data['cancel_notify'] : $this->config('user.settings')->get('notify.status_canceled'), + 'user_cancel_notify' => $account_data['cancel_notify'] ?? $this->config('user.settings')->get('notify.status_canceled'), ]; user_cancel($edit, $user->id(), $account_data['cancel_method']); // Since user_cancel() is not invoked via Form API, batch processing diff --git a/core/modules/user/src/Plugin/migrate/process/UserUpdate8002.php b/core/modules/user/src/Plugin/migrate/process/UserUpdate8002.php index 7a67c466e3..9ba582d46b 100644 --- a/core/modules/user/src/Plugin/migrate/process/UserUpdate8002.php +++ b/core/modules/user/src/Plugin/migrate/process/UserUpdate8002.php @@ -26,7 +26,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable 1 => 'anonymous', 2 => 'authenticated', ]; - return isset($map[$rid]) ? $map[$rid] : $value; + return $map[$rid] ?? $value; } } diff --git a/core/modules/user/src/Plugin/migrate/source/d6/UserPictureFile.php b/core/modules/user/src/Plugin/migrate/source/d6/UserPictureFile.php index 60e38e8e4d..f6dd33fc88 100644 --- a/core/modules/user/src/Plugin/migrate/source/d6/UserPictureFile.php +++ b/core/modules/user/src/Plugin/migrate/source/d6/UserPictureFile.php @@ -51,7 +51,7 @@ public function query() { * {@inheritdoc} */ public function initializeIterator() { - $site_path = isset($this->configuration['site_path']) ? $this->configuration['site_path'] : 'sites/default'; + $site_path = $this->configuration['site_path'] ?? 'sites/default'; $this->filePath = $this->variableGet('file_directory_path', $site_path . '/files') . '/'; $this->tempFilePath = $this->variableGet('file_directory_temp', '/tmp') . '/'; return parent::initializeIterator(); diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 5206957f94..71675834c1 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -517,7 +517,7 @@ function user_user_logout(AccountInterface $account) { */ function user_pass_reset_url($account, $options = []) { $timestamp = REQUEST_TIME; - $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode(); + $langcode = $options['langcode'] ?? $account->getPreferredLangcode(); return Url::fromRoute('user.reset', [ 'uid' => $account->id(), @@ -550,7 +550,7 @@ function user_pass_reset_url($account, $options = []) { */ function user_cancel_url(UserInterface $account, $options = []) { $timestamp = REQUEST_TIME; - $langcode = isset($options['langcode']) ? $options['langcode'] : $account->getPreferredLangcode(); + $langcode = $options['langcode'] ?? $account->getPreferredLangcode(); $url_options = ['absolute' => TRUE, 'language' => \Drupal::languageManager()->getLanguage($langcode)]; return Url::fromRoute('user.cancel_confirm', [ 'user' => $account->id(), diff --git a/core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php b/core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php index f769f73395..d5ffcce36a 100644 --- a/core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php +++ b/core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php @@ -60,9 +60,7 @@ protected function getLangcodeTable(QueryPluginBase $query, $relationship) { // use the revision table or the revision data table, depending on which one // is being used as query base table. if ($this->entityType->isRevisionable()) { - $query_base_table = isset($query->relationships[$relationship]['base']) ? - $query->relationships[$relationship]['base'] : - $this->view->storage->get('base_table'); + $query_base_table = $query->relationships[$relationship]['base'] ?? $this->view->storage->get('base_table'); $revision_table = $storage->getRevisionTable(); $revision_data_table = $storage->getRevisionDataTable(); if ($query_base_table === $revision_table) { @@ -104,7 +102,7 @@ public function render(ResultRow $row) { * {@inheritdoc} */ public function getLangcode(ResultRow $row) { - return isset($row->{$this->langcodeAlias}) ? $row->{$this->langcodeAlias} : $this->languageManager->getDefaultLanguage()->getId(); + return $row->{$this->langcodeAlias} ?? $this->languageManager->getDefaultLanguage()->getId(); } /** diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index 1a19469951..0069beee7e 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -245,7 +245,7 @@ public function unpackOptions(&$storage, $options, $definition = NULL, $all = TR continue; } - $this->unpackOptions($storage[$key], $value, isset($definition[$key]['contains']) ? $definition[$key]['contains'] : [], $all, FALSE); + $this->unpackOptions($storage[$key], $value, $definition[$key]['contains'] ?? [], $all, FALSE); } elseif ($all || !empty($definition[$key])) { $storage[$key] = $value; diff --git a/core/modules/views/src/Plugin/views/area/AreaPluginBase.php b/core/modules/views/src/Plugin/views/area/AreaPluginBase.php index 476a808cd1..a1a9ccf87a 100644 --- a/core/modules/views/src/Plugin/views/area/AreaPluginBase.php +++ b/core/modules/views/src/Plugin/views/area/AreaPluginBase.php @@ -84,7 +84,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['empty'] = [ '#type' => 'checkbox', '#title' => $this->t('Display even if view has no result'), - '#default_value' => isset($this->options['empty']) ? $this->options['empty'] : 0, + '#default_value' => $this->options['empty'] ?? 0, ]; } } diff --git a/core/modules/views/src/Plugin/views/area/Result.php b/core/modules/views/src/Plugin/views/area/Result.php index e8d1947732..0c36c8bcf1 100644 --- a/core/modules/views/src/Plugin/views/area/Result.php +++ b/core/modules/views/src/Plugin/views/area/Result.php @@ -81,7 +81,7 @@ public function render($empty = FALSE) { $per_page = (int) $this->view->getItemsPerPage(); // @TODO: Maybe use a possible is views empty functionality. // Not every view has total_rows set, use view->result instead. - $total = isset($this->view->total_rows) ? $this->view->total_rows : count($this->view->result); + $total = $this->view->total_rows ?? count($this->view->result); $label = Html::escape($this->view->storage->label()); // If there is no result the "start" and "current_record_count" should be // equal to 0. To have the same calculation logic, we use a "start offset" diff --git a/core/modules/views/src/Plugin/views/area/Text.php b/core/modules/views/src/Plugin/views/area/Text.php index aafcbf2095..c62d4646ef 100644 --- a/core/modules/views/src/Plugin/views/area/Text.php +++ b/core/modules/views/src/Plugin/views/area/Text.php @@ -38,7 +38,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#type' => 'text_format', '#default_value' => $this->options['content']['value'], '#rows' => 6, - '#format' => isset($this->options['content']['format']) ? $this->options['content']['format'] : filter_default_format(), + '#format' => $this->options['content']['format'] ?? filter_default_format(), '#editor' => FALSE, ]; } @@ -58,7 +58,7 @@ public function preQuery() { * {@inheritdoc} */ public function render($empty = FALSE) { - $format = isset($this->options['content']['format']) ? $this->options['content']['format'] : filter_default_format(); + $format = $this->options['content']['format'] ?? filter_default_format(); if (!$empty || !empty($this->options['empty'])) { return [ '#type' => 'processed_text', diff --git a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php index 628b6f7a58..3da81eb1a2 100644 --- a/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php +++ b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php @@ -89,7 +89,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o public function isException($arg = NULL) { if (!isset($arg)) { - $arg = isset($this->argument) ? $this->argument : NULL; + $arg = $this->argument ?? NULL; } return !empty($this->options['exception']['value']) && $this->options['exception']['value'] === $arg; } @@ -1066,7 +1066,7 @@ public function getValue() { $position++; } - $arg = isset($this->view->args[$position]) ? $this->view->args[$position] : NULL; + $arg = $this->view->args[$position] ?? NULL; $this->position = $position; // Clone ourselves so that we don't break things when we're really @@ -1123,7 +1123,7 @@ public function getPlugin($type = 'argument_default', $name = NULL) { // we only fetch the options if we're fetching the plugin actually // in use. if ($name == $plugin_name) { - $options = isset($this->options[$options_name]) ? $this->options[$options_name] : []; + $options = $this->options[$options_name] ?? []; } $plugin = Views::pluginManager($type)->createInstance($name); @@ -1171,11 +1171,11 @@ public static function processContainerRadios($element) { // The key is sanitized in drupal_attributes() during output from the // theme function. '#return_value' => $key, - '#default_value' => isset($element['#default_value']) ? $element['#default_value'] : NULL, + '#default_value' => $element['#default_value'] ?? NULL, '#attributes' => $element['#attributes'], '#parents' => $element['#parents'], '#id' => Html::getUniqueId('edit-' . implode('-', $parents_for_id)), - '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL, + '#ajax' => $element['#ajax'] ?? NULL, ]; $element[$key . '_options'] = [ '#type' => 'container', diff --git a/core/modules/views/src/Plugin/views/argument/LanguageArgument.php b/core/modules/views/src/Plugin/views/argument/LanguageArgument.php index 2eb1870ed1..24dfcd967b 100644 --- a/core/modules/views/src/Plugin/views/argument/LanguageArgument.php +++ b/core/modules/views/src/Plugin/views/argument/LanguageArgument.php @@ -42,7 +42,7 @@ public function title() { */ public function language($langcode) { $languages = $this->listLanguages(); - return isset($languages[$langcode]) ? $languages[$langcode] : $this->t('Unknown language'); + return $languages[$langcode] ?? $this->t('Unknown language'); } } diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php index 66df4a6e46..8cbb2fd343 100644 --- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php @@ -110,7 +110,7 @@ public function cacheSet($type) { case 'results': $data = [ 'result' => $this->prepareViewResult($this->view->result), - 'total_rows' => isset($this->view->total_rows) ? $this->view->total_rows : 0, + 'total_rows' => $this->view->total_rows ?? 0, 'current_page' => $this->view->getCurrentPage(), ]; $expire = ($this->cacheSetMaxAge($type) === Cache::PERMANENT) ? Cache::PERMANENT : (int) $this->view->getRequest()->server->get('REQUEST_TIME') + $this->cacheSetMaxAge($type); diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php index 0d89fb724b..d8ef73fc99 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -159,7 +159,7 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio foreach ($extenders as $extender) { /** @var \Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase $plugin */ if ($plugin = $manager->createInstance($extender)) { - $extender_options = isset($display_extender_options[$plugin->getPluginId()]) ? $display_extender_options[$plugin->getPluginId()] : []; + $extender_options = $display_extender_options[$plugin->getPluginId()] ?? []; $plugin->init($this->view, $this, $extender_options); $this->extenders[$extender] = $plugin; } @@ -806,7 +806,7 @@ public function getPlugin($type) { // Query plugins allow specifying a specific query class per base table. if ($type == 'query') { $views_data = Views::viewsData()->get($this->view->storage->get('base_table')); - $name = isset($views_data['table']['base']['query_id']) ? $views_data['table']['base']['query_id'] : 'views_query'; + $name = $views_data['table']['base']['query_id'] ?? 'views_query'; } else { $name = $options['type']; @@ -2205,9 +2205,9 @@ protected function applyDisplayCacheabilityMetadata(array &$element) { $cache = $this->getPlugin('cache'); (new CacheableMetadata()) - ->setCacheTags(Cache::mergeTags($this->view->getCacheTags(), isset($this->display['cache_metadata']['tags']) ? $this->display['cache_metadata']['tags'] : [])) - ->setCacheContexts(isset($this->display['cache_metadata']['contexts']) ? $this->display['cache_metadata']['contexts'] : []) - ->setCacheMaxAge(Cache::mergeMaxAges($cache->getCacheMaxAge(), isset($this->display['cache_metadata']['max-age']) ? $this->display['cache_metadata']['max-age'] : Cache::PERMANENT)) + ->setCacheTags(Cache::mergeTags($this->view->getCacheTags(), $this->display['cache_metadata']['tags'] ?? [])) + ->setCacheContexts($this->display['cache_metadata']['contexts'] ?? []) + ->setCacheMaxAge(Cache::mergeMaxAges($cache->getCacheMaxAge(), $this->display['cache_metadata']['max-age'] ?? Cache::PERMANENT)) ->merge(CacheableMetadata::createFromRenderArray($element)) ->applyTo($element); } @@ -2232,7 +2232,7 @@ public function elementPreRender(array $element) { $element['#feed_icons'] = !empty($view->feedIcons) ? $view->feedIcons : []; if ($view->display_handler->renderPager()) { - $exposed_input = isset($view->exposed_raw_input) ? $view->exposed_raw_input : NULL; + $exposed_input = $view->exposed_raw_input ?? NULL; $element['#pager'] = $view->renderPager($exposed_input); } diff --git a/core/modules/views/src/Plugin/views/display/Page.php b/core/modules/views/src/Plugin/views/display/Page.php index c0c874d9b9..e2104da8a7 100644 --- a/core/modules/views/src/Plugin/views/display/Page.php +++ b/core/modules/views/src/Plugin/views/display/Page.php @@ -348,7 +348,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { $form['menu']['weight'] = [ '#title' => $this->t('Weight'), '#type' => 'textfield', - '#default_value' => isset($menu['weight']) ? $menu['weight'] : 0, + '#default_value' => $menu['weight'] ?? 0, '#description' => $this->t('In the menu, the heavier links will sink and the lighter links will be positioned nearer the top.'), '#states' => [ 'visible' => [ diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php index 646ddcd549..840b08f71b 100644 --- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php @@ -549,7 +549,7 @@ public function getRouteName() { // Check for overridden route names. $view_route_names = $this->getAlteredRouteNames(); - return (isset($view_route_names[$view_route_key]) ? $view_route_names[$view_route_key] : "view.$view_route_key"); + return ($view_route_names[$view_route_key] ?? "view.$view_route_key"); } /** diff --git a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php index 75daffccb0..b0580a13bd 100644 --- a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php +++ b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php @@ -152,8 +152,8 @@ public function renderExposedForm($block = FALSE) { */ public function query() { $view = $this->view; - $exposed_data = isset($view->exposed_data) ? $view->exposed_data : []; - $sort_by = isset($exposed_data['sort_by']) ? $exposed_data['sort_by'] : NULL; + $exposed_data = $view->exposed_data ?? []; + $sort_by = $exposed_data['sort_by'] ?? NULL; if (!empty($sort_by)) { // Make sure the original order of sorts is preserved // (e.g. a sticky sort is often first) diff --git a/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php b/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php index 38a5283606..821fffaaed 100644 --- a/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php +++ b/core/modules/views/src/Plugin/views/exposed_form/InputRequired.php @@ -34,7 +34,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('Text on demand'), '#description' => $this->t('Text to display instead of results until the user selects and applies an exposed filter.'), '#default_value' => $this->options['text_input_required'], - '#format' => isset($this->options['text_input_required_format']) ? $this->options['text_input_required_format'] : filter_default_format(), + '#format' => $this->options['text_input_required_format'] ?? filter_default_format(), '#editor' => FALSE, ]; } diff --git a/core/modules/views/src/Plugin/views/field/Boolean.php b/core/modules/views/src/Plugin/views/field/Boolean.php index 75f097e134..ec542fc52d 100644 --- a/core/modules/views/src/Plugin/views/field/Boolean.php +++ b/core/modules/views/src/Plugin/views/field/Boolean.php @@ -56,7 +56,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o 'boolean' => [1, 0], 'unicode-yes-no' => ['✔', '✖'], ]; - $output_formats = isset($this->definition['output formats']) ? $this->definition['output formats'] : []; + $output_formats = $this->definition['output formats'] ?? []; $custom_format = ['custom' => [t('Custom')]]; $this->formats = array_merge($default_formats, $output_formats, $custom_format); } diff --git a/core/modules/views/src/Plugin/views/field/Date.php b/core/modules/views/src/Plugin/views/field/Date.php index 9d72ddae89..e33994b2eb 100644 --- a/core/modules/views/src/Plugin/views/field/Date.php +++ b/core/modules/views/src/Plugin/views/field/Date.php @@ -101,13 +101,13 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { 'inverse time span' => $this->t('Time span (past dates have "-" prepended)'), 'time span' => $this->t('Time span (with "ago/hence" appended)'), ], - '#default_value' => isset($this->options['date_format']) ? $this->options['date_format'] : 'small', + '#default_value' => $this->options['date_format'] ?? 'small', ]; $form['custom_date_format'] = [ '#type' => 'textfield', '#title' => $this->t('Custom date format'), '#description' => $this->t('If "Custom", see the PHP docs for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.'), - '#default_value' => isset($this->options['custom_date_format']) ? $this->options['custom_date_format'] : '', + '#default_value' => $this->options['custom_date_format'] ?? '', ]; // Setup #states for all possible date_formats on the custom_date_format form element. foreach (['custom', 'raw time ago', 'time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span'] as $custom_date_possible) { diff --git a/core/modules/views/src/Plugin/views/field/EntityField.php b/core/modules/views/src/Plugin/views/field/EntityField.php index 7957cb054c..0553c4d1a4 100644 --- a/core/modules/views/src/Plugin/views/field/EntityField.php +++ b/core/modules/views/src/Plugin/views/field/EntityField.php @@ -394,7 +394,7 @@ protected function defineOptions() { } $options['settings'] = [ - 'default' => isset($this->definition['default_formatter_settings']) ? $this->definition['default_formatter_settings'] : [], + 'default' => $this->definition['default_formatter_settings'] ?? [], ]; $options['group_column'] = [ 'default' => $default_column, @@ -455,7 +455,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { if (count($field->getColumns()) == 1) { $form['click_sort_column'] = [ '#type' => 'value', - '#value' => isset($column_names[0]) ? $column_names[0] : '', + '#value' => $column_names[0] ?? '', ]; } else { @@ -1078,7 +1078,7 @@ public function getValue(ResultRow $values, $field = NULL) { // Some bundles might not have a specific field, in which case the entity // (potentially a fake one) doesn't have it either. /** @var \Drupal\Core\Field\FieldItemListInterface $field_item_list */ - $field_item_list = isset($translated_entity->{$this->definition['field_name']}) ? $translated_entity->{$this->definition['field_name']} : NULL; + $field_item_list = $translated_entity->{$this->definition['field_name']} ?? NULL; if (!isset($field_item_list)) { // There isn't anything we can do without a valid field. diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php index 8207fce70c..0fe56cbc65 100644 --- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php +++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php @@ -228,7 +228,7 @@ public function clickSort($order) { * {@inheritdoc} */ public function clickSortable() { - return isset($this->definition['click sortable']) ? $this->definition['click sortable'] : TRUE; + return $this->definition['click sortable'] ?? TRUE; } /** diff --git a/core/modules/views/src/Plugin/views/field/NumericField.php b/core/modules/views/src/Plugin/views/field/NumericField.php index 19bd477b9b..20e1f6a577 100644 --- a/core/modules/views/src/Plugin/views/field/NumericField.php +++ b/core/modules/views/src/Plugin/views/field/NumericField.php @@ -101,7 +101,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#type' => 'textfield', // @todo Should use better labels https://www.drupal.org/node/2499639 '#title' => ($i == 0 ? $this->t('Singular form') : $this->formatPlural($i, 'First plural form', '@count. plural form')), - '#default_value' => isset($plural_array[$i]) ? $plural_array[$i] : '', + '#default_value' => $plural_array[$i] ?? '', '#description' => $this->t('Text to use for this variant, @count will be replaced with the value.'), '#states' => [ 'visible' => [ diff --git a/core/modules/views/src/Plugin/views/field/TimeInterval.php b/core/modules/views/src/Plugin/views/field/TimeInterval.php index 79cd190605..25511993ac 100644 --- a/core/modules/views/src/Plugin/views/field/TimeInterval.php +++ b/core/modules/views/src/Plugin/views/field/TimeInterval.php @@ -82,7 +82,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { */ public function render(ResultRow $values) { $value = $values->{$this->field_alias}; - return $this->dateFormatter->formatInterval($value, isset($this->options['granularity']) ? $this->options['granularity'] : 2); + return $this->dateFormatter->formatInterval($value, $this->options['granularity'] ?? 2); } } diff --git a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php index 213c8ea2e6..45a0e2b9bb 100644 --- a/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php +++ b/core/modules/views/src/Plugin/views/filter/FilterPluginBase.php @@ -332,8 +332,8 @@ public function operatorSubmit($form, FormStateInterface $form_state) {} protected function showValueForm(&$form, FormStateInterface $form_state) { $this->valueForm($form, $form_state); if (empty($this->no_operator)) { - $form['value']['#prefix'] = '
' . (isset($form['value']['#prefix']) ? $form['value']['#prefix'] : ''); - $form['value']['#suffix'] = (isset($form['value']['#suffix']) ? $form['value']['#suffix'] : '') . '
'; + $form['value']['#prefix'] = '
' . ($form['value']['#prefix'] ?? ''); + $form['value']['#suffix'] = ($form['value']['#suffix'] ?? '') . '
'; } } diff --git a/core/modules/views/src/Plugin/views/filter/StringFilter.php b/core/modules/views/src/Plugin/views/filter/StringFilter.php index 403401c214..5d027309a4 100644 --- a/core/modules/views/src/Plugin/views/filter/StringFilter.php +++ b/core/modules/views/src/Plugin/views/filter/StringFilter.php @@ -325,7 +325,7 @@ public function operator() { */ protected function getConditionOperator($operator) { $mapping = $this->connection->mapConditionOperator($operator); - return isset($mapping['operator']) ? $mapping['operator'] : $operator; + return $mapping['operator'] ?? $operator; } /** diff --git a/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php b/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php index f916808974..5227a6ac43 100644 --- a/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php +++ b/core/modules/views/src/Plugin/views/pager/PagerPluginBase.php @@ -43,7 +43,7 @@ abstract class PagerPluginBase extends PluginBase { * most pagers will not need to override this method. */ public function getItemsPerPage() { - return isset($this->options['items_per_page']) ? $this->options['items_per_page'] : 0; + return $this->options['items_per_page'] ?? 0; } /** @@ -62,7 +62,7 @@ public function setItemsPerPage($items) { * so few pagers will need to override this method. */ public function getOffset() { - return isset($this->options['offset']) ? $this->options['offset'] : 0; + return $this->options['offset'] ?? 0; } /** @@ -108,7 +108,7 @@ public function getTotalItems() { * Get the pager id, if it exists. */ public function getPagerId() { - return isset($this->options['id']) ? $this->options['id'] : 0; + return $this->options['id'] ?? 0; } /** diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php index c6200bc16a..fb68b7aa05 100644 --- a/core/modules/views/src/Plugin/views/query/Sql.php +++ b/core/modules/views/src/Plugin/views/query/Sql.php @@ -1068,7 +1068,7 @@ public function addGroupBy($clause) { * @see \Drupal\views\Plugin\views\query\Sql::addField */ protected function getFieldAlias($table_alias, $field) { - return isset($this->fieldAliases[$table_alias][$field]) ? $this->fieldAliases[$table_alias][$field] : FALSE; + return $this->fieldAliases[$table_alias][$field] ?? FALSE; } /** diff --git a/core/modules/views/src/Plugin/views/row/Fields.php b/core/modules/views/src/Plugin/views/row/Fields.php index 9041bef185..20b4229506 100644 --- a/core/modules/views/src/Plugin/views/row/Fields.php +++ b/core/modules/views/src/Plugin/views/row/Fields.php @@ -74,7 +74,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('Separator'), '#type' => 'textfield', '#size' => 10, - '#default_value' => isset($this->options['separator']) ? $this->options['separator'] : '', + '#default_value' => $this->options['separator'] ?? '', '#description' => $this->t('The separator may be placed between inline fields to keep them from squishing up next to each other. You can use HTML in this field.'), '#states' => [ 'visible' => [ diff --git a/core/modules/views/src/Plugin/views/row/OpmlFields.php b/core/modules/views/src/Plugin/views/row/OpmlFields.php index 61359978e5..c5116f3fbd 100644 --- a/core/modules/views/src/Plugin/views/row/OpmlFields.php +++ b/core/modules/views/src/Plugin/views/row/OpmlFields.php @@ -195,7 +195,7 @@ public function render($row) { '#view' => $this->view, '#options' => $this->options, '#row' => $item, - '#field_alias' => isset($this->field_alias) ? $this->field_alias : '', + '#field_alias' => $this->field_alias ?? '', ]; return $build; } diff --git a/core/modules/views/src/Plugin/views/row/RowPluginBase.php b/core/modules/views/src/Plugin/views/row/RowPluginBase.php index 3335118504..e3d2c58933 100644 --- a/core/modules/views/src/Plugin/views/row/RowPluginBase.php +++ b/core/modules/views/src/Plugin/views/row/RowPluginBase.php @@ -169,7 +169,7 @@ public function render($row) { '#view' => $this->view, '#options' => $this->options, '#row' => $row, - '#field_alias' => isset($this->field_alias) ? $this->field_alias : '', + '#field_alias' => $this->field_alias ?? '', ]; } diff --git a/core/modules/views/src/Plugin/views/row/RssFields.php b/core/modules/views/src/Plugin/views/row/RssFields.php index dc80f7e028..aaa009c442 100644 --- a/core/modules/views/src/Plugin/views/row/RssFields.php +++ b/core/modules/views/src/Plugin/views/row/RssFields.php @@ -177,7 +177,7 @@ public function render($row) { '#view' => $this->view, '#options' => $this->options, '#row' => $item, - '#field_alias' => isset($this->field_alias) ? $this->field_alias : '', + '#field_alias' => $this->field_alias ?? '', ]; return $build; diff --git a/core/modules/views/src/Plugin/views/style/Mapping.php b/core/modules/views/src/Plugin/views/style/Mapping.php index 7db5247886..09b26fad51 100644 --- a/core/modules/views/src/Plugin/views/style/Mapping.php +++ b/core/modules/views/src/Plugin/views/style/Mapping.php @@ -51,7 +51,7 @@ protected function defineOptions() { foreach ($this->defineMapping() as $key => $value) { $default = !empty($value['#multiple']) ? [] : ''; $options['mapping']['contains'][$key] = [ - 'default' => isset($value['#default_value']) ? $value['#default_value'] : $default, + 'default' => $value['#default_value'] ?? $default, ]; if (!empty($value['#toggle'])) { $options['mapping']['contains']["toggle_$key"] = [ diff --git a/core/modules/views/src/Plugin/views/style/StylePluginBase.php b/core/modules/views/src/Plugin/views/style/StylePluginBase.php index b91ce83f1b..faacdf8e51 100644 --- a/core/modules/views/src/Plugin/views/style/StylePluginBase.php +++ b/core/modules/views/src/Plugin/views/style/StylePluginBase.php @@ -230,7 +230,7 @@ public function getRowClass($row_index) { public function tokenizeValue($value, $row_index) { if (strpos($value, '{{') !== FALSE) { // Row tokens might be empty, for example for node row style. - $tokens = isset($this->rowTokens[$row_index]) ? $this->rowTokens[$row_index] : []; + $tokens = $this->rowTokens[$row_index] ?? []; if (!empty($this->view->build_info['substitutions'])) { $tokens += $this->view->build_info['substitutions']; } @@ -498,7 +498,7 @@ public function renderGroupingSets($sets) { $output = []; $theme_functions = $this->view->buildThemeFunctions($this->groupingTheme); foreach ($sets as $set) { - $level = isset($set['level']) ? $set['level'] : 0; + $level = $set['level'] ?? 0; $row = reset($set['rows']); // Render as a grouping set. @@ -591,8 +591,8 @@ public function renderGrouping($records, $groupings = [], $group_rendered = NULL $set = &$sets; foreach ($groupings as $level => $info) { $field = $info['field']; - $rendered = isset($info['rendered']) ? $info['rendered'] : $group_rendered; - $rendered_strip = isset($info['rendered_strip']) ? $info['rendered_strip'] : FALSE; + $rendered = $info['rendered'] ?? $group_rendered; + $rendered_strip = $info['rendered_strip'] ?? FALSE; $grouping = ''; $group_content = ''; // Group on the rendered version of the field, not the raw. That way, diff --git a/core/modules/views/src/Plugin/views/style/Table.php b/core/modules/views/src/Plugin/views/style/Table.php index f6e88034e7..5a508b7799 100644 --- a/core/modules/views/src/Plugin/views/style/Table.php +++ b/core/modules/views/src/Plugin/views/style/Table.php @@ -348,7 +348,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title_display' => 'invisible', '#type' => 'textfield', '#size' => 10, - '#default_value' => isset($this->options['info'][$field]['separator']) ? $this->options['info'][$field]['separator'] : '', + '#default_value' => $this->options['info'][$field]['separator'] ?? '', '#states' => [ 'visible' => [ $column_selector => ['value' => $field], @@ -359,7 +359,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('Hide empty column for @field', ['@field' => $field]), '#title_display' => 'invisible', '#type' => 'checkbox', - '#default_value' => isset($this->options['info'][$field]['empty_column']) ? $this->options['info'][$field]['empty_column'] : FALSE, + '#default_value' => $this->options['info'][$field]['empty_column'] ?? FALSE, '#states' => [ 'visible' => [ $column_selector => ['value' => $field], @@ -370,7 +370,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('Responsive setting for @field', ['@field' => $field]), '#title_display' => 'invisible', '#type' => 'select', - '#default_value' => isset($this->options['info'][$field]['responsive']) ? $this->options['info'][$field]['responsive'] : '', + '#default_value' => $this->options['info'][$field]['responsive'] ?? '', '#options' => ['' => $this->t('High'), RESPONSIVE_PRIORITY_MEDIUM => $this->t('Medium'), RESPONSIVE_PRIORITY_LOW => $this->t('Low')], '#states' => [ 'visible' => [ diff --git a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php index d1188ce411..335ac065e0 100644 --- a/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php @@ -871,8 +871,8 @@ protected function defaultDisplayOptions() { 'table' => $default_table, 'field' => $default_field, 'id' => $default_field, - 'entity_type' => isset($data[$default_field]['entity type']) ? $data[$default_field]['entity type'] : NULL, - 'entity_field' => isset($data[$default_field]['entity field']) ? $data[$default_field]['entity field'] : NULL, + 'entity_type' => $data[$default_field]['entity type'] ?? NULL, + 'entity_field' => $data[$default_field]['entity field'] ?? NULL, 'plugin_id' => $data[$default_field]['field']['id'], ]; @@ -965,8 +965,8 @@ protected function defaultDisplayFiltersUser(array $form, FormStateInterface $fo 'table' => $table, 'field' => $bundle_key, 'value' => $value, - 'entity_type' => isset($table_data['table']['entity type']) ? $table_data['table']['entity type'] : NULL, - 'entity_field' => isset($table_data[$bundle_key]['entity field']) ? $table_data[$bundle_key]['entity field'] : NULL, + 'entity_type' => $table_data['table']['entity type'] ?? NULL, + 'entity_field' => $table_data[$bundle_key]['entity field'] ?? NULL, 'plugin_id' => $handler, ]; } @@ -1045,8 +1045,8 @@ protected function defaultDisplaySortsUser($form, FormStateInterface $form_state 'table' => $table, 'field' => $column, 'order' => $sort, - 'entity_type' => isset($data['table']['entity type']) ? $data['table']['entity type'] : NULL, - 'entity_field' => isset($data[$column]['entity field']) ? $data[$column]['entity field'] : NULL, + 'entity_type' => $data['table']['entity type'] ?? NULL, + 'entity_field' => $data[$column]['entity field'] ?? NULL, 'plugin_id' => $data[$column]['sort']['id'], ]; } @@ -1254,7 +1254,7 @@ protected function retrieveValidatedView(array $form, FormStateInterface $form_s // @todo Figure out why all this hashing is done. Wouldn't it be easier to // store a single entry and that's it? $key = hash('sha256', serialize($form_state->getValues())); - $view = (isset($this->validated_views[$key]) ? $this->validated_views[$key] : NULL); + $view = ($this->validated_views[$key] ?? NULL); if ($unset) { unset($this->validated_views[$key]); } diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index 7637ec8f74..0609ff8979 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -1082,7 +1082,7 @@ protected function _buildArguments() { $argument->setRelationship(); - $arg = isset($this->args[$position]) ? $this->args[$position] : NULL; + $arg = $this->args[$position] ?? NULL; $argument->position = $position; if (isset($arg) || $argument->hasDefaultArgument()) { @@ -1703,7 +1703,7 @@ public function postExecute() { $old_view = array_pop($this->old_view); } - views_set_current_view(isset($old_view) ? $old_view : FALSE); + views_set_current_view($old_view ?? FALSE); } /** @@ -2291,7 +2291,7 @@ public function getHandler($display_id, $type, $id) { // Get the existing configuration $fields = $this->displayHandlers->get($display_id)->getOption($types[$type]['plural']); - return isset($fields[$id]) ? $fields[$id] : NULL; + return $fields[$id] ?? NULL; } /** diff --git a/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php b/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php index 28349f2080..0398003543 100644 --- a/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php +++ b/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php @@ -76,7 +76,7 @@ protected function setUp(): void { ->method('render') ->will($this->returnCallback(function (array &$elements) { $elements['#attached'] = []; - return isset($elements['#markup']) ? $elements['#markup'] : ''; + return $elements['#markup'] ?? ''; })); $this->renderer->expects($this->any()) ->method('executeInRenderContext') diff --git a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php index b72947321c..c0d560db64 100644 --- a/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/field/FieldPluginBaseTest.php @@ -324,7 +324,7 @@ public function testRenderAsLinkWithPathAndOptions($path, $alter, $link_html, $f 'path' => $path, ]; - $final_html = isset($final_html) ? $final_html : $link_html; + $final_html = $final_html ?? $link_html; $this->setUpUrlIntegrationServices(); $this->setupDisplayWithEmptyArgumentsAndFields(); @@ -398,7 +398,7 @@ public function testRenderAsLinkWithUrlAndOptions(Url $url, $alter, Url $expecte 'url' => $url, ]; - $final_html = isset($final_html) ? $final_html : $link_html; + $final_html = $final_html ?? $link_html; $this->setUpUrlIntegrationServices(); $this->setupDisplayWithEmptyArgumentsAndFields(); diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index 01c26ac2d6..3dbe2b33fe 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -154,7 +154,7 @@ public function get($property_name, $langcode = NULL) { return $this->storage->get($property_name, $langcode); } - return isset($this->{$property_name}) ? $this->{$property_name} : NULL; + return $this->{$property_name} ?? NULL; } /** diff --git a/core/modules/views_ui/views_ui.theme.inc b/core/modules/views_ui/views_ui.theme.inc index 153d3d3544..88ab2d0c2b 100644 --- a/core/modules/views_ui/views_ui.theme.inc +++ b/core/modules/views_ui/views_ui.theme.inc @@ -85,8 +85,8 @@ function template_preprocess_views_ui_display_tab_bucket(&$variables) { $variables['attributes']['title'][] = t('Overridden'); } - $variables['name'] = isset($element['#name']) ? $element['#name'] : NULL; - $variables['overridden'] = isset($element['#overridden']) ? $element['#overridden'] : NULL; + $variables['name'] = $element['#name'] ?? NULL; + $variables['overridden'] = $element['#overridden'] ?? NULL; $variables['content'] = $element['#children']; $variables['title'] = $element['#title']; $variables['actions'] = !empty($element['#actions']) ? $element['#actions'] : []; diff --git a/core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php b/core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php index 49b801ac05..f5d9f319fc 100644 --- a/core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php +++ b/core/modules/workspaces/tests/src/Kernel/WorkspaceTestTrait.php @@ -100,7 +100,7 @@ protected function assertWorkspaceAssociation(array $expected, $entity_type_id) $workspace_association = \Drupal::service('workspaces.association'); foreach ($expected as $workspace_id => $expected_tracked_revision_ids) { $tracked_entities = $workspace_association->getTrackedEntities($workspace_id, $entity_type_id); - $tracked_revision_ids = isset($tracked_entities[$entity_type_id]) ? $tracked_entities[$entity_type_id] : []; + $tracked_revision_ids = $tracked_entities[$entity_type_id] ?? []; $this->assertEquals($expected_tracked_revision_ids, array_keys($tracked_revision_ids)); } } diff --git a/core/tests/Drupal/KernelTests/AssertContentTrait.php b/core/tests/Drupal/KernelTests/AssertContentTrait.php index 997d8a959a..42f7548d1e 100644 --- a/core/tests/Drupal/KernelTests/AssertContentTrait.php +++ b/core/tests/Drupal/KernelTests/AssertContentTrait.php @@ -143,7 +143,7 @@ protected function parse() { * The current URL. */ protected function getUrl() { - return isset($this->url) ? $this->url : 'no-url'; + return $this->url ?? 'no-url'; } /** diff --git a/core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/Annotation/Template.php b/core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/Annotation/Template.php index bc31bad21a..385dfd2b0b 100644 --- a/core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/Annotation/Template.php +++ b/core/tests/Drupal/Tests/Component/Annotation/Doctrine/Fixtures/Annotation/Template.php @@ -9,6 +9,6 @@ class Template public function __construct(array $values) { - $this->name = isset($values['value']) ? $values['value'] : null; + $this->name = $values['value'] ?? NULL; } } diff --git a/core/tests/Drupal/Tests/Component/FileCache/StaticFileCacheBackend.php b/core/tests/Drupal/Tests/Component/FileCache/StaticFileCacheBackend.php index 328fd52883..32fa215261 100644 --- a/core/tests/Drupal/Tests/Component/FileCache/StaticFileCacheBackend.php +++ b/core/tests/Drupal/Tests/Component/FileCache/StaticFileCacheBackend.php @@ -30,7 +30,7 @@ class StaticFileCacheBackend implements FileCacheBackendInterface { * (optional) Configuration used to configure this object. */ public function __construct($configuration) { - $this->bin = isset($configuration['bin']) ? $configuration['bin'] : 'file_cache'; + $this->bin = $configuration['bin'] ?? 'file_cache'; } /** diff --git a/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php b/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php index caae2d8279..84c909e1a3 100644 --- a/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php +++ b/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php @@ -32,7 +32,7 @@ public function testPluralsFormula($plural, $expected) { $parsed = $p->parsePluralForms($plural); list($nplurals, $new_plural) = $parsed; foreach ($expected as $number => $plural_form) { - $result = isset($new_plural[$number]) ? $new_plural[$number] : $new_plural['default']; + $result = $new_plural[$number] ?? $new_plural['default']; $this->assertEquals($result, $plural_form, 'Difference found at ' . $number . ': ' . $plural_form . ' versus ' . $result); } } diff --git a/core/tests/Drupal/Tests/Component/Graph/GraphTest.php b/core/tests/Drupal/Tests/Component/Graph/GraphTest.php index 9448e6cdc1..aacd9b5920 100644 --- a/core/tests/Drupal/Tests/Component/Graph/GraphTest.php +++ b/core/tests/Drupal/Tests/Component/Graph/GraphTest.php @@ -112,7 +112,7 @@ protected function assertPaths($graph, $expected_paths) { foreach ($expected_paths as $vertex => $paths) { // Build an array with keys = $paths and values = TRUE. $expected = array_fill_keys($paths, TRUE); - $result = isset($graph[$vertex]['paths']) ? $graph[$vertex]['paths'] : []; + $result = $graph[$vertex]['paths'] ?? []; $this->assertEquals($expected, $result, sprintf('Expected paths for vertex %s: %s, got %s', $vertex, $this->displayArray($expected, TRUE), $this->displayArray($result, TRUE))); } } @@ -130,7 +130,7 @@ protected function assertReversePaths($graph, $expected_reverse_paths) { foreach ($expected_reverse_paths as $vertex => $paths) { // Build an array with keys = $paths and values = TRUE. $expected = array_fill_keys($paths, TRUE); - $result = isset($graph[$vertex]['reverse_paths']) ? $graph[$vertex]['reverse_paths'] : []; + $result = $graph[$vertex]['reverse_paths'] ?? []; $this->assertEquals($expected, $result, sprintf('Expected reverse paths for vertex %s: %s, got %s', $vertex, $this->displayArray($expected, TRUE), $this->displayArray($result, TRUE))); } } diff --git a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php index fc5d60b12e..7ff0db8682 100644 --- a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php @@ -774,7 +774,7 @@ class TestLibraryDiscoveryParser extends LibraryDiscoveryParser { protected $validUris; protected function drupalGetPath($type, $name) { - return isset($this->paths[$type][$name]) ? $this->paths[$type][$name] : NULL; + return $this->paths[$type][$name] ?? NULL; } public function setPaths($type, $name, $path) { @@ -782,7 +782,7 @@ public function setPaths($type, $name, $path) { } protected function fileValidUri($source) { - return isset($this->validUris[$source]) ? $this->validUris[$source] : FALSE; + return $this->validUris[$source] ?? FALSE; } public function setFileValidUri($source, $valid) { diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php index 113543d702..be0bb3e8db 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php @@ -366,17 +366,17 @@ public function testGetFieldTableName($table_names, $expected) { $this->entityType ->expects($this->any()) ->method('getBaseTable') - ->willReturn(isset($table_names['base']) ? $table_names['base'] : 'entity_test'); + ->willReturn($table_names['base'] ?? 'entity_test'); $this->entityType ->expects($this->any()) ->method('getDataTable') - ->willReturn(isset($table_names['data']) ? $table_names['data'] : FALSE); + ->willReturn($table_names['data'] ?? FALSE); $this->entityType ->expects($this->any()) ->method('getRevisionTable') - ->willReturn(isset($table_names['revision']) ? $table_names['revision'] : FALSE); + ->willReturn($table_names['revision'] ?? FALSE); $this->entityType ->expects($this->any()) diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php index 496c6fe55f..5760138547 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalActionManagerTest.php @@ -168,7 +168,7 @@ public function testGetActionsForRoute($route_appears, array $plugin_definitions ->will($this->returnValue($plugin_definition['route_name'])); $plugin->expects($this->any()) ->method('getRouteParameters') - ->will($this->returnValue(isset($plugin_definition['route_parameters']) ? $plugin_definition['route_parameters'] : [])); + ->will($this->returnValue($plugin_definition['route_parameters'] ?? [])); $plugin->expects($this->any()) ->method('getTitle') ->will($this->returnValue($plugin_definition['title'])); diff --git a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php index 4de8170aaa..ae1b804a46 100644 --- a/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Menu/LocalTaskManagerTest.php @@ -452,10 +452,10 @@ protected function setupFactoryAndLocalTaskPlugins(array $definitions, $active_p $mock->getRouteParameters(Argument::cetera())->willReturn([]); $mock->getOptions(Argument::cetera())->willReturn([]); $mock->getActive()->willReturn($plugin_id === $active_plugin_id); - $mock->getWeight()->willReturn(isset($info['weight']) ? $info['weight'] : 0); - $mock->getCacheContexts()->willReturn(isset($info['cache_contexts']) ? $info['cache_contexts'] : []); - $mock->getCacheTags()->willReturn(isset($info['cache_tags']) ? $info['cache_tags'] : []); - $mock->getCacheMaxAge()->willReturn(isset($info['cache_max_age']) ? $info['cache_max_age'] : Cache::PERMANENT); + $mock->getWeight()->willReturn($info['weight'] ?? 0); + $mock->getCacheContexts()->willReturn($info['cache_contexts'] ?? []); + $mock->getCacheTags()->willReturn($info['cache_tags'] ?? []); + $mock->getCacheMaxAge()->willReturn($info['cache_max_age'] ?? Cache::PERMANENT); $access_manager_map[] = [$info['route_name'], [], $this->account, TRUE, $info['access']]; diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php index 7d519335c7..ed9eebac12 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererTest.php @@ -298,7 +298,7 @@ public function providerTestRenderBasic() { if ($theme == 'container') { return '' . $vars['#children'] . "\n"; } - $attributes = new Attribute(['href' => $vars['#url']] + (isset($vars['#attributes']) ? $vars['#attributes'] : [])); + $attributes = new Attribute(['href' => $vars['#url']] + ($vars['#attributes'] ?? [])); return '' . $vars['#title'] . ''; }); }; diff --git a/core/themes/claro/claro.theme b/core/themes/claro/claro.theme index dd4497f169..31ee33e7a3 100644 --- a/core/themes/claro/claro.theme +++ b/core/themes/claro/claro.theme @@ -349,9 +349,7 @@ function claro_preprocess_details(&$variables) { // Mark the details required if needed. If the file widget allows uploading // multiple files, the required state is checked by checking the state of // the first child. - $variables['required'] = isset($element[0]['#required']) ? - $element[0]['#required'] : - !empty($element['#required']); + $variables['required'] = $element[0]['#required'] ?? !empty($element['#required']); // If the error is the same as the one in the multiple field widget element, // we have to avoid displaying it twice. Seven and Stark have this issue diff --git a/core/themes/claro/src/ClaroPreRender.php b/core/themes/claro/src/ClaroPreRender.php index c31505dc2d..3d26a7ee44 100644 --- a/core/themes/claro/src/ClaroPreRender.php +++ b/core/themes/claro/src/ClaroPreRender.php @@ -88,7 +88,7 @@ public static function verticalTabs($element) { foreach ($children_keys as $child_key) { $last_group_with_child_key = $group_key; - $type = isset($element['group']['#groups'][$group_key][$child_key]['#type']) ? $element['group']['#groups'][$group_key][$child_key]['#type'] : NULL; + $type = $element['group']['#groups'][$group_key][$child_key]['#type'] ?? NULL; if ($type === 'details') { // Add BEM class to specify the details element is in a vertical // tabs group.