Skip to content
Snippets Groups Projects
Unverified Commit 330473e7 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #3222251 by bbrala, longwave: [November 8, 2021] Replace all isset...

Issue #3222251 by bbrala, longwave: [November 8, 2021] Replace all isset constructs with the null coalescing operator
parent 4cbbdb2d
No related branches found
No related tags found
31 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!2074Issue #2707689: NodeForm::actions() checks for delete access on new entities,!1896Issue #2940605: Can only intentionally re-render an entity with references 20 times,!1459Issue #3087632: menu_name max length is too long,!1283Issue #2922435: "Add new comment" and "@count comments" links are not following accessibility good practices,!1255Issue #3238922: Refactor (if feasible) uses of the jQuery serialize function to use vanillaJS,!1254Issue #3238915: Refactor (if feasible) uses of the jQuery ready function to use VanillaJS,!1213Issue #3236497: Allow other modules to opt out of security release message from update_page_top,!1185Issue 318778: Rerolled patch.,!1162Issue #3100350: Unable to save '/' root path alias,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!1018Issue #2793343: Dialog drupalAutoButtons option should be respected on initial load,!1014Issue #3226806: Move filter implementations from filter.module to plugin classes,!957Added throwing of InvalidPluginDefinitionException from getDefinition().,!939Issue #2971209: Allow the MediaLibraryUiBuilder service to use an alternative view display,!878Issue #3221534: throw an exception when IDs passed to loadMultiple() are badly formed,!877Issue #2708101: Default value for link text is not saved,!873Issue #2875228: Site install not using batch API service,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links,!866Issue #2845319: The highlighting of the 'Home' menu-link does not respect query strings and fragment identifiers,!844Resolve #3036010 "Updaters",!8293023322 - Contextual Links Style Update,!712Issue #2909128: Autocomplete intermittent on Chrome Android,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493,!485Sets the autocomplete attribute for username/password input field on login form.,!449Issue #2784233: Allow multiple vocabularies in the taxonomy filter,!30Issue #3182188: Updates composer usage to point at ./vendor/bin/composer
Showing
with 45 additions and 45 deletions
......@@ -83,7 +83,7 @@ public function composerLock() {
*/
public function getRequireDev() {
$composerJsonData = $this->rootComposerJson();
return isset($composerJsonData['require-dev']) ? $composerJsonData['require-dev'] : [];
return $composerJsonData['require-dev'] ?? [];
}
/**
......
......@@ -139,7 +139,7 @@ public function getAllCleanupPaths() {
// Merge root config with defaults.
foreach (array_change_key_case(static::$defaultConfig, CASE_LOWER) as $package => $paths) {
$this->configData[$package] = array_merge(
isset($this->configData[$package]) ? $this->configData[$package] : [],
$this->configData[$package] ?? [],
$paths);
}
return $this->configData;
......@@ -157,7 +157,7 @@ public function getAllCleanupPaths() {
public function getPathsForPackage($package) {
$package = strtolower($package);
$paths = $this->getAllCleanupPaths();
return isset($paths[$package]) ? $paths[$package] : [];
return $paths[$package] ?? [];
}
}
......@@ -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,
......
......@@ -415,8 +415,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;
......
......@@ -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,
......
......@@ -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
......
......@@ -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(),
......
......@@ -1523,7 +1523,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)) {
......
......@@ -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 {
......
......@@ -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.
......@@ -1020,7 +1020,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
......@@ -1061,7 +1061,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;
......@@ -1788,7 +1788,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');
......
......@@ -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;
}
/**
......
......@@ -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) {
......
......@@ -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;
......
......@@ -293,11 +293,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);
}
}
}
......
......@@ -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;
}
/**
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
}
/**
......
......@@ -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
......
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment