-
Notifications
You must be signed in to change notification settings - Fork 6
adds strict type and returns for all php files in module #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 2.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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; | ||
|
|
@@ -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 { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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') { | ||
|
|
@@ -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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as |
||
|
|
||
| // This is the inverse of inbound. Maybe less all-encompassing to swap this | ||
|
|
||
| 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; | ||
|
|
@@ -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. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's returning an array from |
||
| * | ||
| * @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); | ||
| } | ||
|
|
||
|
|
@@ -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); | ||
| } | ||
|
|
||
|
|
@@ -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) | ||
|
|
||
There was a problem hiding this comment.
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 = [];