Skip to content

Commit 736da00

Browse files
committed
fix: improve type handling and update comment handling logic
1 parent 77b6432 commit 736da00

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

phpstan-baseline.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,8 @@ parameters:
1212
- message: '#Cannot cast mixed to int#'
1313
path: src/*.php
1414

15+
- message: '#Cannot access an offset on mixed.#'
16+
path: src/*.php
17+
1518
- message: '#Cannot access offset .+ on mixed#'
1619
path: src/*.php

src/Jobs/ProcessAggregatedEvents.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function handle(): void
5757
/**
5858
* Aggregate messages from events.
5959
*
60-
* @param list<string> $eventMessages
60+
* @param array<string, mixed> $eventMessages
6161
*
6262
* @return string
6363
*/

src/Jobs/ProcessWebhookEvent.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ class ProcessWebhookEvent implements ShouldQueue
1616
use Queueable;
1717
use SerializesModels;
1818

19-
protected array $eventData;
20-
2119
/**
2220
* @param array<string, mixed> $eventData
2321
*/
22+
protected array $eventData;
23+
2424
public function __construct(array $eventData)
2525
{
2626
$this->eventData = $eventData;
@@ -35,7 +35,7 @@ public function handle(): void
3535
$commentAggregationCacheKey = config('github-project.comment_aggregation_cache_key')."_{$nodeId}";
3636
$commentAggregationTime = (int) config('github-project.comment_aggregation_time');
3737

38-
$eventMessages = Cache::get($commentAggregationCacheKey, []);
38+
$eventMessages = (array) Cache::get($commentAggregationCacheKey, []);
3939
$eventMessages[] = view('github-project::md.shared.content', ['payload' => $this->eventData])->render();
4040

4141
Cache::put($commentAggregationCacheKey, $eventMessages, now()->addSeconds($commentAggregationTime));

src/Services/GithubService.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ public function commentOnNode(string $contentNodeId, string $message): array
5252
*/
5353
public function handleComment(array $payload): void
5454
{
55-
$contentNodeId = (string) $payload['projects_v2_item']['content_node_id'] ?? '';
56-
5755
if (config('github-project.is_queue_enabled')) {
5856
ProcessWebhookEvent::dispatch($payload);
5957

6058
return;
6159
}
6260

63-
$this->commentOnNode($contentNodeId, view('github-project::md.comment', compact('payload'))->render());
61+
$this->commentOnNode(
62+
(string) $payload['projects_v2_item']['content_node_id'],
63+
view('github-project::md.comment', compact('payload'))->render()
64+
);
6465
}
6566
}

0 commit comments

Comments
 (0)