diff --git a/localgov_forms.install b/localgov_forms.install index de960f5..d299eef 100644 --- a/localgov_forms.install +++ b/localgov_forms.install @@ -6,12 +6,13 @@ */ use Drupal\Component\Serialization\Yaml; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\webform\Entity\WebformOptions; /** * Implements hook_install(). */ -function localgov_forms_install() { +function localgov_forms_install(): void { // Override Webforms default configuration. $config = \Drupal::configFactory()->getEditable('localgov_forms.webform.settings'); @@ -24,7 +25,7 @@ function localgov_forms_install() { * * Creates a Webform option for Local custodian codes. */ -function localgov_forms_update_8001() { +function localgov_forms_update_8001(): ?TranslatableMarkup { $has_local_custodian_codes_option = Drupal::service('entity_type.manager')->getStorage('webform_options')->load('local_custodian_codes_gb'); if ($has_local_custodian_codes_option) { @@ -39,4 +40,6 @@ function localgov_forms_update_8001() { $local_custodian_codes_option = Yaml::decode(file_get_contents(__DIR__ . '/config/install/webform.webform_options.local_custodian_codes_gb.yml')); $new_local_custodian_codes_option = WebformOptions::create($local_custodian_codes_option); $new_local_custodian_codes_option->save(); + + return NULL; } diff --git a/localgov_forms.module b/localgov_forms.module index 64d3ccf..a8f1b00 100644 --- a/localgov_forms.module +++ b/localgov_forms.module @@ -10,7 +10,7 @@ use Drupal\Core\Render\Element; /** * Implements hook_theme(). */ -function localgov_forms_theme() { +function localgov_forms_theme(): array { return [ // Form element: localgov_webform_uk_address. 'localgov_forms_uk_address_lookup' => [ @@ -29,7 +29,7 @@ function localgov_forms_theme() { * Makes sub-elements available within the `content` variable. Mostly lifted * from _template_preprocess_webform_composite(). */ -function template_preprocess_localgov_forms_uk_address_lookup(array &$variables) { +function template_preprocess_localgov_forms_uk_address_lookup(array &$variables): void { $element = $variables['element']; foreach (Element::children($element) as $key) { @@ -44,7 +44,7 @@ function template_preprocess_localgov_forms_uk_address_lookup(array &$variables) /** * Prepares variables for the UK address element template. */ -function template_preprocess_localgov_forms_uk_address(array &$variables) { +function template_preprocess_localgov_forms_uk_address(array &$variables): void { template_preprocess_localgov_forms_uk_address_lookup($variables); } @@ -52,6 +52,6 @@ function template_preprocess_localgov_forms_uk_address(array &$variables) { /** * Implements hook_preprocess_hook() for hook_preprocess_webform(). */ -function localgov_forms_preprocess_webform(array &$variables) { +function localgov_forms_preprocess_webform(array &$variables): void { $variables['#attached']['library'][] = 'localgov_forms/localgov_forms.form_errors'; } diff --git a/localgov_forms.tokens.inc b/localgov_forms.tokens.inc index 0c8885c..fc2ee17 100644 --- a/localgov_forms.tokens.inc +++ b/localgov_forms.tokens.inc @@ -16,7 +16,7 @@ use Drupal\webform\Utility\WebformDateHelper; * * Token declarations. */ -function localgov_forms_token_info() { +function localgov_forms_token_info(): array { return [ 'tokens' => [ @@ -42,7 +42,7 @@ function localgov_forms_token_info() { * * @see system_tokens() */ -function localgov_forms_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) { +function localgov_forms_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata): array { $replacements = []; diff --git a/modules/localgov_forms_date/localgov_forms_date.install b/modules/localgov_forms_date/localgov_forms_date.install index a377ffc..17d6139 100644 --- a/modules/localgov_forms_date/localgov_forms_date.install +++ b/modules/localgov_forms_date/localgov_forms_date.install @@ -10,7 +10,7 @@ use Drupal\Component\Serialization\Yaml; /** * Adds a UK short date style e.g dd-mm-yyyy. */ -function localgov_forms_date_update_8001() { +function localgov_forms_date_update_8001(): void { $config_id = 'core.date_format.localgov_forms_date_short_date'; $config_path = \Drupal::service('extension.list.module')->getPath('localgov_forms_date'); $uk_short_html_date_config = Yaml::decode(file_get_contents($config_path . '/config/install/' . $config_id . '.yml')); @@ -20,7 +20,7 @@ function localgov_forms_date_update_8001() { /** * Adds a UK short date style e.g dd-mm-yyyy HH:mm:ss. */ -function localgov_forms_date_update_8002() { +function localgov_forms_date_update_8002(): void { $config_id = 'core.date_format.localgov_forms_date_datetime'; $config_path = \Drupal::service('extension.list.module')->getPath('localgov_forms_date'); $uk_html_datetime_config = Yaml::decode(file_get_contents($config_path . '/config/install/' . $config_id . '.yml')); @@ -30,7 +30,7 @@ function localgov_forms_date_update_8002() { /** * Adds a UUID to LocalGov Forms Date formats. */ -function localgov_forms_date_update_8003() { +function localgov_forms_date_update_8003(): void { $localgov_date_formats = [ 'core.date_format.localgov_forms_date_short_date', 'core.date_format.localgov_forms_date_datetime', diff --git a/modules/localgov_forms_date/localgov_forms_date.module b/modules/localgov_forms_date/localgov_forms_date.module index 104ee79..5351b9f 100644 --- a/modules/localgov_forms_date/localgov_forms_date.module +++ b/modules/localgov_forms_date/localgov_forms_date.module @@ -8,7 +8,7 @@ /** * Datetime Form preprocess function. */ -function localgov_forms_date_preprocess_datetime_form(array &$variables) { +function localgov_forms_date_preprocess_datetime_form(array &$variables): void { // Check that this is a localgov_forms_date form element. if ($variables['element']['#type'] === 'localgov_forms_date') { $variables['attributes']['class'][] = 'localgov-forms-date'; diff --git a/modules/localgov_forms_date/src/Element/LocalgovFormsDate.php b/modules/localgov_forms_date/src/Element/LocalgovFormsDate.php index 4c51003..fad64fa 100644 --- a/modules/localgov_forms_date/src/Element/LocalgovFormsDate.php +++ b/modules/localgov_forms_date/src/Element/LocalgovFormsDate.php @@ -132,7 +132,7 @@ private static function restoreUnprocessedDate(array &$element) :void { * be set in the UI which should take precedence over * the default error message. */ - public static function validateDatelist(&$element, FormStateInterface $form_state, &$complete_form) { + public static function validateDatelist(&$element, FormStateInterface $form_state, &$complete_form): void { $input_exists = FALSE; $input = NestedArray::getValue($form_state->getValues(), $element['#parents'], $input_exists); diff --git a/modules/localgov_forms_date/src/Plugin/WebformElement/LocalgovFormsDate.php b/modules/localgov_forms_date/src/Plugin/WebformElement/LocalgovFormsDate.php index 7b223ce..4c25ad7 100644 --- a/modules/localgov_forms_date/src/Plugin/WebformElement/LocalgovFormsDate.php +++ b/modules/localgov_forms_date/src/Plugin/WebformElement/LocalgovFormsDate.php @@ -65,7 +65,7 @@ public function form(array $form, FormStateInterface $form_state) { /** * {@inheritdoc} */ - public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { + public function validateConfigurationForm(array &$form, FormStateInterface $form_state): void { parent::validateConfigurationForm($form, $form_state); $values = $form_state->getValues(); $values['date_part_order'] = ['day', 'month', 'year']; @@ -77,7 +77,7 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form /** * After build handler for Datelist element. */ - public static function afterBuild(array $element, FormStateInterface $form_state) { + public static function afterBuild(array $element, FormStateInterface $form_state): array { $element = parent::afterBuild($element, $form_state); // Set the property of the date of birth elements. @@ -112,7 +112,7 @@ public static function afterBuild(array $element, FormStateInterface $form_state * * @see Drupal\Webform\Plugin\WebformElement\DateBase::setDefaultValue() */ - public function setDefaultValue(array &$element) { + public function setDefaultValue(array &$element): void { $orig_type = $element['#type']; $element['#type'] = 'datelist'; @@ -127,7 +127,7 @@ public function setDefaultValue(array &$element) { * date validation error messages display in * a UK Style format e.g dd-mm-yyyy. */ - public static function validateDate(&$element, FormStateInterface $form_state, &$complete_form) { + public static function validateDate(&$element, FormStateInterface $form_state, &$complete_form): void { // Adds a short date and short date time format. $localgov_forms_short_date_format = DateFormat::load('localgov_forms_date_short_date')->getPattern(); diff --git a/modules/localgov_forms_date/tests/src/Kernel/DateWebformElementTest.php b/modules/localgov_forms_date/tests/src/Kernel/DateWebformElementTest.php index 789eca5..b529afd 100644 --- a/modules/localgov_forms_date/tests/src/Kernel/DateWebformElementTest.php +++ b/modules/localgov_forms_date/tests/src/Kernel/DateWebformElementTest.php @@ -17,7 +17,7 @@ class DateWebformElementTest extends KernelTestBase { /** * Tests a webform with our date field. */ - public function testFormSubmission() { + public function testFormSubmission(): void { $this->passCase(); $this->failCaseWithInvalidDay(); @@ -28,7 +28,7 @@ public function testFormSubmission() { /** * Tests valid date. */ - protected function passCase() { + protected function passCase(): void { $form_state = new FormState(); $form_state->setValue('date', @@ -42,7 +42,7 @@ protected function passCase() { /** * Tests date with invalid day. */ - protected function failCaseWithInvalidDay() { + protected function failCaseWithInvalidDay(): void { $form_state = new FormState(); $form_state->setValue('date', ['day' => '1D']); @@ -55,7 +55,7 @@ protected function failCaseWithInvalidDay() { /** * Tests date with nonnumeric day. */ - protected function failCaseWithNonNumericDay() { + protected function failCaseWithNonNumericDay(): void { $form_state = new FormState(); $form_state->setValue('date', @@ -69,7 +69,7 @@ protected function failCaseWithNonNumericDay() { /** * Tests date with invalid year. */ - protected function failCaseWithInvalidYear() { + protected function failCaseWithInvalidYear(): void { $form_state = new FormState(); $form_state->setValue('date', @@ -83,7 +83,7 @@ protected function failCaseWithInvalidYear() { /** * {@inheritdoc} */ - protected function setUp() :void { + protected function setUp(): void { parent::setUp(); diff --git a/modules/localgov_forms_example_liberty_create_integration/localgov_forms_example_liberty_create_integration.module b/modules/localgov_forms_example_liberty_create_integration/localgov_forms_example_liberty_create_integration.module index b81d75c..fed4d5f 100644 --- a/modules/localgov_forms_example_liberty_create_integration/localgov_forms_example_liberty_create_integration.module +++ b/modules/localgov_forms_example_liberty_create_integration/localgov_forms_example_liberty_create_integration.module @@ -20,7 +20,7 @@ use Drupal\webform\WebformSubmissionInterface; * - DRUPAL_LIBERTY_CREATE_API_USERNAME * - DRUPAL_LIBERTY_CREATE_API_USER_KEY. */ -function localgov_forms_example_liberty_create_integration_modules_installed($modules, $is_syncing) { +function localgov_forms_example_liberty_create_integration_modules_installed($modules, $is_syncing): void { if (!$is_syncing && in_array('token_environment', $modules, TRUE)) { $token_env_config = Drupal::service('config.factory')->getEditable('token_environment.settings'); @@ -48,7 +48,7 @@ function localgov_forms_example_liberty_create_integration_modules_installed($mo * `[webform_submission:values:name:extracted_lastname:clear]` will resolve to * "Bar". */ -function localgov_forms_example_liberty_create_integration_tokens_alter(array &$replacements, array $context, BubbleableMetadata $bubbleable_metadata) { +function localgov_forms_example_liberty_create_integration_tokens_alter(array &$replacements, array $context, BubbleableMetadata $bubbleable_metadata): void { if ($context['type'] === 'webform_submission' && !empty($context['data']['webform_submission'])) { $firstname_extraction_tokens = array_filter($context['tokens'], fn($token) => strpos($token, ':extracted_firstname')); @@ -76,7 +76,7 @@ function localgov_forms_example_liberty_create_integration_tokens_alter(array &$ * @see localgov_forms_example_liberty_create_integration_webform_handler_invoke_post_save_alter() * @see localgov_forms_example_liberty_create_integration_webform_handler_invoke_post_load_alter() */ -function localgov_forms_example_liberty_create_integration_token_info_alter(&$token_info) { +function localgov_forms_example_liberty_create_integration_token_info_alter(&$token_info): void { $token_info['tokens']['webform_submission']['values:?:file_details_for_liberty_create_api'] = [ 'name' => t('File detail for Liberty Create API'), @@ -87,7 +87,7 @@ function localgov_forms_example_liberty_create_integration_token_info_alter(&$to /** * Implements hook_webform_handler_invoke_METHOD_NAME_alter() for hook_webform_handler_invoke_post_save_alter(). */ -function localgov_forms_example_liberty_create_integration_webform_handler_invoke_post_save_alter(WebformHandlerInterface $handler, array &$args) { +function localgov_forms_example_liberty_create_integration_webform_handler_invoke_post_save_alter(WebformHandlerInterface $handler, array &$args): void { $handler_id = $handler->getHandlerId(); if ($handler_id === 'remote_post' || $handler_id === 'async_remote_post') { @@ -100,7 +100,7 @@ function localgov_forms_example_liberty_create_integration_webform_handler_invok * * Relevant during Queue processing. */ -function localgov_forms_example_liberty_create_integration_webform_handler_invoke_post_load_alter(WebformHandlerInterface $handler, array &$args) { +function localgov_forms_example_liberty_create_integration_webform_handler_invoke_post_load_alter(WebformHandlerInterface $handler, array &$args): void { localgov_forms_example_liberty_create_integration_webform_handler_invoke_post_save_alter($handler, $args); } @@ -121,7 +121,7 @@ function localgov_forms_example_liberty_create_integration_webform_handler_invok * * @see Drupal\webform\Plugin\WebformHandler\RemotePostWebformHandler::getRequestData() */ -function _localgov_forms_example_liberty_create_integration_manage_remote_post_custom_data(WebformHandlerInterface $handler) { +function _localgov_forms_example_liberty_create_integration_manage_remote_post_custom_data(WebformHandlerInterface $handler): void { $webform_submission = $handler->getWebformSubmission(); if (!$webform_submission instanceof WebformSubmissionInterface) { diff --git a/modules/localgov_forms_feedback_form/localgov_forms_feedback_form.install b/modules/localgov_forms_feedback_form/localgov_forms_feedback_form.install index 42431af..4b9218f 100644 --- a/modules/localgov_forms_feedback_form/localgov_forms_feedback_form.install +++ b/modules/localgov_forms_feedback_form/localgov_forms_feedback_form.install @@ -8,6 +8,6 @@ /** * Implements hook_install(). */ -function localgov_forms_feedback_form_install() { +function localgov_forms_feedback_form_install(): void { \Drupal::messenger()->addStatus(t('You have installed the LocalGov Forms Feedback Form. This form stores the form submissions in the database. Make sure you have checked this is okay with your data protection officer, or else change the form settings to store the data somewhere else.')); } diff --git a/modules/localgov_forms_feedback_form/localgov_forms_feedback_form.module b/modules/localgov_forms_feedback_form/localgov_forms_feedback_form.module index a280310..93488ff 100644 --- a/modules/localgov_forms_feedback_form/localgov_forms_feedback_form.module +++ b/modules/localgov_forms_feedback_form/localgov_forms_feedback_form.module @@ -8,6 +8,6 @@ /** * Implements hook_form_FORM_ID_alter(). */ -function localgov_forms_feedback_form_form_webform_submission_localgov_forms_feedback_form_add_form_alter(&$form, $form_state, $form_id) { +function localgov_forms_feedback_form_form_webform_submission_localgov_forms_feedback_form_add_form_alter(&$form, $form_state, $form_id): void { $form['#attached']['library'][] = 'localgov_forms_feedback_form/localgov_forms_feedback_form'; } diff --git a/modules/localgov_forms_lts/localgov_forms_lts.install b/modules/localgov_forms_lts/localgov_forms_lts.install index 6994c61..fa49b55 100644 --- a/modules/localgov_forms_lts/localgov_forms_lts.install +++ b/modules/localgov_forms_lts/localgov_forms_lts.install @@ -34,7 +34,7 @@ function localgov_forms_lts_install($is_syncing): void { * * Checks for the presence of the localgov_forms_lts database. */ -function localgov_forms_lts_requirements($phase) { +function localgov_forms_lts_requirements($phase): array { $requirements = [ 'localgov_forms_lts' => [ @@ -79,7 +79,7 @@ function _localgov_forms_lts_get_webform_submission_storage_schema(): array { /** * Public wrapper over protected method. */ - public function getEntitySchemaWrapper(ContentEntityTypeInterface $entity_type) { + public function getEntitySchemaWrapper(ContentEntityTypeInterface $entity_type): array { return parent::getEntitySchema($entity_type); } diff --git a/modules/localgov_forms_lts/localgov_forms_lts.module b/modules/localgov_forms_lts/localgov_forms_lts.module index 18ed91c..a746817 100644 --- a/modules/localgov_forms_lts/localgov_forms_lts.module +++ b/modules/localgov_forms_lts/localgov_forms_lts.module @@ -30,7 +30,7 @@ function localgov_forms_lts_has_db(): bool { /** * Implements hook_cron(). */ -function localgov_forms_lts_cron() { +function localgov_forms_lts_cron(): void { localgov_forms_lts_copy_recently_added_n_updated_subs(); } diff --git a/modules/localgov_forms_lts/src/Controller/WebformSubmissionLtsViewController.php b/modules/localgov_forms_lts/src/Controller/WebformSubmissionLtsViewController.php index 8f2bca0..7823869 100644 --- a/modules/localgov_forms_lts/src/Controller/WebformSubmissionLtsViewController.php +++ b/modules/localgov_forms_lts/src/Controller/WebformSubmissionLtsViewController.php @@ -18,7 +18,7 @@ class WebformSubmissionLtsViewController extends WebformSubmissionViewController * * Loads the Webform submission from Long term storage. */ - public function viewFromLts(int $webform_sid, $view_mode = 'default', $langcode = NULL) { + public function viewFromLts(int $webform_sid, $view_mode = 'default', $langcode = NULL): array { $webform_sub = $this->ltsStorage->load($webform_sid); return parent::view($webform_sub, $view_mode, $langcode); @@ -29,7 +29,7 @@ public function viewFromLts(int $webform_sid, $view_mode = 'default', $langcode * * Loads the Webform submission from Long term storage. */ - public function noteViewFromLts(int $webform_sid, $view_mode = 'default', $langcode = NULL) { + public function noteViewFromLts(int $webform_sid, $view_mode = 'default', $langcode = NULL): array { $webform_sub = $this->ltsStorage->load($webform_sid); return [ @@ -42,7 +42,7 @@ public function noteViewFromLts(int $webform_sid, $view_mode = 'default', $langc * * Loads the Webform submission from Long term storage. */ - public function titleFromLts(int $webform_sid, $duplicate = FALSE) { + public function titleFromLts(int $webform_sid, $duplicate = FALSE): string { $webform_sub = $this->ltsStorage->load($webform_sid); return parent::title($webform_sub, $duplicate); @@ -51,7 +51,7 @@ public function titleFromLts(int $webform_sid, $duplicate = FALSE) { /** * Factory. */ - public static function create(ContainerInterface $container) { + public static function create(ContainerInterface $container): static { $instance = parent::create($container); diff --git a/modules/localgov_forms_lts/src/Drush/Commands/LocalgovFormsLtsCommands.php b/modules/localgov_forms_lts/src/Drush/Commands/LocalgovFormsLtsCommands.php index 667609f..44ddaa5 100644 --- a/modules/localgov_forms_lts/src/Drush/Commands/LocalgovFormsLtsCommands.php +++ b/modules/localgov_forms_lts/src/Drush/Commands/LocalgovFormsLtsCommands.php @@ -30,7 +30,7 @@ final class LocalgovFormsLtsCommands extends DrushCommands { #[CLI\Command(name: 'localgov-forms-lts:copy', aliases: ['forms-lts-copy'])] #[CLI\Option(name: 'force', description: 'Ignore copy disablement config and copy anyway. Useful immediately after module installation.')] #[CLI\Usage(name: 'localgov-forms-lts:copy', description: 'Copies all existing Webform submissions.')] - public function copy($options = ['force' => FALSE]) { + public function copy($options = ['force' => FALSE]): void { if (!localgov_forms_lts_has_db()) { $this->logger->error(dt('The LocalGov Forms LTS database must exist for this Drush command to function.')); @@ -71,7 +71,7 @@ public function copy($options = ['force' => FALSE]) { * * Copies a fixed number of Webform submissions to LTS. */ - public static function copyInBatch(?PluginInspectionInterface $pii_redactor_plugin, LoggerInterface $drupal_logger, &$context) { + public static function copyInBatch(?PluginInspectionInterface $pii_redactor_plugin, LoggerInterface $drupal_logger, &$context): void { $lts_copy_obj = LtsCopy::create(\Drupal::getContainer(), $pii_redactor_plugin); $copy_results = $lts_copy_obj->copy(); diff --git a/modules/localgov_forms_lts/src/Form/LTSSettingsForm.php b/modules/localgov_forms_lts/src/Form/LTSSettingsForm.php index 09bbfd4..eb930bf 100644 --- a/modules/localgov_forms_lts/src/Form/LTSSettingsForm.php +++ b/modules/localgov_forms_lts/src/Form/LTSSettingsForm.php @@ -64,7 +64,7 @@ public function __construct(protected ?PluginManagerInterface $optionalPIIRedact * If the PII redactor plugin manager is available, passes it to the * constructor. */ - public static function create(ContainerInterface $container) { + public static function create(ContainerInterface $container): static { $pii_redactor_plugin_manager = $container->has(Constants::PII_REDACTOR_PLUGIN_MANAGER) ? $container->get(Constants::PII_REDACTOR_PLUGIN_MANAGER) : NULL; diff --git a/modules/localgov_forms_lts/src/LtsStorageForWebformSubmission.php b/modules/localgov_forms_lts/src/LtsStorageForWebformSubmission.php index 241f009..4bd6ba3 100644 --- a/modules/localgov_forms_lts/src/LtsStorageForWebformSubmission.php +++ b/modules/localgov_forms_lts/src/LtsStorageForWebformSubmission.php @@ -63,7 +63,7 @@ protected function getFromPersistentCache(?array &$ids = NULL) { /** * See above. */ - protected function setPersistentCache($entities) {} + protected function setPersistentCache($entities): void {} /** * Customizes cache Ids for LTS. diff --git a/modules/localgov_forms_lts/src/WebformSubmissionLtsListBuilder.php b/modules/localgov_forms_lts/src/WebformSubmissionLtsListBuilder.php index 4192694..82a56bf 100644 --- a/modules/localgov_forms_lts/src/WebformSubmissionLtsListBuilder.php +++ b/modules/localgov_forms_lts/src/WebformSubmissionLtsListBuilder.php @@ -73,7 +73,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI /** * {@inheritdoc} */ - public static function create(ContainerInterface $container) { + public static function create(ContainerInterface $container): static { $webform_sub_def = $container->get('entity_type.manager')->getDefinition('webform_submission'); return self::createInstance($container, $webform_sub_def); diff --git a/modules/localgov_forms_lts/tests/src/Kernel/LtsStorageForWebformSubmissionTest.php b/modules/localgov_forms_lts/tests/src/Kernel/LtsStorageForWebformSubmissionTest.php index ee106a3..1a4efac 100644 --- a/modules/localgov_forms_lts/tests/src/Kernel/LtsStorageForWebformSubmissionTest.php +++ b/modules/localgov_forms_lts/tests/src/Kernel/LtsStorageForWebformSubmissionTest.php @@ -25,7 +25,7 @@ class LtsStorageForWebformSubmissionTest extends KernelTestBase { * - Creates a fresh Webform submission entity. * - Tries to save it into the LTS database. */ - public function testLtsDbUsage() { + public function testLtsDbUsage(): void { $contact2_webform = $this->container->get('entity_type.manager')->getStorage('webform')->load(self::TEST_WEBFORM_ID); $this->assertNotNull($contact2_webform); diff --git a/modules/localgov_forms_lts/tests/src/Unit/LtsCopyTest.php b/modules/localgov_forms_lts/tests/src/Unit/LtsCopyTest.php index 9ea869d..48c3223 100644 --- a/modules/localgov_forms_lts/tests/src/Unit/LtsCopyTest.php +++ b/modules/localgov_forms_lts/tests/src/Unit/LtsCopyTest.php @@ -30,7 +30,7 @@ class LtsCopyTest extends UnitTestCase { /** * Tests LtsCopy::copy(). */ - public function testCopySub() { + public function testCopySub(): void { $test_obj = new LtsCopy($this->mockEntityTypeManager, $this->mockLtsKeyValueFactory, $this->mockLtsLoggerFactory, $this->mockLtsStorage); diff --git a/src/Element/AddressLookupElement.php b/src/Element/AddressLookupElement.php index 33c968d..88dc0f4 100644 --- a/src/Element/AddressLookupElement.php +++ b/src/Element/AddressLookupElement.php @@ -79,7 +79,7 @@ public function getInfo() { /** * {@inheritdoc} */ - public static function processAddressLookupElement(&$element, FormStateInterface $form_state, &$form) { + public static function processAddressLookupElement(&$element, FormStateInterface $form_state, &$form): mixed { // Generate a unique ID that can be used by #states. $html_id = Html::getUniqueId('localgov_forms_address_lookup'); $name = $element['#name']; diff --git a/src/Element/UKAddressLookup.php b/src/Element/UKAddressLookup.php index 346d156..5850ef4 100644 --- a/src/Element/UKAddressLookup.php +++ b/src/Element/UKAddressLookup.php @@ -84,6 +84,8 @@ public static function getCompositeElements(array $element) { /** * {@inheritdoc} + * + * @phpstan-ignore-next-line Ignore the next line for return type until webform give one. */ public static function validateWebformComposite(&$element, FormStateInterface $form_state, &$complete_form) { // IMPORTANT: Must get values from the $form_states since sub-elements diff --git a/src/Plugin/WebformElement/UKAddressLookup.php b/src/Plugin/WebformElement/UKAddressLookup.php index 607acb5..f364d4e 100644 --- a/src/Plugin/WebformElement/UKAddressLookup.php +++ b/src/Plugin/WebformElement/UKAddressLookup.php @@ -63,7 +63,7 @@ protected function defineDefaultProperties() { /** * {@inheritdoc} */ - public function preSave(array &$element, WebformSubmissionInterface $webform_submission) { + public function preSave(array &$element, WebformSubmissionInterface $webform_submission): void { $submission_data = $webform_submission->getData(); $webform = $webform_submission->getWebform(); foreach ($submission_data as $key => $value) { diff --git a/tests/src/FunctionalJavascript/GeocoderAddressLookupTest.php b/tests/src/FunctionalJavascript/GeocoderAddressLookupTest.php index 95284be..77f35fd 100644 --- a/tests/src/FunctionalJavascript/GeocoderAddressLookupTest.php +++ b/tests/src/FunctionalJavascript/GeocoderAddressLookupTest.php @@ -28,7 +28,7 @@ class GeocoderAddressLookupTest extends WebDriverTestBase { /** * Test for postcode-based address lookup. */ - public function testAddressLookup() { + public function testAddressLookup(): void { $page = $this->getSession()->getPage(); $session_assert = $this->assertSession(); @@ -87,7 +87,7 @@ public function testAddressLookup() { * restricted to Croydon. Searching for the same search string in these two * elements should bring up different results. */ - public function testLocalCustodianCodeCaching() { + public function testLocalCustodianCodeCaching(): void { $page = $this->getSession()->getPage(); $session_assert = $this->assertSession(); diff --git a/tests/src/FunctionalJavascript/ManualAddressEntryTest.php b/tests/src/FunctionalJavascript/ManualAddressEntryTest.php index fd117dc..2014a93 100644 --- a/tests/src/FunctionalJavascript/ManualAddressEntryTest.php +++ b/tests/src/FunctionalJavascript/ManualAddressEntryTest.php @@ -33,7 +33,7 @@ class ManualAddressEntryTest extends WebDriverTestBase { * - But in the "contact4" Webform, this button should only reveal itself * after an address search. */ - public function testManualAddressEntryBtnPresence() { + public function testManualAddressEntryBtnPresence(): void { $page = $this->getSession()->getPage(); $session_assert = $this->assertSession(); diff --git a/tests/src/Unit/BestEffortPIIRedactorForTextTest.php b/tests/src/Unit/BestEffortPIIRedactorForTextTest.php index a1105b5..f4deae6 100644 --- a/tests/src/Unit/BestEffortPIIRedactorForTextTest.php +++ b/tests/src/Unit/BestEffortPIIRedactorForTextTest.php @@ -17,7 +17,7 @@ class BestEffortPIIRedactorForTextTest extends UnitTestCase { * * Tests redaction of emails, postcodes, and numbers from a given text. */ - public function testRedaction() { + public function testRedaction(): void { $redactable_text = "My email address is foo+bar@example.net.\n Also reachable at qux@example.net. My address is 7 Example road, CR8 2XX.\n I was born on 2001-01-01.\n I have 5 cats."; [, $redaction_count] = BestEffortPIIRedactorForText::redact($redactable_text); diff --git a/tests/src/Unit/BestEffortPIIRedactorTest.php b/tests/src/Unit/BestEffortPIIRedactorTest.php index 4b04734..2c65fae 100644 --- a/tests/src/Unit/BestEffortPIIRedactorTest.php +++ b/tests/src/Unit/BestEffortPIIRedactorTest.php @@ -17,7 +17,7 @@ class BestEffortPIIRedactorTest extends UnitTestCase { /** * Tests PIIRedactorTest::findElemsToRedact(). */ - public function testFindElemsToRedact() { + public function testFindElemsToRedact(): void { $mock_webform = $this->createConfiguredMock(WebformInterface::class, [ 'getElementsDecodedAndFlattened' => [