Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Aug 29, 2023
1 parent f306201 commit c88930f
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 8 deletions.
35 changes: 35 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,31 @@ parameters:
count: 2
path: src/Queries/CacheInteractions.php

-
message: "#^Call to method count\\(\\) on an unknown class Illuminate\\\\Queue\\\\Failed\\\\CountableFailedJobProvider\\.$#"
count: 1
path: src/Queries/Queues.php

-
message: "#^Class Illuminate\\\\Queue\\\\Failed\\\\CountableFailedJobProvider not found\\.$#"
count: 1
path: src/Queries/Queues.php

-
message: "#^Method Laravel\\\\Pulse\\\\Queries\\\\Queues\\:\\:__invoke\\(\\) should return Illuminate\\\\Support\\\\Enumerable\\<int, array\\{connection\\: string, queue\\: string, size\\: int, failed\\: int\\}\\> but returns Illuminate\\\\Support\\\\Enumerable\\<\\(int\\|string\\), array\\{connection\\: string, queue\\: string, size\\: int, failed\\: mixed\\}\\>\\.$#"
count: 1
path: src/Queries/Queues.php

-
message: "#^Return type of call to method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:map\\(\\) contains unresolvable type\\.$#"
count: 1
path: src/Queries/Queues.php

-
message: "#^Return type of call to method Illuminate\\\\Support\\\\Enumerable\\<\\(int\\|string\\),mixed\\>\\:\\:flatMap\\(\\) contains unresolvable type\\.$#"
count: 1
path: src/Queries/Queues.php

-
message: "#^Unable to resolve the template type TKey in call to function collect$#"
count: 1
Expand Down Expand Up @@ -95,6 +120,16 @@ parameters:
count: 1
path: src/Recorders/Exceptions.php

-
message: "#^Call to method count\\(\\) on an unknown class Illuminate\\\\Queue\\\\Failed\\\\CountableFailedJobProvider\\.$#"
count: 1
path: src/Recorders/QueueSizes.php

-
message: "#^Class Illuminate\\\\Queue\\\\Failed\\\\CountableFailedJobProvider not found\\.$#"
count: 1
path: src/Recorders/QueueSizes.php

-
message: "#^Unable to resolve the template type TKey in call to function collect$#"
count: 1
Expand Down
6 changes: 3 additions & 3 deletions src/Queries/Queues.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Queue\Failed\FailedJobProviderInterface;
use Illuminate\Queue\QueueManager;
use Illuminate\Support\Collection;
use Illuminate\Support\Enumerable;

/**
* @interval
Expand All @@ -28,9 +29,9 @@ public function __construct(
/**
* Run the query.
*
* @return \Illuminate\Support\Collection<int, array{queue: string, size: int, failed: int}>
* @return \Illuminate\Support\Enumerable<int, array{connection: string, queue: string, size: int, failed: int}>
*/
public function __invoke(): Collection
public function __invoke(): Enumerable
{
return collect($this->config->get('pulse.queues'))
->groupBy(fn ($value, $key) => is_int($key) ? $this->config->get('queue.default') : $key)
Expand All @@ -39,7 +40,6 @@ public function __invoke(): Collection
'connection' => $connection,
'queue' => $queue,
'size' => $this->queue->connection($connection)->size($queue),
'supported' => $this->failedJobs instanceof CountableFailedJobProvider,
'failed' => $this->failedJobs instanceof CountableFailedJobProvider
? $this->failedJobs->count($connection, $queue)
: 0,
Expand Down
3 changes: 2 additions & 1 deletion src/Recorders/Concerns/ConfiguresAfterResolving.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

namespace Laravel\Pulse\Recorders\Concerns;

use Closure;
use Illuminate\Foundation\Application;

trait ConfiguresAfterResolving
{
/**
* Configure the class after resolving.
*/
public function afterResolving(Application $app, string $class, callable $callback): void
public function afterResolving(Application $app, string $class, Closure $callback): void
{
$app->afterResolving($class, $callback);

Expand Down
2 changes: 1 addition & 1 deletion src/Recorders/OutgoingRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(
public function register(callable $record, Application $app): void
{
if (method_exists(HttpFactory::class, 'globalMiddleware')) {
$this->afterResolving($app, HttpFactory::class, fn (HttpFactory $factory) => $factory->globalMiddleware($this->middleware($record))));
$this->afterResolving($app, HttpFactory::class, fn (HttpFactory $factory) => $factory->globalMiddleware($this->middleware($record)));
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/Recorders/QueueSizes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Queue\Failed\FailedJobProviderInterface;
use Illuminate\Queue\QueueManager;
use Illuminate\Support\Collection;
use Illuminate\Support\Enumerable;
use Laravel\Pulse\Entries\Entry;
use Laravel\Pulse\Events\Beat;

Expand Down Expand Up @@ -43,9 +44,9 @@ public function __construct(
/**
* Record the queue sizes.
*
* @return \Illuminate\Support\Collection<int, \Laravel\Pulse\Entries\Entry>
* @return \Illuminate\Support\Enumerable<int, \Laravel\Pulse\Entries\Entry>
*/
public function record(Beat $event): Collection
public function record(Beat $event): Enumerable
{
if ($event->time->second % 15 !== 0) {
return collect([]);
Expand Down
1 change: 0 additions & 1 deletion tests/Feature/HttpRequestsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Illuminate\Support\Facades\Route;
use Laravel\Pulse\Facades\Pulse;
use Laravel\Pulse\Pulse as PulseInstance;

use function Pest\Laravel\actingAs;
use function Pest\Laravel\get;
use function Pest\Laravel\post;
Expand Down

0 comments on commit c88930f

Please sign in to comment.