Skip to content

Commit d8dcd2d

Browse files
committed
Fixed PHPStan errors
1 parent af23b63 commit d8dcd2d

5 files changed

Lines changed: 39 additions & 22 deletions

File tree

src/Cloud/DTO/JobList.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,43 @@
44

55
namespace Kiboko\Component\Satellite\Cloud\DTO;
66

7-
use Kiboko\Component\Satellite\Cloud\DTO\Workflow\JobInterface;
7+
use Kiboko\Component\Satellite\Cloud\DTO;
88

99
readonly class JobList implements \Countable, \IteratorAggregate
1010
{
11-
/** @var list<JobInterface> */
1211
private array $jobs;
1312

1413
public function __construct(
15-
JobInterface ...$job,
14+
DTO\Workflow\JobInterface ...$job,
1615
) {
1716
$this->jobs = $job;
1817
}
1918

2019
public function getIterator(): \Traversable
2120
{
2221
$jobs = $this->jobs;
23-
usort($jobs, fn (JobInterface $left, JobInterface $right) => $left->order <=> $right->order);
22+
23+
/** @phpstan-ignore-next-line */
24+
usort($jobs, fn (DTO\Workflow\JobInterface $left, DTO\Workflow\JobInterface $right) => $left->order <=> $right->order);
2425

2526
return new \ArrayIterator($jobs);
2627
}
2728

2829
public function codes(): array
2930
{
3031
$jobs = $this->jobs;
31-
usort($jobs, fn (JobInterface $left, JobInterface $right) => $left->order <=> $right->order);
3232

33-
return array_map(fn (JobInterface $job) => $job->code->asString(), $jobs);
33+
/** @phpstan-ignore-next-line */
34+
usort($jobs, fn (DTO\Workflow\JobInterface $left, DTO\Workflow\JobInterface $right) => $left->order <=> $right->order);
35+
36+
/** @phpstan-ignore-next-line */
37+
return array_map(fn (DTO\Workflow\JobInterface $job) => $job->code->asString(), $jobs);
3438
}
3539

36-
public function get(string $code): JobInterface
40+
public function get(string $code): DTO\Workflow\JobInterface
3741
{
3842
foreach ($this->jobs as $job) {
43+
/** @phpstan-ignore-next-line */
3944
if ($job->code->asString() === $code) {
4045
return $job;
4146
}

src/Cloud/DTO/ReferencedPipeline.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ public function steps(): StepList
3333

3434
public function autoload(): Autoload
3535
{
36-
return $this->decorated->autoload();
36+
return $this->decorated->composer()->autoload();
3737
}
3838

3939
public function packages(): PackageList
4040
{
41-
return $this->decorated->packages();
41+
return $this->decorated->composer()->packages();
4242
}
4343

4444
public function repositories(): RepositoryList
4545
{
46-
return $this->decorated->repositories();
46+
return $this->decorated->composer()->repositories();
4747
}
4848

4949
public function auths(): AuthList
5050
{
51-
return $this->decorated->auths();
51+
return $this->decorated->composer()->auths();
5252
}
5353
}

src/Cloud/DTO/ReferencedWorkflow.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ public function jobs(): JobList
3333

3434
public function autoload(): Autoload
3535
{
36-
return $this->decorated->autoload();
36+
return $this->decorated->composer()->autoload();
3737
}
3838

3939
public function packages(): PackageList
4040
{
41-
return $this->decorated->packages();
41+
return $this->decorated->composer()->packages();
4242
}
4343

4444
public function repositories(): RepositoryList
4545
{
46-
return $this->decorated->repositories();
46+
return $this->decorated->composer()->repositories();
4747
}
4848

4949
public function auths(): AuthList
5050
{
51-
return $this->decorated->auths();
51+
return $this->decorated->composer()->auths();
5252
}
5353
}

src/Cloud/Handler/Pipeline/AddPipelineStepProbeCommandHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __invoke(Cloud\Command\Pipeline\AddPipelineStepProbeCommand $com
1919
/** @var \stdClass $result */
2020
$result = $this->client->addPipelineStepProbePipelineItem(
2121
$command->pipeline->asString(),
22-
(new Api\Model\PipelineAddPipelineStepProbCommandInput())
22+
(new Api\Model\PipelineAddPipelineStepProbeCommandInput())
2323
->setProbe(
2424
(new Api\Model\Probe())
2525
->setCode($command->probe->code)

src/Cloud/Workflow.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Kiboko\Component\Satellite\Cloud\DTO\Composer;
1010
use Kiboko\Component\Satellite\Cloud\DTO\JobCode;
1111
use Kiboko\Component\Satellite\Cloud\DTO\Package;
12+
use Kiboko\Component\Satellite\Cloud\DTO\Probe;
1213
use Kiboko\Component\Satellite\Cloud\DTO\ProbeList;
1314
use Kiboko\Component\Satellite\Cloud\DTO\ReferencedWorkflow;
1415
use Kiboko\Component\Satellite\Cloud\DTO\RepositoryList;
@@ -154,7 +155,7 @@ public static function fromApiWithCode(Api\Client $client, string $code): DTO\Re
154155
\assert(1 === \count($collection));
155156
\assert($collection[0] instanceof Api\Model\WorkflowRead);
156157
} catch (\AssertionError) {
157-
throw new \OverflowException('There seems to be several pipelines with the same code, please contact your Customer Success Manager.');
158+
throw new \OverflowException('There seems to be several workflows with the same code, please contact your Customer Success Manager.');
158159
}
159160

160161
return new ReferencedWorkflow(
@@ -173,21 +174,32 @@ private static function fromApiModel(Api\Client $client, Api\Model\WorkflowRead
173174
$workflow->getCode(),
174175
new DTO\JobList(
175176
...array_map(function (Api\Model\Job $job, int $order) {
176-
if (null == $job->getPipeline()) {
177+
if (null !== $job->getPipeline()) {
177178
return new DTO\Workflow\Pipeline(
178179
$job->getLabel(),
179180
new JobCode($job->getCode()),
180-
$job->getConfiguration(),
181+
new StepList(...array_map(
182+
fn (Api\Model\PipelineStepRead $step, int $order) => new Step(
183+
$step->getLabel(),
184+
new StepCode($step->getCode()),
185+
$step->getConfiguration(),
186+
/** TODO : implement probes when it is enabled */
187+
new ProbeList(),
188+
$order
189+
),
190+
$steps = $job->getPipeline()->getSteps(),
191+
range(0, \count((array) $steps)),
192+
)),
181193
$order
182194
);
183195
}
184196

185-
if (null == $job->getAction()) {
197+
if (null !== $job->getAction()) {
186198
return new DTO\Workflow\Action(
187199
$job->getLabel(),
188200
new JobCode($job->getCode()),
189-
$job->getConfiguration(),
190-
$order
201+
$job->getAction()->getConfiguration(),
202+
$order,
191203
);
192204
}
193205

0 commit comments

Comments
 (0)