diff --git a/languagefield.module b/languagefield.module index 9439ea0e12b5ad062c4241cd68b024cb387f6731..0773b89ca6d1d00720de9a8b9ef1d81dca1ed720 100644 --- a/languagefield.module +++ b/languagefield.module @@ -33,7 +33,7 @@ function languagefield_field_formatter_info_alter(array &$info): void { * @see callback_allowed_values_function() * @see options_allowed_values() */ -function languagefield_allowed_values(FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity = NULL, &$cacheable = TRUE): array { +function languagefield_allowed_values(FieldStorageDefinitionInterface $definition, ?FieldableEntityInterface $entity = NULL, &$cacheable = TRUE): array { $valueOptions = CustomLanguageManager::allowedValues($definition->getSettings()); return $valueOptions; } diff --git a/src/Plugin/Field/FieldType/LanguageItem.php b/src/Plugin/Field/FieldType/LanguageItem.php index 16ae844547667fa90b05572042b26f678e9f9bee..5d31592e6256b5e3bac1d3c38054a4de74de979d 100644 --- a/src/Plugin/Field/FieldType/LanguageItem.php +++ b/src/Plugin/Field/FieldType/LanguageItem.php @@ -297,13 +297,13 @@ class LanguageItem extends LanguageItemBase implements OptionsProviderInterface /** * {@inheritdoc} * - * @param \Drupal\Core\Session\AccountInterface $account + * @param \Drupal\Core\Session\AccountInterface|null $account * (optional) The user account for which to filter the possible options. * If omitted, all possible options are returned. * @param string $format * Extra parameter for formatting options. */ - public function getPossibleOptions(AccountInterface $account = NULL, string $format = 'en'): array { + public function getPossibleOptions(?AccountInterface $account = NULL, string $format = 'en'): array { // Caching as per https://www.drupal.org/node/2661204 static $possible_options = []; @@ -349,7 +349,7 @@ class LanguageItem extends LanguageItemBase implements OptionsProviderInterface /** * {@inheritdoc} */ - public function getPossibleValues(AccountInterface $account = NULL): array { + public function getPossibleValues(?AccountInterface $account = NULL): array { $options = $this->getPossibleOptions($account); return array_keys($options); } @@ -357,7 +357,7 @@ class LanguageItem extends LanguageItemBase implements OptionsProviderInterface /** * {@inheritdoc} */ - public function getSettableValues(AccountInterface $account = NULL): array { + public function getSettableValues(?AccountInterface $account = NULL): array { $options = $this->getSettableOptions($account); // Remove groups from Settable Options. $options = OptGroup::flattenOptions($options); @@ -367,7 +367,7 @@ class LanguageItem extends LanguageItemBase implements OptionsProviderInterface /** * {@inheritdoc} */ - public function getSettableOptions(AccountInterface $account = NULL): array { + public function getSettableOptions(?AccountInterface $account = NULL): array { // Caching as per https://www.drupal.org/node/2661204 static $settable_options; diff --git a/src/Plugin/Tamper/LanguageToCode.php b/src/Plugin/Tamper/LanguageToCode.php index c2a91fa5064310db66e0b94fd1bc8e0b19131a4e..5122a33a1d6c91c3a71eccd5b8356bed1864ee26 100644 --- a/src/Plugin/Tamper/LanguageToCode.php +++ b/src/Plugin/Tamper/LanguageToCode.php @@ -41,7 +41,7 @@ class LanguageToCode extends TamperBase implements ContainerFactoryPluginInterfa /** * {@inheritdoc} */ - public function tamper($data, TamperableItemInterface $item = NULL): array { + public function tamper($data, ?TamperableItemInterface $item = NULL): array { if (!is_string($data)) { throw new TamperException('Input should be a string.'); }