Skip to content

Commit

Permalink
Fixed PHPStan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sebprt committed Oct 26, 2023
1 parent 4322f24 commit b7f19b3
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/Cloud/DTO/JobList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,11 @@
namespace Kiboko\Component\Satellite\Cloud\DTO;

use Kiboko\Component\Satellite\Cloud\DTO;
use Kiboko\Component\Satellite\Cloud\DTO\Workflow\JobInterface;

readonly class JobList implements \Countable, \IteratorAggregate
{
/**
* @var list<DTO\Workflow\JobInterface> $jobs
* @phpstan-var list<DTO\Workflow\Pipeline|DTO\Workflow\Action> $jobs
*/
private array $jobs;

/**
* @param JobInterface<DTO\Workflow\Pipeline|DTO\Workflow\Action> ...$job
*/
public function __construct(
DTO\Workflow\JobInterface ...$job,
) {
Expand All @@ -27,6 +19,8 @@ public function __construct(
public function getIterator(): \Traversable
{
$jobs = $this->jobs;

/** @phpstan-ignore-next-line */
usort($jobs, fn (DTO\Workflow\JobInterface $left, DTO\Workflow\JobInterface $right) => $left->order <=> $right->order);

return new \ArrayIterator($jobs);
Expand All @@ -35,14 +29,18 @@ public function getIterator(): \Traversable
public function codes(): array
{
$jobs = $this->jobs;

/** @phpstan-ignore-next-line */
usort($jobs, fn (DTO\Workflow\JobInterface $left, DTO\Workflow\JobInterface $right) => $left->order <=> $right->order);

/** @phpstan-ignore-next-line */
return array_map(fn (DTO\Workflow\JobInterface $job) => $job->code->asString(), $jobs);
}

public function get(string $code): DTO\Workflow\JobInterface
{
foreach ($this->jobs as $job) {
/** @phpstan-ignore-next-line */
if ($job->code->asString() === $code) {

Check failure on line 44 in src/Cloud/DTO/JobList.php

View workflow job for this annotation

GitHub Actions / phpstan

No error to ignore is reported on line 44.
return $job;
}
Expand Down

0 comments on commit b7f19b3

Please sign in to comment.