diff --git a/src/Cloud/DTO/JobList.php b/src/Cloud/DTO/JobList.php index 11586708..f6c12499 100644 --- a/src/Cloud/DTO/JobList.php +++ b/src/Cloud/DTO/JobList.php @@ -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 $jobs - * @phpstan-var list $jobs - */ private array $jobs; - /** - * @param JobInterface ...$job - */ public function __construct( DTO\Workflow\JobInterface ...$job, ) { @@ -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); @@ -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) { return $job; }