Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_landing\Plugin\Field\FieldFormatter;

use Drupal\Core\Field\FieldItemListInterface;
Expand All @@ -24,7 +26,7 @@ class ButtonsInsideWell extends FormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
public function viewElements(FieldItemListInterface $items, $langcode): array {
$elements = [];

foreach ($items as $delta => $item) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_landing\Plugin\Field\FieldFormatter;

use Drupal\Core\Field\FieldItemListInterface;
Expand Down Expand Up @@ -34,7 +36,7 @@ public static function defaultSettings() {
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
public function settingsForm(array $form, FormStateInterface $form_state): array {
$elements['title'] = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're being strict here we should also declare $elements as an array before accessing it as such.

$elements = [];

'#type' => 'textfield',
'#title' => $this->t('Title'),
Expand All @@ -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')) {
Expand All @@ -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'),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_landing\Plugin\Field\FieldFormatter;

use Drupal\Core\Field\FieldItemListInterface;
Expand All @@ -24,7 +26,7 @@ class TwitterFeed extends FormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
public function viewElements(FieldItemListInterface $items, $langcode): array {
$elements = [];

foreach ($items as $delta => $item) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\Tests\localgov_services_landing\Functional;

use Drupal\Tests\BrowserTestBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_navigation;

use Drupal\Component\Utility\Html;
Expand Down Expand Up @@ -91,7 +93,7 @@ public static function create(ContainerInterface $container) {
*
* @see hook_entity_extra_field_info()
*/
public function entityExtraFieldInfo() {
public function entityExtraFieldInfo(): array {
$fields = [];
foreach (['localgov_services_landing', 'localgov_services_sublanding'] as $bundle) {
$fields['node'][$bundle]['form']['localgov_services_navigation_children'] = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_navigation;

use Drupal\Component\Utility\Tags;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_navigation\Plugin\EntityReferenceSelection;

use Drupal\Component\Utility\Html;
Expand Down Expand Up @@ -115,7 +117,7 @@ public static function create(ContainerInterface $container, array $configuratio
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
public function defaultConfiguration(): array {
return [
'target_type' => 'node',
'target_bundles' => [],
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\Tests\localgov_services_navigation\FunctionalJavascript;

use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\Tests\localgov_services_navigation\FunctionalJavascript;

use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\Tests\localgov_services_navigation\Kernel;

use Drupal\KernelTests\KernelTestBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\Tests\localgov_services_navigation\Kernel;

use Drupal\KernelTests\KernelTestBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_page\Plugin\Block;

use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_page\Plugin\Block;

use Drupal\localgov_services\Plugin\Block\ServicesBlockBase;
Expand All @@ -21,7 +23,7 @@ class ServicesRelatedTopicsBlock extends ServicesBlockBase {
/**
* {@inheritdoc}
*/
public function build() {
public function build(): array {
$build = [];
$links = [];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\Tests\localgov_services_page\Functional;

use Drupal\Tests\BrowserTestBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_status\Controller;

use Drupal\Core\Access\AccessResult;
Expand Down Expand Up @@ -62,12 +64,12 @@ public function access(NodeInterface $node): AccessResult {
* Build service status page.
*
* @param \Drupal\node\Entity\Node $node
* Service node.
* The service node.
*
* @return array
* A render array.
*/
public function build(Node $node) {
public function build(Node $node): array {
$build = [];

$build[] = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_status\EventSubscriber;

use Drupal\Core\Path\CurrentPathStack;
Expand Down
6 changes: 4 additions & 2 deletions modules/localgov_services_status/src/PathProcessor.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_status;

use Drupal\Core\Language\LanguageInterface;
Expand Down Expand Up @@ -51,7 +53,7 @@ public function __construct(InboundPathProcessorInterface $path_processor, Langu
/**
* {@inheritdoc}
*/
public function processInbound($path, Request $request) {
public function processInbound($path, Request $request): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If $path is always a string on return, then it must be a string on being called ie: processInbound(string $path, Request $request). I guess that is the case? Is it? If not then it can't guarantee that it'll not return NULL or whatever passed in as $path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21PathProcessor%21InboundPathProcessorInterface.php/function/InboundPathProcessorInterface%3A%3AprocessInbound/11.x

So at the moment we technically can't guarantee that a string is returned, unless we cast $path to a string. So maybe we should wait for the interface to be updated?

$request_path = $this->getPath($request->getPathInfo());

if (substr($request_path, -7) == '/status') {
Expand All @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as processInbound except even more so as we run substr on $path.


// This is the inverse of inbound. Maybe less all-encompassing to swap this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_status\Plugin\Block;

use Drupal\Core\Access\AccessResult;
Expand Down Expand Up @@ -121,7 +123,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
/**
* {@inheritdoc}
*/
public function build() {
public function build(): array {
$build = [];

$build['#theme'] = 'service_status_message';
Expand All @@ -145,14 +147,14 @@ protected function blockAccess(AccountInterface $account) {
/**
* {@inheritdoc}
*/
public function getCacheContexts() {
public function getCacheContexts(): array {
return Cache::mergeContexts(parent::getCacheContexts(), $this->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']);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_status\Plugin\views\style;

use Drupal\views\Plugin\views\style\StylePluginBase;
Expand Down
12 changes: 7 additions & 5 deletions modules/localgov_services_status/src/ServiceStatus.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\localgov_services_status;

use Drupal\Core\Entity\EntityRepositoryInterface;
Expand Down Expand Up @@ -42,20 +44,20 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Ent
}

/**
* Returns the latest 2 status updates for the service landing page.
* Returns the latest 2 status updates for the service landing page blocks.
*
* @param \Drupal\node\Entity\Node $node
* Service landing page node to get status pages for.
*
* @return array
* Array of item variables to render in Twig template.
* Array of status objects.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's returning an array from ::getStatusUpdates() and that is returning a render array, not objects.

*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* @throws \Drupal\Core\Entity\EntityMalformedException
* @throws \Drupal\Core\TypedData\Exception\MissingDataException
*/
public function getStatusForBlock(Node $node) {
public function getStatusForBlock(Node $node): array {
return $this->getStatusUpdates($node, 2, FALSE, TRUE);
}

Expand All @@ -73,7 +75,7 @@ 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);
}

Expand All @@ -97,7 +99,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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\Tests\localgov_services_status\Functional;

use Drupal\Tests\BrowserTestBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\Tests\localgov_services_status\Functional;

use Drupal\Tests\BrowserTestBase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Drupal\Tests\localgov_services_status\Kernel;

use Drupal\KernelTests\KernelTestBase;
Expand Down
Loading