From 330473e759cbe9fd0e9a404b48ad18aebd0293a7 Mon Sep 17 00:00:00 2001 From: Lee Rowlands <lee.rowlands@previousnext.com.au> Date: Mon, 15 Nov 2021 12:19:43 +1000 Subject: [PATCH] Issue #3222251 by bbrala, longwave: [November 8, 2021] Replace all isset constructs with the null coalescing operator --- composer/Generator/Util/DrupalCoreComposer.php | 2 +- composer/Plugin/VendorHardening/Config.php | 4 ++-- core/includes/batch.inc | 2 +- core/includes/bootstrap.inc | 4 ++-- core/includes/common.inc | 4 ++-- core/includes/errors.inc | 2 +- core/includes/form.inc | 14 +++++++------- core/includes/install.core.inc | 2 +- core/includes/install.inc | 4 ++-- core/includes/theme.inc | 12 ++++++------ .../lib/Drupal/Component/Annotation/Plugin.php | 2 +- .../DependencyInjection/Container.php | 10 +++++----- .../DependencyInjection/PhpArrayContainer.php | 8 ++++---- .../ContainerAwareEventDispatcher.php | 4 ++-- .../Drupal/Component/FileCache/FileCache.php | 2 +- .../Component/Gettext/PoStreamReader.php | 2 +- .../Plugin/ContextAwarePluginBase.php | 2 +- .../Transliteration/PhpTransliteration.php | 2 +- .../lib/Drupal/Component/Utility/UserAgent.php | 4 ++-- .../Ajax/AjaxResponseAttachmentsProcessor.php | 4 ++-- .../lib/Drupal/Core/Annotation/Translation.php | 2 +- .../Core/Asset/LibraryDiscoveryParser.php | 2 +- .../Authentication/AuthenticationCollector.php | 2 +- core/lib/Drupal/Core/Cache/ApcuBackend.php | 2 +- .../Core/Cache/ChainedFastBackendFactory.php | 2 +- core/lib/Drupal/Core/Cache/MemoryBackend.php | 2 +- .../Drupal/Core/Cache/MemoryCounterBackend.php | 4 ++-- core/lib/Drupal/Core/Cache/PhpBackend.php | 2 +- core/lib/Drupal/Core/Command/DbDumpCommand.php | 2 +- .../lib/Drupal/Core/Command/InstallCommand.php | 4 ++-- core/lib/Drupal/Core/Config/CachedStorage.php | 2 +- core/lib/Drupal/Core/Config/Config.php | 4 ++-- core/lib/Drupal/Core/Config/ConfigBase.php | 2 +- .../Core/Config/ConfigCollectionInfo.php | 2 +- .../Core/Config/Entity/ConfigEntityBase.php | 8 ++++---- .../Core/Config/Entity/ConfigEntityStorage.php | 2 +- .../Drupal/Core/Config/Entity/Query/Query.php | 4 ++-- .../Drupal/Core/Config/Schema/ArrayElement.php | 4 ++-- core/lib/Drupal/Core/Config/Schema/Mapping.php | 4 ++-- .../lib/Drupal/Core/Config/Schema/Sequence.php | 2 +- .../Config/Schema/SequenceDataDefinition.php | 2 +- core/lib/Drupal/Core/Cron.php | 2 +- core/lib/Drupal/Core/Database/Connection.php | 2 +- .../Core/Database/Driver/mysql/Schema.php | 2 +- .../Core/Database/Driver/pgsql/Connection.php | 2 +- .../Core/Database/Driver/sqlite/Connection.php | 2 +- .../Drupal/Core/Database/Query/Condition.php | 2 +- core/lib/Drupal/Core/Database/Query/Merge.php | 2 +- core/lib/Drupal/Core/Database/Query/Select.php | 4 ++-- .../Drupal/Core/Database/StatementPrefetch.php | 6 +++--- .../Drupal/Core/Datetime/Element/Datetime.php | 2 +- .../Compiler/MimeTypePass.php | 2 +- .../Compiler/RegisterEventSubscribersPass.php | 4 ++-- .../Compiler/StackedKernelPass.php | 2 +- .../Compiler/StackedSessionHandlerPass.php | 2 +- .../Compiler/TaggedHandlersPass.php | 16 ++++++++-------- .../DependencyInjection/YamlFileLoader.php | 4 ++-- core/lib/Drupal/Core/DrupalKernel.php | 4 ++-- .../Drupal/Core/Entity/ContentEntityBase.php | 2 +- .../Core/Entity/ContentEntityStorageBase.php | 2 +- .../Drupal/Core/Entity/ContentEntityType.php | 2 +- .../Entity/Controller/EntityController.php | 2 +- .../Core/Entity/Element/EntityAutocomplete.php | 6 +++--- .../Core/Entity/Entity/EntityFormDisplay.php | 2 +- core/lib/Drupal/Core/Entity/EntityBase.php | 4 ++-- .../Drupal/Core/Entity/EntityDisplayBase.php | 6 +++--- .../Drupal/Core/Entity/EntityFieldManager.php | 2 +- .../Drupal/Core/Entity/EntityStorageBase.php | 2 +- core/lib/Drupal/Core/Entity/EntityType.php | 8 ++++---- .../Core/Entity/EntityTypeBundleInfo.php | 2 +- .../Drupal/Core/Entity/EntityTypeManager.php | 2 +- .../Drupal/Core/Entity/EntityViewBuilder.php | 2 +- .../lib/Drupal/Core/Entity/Query/QueryBase.php | 4 ++-- .../lib/Drupal/Core/Entity/Query/Sql/Query.php | 2 +- .../Entity/Sql/SqlContentEntityStorage.php | 2 +- .../Entity/TypedData/EntityDataDefinition.php | 9 +++------ .../EventSubscriber/ConfigImportSubscriber.php | 2 +- .../Core/Extension/InfoParserDynamic.php | 2 +- .../Core/Extension/ModuleExtensionList.php | 2 +- .../Drupal/Core/Extension/ModuleHandler.php | 4 ++-- .../Drupal/Core/Extension/ModuleInstaller.php | 4 ++-- .../Drupal/Core/Field/BaseFieldDefinition.php | 18 +++++++++--------- core/lib/Drupal/Core/Field/FieldConfigBase.php | 2 +- core/lib/Drupal/Core/Field/FieldDefinition.php | 8 ++++---- .../EntityReferenceEntityFormatter.php | 2 +- .../Field/FieldWidget/EmailDefaultWidget.php | 2 +- .../EntityReferenceAutocompleteWidget.php | 4 ++-- .../Plugin/Field/FieldWidget/NumberWidget.php | 2 +- .../FieldWidget/StringTextfieldWidget.php | 2 +- .../Plugin/Field/FieldWidget/UriWidget.php | 2 +- .../Drupal/Core/Field/PluginSettingsBase.php | 6 +++--- core/lib/Drupal/Core/Field/WidgetBase.php | 8 ++++---- .../Drupal/Core/Field/WidgetPluginManager.php | 2 +- core/lib/Drupal/Core/Form/FormBuilder.php | 2 +- core/lib/Drupal/Core/Http/LinkRelationType.php | 6 +++--- .../Core/Installer/Form/SelectProfileForm.php | 2 +- .../Drupal/Core/KeyValueStore/StorageBase.php | 2 +- .../Drupal/Core/Language/LanguageManager.php | 2 +- .../Drupal/Core/Layout/LayoutDefinition.php | 4 ++-- .../Drupal/Core/Layout/LayoutPluginManager.php | 4 ++-- .../Drupal/Core/Menu/LocalActionDefault.php | 2 +- core/lib/Drupal/Core/Menu/LocalTaskDefault.php | 2 +- core/lib/Drupal/Core/Menu/MenuLinkBase.php | 4 ++-- core/lib/Drupal/Core/Menu/MenuTreeStorage.php | 4 ++-- core/lib/Drupal/Core/Pager/PagerManager.php | 2 +- .../Core/PhpStorage/PhpStorageFactory.php | 2 +- .../Plugin/CategorizingPluginManagerTrait.php | 4 ++-- .../Core/Plugin/Context/ContextDefinition.php | 2 +- .../Core/Plugin/Context/ContextHandler.php | 2 +- .../Core/Plugin/ContextAwarePluginTrait.php | 2 +- .../Plugin/DefaultLazyPluginCollection.php | 2 +- .../Drupal/Core/Render/Element/Checkbox.php | 2 +- .../Drupal/Core/Render/Element/Checkboxes.php | 2 +- .../Drupal/Core/Render/Element/FormElement.php | 2 +- .../lib/Drupal/Core/Render/Element/HtmlTag.php | 6 +++--- core/lib/Drupal/Core/Render/Element/Number.php | 2 +- core/lib/Drupal/Core/Render/Element/Radios.php | 6 +++--- .../Drupal/Core/Render/Element/Tableselect.php | 4 ++-- .../Drupal/Core/Render/ElementInfoManager.php | 4 ++-- .../HtmlResponseAttachmentsProcessor.php | 2 +- .../Core/Render/MainContent/DialogRenderer.php | 2 +- .../Core/Render/MainContent/HtmlRenderer.php | 4 ++-- .../Core/Render/MainContent/ModalRenderer.php | 2 +- .../Render/MainContent/OffCanvasRenderer.php | 2 +- core/lib/Drupal/Core/Render/RenderCache.php | 4 ++-- core/lib/Drupal/Core/Render/Renderer.php | 10 +++++----- core/lib/Drupal/Core/Site/Settings.php | 2 +- core/lib/Drupal/Core/State/State.php | 2 +- .../StringTranslation/TranslatableMarkup.php | 2 +- .../Core/Test/FunctionalTestSetupTrait.php | 6 +++--- core/lib/Drupal/Core/Test/TestSetupTrait.php | 2 +- core/lib/Drupal/Core/Theme/Registry.php | 2 +- .../Drupal/Core/Theme/ThemeInitialization.php | 4 ++-- .../Core/TypedData/ComputedItemListTrait.php | 2 +- .../Drupal/Core/TypedData/DataDefinition.php | 12 ++++++------ .../TypedData/Plugin/DataType/ItemList.php | 4 ++-- .../Core/TypedData/Plugin/DataType/Map.php | 2 +- .../Core/Validation/DrupalTranslator.php | 2 +- core/modules/big_pipe/src/Render/BigPipe.php | 4 ++-- core/modules/block/src/BlockForm.php | 2 +- core/modules/book/src/BookManager.php | 8 ++++---- core/modules/ckeditor/ckeditor.admin.inc | 2 +- core/modules/comment/src/CommentManager.php | 2 +- .../FieldFormatter/CommentDefaultFormatter.php | 2 +- .../src/FormElement/ListElement.php | 2 +- .../src/FormElement/PluralVariants.php | 4 ++-- .../tests/src/Unit/ConfigNamesMapperTest.php | 2 +- core/modules/contact/contact.module | 2 +- .../Form/ContentModerationConfigureForm.php | 2 +- .../Plugin/WorkflowType/ContentModeration.php | 2 +- .../src/FieldTranslationSynchronizer.php | 4 ++-- .../source/d7/EntityTranslationSettings.php | 16 ++++++++-------- .../contextual/src/Element/ContextualLinks.php | 2 +- .../Field/FieldType/DateTimeFieldItemList.php | 2 +- .../Field/FieldType/DateRangeFieldItemList.php | 2 +- core/modules/editor/editor.module | 5 ++--- .../editor/src/Form/EditorImageDialog.php | 4 ++-- .../editor/src/Form/EditorLinkDialog.php | 4 ++-- core/modules/field/src/FieldConfigStorage.php | 2 +- .../field/src/FieldStorageConfigStorage.php | 2 +- .../d6/FieldFormatterSettingsDefaults.php | 2 +- .../d6/FieldInstanceOptionTranslation.php | 2 +- .../process/d6/FieldInstanceWidgetSettings.php | 8 ++++---- .../migrate/process/d6/FieldSettings.php | 6 +++--- .../Field/FieldWidget/TestFieldWidget.php | 2 +- .../field_ui/src/Element/FieldUiTable.php | 2 +- .../src/Form/EntityDisplayFormBase.php | 8 ++++---- .../src/Form/EntityFormDisplayEditForm.php | 2 +- .../src/Form/EntityViewDisplayEditForm.php | 2 +- .../field_ui/src/Form/FieldStorageAddForm.php | 8 ++++---- .../src/Form/FieldStorageConfigEditForm.php | 2 +- core/modules/file/file.module | 10 +++++----- core/modules/file/src/Element/ManagedFile.php | 8 ++++---- .../src/Plugin/Field/FieldType/FileItem.php | 2 +- .../Plugin/Field/FieldWidget/FileWidget.php | 2 +- .../Plugin/migrate/process/d6/FieldFile.php | 6 +++--- .../file/src/Plugin/migrate/source/d6/File.php | 2 +- .../tests/src/Functional/FileFieldTestBase.php | 6 +++--- .../process/d6/FilterFormatPermission.php | 2 +- core/modules/forum/forum.module | 2 +- core/modules/forum/src/ForumManager.php | 2 +- .../EntityReferenceItemNormalizer.php | 2 +- .../image/src/Form/ImageStyleEditForm.php | 2 +- core/modules/image/src/ImageStyleStorage.php | 2 +- .../Plugin/Field/FieldWidget/ImageWidget.php | 4 ++-- .../src/Functional/ImageFieldTestBase.php | 2 +- .../jsonapi/src/Access/TemporaryQueryGuard.php | 2 +- .../jsonapi/src/Controller/EntityResource.php | 4 ++-- ...egisterSerializationClassesCompilerPass.php | 4 ++-- core/modules/jsonapi/src/IncludeResolver.php | 2 +- ...tityAccessDeniedHttpExceptionNormalizer.php | 5 ++--- .../ResourceIdentifierNormalizer.php | 2 +- .../Normalizer/ResourceObjectNormalizer.php | 6 +----- .../ResourceType/ResourceTypeRepository.php | 2 +- core/modules/jsonapi/src/Routing/Routes.php | 2 +- .../tests/src/Functional/ResourceTestBase.php | 2 +- core/modules/language/language.admin.inc | 2 +- .../src/Element/LanguageConfiguration.php | 2 +- .../src/Entity/ConfigurableLanguage.php | 2 +- .../language/src/Form/LanguageAddForm.php | 2 +- .../src/Form/NegotiationConfigureForm.php | 4 ++-- .../language/src/Form/NegotiationUrlForm.php | 4 ++-- .../language/src/LanguageNegotiator.php | 2 +- .../LanguageNegotiationContentEntity.php | 4 ++-- .../LanguageNegotiationSession.php | 2 +- .../Functional/LanguageUrlRewritingTest.php | 2 +- .../layout_builder/layout_builder.module | 2 +- .../src/Element/LayoutBuilder.php | 2 +- .../Entity/LayoutBuilderEntityViewDisplay.php | 2 +- core/modules/layout_builder/src/Section.php | 4 ++-- .../layout_builder/src/SectionComponent.php | 4 ++-- .../SectionStorageDefinition.php | 4 ++-- .../layout_discovery/layout_discovery.module | 4 ++-- .../Plugin/Field/FieldWidget/LinkWidget.php | 2 +- core/modules/locale/locale.batch.inc | 2 +- core/modules/locale/locale.bulk.inc | 4 ++-- core/modules/locale/locale.compare.inc | 2 +- core/modules/locale/locale.module | 2 +- core/modules/locale/locale.translation.inc | 4 ++-- .../locale/src/Form/TranslateEditForm.php | 4 ++-- .../locale/src/Form/TranslateFilterForm.php | 2 +- .../locale/src/Form/TranslationStatusForm.php | 8 ++++---- .../locale/src/LocaleConfigSubscriber.php | 2 +- .../locale/src/LocaleProjectStorage.php | 2 +- core/modules/locale/src/PluralFormula.php | 2 +- core/modules/locale/src/SourceString.php | 2 +- core/modules/locale/src/StringBase.php | 8 ++++---- core/modules/locale/src/TranslationString.php | 2 +- core/modules/media/media.module | 4 ++-- .../media/src/Form/EditorMediaDialog.php | 2 +- core/modules/media/src/MediaSourceBase.php | 4 ++-- core/modules/media/src/MediaTypeForm.php | 2 +- .../media_library/src/Form/AddFormBase.php | 2 +- .../Field/FieldWidget/MediaLibraryWidget.php | 12 ++++++------ .../src/Plugin/Menu/MenuLinkContent.php | 2 +- .../tests/src/Kernel/MenuLinksTest.php | 2 +- core/modules/menu_ui/menu_ui.module | 2 +- core/modules/migrate/src/MigrateMessage.php | 2 +- core/modules/migrate/src/Plugin/Migration.php | 4 ++-- .../src/Plugin/MigrationPluginManager.php | 6 +++--- .../src/Plugin/migrate/destination/Entity.php | 2 +- .../src/Plugin/migrate/process/Concat.php | 2 +- .../Plugin/migrate/process/DefaultValue.php | 2 +- .../src/Plugin/migrate/process/Explode.php | 2 +- .../src/Plugin/migrate/process/FormatDate.php | 6 +++--- .../Plugin/migrate/process/MakeUniqueBase.php | 6 +++--- .../src/Plugin/migrate/process/Substr.php | 4 ++-- .../migrate_drupal/src/FieldDiscovery.php | 2 +- .../Plugin/migrate/source/DrupalSqlBase.php | 2 +- .../migrate/source/d7/FieldableEntity.php | 2 +- .../node/src/Plugin/Search/NodeSearch.php | 14 +++++++------- .../node/src/Plugin/migrate/source/d6/Node.php | 2 +- .../src/Plugin/migrate/source/d6/NodeType.php | 2 +- .../node/src/Plugin/views/field/Node.php | 2 +- .../FieldFormatter/OptionsDefaultFormatter.php | 2 +- .../migrate/process/PathSetTranslated.php | 2 +- core/modules/rdf/rdf.module | 4 ++-- .../src/ResponsiveImageStyleForm.php | 6 +++--- core/modules/rest/src/Plugin/ResourceBase.php | 4 ++-- .../rest/src/Plugin/views/row/DataFieldRow.php | 6 +++--- core/modules/search/search.pages.inc | 2 +- .../Normalizer/DateTimeIso8601Normalizer.php | 11 +++++++---- .../src/Normalizer/DateTimeNormalizer.php | 4 +--- .../FieldableEntityNormalizerTrait.php | 2 +- .../RegisterEntityResolversCompilerPass.php | 2 +- ...egisterSerializationClassesCompilerPass.php | 4 ++-- .../tests/src/Functional/ShortcutTestBase.php | 2 +- .../system/src/Controller/BatchController.php | 2 +- .../src/Controller/DbUpdateController.php | 2 +- .../system/src/Form/ModulesListForm.php | 4 ++-- .../src/Form/ThemeExperimentalConfirmForm.php | 4 ++-- .../system/src/Form/ThemeSettingsForm.php | 2 +- .../system/src/PhpStorage/MockPhpStorage.php | 2 +- core/modules/system/system.admin.inc | 2 +- core/modules/system/system.module | 2 +- .../Render/MainContent/WideModalRenderer.php | 2 +- .../ShapeOnlyColorEditableWidget.php | 2 +- .../mock_block/MockUserLoginBlock.php | 2 +- .../Traits/EntityDefinitionTestTrait.php | 4 ++-- .../tests/src/Functional/Form/FormTest.php | 6 +++--- .../src/Kernel/Block/SystemMenuBlockTest.php | 6 +++--- .../taxonomy/src/Form/OverviewTerms.php | 2 +- .../views/argument/IndexTidDepthModifier.php | 2 +- .../Plugin/views/field/TaxonomyIndexTid.php | 2 +- .../FieldWidget/TelephoneDefaultWidget.php | 2 +- .../Field/FieldWidget/TextfieldWidget.php | 2 +- .../src/Plugin/migrate/field/d6/TextField.php | 2 +- core/modules/tour/src/Entity/Tour.php | 2 +- .../src/Plugin/HelpSection/TourHelpSection.php | 2 +- .../user/src/Controller/UserController.php | 2 +- .../Plugin/migrate/process/UserUpdate8002.php | 2 +- .../migrate/source/d6/UserPictureFile.php | 2 +- core/modules/user/user.module | 4 ++-- .../Render/TranslationLanguageRenderer.php | 5 ++--- .../views/src/Plugin/views/PluginBase.php | 2 +- .../src/Plugin/views/area/AreaPluginBase.php | 2 +- .../views/src/Plugin/views/area/Result.php | 2 +- .../views/src/Plugin/views/area/Text.php | 4 ++-- .../views/argument/ArgumentPluginBase.php | 10 +++++----- .../Plugin/views/argument/LanguageArgument.php | 2 +- .../src/Plugin/views/cache/CachePluginBase.php | 2 +- .../Plugin/views/display/DisplayPluginBase.php | 10 +++++----- .../views/src/Plugin/views/display/Page.php | 2 +- .../Plugin/views/display/PathPluginBase.php | 2 +- .../exposed_form/ExposedFormPluginBase.php | 4 ++-- .../views/exposed_form/InputRequired.php | 2 +- .../views/src/Plugin/views/field/Boolean.php | 2 +- .../views/src/Plugin/views/field/Date.php | 4 ++-- .../src/Plugin/views/field/EntityField.php | 6 +++--- .../src/Plugin/views/field/FieldPluginBase.php | 2 +- .../src/Plugin/views/field/NumericField.php | 2 +- .../src/Plugin/views/field/TimeInterval.php | 2 +- .../Plugin/views/filter/FilterPluginBase.php | 4 ++-- .../src/Plugin/views/filter/StringFilter.php | 2 +- .../src/Plugin/views/pager/PagerPluginBase.php | 6 +++--- .../views/src/Plugin/views/query/Sql.php | 2 +- .../views/src/Plugin/views/row/Fields.php | 2 +- .../views/src/Plugin/views/row/OpmlFields.php | 2 +- .../src/Plugin/views/row/RowPluginBase.php | 2 +- .../views/src/Plugin/views/row/RssFields.php | 2 +- .../views/src/Plugin/views/style/Mapping.php | 2 +- .../src/Plugin/views/style/StylePluginBase.php | 8 ++++---- .../views/src/Plugin/views/style/Table.php | 6 +++--- .../Plugin/views/wizard/WizardPluginBase.php | 14 +++++++------- core/modules/views/src/ViewExecutable.php | 6 +++--- .../Unit/Controller/ViewAjaxControllerTest.php | 2 +- .../Unit/Plugin/field/FieldPluginBaseTest.php | 4 ++-- core/modules/views_ui/src/ViewUI.php | 2 +- core/modules/views_ui/views_ui.theme.inc | 4 ++-- .../tests/src/Kernel/WorkspaceTestTrait.php | 2 +- core/scripts/run-tests.sh | 2 +- .../Drupal/KernelTests/AssertContentTrait.php | 2 +- .../FileCache/StaticFileCacheBackend.php | 2 +- .../Tests/Component/Gettext/PoHeaderTest.php | 2 +- .../Drupal/Tests/Component/Graph/GraphTest.php | 4 ++-- .../Core/Asset/LibraryDiscoveryParserTest.php | 2 +- .../Entity/Sql/DefaultTableMappingTest.php | 6 +++--- .../Tests/Core/Menu/LocalActionManagerTest.php | 2 +- .../Tests/Core/Menu/LocalTaskManagerTest.php | 8 ++++---- .../Drupal/Tests/Core/Render/RendererTest.php | 2 +- core/themes/claro/claro.theme | 4 +--- core/themes/claro/src/ClaroPreRender.php | 2 +- 342 files changed, 585 insertions(+), 596 deletions(-) diff --git a/composer/Generator/Util/DrupalCoreComposer.php b/composer/Generator/Util/DrupalCoreComposer.php index f33e759e20ce..cf4aea0ce8df 100644 --- a/composer/Generator/Util/DrupalCoreComposer.php +++ b/composer/Generator/Util/DrupalCoreComposer.php @@ -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'] ?? []; } /** diff --git a/composer/Plugin/VendorHardening/Config.php b/composer/Plugin/VendorHardening/Config.php index b63238756874..6baf99aedc38 100644 --- a/composer/Plugin/VendorHardening/Config.php +++ b/composer/Plugin/VendorHardening/Config.php @@ -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] ?? []; } } diff --git a/core/includes/batch.inc b/core/includes/batch.inc index ebee3eb35cd7..ce812f155b09 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 74dfb3f4d5af..12464555f759 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -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; diff --git a/core/includes/common.inc b/core/includes/common.inc index 5350acba31ec..f6a42a17109a 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 045b2dd417c8..69543cf0af89 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 4eb5f48bace6..d85ae6313d2d 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 e488cd7f3641..5a5f92339baa 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -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)) { diff --git a/core/includes/install.inc b/core/includes/install.inc index 44dc75c15255..c24c16533342 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 d2f65b2bfcc6..7476d323c3b2 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. @@ -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'); diff --git a/core/lib/Drupal/Component/Annotation/Plugin.php b/core/lib/Drupal/Component/Annotation/Plugin.php index 504ff401d1aa..6bae9c4f6eb3 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 41684d3e709c..127656539ad5 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 be690488defa..95c4e34d0c7a 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 8aa35299beea..eda980cfd8ae 100644 --- a/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php +++ b/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php @@ -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); } } } diff --git a/core/lib/Drupal/Component/FileCache/FileCache.php b/core/lib/Drupal/Component/FileCache/FileCache.php index eea92ac1947e..256d5dd79fe3 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 a92bccb1271a..bbdd8e8ae6a2 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 533b026236ab..f664a06fa30a 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 8d62175e604d..977892ddabf4 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 934049033c1a..f7403e2fdd57 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 875c9d3ef961..55a3b4374c0a 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 14fdda986e59..f63a9a0ab875 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 5631483d45bd..9392d565109c 100644 --- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php +++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php @@ -257,7 +257,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 616e936b557e..de6edae00619 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 6014fb8bff61..fc6fab38bfa9 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 b04ee5c55cfd..789b7274aafc 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 d402d70b543a..18e3658d3237 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 63d20076c6fb..634120133dd2 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 96a2b834bdaf..85935b0b618a 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 404a38820a02..bb345e4d2659 100644 --- a/core/lib/Drupal/Core/Command/DbDumpCommand.php +++ b/core/lib/Drupal/Core/Command/DbDumpCommand.php @@ -186,7 +186,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 5736bd1f5a1c..4b76025c11d1 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 f43ede2a6375..c1633dbcb538 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 3a3ccbad3d57..abcb41fe7e78 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); @@ -293,7 +293,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 4f445ea21c77..0bf960e93e4d 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 35fe0284e3ee..c68ac7255e68 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 fad13076ec03..08731ab9d7a5 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() ?? ''; @@ -521,7 +521,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 1f91da8c69c5..d631a66f97dd 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php @@ -471,7 +471,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 757ce8ba6f1d..a18968873c83 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 fed16db7d0ac..14e45059efce 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 220a350490e2..3fa470be170e 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 547969bbccec..8e715baf6704 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 c317e29e02cf..c616741a5cc8 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 59e0a67ae623..c45dfbd28761 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 9337ff1b384f..4f28e5b669a7 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -958,7 +958,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 e05f10c86eb0..283035b835b7 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 a5b6ae3296ca..9154a0188a9d 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 4f4663d5cb5e..210b2a64088d 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php @@ -428,7 +428,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 16793b803403..80198371bb28 100644 --- a/core/lib/Drupal/Core/Database/Query/Condition.php +++ b/core/lib/Drupal/Core/Database/Query/Condition.php @@ -399,7 +399,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 b758f2214e15..90a9abab1e11 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 8a8672367532..5da38481662c 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 8c083e37babf..ab68dec877b4 100644 --- a/core/lib/Drupal/Core/Database/StatementPrefetch.php +++ b/core/lib/Drupal/Core/Database/StatementPrefetch.php @@ -435,7 +435,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. @@ -521,7 +521,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; @@ -586,7 +586,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 e3bfa9c59a3c..e1d0aea4720a 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 87294d933a7c..5daa81a65587 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 aa943c724650..c2c28b38e774 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 a6f79c6820e2..21f77dd55dad 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 cf535dfc8b1f..6862cc465f34 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 8a79378919ee..8022440efafb 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/TaggedHandlersPass.php @@ -134,9 +134,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); @@ -181,10 +181,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(); } } @@ -228,15 +228,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 55cd154e0502..cab99558f0aa 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 04ce6ca97b03..d9c18029994a 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)); @@ -778,7 +778,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 3913143156ff..ee965898bc6a 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 a395e3bc4157..d1044043a577 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -632,7 +632,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 5904851dabfc..73f07bf0916e 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 5d8f25698b4a..4dd93475fb72 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 1083f1127ae1..083de1d63975 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 dfa011ed55f7..3dcffd2cfa4b 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 68dbe437c0d3..44a673489679 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 c2b67869305c..7dce1ff3c307 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 c8459426125d..4b1b9b1d7fe4 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 ca3e1e04d378..6f970268090c 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageBase.php @@ -294,7 +294,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 4b8abf1e1d3d..527930c0670b 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 aa917c845cb5..8aef5ee039e1 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 fae13959578d..8b7daa354fed 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 90e56472cf8c..2ff43fcb1622 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 da5c76031b55..85878aa75cbc 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 c2699dd4c906..ad66a4297210 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 7f307debaf74..a21f2646987d 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -1048,7 +1048,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 3e362317b574..e3910fd6f01e 100644 --- a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php +++ b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php @@ -60,10 +60,7 @@ public static function createFromDataType($data_type) { 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 @@ 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 +131,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 dd0b355c79f1..906dab45deb9 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 718be0aa53b1..7189560d1720 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 ab4be3869846..5aed60c0b04c 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 74b0834ab3c8..1b22117ae227 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 bb55a1d85299..21970253e91b 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 7cd56e25788e..4a0b53d2f052 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 4f3bdf99b748..3f4fc4ea5d8a 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 80bb222d9dc2..9fbc65937a80 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 efdc92eddf85..d337350983ef 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/EmailDefaultWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php index 07f66cf269a8..76d0bdd24e68 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/EmailDefaultWidget.php @@ -74,7 +74,7 @@ public function settingsSummary() { 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, 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 d9f5b581f389..2ce3912d8bda 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/Plugin/Field/FieldWidget/NumberWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php index b4fac537b476..976b52832e71 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php @@ -66,7 +66,7 @@ public function settingsSummary() { * {@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 += [ diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php index 3be168176143..a0bb425f0cb8 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/StringTextfieldWidget.php @@ -70,7 +70,7 @@ public function settingsSummary() { 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'), diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php index f89b4442e45a..4d8dc0e14389 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php @@ -70,7 +70,7 @@ public function settingsSummary() { 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'), diff --git a/core/lib/Drupal/Core/Field/PluginSettingsBase.php b/core/lib/Drupal/Core/Field/PluginSettingsBase.php index 4e38e755f142..528d7d507c14 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 ce896fb5f45c..a5549e670132 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'] = '<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 @@ 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 80e9718769c6..e5afb21e5fcd 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 8acb6321b9d5..6388b857c767 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 b0366e5ef64d..8c2af13bb0ca 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 c37150c7796c..82b7d3c9e251 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 ad5e3b4a56f7..ead499c70ce0 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 eb5295cdbe57..dd1687d56bac 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 033175188a69..d80a8720cabd 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 2cd0c6895735..12d740350918 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 5e161ec1de31..f3c0962306ae 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 49a7a2cc6862..edc09131db2e 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 c61b5db0aa0b..22d5bbaf02c7 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 62a7fc7007d4..b343a2f36fed 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 6a9cb7c9b82a..1fad49ce79c3 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 87e78d868ce5..85ca11bb63f9 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 52d153c3edc1..7f8ae617a400 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 05887d3da1f0..895650c89ca1 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 d07556bc1815..248cf7adbf25 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 a6060b710f23..444f8654d7de 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 071a5648b01a..c3fa2ee5bb2c 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 c1e657b1675d..f2e1501253cb 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 0d25f75c6951..cdf055487325 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 62fe3c1112cf..f911d72e8594 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 78c477e65f87..eedc008382e4 100644 --- a/core/lib/Drupal/Core/Render/Element/HtmlTag.php +++ b/core/lib/Drupal/Core/Render/Element/HtmlTag.php @@ -146,7 +146,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, @@ -181,11 +181,11 @@ public static function preRenderConditionalComments($element) { // Ensure what we are dealing with is safe. This would be done later anyway // in \Drupal::service('renderer')->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 36abb32b1844..8f7efca552d8 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 a64312ff630c..38a043e5f917 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 a8a7a36d91cb..908e66044a74 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 1de1f4c61c38..ed927652634d 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 2dc416f4bd7b..950eb68ae685 100644 --- a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php +++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php @@ -429,7 +429,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 c445d8507c6b..e9dd1ed17539 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 46992d8f68c2..fe1890f57ddd 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 d250d57329b0..d903acf88d15 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 086e84f929de..6c598ccb0a91 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 385d317f4ae9..674c00e28f2a 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 9deb15d9f419..f95116e5f77e 100644 --- a/core/lib/Drupal/Core/Render/Renderer.php +++ b/core/lib/Drupal/Core/Render/Renderer.php @@ -370,9 +370,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'])) { @@ -581,7 +581,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; } /** @@ -731,7 +731,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 dac9714d1f92..31b2b8f0afa5 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 f35c954596fc..a71e5b2752fa 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 517bfb208356..8f24cf3cb09c 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 03631793c29e..e1a234c92973 100644 --- a/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php +++ b/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php @@ -543,8 +543,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 @@ -585,7 +585,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 de780437b889..24795a466ea0 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 08f1b7cea338..2a4e8d95f131 100644 --- a/core/lib/Drupal/Core/Theme/Registry.php +++ b/core/lib/Drupal/Core/Theme/Registry.php @@ -500,7 +500,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 c81be077f54c..d9c3830143a2 100644 --- a/core/lib/Drupal/Core/Theme/ThemeInitialization.php +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php @@ -261,8 +261,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 18f05b9ea007..09a2dc267959 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 44a8301ef062..8ac57a164100 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 71fa357778d0..18d68267a456 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 72768aa39bdf..800bcb37a532 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 3003c1737c5b..6ac4169877e4 100644 --- a/core/lib/Drupal/Core/Validation/DrupalTranslator.php +++ b/core/lib/Drupal/Core/Validation/DrupalTranslator.php @@ -115,7 +115,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 40174b349b24..53e4424984c0 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 22c35644e669..297149dda8aa 100644 --- a/core/modules/block/src/BlockForm.php +++ b/core/modules/block/src/BlockForm.php @@ -248,7 +248,7 @@ protected function buildVisibilityInterface(array $form, FormStateInterface $for } /** @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 12d023cd3912..58a44e66373b 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -540,7 +540,7 @@ public function deleteFromBook($nid) { */ public function bookTreeAllData($bid, $link = NULL, $max_depth = NULL) { // Use $nid as flag for whether the data being loaded is for the whole tree. - $nid = isset($link['nid']) ? $link['nid'] : 0; + $nid = $link['nid'] ?? 0; $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(); // Create a cache ID for the given $nid, $link, $langcode and $max_depth. @@ -747,7 +747,7 @@ protected function doBookTreeBuild($bid, array $parameters = []) { return $cache->data; } - $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. @@ -756,7 +756,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']); @@ -821,7 +821,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 f9316c6a586d..b344edff9d4d 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' => '<a href="#" role="button" title="' . $button['label'] . '" aria-label="' . $button['label'] . '"><span class="cke_button_icon">', '#suffix' => '</span></a>', diff --git a/core/modules/comment/src/CommentManager.php b/core/modules/comment/src/CommentManager.php index 815a391b180f..565df434b851 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 35ce99b7ebe4..4e918ed5a8bc 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 1ea452362b8b..612b0f1bc32f 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 42754e2c9b23..c659531b1331 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('<span lang="@langcode">@value</span>', [ '@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 1a66307611c0..728063ad5756 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 6a81f5401dee..da2541b1c1f2 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 12259d8dba27..301932f46c39 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 b585961d2dfd..d967f717e4a2 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/FieldTranslationSynchronizer.php b/core/modules/content_translation/src/FieldTranslationSynchronizer.php index 4c4aaaf93bf2..336909d2a7e8 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 1723e09708b3..c5f3bb2aa06a 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 c4bd3b21f714..27c71dcbcb87 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 203f15d0bd0a..5f77efcd6cd6 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 f4ca8b8febf5..bf2e578feff9 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 4a76f7c86557..da32ff01cba0 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; } /** @@ -403,8 +403,7 @@ function editor_entity_update(EntityInterface $entity) { // Detect file usages that should be incremented. foreach ($uuids_by_field as $field => $uuids) { - $original_uuids = isset($original_uuids_by_field[$field]) ? - $original_uuids_by_field[$field] : []; + $original_uuids = $original_uuids_by_field[$field] ?? []; if ($added_files = array_diff($uuids_by_field[$field], $original_uuids)) { _editor_record_file_usage($added_files, $entity); diff --git a/core/modules/editor/src/Form/EditorImageDialog.php b/core/modules/editor/src/Form/EditorImageDialog.php index 6308aea77313..a1ced5747b31 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 1b1735a2e781..df0bcfef69d8 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 7d5389778c4f..3f18a0fed7a6 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 1125ab97ec3f..dee08eb58d34 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 9a8e86abb735..1e9c82cd3a94 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 72e954bf0cb4..4b612bffaa78 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 758e803eb5d4..a64a14968903 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 e8cf7f5fa687..967b4cbd796c 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/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php index 9dd3387e5aae..b2f9738f24c8 100644 --- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php +++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php @@ -63,7 +63,7 @@ public function settingsSummary() { public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element += [ '#type' => 'textfield', - '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : '', + '#default_value' => $items[$delta]->value ?? '', ]; return ['value' => $element]; } diff --git a/core/modules/field_ui/src/Element/FieldUiTable.php b/core/modules/field_ui/src/Element/FieldUiTable.php index 839a0ed5f44a..8dee40d7333a 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 97d234aad4f2..8f399144099f 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'] = '<div class="ajax-new-content">' . (isset($element['#prefix']) ? $element['#prefix'] : ''); - $element['#suffix'] = (isset($element['#suffix']) ? $element['#suffix'] : '') . '</div>'; + $element['#prefix'] = '<div class="ajax-new-content">' . ($element['#prefix'] ?? ''); + $element['#suffix'] = ($element['#suffix'] ?? '') . '</div>'; } } @@ -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 5442d7fa7ee6..6ee46132f2d4 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 eeb54fcb4415..73ed8b439599 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 c4af96099c9b..8a1139b0df0e 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 bf1994c1f93c..d70c0aadd4cb 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 62e44a390724..d222f3560c9d 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -713,9 +713,9 @@ function _file_save_upload_from_form(array $element, FormStateInterface $form_st // from the messenger service. $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); @@ -1431,7 +1431,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.')); @@ -1725,7 +1725,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)); @@ -1807,7 +1807,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 cd5006a62801..e198f353dc8f 100644 --- a/core/modules/file/src/Element/ManagedFile.php +++ b/core/modules/file/src/Element/ManagedFile.php @@ -136,11 +136,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' => []]; } @@ -220,7 +220,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 9f8bc687fb7a..758d483e0139 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 <em>Description</em> 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 da7c22e8d750..889279788871 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 9a0c93f610d6..86987453de7e 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 7b7b2df31164..1332a0c9cfda 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 cdb0e3da3194..cbfe67fa3c18 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 db17056c178d..2e688aa71f3b 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 8bf800e11a86..c11ec858f803 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 3a5ec47c74d8..3e9a16e9a6cc 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 50315dc30ad6..d078cf154a72 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 5f075b3bbf8e..5a7ad036f8ff 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 69b7a513e400..1a629dd0a488 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 17360160a35e..5a602339a226 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 d4a03267bb53..82cef6e7757c 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 7a7991f158dc..1c5c34db1612 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 ca588d12f7a2..9ce8a725ce2d 100644 --- a/core/modules/jsonapi/src/Controller/EntityResource.php +++ b/core/modules/jsonapi/src/Controller/EntityResource.php @@ -901,8 +901,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 7587cb324290..a0a33b69bfd6 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 af055b1c16ee..2aad83386f94 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 1e0930eea994..ff9c1c7b532b 100644 --- a/core/modules/jsonapi/src/Normalizer/EntityAccessDeniedHttpExceptionNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/EntityAccessDeniedHttpExceptionNormalizer.php @@ -40,9 +40,8 @@ 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 c428b3c788f4..8e65b7789c72 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.'); diff --git a/core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php b/core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php index 8a21f420202b..a79eb95b5411 100644 --- a/core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php +++ b/core/modules/jsonapi/src/Normalizer/ResourceObjectNormalizer.php @@ -122,11 +122,7 @@ 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 faa7017455c5..7963ca2ac2e1 100644 --- a/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php +++ b/core/modules/jsonapi/src/ResourceType/ResourceTypeRepository.php @@ -204,7 +204,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 8a7586a26207..609ed91312a0 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 ba22bb7db7e4..58838f000275 100644 --- a/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php +++ b/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php @@ -1705,7 +1705,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 a55e65a23cb6..7a5c4fa1d1c5 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 543e9a0e754d..b6790da2b5a1 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 f268cb65a3fd..5dbdeda0eff1 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 22d569f64ee8..44900447060b 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 0679a563d21e..6af8c1458569 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 707b5ebe9edf..8f43315452e9 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 40a0d0296d74..c4e083ab1a30 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 b78dbb9e4008..34474f35e553 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; @@ -214,7 +214,7 @@ protected function hasLowerLanguageNegotiationWeight() { */ protected function meetsContentEntityRoutesCondition(Route $outbound_route, Request $request) { $outbound_path_pattern = $outbound_route->getPath(); - $storage = isset($this->paths[$request]) ? $this->paths[$request] : []; + $storage = $this->paths[$request] ?? []; if (!isset($storage[$outbound_path_pattern])) { $storage[$outbound_path_pattern] = FALSE; diff --git a/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php b/core/modules/language/src/Plugin/LanguageNegotiation/LanguageNegotiationSession.php index a9dce393aeb7..f36d43e94652 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 = $request->query->all(); foreach ($this->languageManager->getNativeLanguages() as $language) { diff --git a/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php b/core/modules/language/tests/src/Functional/LanguageUrlRewritingTest.php index 018ed621f7a3..93827d3e135e 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('<front>', [], $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 cc849733e362..6e8d0a25f93a 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 8bf656475bd5..5c91b1e39208 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 60948896647a..c0794f9e2707 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 e87bb7c30551..b06f66f5a9b8 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 2627ccf1d862..b0f8ff13e4f3 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 eb9e5afc4f06..c97584b39cff 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 3eed9fe2f994..ce08617e025d 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/link/src/Plugin/Field/FieldWidget/LinkWidget.php b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php index 9bb9f8de5eea..721841f1ae4a 100644 --- a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php +++ b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php @@ -233,7 +233,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen '#type' => 'textfield', '#title' => $this->t('Link text'), '#placeholder' => $this->getSetting('placeholder_title'), - '#default_value' => isset($items[$delta]->title) ? $items[$delta]->title : NULL, + '#default_value' => $items[$delta]->title ?? NULL, '#maxlength' => 255, '#access' => $this->getFieldSetting('title') != DRUPAL_DISABLED, '#required' => $this->getFieldSetting('title') === DRUPAL_REQUIRED && $element['#required'], diff --git a/core/modules/locale/locale.batch.inc b/core/modules/locale/locale.batch.inc index fcc284618fcc..8b3fe6ac434a 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 dd67e8f2b4ea..b4f70a4be6d6 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 1c81cc87f9a4..9b0209fd57ac 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 e1ac093d629e..c781ec0f46ec 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 2672d5c38a56..74667cf1fe3a 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 aa2f74bc4a6e..18b8f834b357 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 ? ('<span class="visually-hidden">' . $this->t('Translated string (@language)', ['@language' => $langname]) . '</span>') : '', ]; @@ -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 2186187ad61a..649499377796 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 4ac817c784dc..e354153dfd75 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 289e838e0545..2817251a829c 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 05faa17db31e..8147b4c0eb4c 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 8f1920e64930..0913a69cdaf7 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 dd59954bf7c1..94cd6413a2df 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 55572d07d51a..832d1965b0fa 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 c32d23f2d25f..ac8ef1440b52 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 0dc9bd20a771..b4d3112e9c6d 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 ca8b7671a0f6..65f2d5986505 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 5cc284835e60..df21b94c3834 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 289fc8aad080..ded58b036c86 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 a63bc7dc875f..83742a3a172d 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 1d890c974d3a..017c99e65be0 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'], @@ -636,7 +636,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; } /** @@ -920,10 +920,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 0aec98069ce2..83a2a086f2a0 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 afe0aee563e3..61279cb7a76c 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 090567541ee2..aaa740624153 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 4cc166c81c55..bcf73ad537f8 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 021edfd6ba72..0891311cfa46 100644 --- a/core/modules/migrate/src/Plugin/Migration.php +++ b/core/modules/migrate/src/Plugin/Migration.php @@ -412,7 +412,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; @@ -657,7 +657,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 bb4f6c0be8ba..6f53b87f5043 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 d96bfab70dcb..0e9668b54f27 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 3490ae81e318..801d65d6c469 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 b6f3839df8cf..05229f03d1b7 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 536a9e1b0ab8..b2051c2a5b51 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 e5d14efe7a64..4cb76c801e43 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 granularity values (also // known as "collected date attributes") resulted in invalid timestamps diff --git a/core/modules/migrate/src/Plugin/migrate/process/MakeUniqueBase.php b/core/modules/migrate/src/Plugin/migrate/process/MakeUniqueBase.php index 861a6b6f8890..ee421b08466c 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 d97c3ba51a78..45835f153cde 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/Substr.php +++ b/core/modules/migrate/src/Plugin/migrate/process/Substr.php @@ -71,11 +71,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_drupal/src/FieldDiscovery.php b/core/modules/migrate_drupal/src/FieldDiscovery.php index 176988532440..f1c4745ece90 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 428bfd2b42cd..0df37ea25641 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/DrupalSqlBase.php @@ -133,7 +133,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 176749480b54..4ddc36e84715 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 @@ -40,7 +40,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/Plugin/Search/NodeSearch.php b/core/modules/node/src/Plugin/Search/NodeSearch.php index b23112ae31f3..5412541a49b7 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' => '<div class="criterion">', '#suffix' => '</div>', '#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' => '<div class="criterion">', '#suffix' => '</div>', '#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 e120ef9cc671..a1a3166420e6 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 1238e0ee981d..c741e2742fa0 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 ae35363e270e..f81777e42199 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 5ad9539d3ea4..228352045465 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 74ed9652d962..b982d2b34820 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 1c003a51639b..69b5f724ebdd 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 17e00500c9de..7bceff174ec4 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 b7c4ab41c025..0c64978df8b5 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 9b9e28573ea5..b328e452e03e 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 8db7d159f2a8..a9e49ffc21a6 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 c70c43d8bbb2..10d0037bf39e 100644 --- a/core/modules/serialization/src/Normalizer/DateTimeIso8601Normalizer.php +++ b/core/modules/serialization/src/Normalizer/DateTimeIso8601Normalizer.php @@ -56,10 +56,13 @@ public function normalize($datetime, $format = NULL, array $context = []) { */ 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); - if ($field_definition === NULL) { + if (isset($context['target_instance'])) { + $field_definition = $context['target_instance']->getFieldDefinition(); + } + elseif (isset($context['field_definition'])) { + $field_definition = $context['field_definition']; + } + else { 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 b84e170d6b75..42a715092b75 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 c35ed41add84..379d0f9d8a79 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 483ad43efe5e..2e61158dda35 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 eba01ba91856..3071c59d606f 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 636db2008cf8..bdec9903dffc 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 038b1333019e..761c32a08ddd 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 be3adb210fad..417fa6a5f560 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 b7e0450320ba..ec50babddce8 100644 --- a/core/modules/system/src/Form/ModulesListForm.php +++ b/core/modules/system/src/Form/ModulesListForm.php @@ -276,7 +276,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', @@ -320,7 +320,7 @@ protected function buildRow(array $modules, Extension $module, $distribution) { '@core_version' => \Drupal::VERSION, ]); $row['#requires']['core'] = $this->t('Drupal Core (@core_requirement) (<span class="admin-missing">incompatible with</span> 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 d83cd422ef9b..c9c993775161 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 8fa152625f2a..51b57e6be1e0 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: <code>@implicit-public-file</code> (for a file in the public filesystem), <code>@explicit-file</code>, or <code>@local-file</code>.', [ - '@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 faac373b9eab..cb3c42f8a42a 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 40fa1037ec75..65fb20a62b06 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 2d3606bfeded..1295b6d18b3f 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -944,7 +944,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 aecb4dd0de93..88f304e2bdde 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/entity_test/src/Plugin/Field/FieldWidget/ShapeOnlyColorEditableWidget.php b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldWidget/ShapeOnlyColorEditableWidget.php index 6283bc3cea9c..e12c6bff62ca 100644 --- a/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldWidget/ShapeOnlyColorEditableWidget.php +++ b/core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldWidget/ShapeOnlyColorEditableWidget.php @@ -30,7 +30,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $element['color'] = [ '#type' => 'textfield', - '#default_value' => isset($items[$delta]->color) ? $items[$delta]->color : NULL, + '#default_value' => $items[$delta]->color ?? NULL, '#size' => 255, ]; 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 6741eac9646d..f9354820a430 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 350d14530223..206bf394b492 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 75097b3954b4..47416c0dba35 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 720ff0850b5a..30575f2abe62 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 a7a38cbbcfdc..0b918bf7314e 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 b1822dedda45..65af6623be71 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 93d0ab397881..805f56b8c28f 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/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php b/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php index 1ea1837dea1d..99db3c13fe94 100644 --- a/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php +++ b/core/modules/telephone/src/Plugin/Field/FieldWidget/TelephoneDefaultWidget.php @@ -64,7 +64,7 @@ public function settingsSummary() { public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $element['value'] = $element + [ '#type' => 'tel', - '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL, + '#default_value' => $items[$delta]->value ?? NULL, '#placeholder' => $this->getSetting('placeholder'), ]; return $element; diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php index 8f4c73ba695c..e6954cc1df05 100644 --- a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php +++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php @@ -28,7 +28,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $element = $main_widget['value']; $element['#type'] = 'text_format'; - $element['#format'] = isset($items[$delta]->format) ? $items[$delta]->format : NULL; + $element['#format'] = $items[$delta]->format ?? NULL; $element['#base_type'] = $main_widget['value']['#type']; return $element; } 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 e279332a5717..59c5ab57ed24 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 032817a91293..8e168fe0a816 100644 --- a/core/modules/tour/src/Entity/Tour.php +++ b/core/modules/tour/src/Entity/Tour.php @@ -144,7 +144,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 ab9fc8e39f6b..4716af427131 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/user/src/Controller/UserController.php b/core/modules/user/src/Controller/UserController.php index ac3540cb1a43..d6c298d3008b 100644 --- a/core/modules/user/src/Controller/UserController.php +++ b/core/modules/user/src/Controller/UserController.php @@ -345,7 +345,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 7a67c466e3fe..9ba582d46b4b 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 02ba6163f6bc..26f8d64e5e54 100644 --- a/core/modules/user/src/Plugin/migrate/source/d6/UserPictureFile.php +++ b/core/modules/user/src/Plugin/migrate/source/d6/UserPictureFile.php @@ -52,7 +52,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 08143dca37be..833cdc5be64a 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -522,7 +522,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(), @@ -555,7 +555,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 f769f7339520..89f465988be1 100644 --- a/core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php +++ b/core/modules/views/src/Entity/Render/TranslationLanguageRenderer.php @@ -60,8 +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'] : + $query_base_table = $query->relationships[$relationship]['base'] ?? $this->view->storage->get('base_table'); $revision_table = $storage->getRevisionTable(); $revision_data_table = $storage->getRevisionDataTable(); @@ -104,7 +103,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 1a194699516c..0069beee7e19 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 476a808cd133..a1a9ccf87a31 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 6fc6805dbc93..efe78d077068 100644 --- a/core/modules/views/src/Plugin/views/area/Result.php +++ b/core/modules/views/src/Plugin/views/area/Result.php @@ -80,7 +80,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 aafcbf2095d6..c62d4646effb 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 628b6f7a58e1..3da81eb1a2ee 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 2eb1870ed140..24dfcd967bec 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 66df4a6e465a..8cbb2fd3439f 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 0d89fb724be7..4a9f2fbbdd85 100644 --- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php @@ -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 c0c874d9b9cc..e2104da8a751 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 b733524033cb..ca3e6b7dfd67 100644 --- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php @@ -554,7 +554,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 ff6a2dce2e6e..ff5261cadb79 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 38a5283606c9..821fffaaedfd 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 75f097e1348b..ec542fc52d3d 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 9d72ddae892a..e33994b2ebde 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 <a href="https://www.php.net/manual/datetime.format.php#refsect1-datetime.format-parameters" target="_blank">the PHP docs</a> 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 d3525f4e1042..61db27cd1033 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 8207fce70cb2..0fe56cbc65e8 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 83d6dee7f653..8ee361729c12 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 77924234d1ce..3c288fe61e4d 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((int) $value, isset($this->options['granularity']) ? $this->options['granularity'] : 2); + return $this->dateFormatter->formatInterval((int) $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 4d4cdb8be06f..4207ef9ea68a 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'] = '<div class="views-group-box views-right-70">' . (isset($form['value']['#prefix']) ? $form['value']['#prefix'] : ''); - $form['value']['#suffix'] = (isset($form['value']['#suffix']) ? $form['value']['#suffix'] : '') . '</div>'; + $form['value']['#prefix'] = '<div class="views-group-box views-right-70">' . ($form['value']['#prefix'] ?? ''); + $form['value']['#suffix'] = ($form['value']['#suffix'] ?? '') . '</div>'; } } diff --git a/core/modules/views/src/Plugin/views/filter/StringFilter.php b/core/modules/views/src/Plugin/views/filter/StringFilter.php index 403401c2147e..5d027309a4a6 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 f9168089747f..5227a6ac4306 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 53a9ac037c68..1f090ac81bd2 100644 --- a/core/modules/views/src/Plugin/views/query/Sql.php +++ b/core/modules/views/src/Plugin/views/query/Sql.php @@ -1074,7 +1074,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 9041bef185b0..20b4229506e0 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 61359978e58a..c5116f3fbd49 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 33351185041c..e3d2c5893389 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 dc80f7e028fe..aaa009c4426e 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 7db524788665..09b26fad5138 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 b91ce83f1bb4..faacdf8e51a2 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 f6e88034e76d..5a508b779902 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 d1188ce411e6..335ac065e005 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 5cd0938bad89..adf8ade188cc 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 859243f6873b..8964cecc0c97 100644 --- a/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php +++ b/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php @@ -77,7 +77,7 @@ protected function setUp(): void { ->willReturnCallback(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 15c4e5b4d98b..8517215b572f 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 01c26ac2d6e9..3dbe2b33fe90 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 153d3d3544e2..88ab2d0c2b1e 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 09061d4c91f9..6f6d723cd653 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/scripts/run-tests.sh b/core/scripts/run-tests.sh index 542006552675..edb6cab39de0 100755 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -500,7 +500,7 @@ function simpletest_script_init() { $parsed_url = parse_url($args['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'] : $port); + $port = $parsed_url['port'] ?? $port; if ($path == '/') { $path = ''; } diff --git a/core/tests/Drupal/KernelTests/AssertContentTrait.php b/core/tests/Drupal/KernelTests/AssertContentTrait.php index 58eabfc38890..a76d357ea4a3 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/FileCache/StaticFileCacheBackend.php b/core/tests/Drupal/Tests/Component/FileCache/StaticFileCacheBackend.php index 328fd5288366..32fa21526114 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 caae2d827938..84c909e1a3b5 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 9448e6cdc1bf..aacd9b59203a 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 da914e766615..e355bc053d23 100644 --- a/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php @@ -851,7 +851,7 @@ class TestLibraryDiscoveryParser extends LibraryDiscoveryParser { protected $validUris; 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 5753f1a7d702..cd1be3f9fcae 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/DefaultTableMappingTest.php @@ -369,17 +369,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 545c0e12105d..4bba2d2326f2 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 cfba3cb61a72..ae72ea1c8de9 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 44ccb5b73c21..8938dd44e641 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 '<div' . (string) (new Attribute($vars['#attributes'])) . '>' . $vars['#children'] . "</div>\n"; } - $attributes = new Attribute(['href' => $vars['#url']] + (isset($vars['#attributes']) ? $vars['#attributes'] : [])); + $attributes = new Attribute(['href' => $vars['#url']] + ($vars['#attributes'] ?? [])); return '<a' . (string) $attributes . '>' . $vars['#title'] . '</a>'; }); }; diff --git a/core/themes/claro/claro.theme b/core/themes/claro/claro.theme index 73da194e6205..d7c49a793ea1 100644 --- a/core/themes/claro/claro.theme +++ b/core/themes/claro/claro.theme @@ -348,9 +348,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 40885064e95b..82f73ac9fa3b 100644 --- a/core/themes/claro/src/ClaroPreRender.php +++ b/core/themes/claro/src/ClaroPreRender.php @@ -85,7 +85,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. -- GitLab