From 00decfec6c0fdcd499015845f476dcdcd77c4b00 Mon Sep 17 00:00:00 2001 From: Mark Conroy Date: Mon, 13 Oct 2025 12:58:37 +0100 Subject: [PATCH 1/2] adds strict type and returns for all php files in module --- .../Field/FieldFormatter/ButtonsInsideWell.php | 4 +++- .../Field/FieldFormatter/TaxonomyVerticalList.php | 8 +++++--- .../Plugin/Field/FieldFormatter/TwitterFeed.php | 4 +++- .../src/Functional/ServicesLandingPageTest.php | 2 ++ .../src/EntityChildRelationshipUi.php | 4 +++- .../src/EntityReferenceValue.php | 2 ++ .../EntityReferenceSelection/ServicesSelection.php | 12 +++++++----- .../EntityReferenceServicesAutocompleteTest.php | 2 ++ .../LandingPageChildrenTest.php | 2 ++ .../tests/src/Kernel/ChildReferencesTest.php | 2 ++ .../tests/src/Kernel/ParentFieldPathautoTest.php | 2 ++ .../src/Plugin/Block/ServicesRelatedLinksBlock.php | 2 ++ .../Plugin/Block/ServicesRelatedTopicsBlock.php | 4 +++- .../tests/src/Functional/ServicesPageTest.php | 2 ++ .../src/Controller/ServiceStatusPageController.php | 6 ++++-- .../src/EventSubscriber/PageHeaderSubscriber.php | 2 ++ .../localgov_services_status/src/PathProcessor.php | 6 ++++-- .../src/Plugin/Block/ServiceStatusMessage.php | 8 +++++--- .../src/Plugin/views/style/ServiceStatus.php | 2 ++ .../localgov_services_status/src/ServiceStatus.php | 14 +++++++++----- .../ServiceStatusMessageVisibilityTest.php | 2 ++ .../tests/src/Functional/ServiceStatusTest.php | 2 ++ .../tests/src/Kernel/PathTest.php | 2 ++ .../Field/FieldFormatter/LinkNodeReference.php | 6 ++++-- .../tests/src/Functional/ServiceSublandingTest.php | 2 ++ .../tests/src/Functional/TopicListBuilderTest.php | 2 ++ src/Plugin/Block/ServicesBlockBase.php | 6 ++++-- src/Plugin/Block/ServicesCtaBlock.php | 4 +++- src/Plugin/Field/FieldWidget/LinkWithType.php | 4 +++- tests/src/Functional/PagesIntegrationTest.php | 2 ++ tests/src/Functional/ServicesBlockTest.php | 2 ++ tests/src/Functional/WorkflowsIntegrationTest.php | 2 ++ 32 files changed, 96 insertions(+), 30 deletions(-) diff --git a/modules/localgov_services_landing/src/Plugin/Field/FieldFormatter/ButtonsInsideWell.php b/modules/localgov_services_landing/src/Plugin/Field/FieldFormatter/ButtonsInsideWell.php index d1388e9..9e28b59 100644 --- a/modules/localgov_services_landing/src/Plugin/Field/FieldFormatter/ButtonsInsideWell.php +++ b/modules/localgov_services_landing/src/Plugin/Field/FieldFormatter/ButtonsInsideWell.php @@ -1,5 +1,7 @@ $item) { diff --git a/modules/localgov_services_landing/src/Plugin/Field/FieldFormatter/TaxonomyVerticalList.php b/modules/localgov_services_landing/src/Plugin/Field/FieldFormatter/TaxonomyVerticalList.php index b91035a..1c2be00 100644 --- a/modules/localgov_services_landing/src/Plugin/Field/FieldFormatter/TaxonomyVerticalList.php +++ b/modules/localgov_services_landing/src/Plugin/Field/FieldFormatter/TaxonomyVerticalList.php @@ -1,5 +1,7 @@ 'textfield', '#title' => $this->t('Title'), @@ -47,7 +49,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { /** * {@inheritdoc} */ - public function settingsSummary() { + public function settingsSummary(): array { $summary = []; if ($this->getSetting('title')) { @@ -63,7 +65,7 @@ public function settingsSummary() { /** * {@inheritdoc} */ - public function viewElements(FieldItemListInterface $items, $langcode) { + public function viewElements(FieldItemListInterface $items, $langcode): array { return [ '#theme' => 'taxonomy_vertical_list', '#title' => $this->getSetting('title'), diff --git a/modules/localgov_services_landing/src/Plugin/Field/FieldFormatter/TwitterFeed.php b/modules/localgov_services_landing/src/Plugin/Field/FieldFormatter/TwitterFeed.php index 92a7737..19826cb 100644 --- a/modules/localgov_services_landing/src/Plugin/Field/FieldFormatter/TwitterFeed.php +++ b/modules/localgov_services_landing/src/Plugin/Field/FieldFormatter/TwitterFeed.php @@ -1,5 +1,7 @@ $item) { diff --git a/modules/localgov_services_landing/tests/src/Functional/ServicesLandingPageTest.php b/modules/localgov_services_landing/tests/src/Functional/ServicesLandingPageTest.php index 0ed1df5..7299a8c 100644 --- a/modules/localgov_services_landing/tests/src/Functional/ServicesLandingPageTest.php +++ b/modules/localgov_services_landing/tests/src/Functional/ServicesLandingPageTest.php @@ -1,5 +1,7 @@ 'node', 'target_bundles' => [], @@ -125,7 +127,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + public function buildConfigurationForm(array $form, FormStateInterface $form_state): array { $form = parent::buildConfigurationForm($form, $form_state); $configuration = $this->getConfiguration(); @@ -165,7 +167,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta /** * {@inheritdoc} */ - public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) { + public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0): array { $entities = []; $query = $this->buildEntityQuery($match, $match_operator) ->accessCheck(TRUE); @@ -249,7 +251,7 @@ protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') /** * {@inheritdoc} */ - public function countReferenceableEntities($match = NULL, $match_operator = 'CONTAINS') { + public function countReferenceableEntities($match = NULL, $match_operator = 'CONTAINS'): int { $query = $this->buildEntityQuery($match, $match_operator); return $query ->count() @@ -260,7 +262,7 @@ public function countReferenceableEntities($match = NULL, $match_operator = 'CON /** * {@inheritdoc} */ - public function validateReferenceableEntities(array $ids) { + public function validateReferenceableEntities(array $ids): array { $result = []; if ($ids) { $entity_type = $this->entityTypeManager->getDefinition('node'); diff --git a/modules/localgov_services_navigation/tests/src/FunctionalJavascript/EntityReferenceServicesAutocompleteTest.php b/modules/localgov_services_navigation/tests/src/FunctionalJavascript/EntityReferenceServicesAutocompleteTest.php index 4bcac1e..d61d49d 100644 --- a/modules/localgov_services_navigation/tests/src/FunctionalJavascript/EntityReferenceServicesAutocompleteTest.php +++ b/modules/localgov_services_navigation/tests/src/FunctionalJavascript/EntityReferenceServicesAutocompleteTest.php @@ -1,5 +1,7 @@ getPath($request->getPathInfo()); if (substr($request_path, -7) == '/status') { @@ -68,7 +70,7 @@ public function processInbound($path, Request $request) { /** * {@inheritdoc} */ - public function processOutbound($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleableMetadata = NULL) { + public function processOutbound($path, &$options = [], ?Request $request = NULL, ?BubbleableMetadata $bubbleableMetadata = NULL): string { assert($this->pathProcessor instanceof OutboundPathProcessorInterface); // This is the inverse of inbound. Maybe less all-encompassing to swap this diff --git a/modules/localgov_services_status/src/Plugin/Block/ServiceStatusMessage.php b/modules/localgov_services_status/src/Plugin/Block/ServiceStatusMessage.php index 3b5264a..a66c8a3 100644 --- a/modules/localgov_services_status/src/Plugin/Block/ServiceStatusMessage.php +++ b/modules/localgov_services_status/src/Plugin/Block/ServiceStatusMessage.php @@ -1,5 +1,7 @@ cacheContexts); } /** * {@inheritdoc} */ - public function getCacheTags() { + public function getCacheTags(): array { // Invalidate cache on changes to localgov_services_status nodes. return Cache::mergeTags(parent::getCacheTags(), $this->cacheTags, ['node_list:localgov_services_status']); } diff --git a/modules/localgov_services_status/src/Plugin/views/style/ServiceStatus.php b/modules/localgov_services_status/src/Plugin/views/style/ServiceStatus.php index 1ec121b..ddff73e 100644 --- a/modules/localgov_services_status/src/Plugin/views/style/ServiceStatus.php +++ b/modules/localgov_services_status/src/Plugin/views/style/ServiceStatus.php @@ -1,5 +1,7 @@ getStatusUpdates($node, 2, FALSE, TRUE); } @@ -73,10 +75,12 @@ public function getStatusForBlock(Node $node) { * @throws \Drupal\Core\Entity\EntityMalformedException * @throws \Drupal\Core\TypedData\Exception\MissingDataException */ - public function getStatusForPage(Node $node) { + public function getStatusForPage(Node $node): array { return $this->getStatusUpdates($node, 10, TRUE, FALSE); } + + /** * Returns the latest $n status updates for the service landing page. * @@ -97,7 +101,7 @@ public function getStatusForPage(Node $node) { * @throws \Drupal\Core\Entity\EntityMalformedException * @throws \Drupal\Core\TypedData\Exception\MissingDataException */ - public function getStatusUpdates(NodeInterface $landing_node, $n, $hide_from_list = FALSE, $hide_from_landing = FALSE) { + public function getStatusUpdates(NodeInterface $landing_node, $n, $hide_from_list = FALSE, $hide_from_landing = FALSE): array { $query = $this->statusUpdatesQuery($landing_node->id(), $hide_from_list, $hide_from_landing); $result = $query->sort('created', 'DESC') ->range(0, $n) diff --git a/modules/localgov_services_status/tests/src/Functional/ServiceStatusMessageVisibilityTest.php b/modules/localgov_services_status/tests/src/Functional/ServiceStatusMessageVisibilityTest.php index f67536d..b1bf017 100644 --- a/modules/localgov_services_status/tests/src/Functional/ServiceStatusMessageVisibilityTest.php +++ b/modules/localgov_services_status/tests/src/Functional/ServiceStatusMessageVisibilityTest.php @@ -1,5 +1,7 @@ $this->t('View Mode'), '#type' => 'select', diff --git a/modules/localgov_services_sublanding/tests/src/Functional/ServiceSublandingTest.php b/modules/localgov_services_sublanding/tests/src/Functional/ServiceSublandingTest.php index 4df4b2b..a2dd232 100644 --- a/modules/localgov_services_sublanding/tests/src/Functional/ServiceSublandingTest.php +++ b/modules/localgov_services_sublanding/tests/src/Functional/ServiceSublandingTest.php @@ -1,5 +1,7 @@ node->id()]); } /** * {@inheritdoc} */ - public function getCacheContexts() { + public function getCacheContexts(): array { return Cache::mergeContexts(parent::getCacheContexts(), ['route']); } diff --git a/src/Plugin/Block/ServicesCtaBlock.php b/src/Plugin/Block/ServicesCtaBlock.php index af102ac..5fe5996 100644 --- a/src/Plugin/Block/ServicesCtaBlock.php +++ b/src/Plugin/Block/ServicesCtaBlock.php @@ -1,5 +1,7 @@ node->get('localgov_common_tasks')->getValue() as $call_to_action) { diff --git a/src/Plugin/Field/FieldWidget/LinkWithType.php b/src/Plugin/Field/FieldWidget/LinkWithType.php index ab8cb69..da5548a 100644 --- a/src/Plugin/Field/FieldWidget/LinkWithType.php +++ b/src/Plugin/Field/FieldWidget/LinkWithType.php @@ -1,5 +1,7 @@ Date: Mon, 13 Oct 2025 13:24:15 +0100 Subject: [PATCH 2/2] coding standards fix --- modules/localgov_services_status/src/ServiceStatus.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/localgov_services_status/src/ServiceStatus.php b/modules/localgov_services_status/src/ServiceStatus.php index 8cbec73..e978a84 100644 --- a/modules/localgov_services_status/src/ServiceStatus.php +++ b/modules/localgov_services_status/src/ServiceStatus.php @@ -79,8 +79,6 @@ public function getStatusForPage(Node $node): array { return $this->getStatusUpdates($node, 10, TRUE, FALSE); } - - /** * Returns the latest $n status updates for the service landing page. *