Issue #3222251 by bbrala, longwave: [November 8, 2021] Replace all isset constructs with the null coalescing operator

merge-requests/454/merge
Lee Rowlands 2021-11-15 12:19:43 +10:00
parent 4cbbdb2d99
commit 330473e759
No known key found for this signature in database
GPG Key ID: 2B829A3DF9204DC4
342 changed files with 585 additions and 596 deletions

View File

@ -83,7 +83,7 @@ class DrupalCoreComposer {
*/
public function getRequireDev() {
$composerJsonData = $this->rootComposerJson();
return isset($composerJsonData['require-dev']) ? $composerJsonData['require-dev'] : [];
return $composerJsonData['require-dev'] ?? [];
}
/**

View File

@ -139,7 +139,7 @@ class Config {
// 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 @@ class Config {
public function getPathsForPackage($package) {
$package = strtolower($package);
$paths = $this->getAllCleanupPaths();
return isset($paths[$package]) ? $paths[$package] : [];
return $paths[$package] ?? [];
}
}

View File

@ -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,

View File

@ -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;

View File

@ -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,

View File

@ -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

View File

@ -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(),

View File

@ -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)) {

View File

@ -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 {

View File

@ -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');

View File

@ -78,7 +78,7 @@ class Plugin implements AnnotationInterface {
* {@inheritdoc}
*/
public function getProvider() {
return isset($this->definition['provider']) ? $this->definition['provider'] : FALSE;
return $this->definition['provider'] ?? FALSE;
}
/**

View File

@ -115,10 +115,10 @@ class Container implements ContainerInterface, ResetInterface {
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 @@ class Container implements ContainerInterface, ResetInterface {
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) {

View File

@ -34,10 +34,10 @@ class PhpArrayContainer extends Container {
// 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;

View File

@ -293,11 +293,11 @@ class ContainerAwareEventDispatcher implements EventDispatcherInterface {
$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);
}
}
}

View File

@ -68,7 +68,7 @@ class FileCache implements FileCacheInterface {
public function get($filepath) {
$filepaths = [$filepath];
$cached = $this->getMultiple($filepaths);
return isset($cached[$filepath]) ? $cached[$filepath] : NULL;
return $cached[$filepath] ?? NULL;
}
/**

View File

@ -526,7 +526,7 @@ class PoStreamReader implements PoStreamInterface, PoReaderInterface {
}
$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);

View File

@ -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);

View File

@ -260,7 +260,7 @@ class PhpTransliteration implements TransliterationInterface {
$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;
}
/**

View File

@ -68,7 +68,7 @@ class UserAgent {
// 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 @@ class UserAgent {
// 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

View File

@ -138,9 +138,9 @@ class AjaxResponseAttachmentsProcessor implements AttachmentsResponseProcessorIn
// 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);

View File

@ -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 = [

View File

@ -257,7 +257,7 @@ class LibraryDiscoveryParser {
// 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;

View File

@ -60,7 +60,7 @@ class AuthenticationCollector implements AuthenticationCollectorInterface {
* {@inheritdoc}
*/
public function getProvider($provider_id) {
return isset($this->providers[$provider_id]) ? $this->providers[$provider_id] : NULL;
return $this->providers[$provider_id] ?? NULL;
}
/**

View File

@ -184,7 +184,7 @@ class ApcuBackend implements CacheBackendInterface {
*/
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'] ?? []);
}
}

View File

@ -48,7 +48,7 @@ class ChainedFastBackendFactory implements CacheFactoryInterface {
// 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.

View File

@ -118,7 +118,7 @@ class MemoryBackend implements CacheBackendInterface, CacheTagsInvalidatorInterf
*/
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'] ?? []);
}
}

View File

@ -73,10 +73,10 @@ class MemoryCounterBackend extends MemoryBackend {
*/
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;

View File

@ -84,7 +84,7 @@ class PhpBackend implements CacheBackendInterface {
*/
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'] ?? []);
}
}

View File

@ -186,7 +186,7 @@ class DbDumpCommand extends DbCommandBase {
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'])) {

View File

@ -328,8 +328,8 @@ class InstallCommand extends Command {
}
// 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'])) {

View File

@ -97,7 +97,7 @@ class CachedStorage implements StorageInterface, StorageCacheInterface {
// 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];
}

View File

@ -91,7 +91,7 @@ class Config extends StorableConfigBase {
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);
@ -293,7 +293,7 @@ class Config extends StorableConfigBase {
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);

View File

@ -135,7 +135,7 @@ abstract class ConfigBase implements RefinableCacheableDependencyInterface {
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);

View File

@ -68,7 +68,7 @@ class ConfigCollectionInfo extends Event {
* if not.
*/
public function getOverrideService($collection) {
return isset($this->collections[$collection]) ? $this->collections[$collection] : NULL;
return $this->collections[$collection] ?? NULL;
}
}

View File

@ -150,7 +150,7 @@ abstract class ConfigEntityBase extends EntityBase implements ConfigEntityInterf
* {@inheritdoc}
*/
public function get($property_name) {
return isset($this->{$property_name}) ? $this->{$property_name} : NULL;
return $this->{$property_name} ?? NULL;
}
/**
@ -228,8 +228,8 @@ abstract class ConfigEntityBase extends EntityBase implements ConfigEntityInterf
* 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() ?? '';
@ -521,7 +521,7 @@ abstract class ConfigEntityBase extends EntityBase implements ConfigEntityInterf
* {@inheritdoc}
*/
public function getThirdPartySettings($module) {
return isset($this->third_party_settings[$module]) ? $this->third_party_settings[$module] : [];
return $this->third_party_settings[$module] ?? [];
}
/**

View File

@ -471,7 +471,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora
*/
public function loadOverrideFree($id) {
$entities = $this->loadMultipleOverrideFree([$id]);
return isset($entities[$id]) ? $entities[$id] : NULL;
return $entities[$id] ?? NULL;
}
/**

View File

@ -92,8 +92,8 @@ class Query extends QueryBase implements QueryInterface {
$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;

View File

@ -33,7 +33,7 @@ abstract class ArrayElement extends Element implements \IteratorAggregate, Typed
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 @@ abstract class ArrayElement extends Element implements \IteratorAggregate, Typed
* {@inheritdoc}
*/
public function toArray() {
return isset($this->value) ? $this->value : [];
return $this->value ?? [];
}
/**

View File

@ -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);
}

View File

@ -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])) {

View File

@ -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;
}
}

View File

@ -174,7 +174,7 @@ class Cron implements CronInterface {
$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))) {

View File

@ -958,7 +958,7 @@ abstract class Connection {
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:

View File

@ -313,7 +313,7 @@ class Schema extends DatabaseSchema {
* 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.

View File

@ -263,7 +263,7 @@ class Connection extends DatabaseConnection {
}
public function mapConditionOperator($operator) {
return isset(static::$postgresqlConditionOperatorMap[$operator]) ? static::$postgresqlConditionOperatorMap[$operator] : NULL;
return static::$postgresqlConditionOperatorMap[$operator] ?? NULL;
}
/**

View File

@ -428,7 +428,7 @@ class Connection extends DatabaseConnection {
}
public function mapConditionOperator($operator) {
return isset(static::$sqliteConditionOperatorMap[$operator]) ? static::$sqliteConditionOperatorMap[$operator] : NULL;
return static::$sqliteConditionOperatorMap[$operator] ?? NULL;
}
/**

View File

@ -399,7 +399,7 @@ class Condition implements ConditionInterface, \Countable {
// 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];

View File

@ -331,7 +331,7 @@ class Merge extends Query implements ConditionInterface {
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]);

View File

@ -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 @@ class Select extends Query implements SelectInterface {
* {@inheritdoc}
*/
public function getMetaData($key) {
return isset($this->alterMetaData[$key]) ? $this->alterMetaData[$key] : NULL;
return $this->alterMetaData[$key] ?? NULL;
}
/**

View File

@ -435,7 +435,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
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.
@ -521,7 +521,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
* {@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;
@ -586,7 +586,7 @@ class StatementPrefetch implements \Iterator, StatementInterface {
* {@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 = [];

View File

@ -105,7 +105,7 @@ class Datetime extends DateElementBase {
];
}
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 = [

View File

@ -42,7 +42,7 @@ class MimeTypePass implements CompilerPassInterface {
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)) {

View File

@ -40,12 +40,12 @@ class RegisterEventSubscribersPass implements CompilerPassInterface {
$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]]];
}
}

View File

@ -68,7 +68,7 @@ class StackedKernelPass implements CompilerPassInterface {
$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']);
}

View File

@ -24,7 +24,7 @@ class StackedSessionHandlerPass implements CompilerPassInterface {
$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);
}

View File

@ -134,9 +134,9 @@ class TaggedHandlersPass implements CompilerPassInterface {
* 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);
@ -181,10 +181,10 @@ class TaggedHandlersPass implements CompilerPassInterface {
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();
}
}
@ -228,15 +228,15 @@ class TaggedHandlersPass implements CompilerPassInterface {
* 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)) {

View File

@ -311,8 +311,8 @@ class YamlFileLoader
}
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);
}

View File

@ -635,7 +635,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
$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));
@ -778,7 +778,7 @@ class DrupalKernel implements DrupalKernelInterface, TerminableInterface {
// Now find modules.
$this->moduleData = $profiles + $listing->scan('module');
}
return isset($this->moduleData[$module]) ? $this->moduleData[$module] : FALSE;
return $this->moduleData[$module] ?? FALSE;
}
/**

View File

@ -606,7 +606,7 @@ abstract class ContentEntityBase extends EntityBase implements \IteratorAggregat
// $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;

View File

@ -632,7 +632,7 @@ abstract class ContentEntityStorageBase extends EntityStorageBase implements Con
public function loadRevision($revision_id) {
$revisions = $this->loadMultipleRevisions([$revision_id]);
return isset($revisions[$revision_id]) ? $revisions[$revision_id] : NULL;
return $revisions[$revision_id] ?? NULL;
}
/**

View File

@ -65,7 +65,7 @@ class ContentEntityType extends EntityType implements ContentEntityTypeInterface
*/
public function getRevisionMetadataKey($key) {
$keys = $this->getRevisionMetadataKeys();
return isset($keys[$key]) ? $keys[$key] : FALSE;
return $keys[$key] ?? FALSE;
}
/**

View File

@ -183,7 +183,7 @@ class EntityController implements ContainerInjectionInterface {
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]),
];
}

View File

@ -167,12 +167,12 @@ class EntityAutocomplete extends Textfield {
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 @@ class EntityAutocomplete extends Textfield {
// 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;
}
}

View File

@ -216,7 +216,7 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
// 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;

View File

@ -104,14 +104,14 @@ abstract class EntityBase implements EntityInterface {
* {@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;
}
/**

View File

@ -158,7 +158,7 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
// 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 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
* {@inheritdoc}
*/
public function getComponent($name) {
return isset($this->content[$name]) ? $this->content[$name] : NULL;
return $this->content[$name] ?? NULL;
}
/**
@ -391,7 +391,7 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
*/
protected function getFieldDefinition($field_name) {
$definitions = $this->getFieldDefinitions();
return isset($definitions[$field_name]) ? $definitions[$field_name] : NULL;
return $definitions[$field_name] ?? NULL;
}
/**

View File

@ -656,7 +656,7 @@ class EntityFieldManager implements EntityFieldManagerInterface {
$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' => [],

View File

@ -294,7 +294,7 @@ abstract class EntityStorageBase extends EntityHandlerBase implements EntityStor
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;
}
/**

View File

@ -332,10 +332,10 @@ class EntityType extends PluginDefinition implements EntityTypeInterface {
*/
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 @@ class EntityType extends PluginDefinition implements EntityTypeInterface {
*/
public function getKey($key) {
$keys = $this->getKeys();
return isset($keys[$key]) ? $keys[$key] : FALSE;
return $keys[$key] ?? FALSE;
}
/**
@ -627,7 +627,7 @@ class EntityType extends PluginDefinition implements EntityTypeInterface {
*/
public function getLinkTemplate($key) {
$links = $this->getLinkTemplates();
return isset($links[$key]) ? $links[$key] : FALSE;
return $links[$key] ?? FALSE;
}
/**

View File

@ -78,7 +78,7 @@ class EntityTypeBundleInfo implements EntityTypeBundleInfoInterface {
*/
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] ?? [];
}
/**

View File

@ -232,7 +232,7 @@ class EntityTypeManager extends DefaultPluginManager implements EntityTypeManage
}
}
return isset($this->handlers['route_provider'][$entity_type_id]) ? $this->handlers['route_provider'][$entity_type_id] : [];
return $this->handlers['route_provider'][$entity_type_id] ?? [];
}
/**

View File

@ -482,7 +482,7 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf
$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'];
}

View File

@ -330,7 +330,7 @@ abstract class QueryBase implements QueryInterface {
$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 @@ abstract class QueryBase implements QueryInterface {
* {@inheritdoc}
*/
public function getMetaData($key) {
return isset($this->alterMetaData[$key]) ? $this->alterMetaData[$key] : NULL;
return $this->alterMetaData[$key] ?? NULL;
}
/**

View File

@ -250,7 +250,7 @@ class Query extends QueryBase implements QueryInterface {
$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;
}

View File

@ -1048,7 +1048,7 @@ class SqlContentEntityStorage extends ContentEntityStorageBase implements SqlEnt
$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);

View File

@ -60,10 +60,7 @@ class EntityDataDefinition extends ComplexDataDefinitionBase implements EntityDa
if ($parts[0] != 'entity') {
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
);
return static::create($parts[1] ?? NULL, $parts[2] ?? NULL);
}
/**
@ -120,7 +117,7 @@ class EntityDataDefinition extends ComplexDataDefinitionBase implements EntityDa
* {@inheritdoc}
*/
public function getEntityTypeId() {
return isset($this->definition['constraints']['EntityType']) ? $this->definition['constraints']['EntityType'] : NULL;
return $this->definition['constraints']['EntityType'] ?? NULL;
}
/**
@ -134,7 +131,7 @@ class EntityDataDefinition extends ComplexDataDefinitionBase implements EntityDa
* {@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;
}

View File

@ -92,7 +92,7 @@ class ConfigImportSubscriber extends ConfigImportValidateEventSubscriberBase {
// 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']) {

View File

@ -102,7 +102,7 @@ class InfoParserDynamic implements InfoParserInterface {
// 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;

View File

@ -162,7 +162,7 @@ class ModuleExtensionList extends ExtensionList {
// 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;
}

View File

@ -233,8 +233,8 @@ class ModuleHandler implements ModuleHandlerInterface {
$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;

View File

@ -583,9 +583,9 @@ class ModuleInstaller implements ModuleInstallerInterface {
$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;

View File

@ -192,7 +192,7 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI
* {@inheritdoc}
*/
public function getProvider() {
return isset($this->definition['provider']) ? $this->definition['provider'] : NULL;
return $this->definition['provider'] ?? NULL;
}
/**
@ -257,7 +257,7 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI
*/
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 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI
* {@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 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI
* 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 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI
* {@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 @@ class BaseFieldDefinition extends ListDataDefinition implements FieldDefinitionI
* {@inheritdoc}
*/
public function getTargetBundle() {
return isset($this->definition['bundle']) ? $this->definition['bundle'] : NULL;
return $this->definition['bundle'] ?? NULL;
}
/**

View File

@ -505,7 +505,7 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
*/
public function getConstraint($constraint_name) {
$constraints = $this->getConstraints();
return isset($constraints[$constraint_name]) ? $constraints[$constraint_name] : NULL;
return $constraints[$constraint_name] ?? NULL;
}
/**

View File

@ -124,7 +124,7 @@ class FieldDefinition extends ListDataDefinition implements FieldDefinitionInter
* {@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 @@ class FieldDefinition extends ListDataDefinition implements FieldDefinitionInter
* {@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 @@ class FieldDefinition extends ListDataDefinition implements FieldDefinitionInter
* {@inheritdoc}
*/
public function getDefaultValueCallback() {
return isset($this->definition['default_value_callback']) ? $this->definition['default_value_callback'] : NULL;
return $this->definition['default_value_callback'] ?? NULL;
}
/**

View File

@ -146,7 +146,7 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase {
$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;
}

View File

@ -74,7 +74,7 @@ class EmailDefaultWidget extends WidgetBase {
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element['value'] = $element + [
'#type' => 'email',
'#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL,
'#default_value' => $items[$delta]->value ?? NULL,
'#placeholder' => $this->getSetting('placeholder'),
'#size' => $this->getSetting('size'),
'#maxlength' => Email::EMAIL_MAX_LENGTH,

View File

@ -112,7 +112,7 @@ class EntityReferenceAutocompleteWidget extends WidgetBase {
// 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 @@ class EntityReferenceAutocompleteWidget extends WidgetBase {
*/
protected function getSelectionHandlerSetting($setting_name) {
$settings = $this->getFieldSetting('handler_settings');
return isset($settings[$setting_name]) ? $settings[$setting_name] : NULL;
return $settings[$setting_name] ?? NULL;
}
/**

View File

@ -66,7 +66,7 @@ class NumberWidget extends WidgetBase {
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$value = isset($items[$delta]->value) ? $items[$delta]->value : NULL;
$value = $items[$delta]->value ?? NULL;
$field_settings = $this->getFieldSettings();
$element += [

View File

@ -70,7 +70,7 @@ class StringTextfieldWidget extends WidgetBase {
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element['value'] = $element + [
'#type' => 'textfield',
'#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL,
'#default_value' => $items[$delta]->value ?? NULL,
'#size' => $this->getSetting('size'),
'#placeholder' => $this->getSetting('placeholder'),
'#maxlength' => $this->getFieldSetting('max_length'),

View File

@ -70,7 +70,7 @@ class UriWidget extends WidgetBase {
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element['value'] = $element + [
'#type' => 'url',
'#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL,
'#default_value' => $items[$delta]->value ?? NULL,
'#size' => $this->getSetting('size'),
'#placeholder' => $this->getSetting('placeholder'),
'#maxlength' => $this->getFieldSetting('max_length'),

View File

@ -61,7 +61,7 @@ abstract class PluginSettingsBase extends PluginBase implements PluginSettingsIn
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 @@ abstract class PluginSettingsBase extends PluginBase implements PluginSettingsIn
*/
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 @@ abstract class PluginSettingsBase extends PluginBase implements PluginSettingsIn
* {@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;
}
/**

View File

@ -84,7 +84,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface,
// 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 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface,
// Add a DIV around the delta receiving the Ajax effect.
$delta = $element['#max_delta'];
$element[$delta]['#prefix'] = '<div class="ajax-new-content">' . (isset($element[$delta]['#prefix']) ? $element[$delta]['#prefix'] : '');
$element[$delta]['#suffix'] = (isset($element[$delta]['#suffix']) ? $element[$delta]['#suffix'] : '') . '</div>';
$element[$delta]['#prefix'] = '<div class="ajax-new-content">' . ($element[$delta]['#prefix'] ?? '');
$element[$delta]['#suffix'] = ($element[$delta]['#suffix'] ?? '') . '</div>';
return $element;
}
@ -406,7 +406,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface,
// 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);

View File

@ -145,7 +145,7 @@ class WidgetPluginManager extends DefaultPluginManager {
// 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']);

View File

@ -1280,7 +1280,7 @@ class FormBuilder implements FormBuilderInterface, FormValidatorInterface, FormS
// 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'] ?? '';
}
}
}

View File

@ -41,21 +41,21 @@ class LinkRelationType extends PluginBase implements LinkRelationTypeInterface {
* {@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'] ?? '';
}
}

View File

@ -48,7 +48,7 @@ class SelectProfileForm extends FormBase {
// 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;
}

View File

@ -33,7 +33,7 @@ abstract class StorageBase implements KeyValueStoreInterface {
*/
public function get($key, $default = NULL) {
$values = $this->getMultiple([$key]);
return isset($values[$key]) ? $values[$key] : $default;
return $values[$key] ?? $default;
}
/**

View File

@ -149,7 +149,7 @@ class LanguageManager implements LanguageManagerInterface {
*/
public function getLanguage($langcode) {
$languages = $this->getLanguages(LanguageInterface::STATE_ALL);
return isset($languages[$langcode]) ? $languages[$langcode] : NULL;
return $languages[$langcode] ?? NULL;
}
/**

View File

@ -158,10 +158,10 @@ class LayoutDefinition extends PluginDefinition implements PluginDefinitionInter
*/
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;
}

View File

@ -198,7 +198,7 @@ class LayoutPluginManager extends DefaultPluginManager implements LayoutPluginMa
*/
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 @@ class LayoutPluginManager extends DefaultPluginManager implements LayoutPluginMa
* @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;

Some files were not shown because too many files have changed in this diff Show More