Skip to content

Commit 19935af

Browse files
committed
Fix phpstan
1 parent 7df3979 commit 19935af

5 files changed

Lines changed: 18 additions & 110 deletions

File tree

phpstan-baseline.neon

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ parameters:
1111
path: src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php
1212

1313
-
14-
message: "#^Parameter \\#1 \\$class of class Yokai\\\\Batch\\\\Failure constructor expects string, mixed given\\.$#"
14+
message: "#^Parameter \\#1 \\$class of class Yokai\\\\Batch\\\\Failure constructor expects class\\-string\\<Throwable\\>, mixed given\\.$#"
1515
count: 1
1616
path: src/batch-doctrine-dbal/src/JobExecutionRowNormalizer.php
1717

@@ -160,103 +160,3 @@ parameters:
160160
count: 1
161161
path: src/batch-openspout/src/Writer/FlatFileWriter.php
162162

163-
-
164-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
165-
count: 3
166-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
167-
168-
-
169-
message: "#^Parameter \\#1 \\$array of method Yokai\\\\Batch\\\\Serializer\\\\JsonJobExecutionSerializer\\:\\:failureFromArray\\(\\) expects array\\<string, mixed\\>, mixed given\\.$#"
170-
count: 1
171-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
172-
173-
-
174-
message: "#^Parameter \\#1 \\$array of method Yokai\\\\Batch\\\\Serializer\\\\JsonJobExecutionSerializer\\:\\:warningFromArray\\(\\) expects array\\<string, mixed\\>, mixed given\\.$#"
175-
count: 1
176-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
177-
178-
-
179-
message: "#^Parameter \\#1 \\$class of class Yokai\\\\Batch\\\\Failure constructor expects string, mixed given\\.$#"
180-
count: 1
181-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
182-
183-
-
184-
message: "#^Parameter \\#1 \\$date of method Yokai\\\\Batch\\\\Serializer\\\\JsonJobExecutionSerializer\\:\\:stringToDate\\(\\) expects string\\|null, mixed given\\.$#"
185-
count: 2
186-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
187-
188-
-
189-
message: "#^Parameter \\#1 \\$id of static method Yokai\\\\Batch\\\\JobExecution\\:\\:createRoot\\(\\) expects string, mixed given\\.$#"
190-
count: 1
191-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
192-
193-
-
194-
message: "#^Parameter \\#1 \\$jobExecutionData of method Yokai\\\\Batch\\\\Serializer\\\\JsonJobExecutionSerializer\\:\\:fromArray\\(\\) expects array\\<string, mixed\\>, mixed given\\.$#"
195-
count: 1
196-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
197-
198-
-
199-
message: "#^Parameter \\#1 \\$logs of class Yokai\\\\Batch\\\\JobExecutionLogs constructor expects string, mixed given\\.$#"
200-
count: 1
201-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
202-
203-
-
204-
message: "#^Parameter \\#1 \\$message of class Yokai\\\\Batch\\\\Warning constructor expects string, mixed given\\.$#"
205-
count: 1
206-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
207-
208-
-
209-
message: "#^Parameter \\#1 \\$parameters of class Yokai\\\\Batch\\\\JobParameters constructor expects array\\<string, mixed\\>, mixed given\\.$#"
210-
count: 1
211-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
212-
213-
-
214-
message: "#^Parameter \\#1 \\$value of class Yokai\\\\Batch\\\\BatchStatus constructor expects int, mixed given\\.$#"
215-
count: 1
216-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
217-
218-
-
219-
message: "#^Parameter \\#1 \\$values of class Yokai\\\\Batch\\\\Summary constructor expects array\\<string, mixed\\>, mixed given\\.$#"
220-
count: 1
221-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
222-
223-
-
224-
message: "#^Parameter \\#2 \\$jobName of static method Yokai\\\\Batch\\\\JobExecution\\:\\:createChild\\(\\) expects string, mixed given\\.$#"
225-
count: 1
226-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
227-
228-
-
229-
message: "#^Parameter \\#2 \\$jobName of static method Yokai\\\\Batch\\\\JobExecution\\:\\:createRoot\\(\\) expects string, mixed given\\.$#"
230-
count: 1
231-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
232-
233-
-
234-
message: "#^Parameter \\#2 \\$message of class Yokai\\\\Batch\\\\Failure constructor expects string, mixed given\\.$#"
235-
count: 1
236-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
237-
238-
-
239-
message: "#^Parameter \\#2 \\$parameters of class Yokai\\\\Batch\\\\Warning constructor expects array\\<string, string\\>, mixed given\\.$#"
240-
count: 1
241-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
242-
243-
-
244-
message: "#^Parameter \\#3 \\$code of class Yokai\\\\Batch\\\\Failure constructor expects int, mixed given\\.$#"
245-
count: 1
246-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
247-
248-
-
249-
message: "#^Parameter \\#3 \\$context of class Yokai\\\\Batch\\\\Warning constructor expects array\\<string, mixed\\>, mixed given\\.$#"
250-
count: 1
251-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
252-
253-
-
254-
message: "#^Parameter \\#4 \\$parameters of class Yokai\\\\Batch\\\\Failure constructor expects array\\<string, string\\>, mixed given\\.$#"
255-
count: 1
256-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
257-
258-
-
259-
message: "#^Parameter \\#5 \\$trace of class Yokai\\\\Batch\\\\Failure constructor expects string\\|null, mixed given\\.$#"
260-
count: 1
261-
path: src/batch/src/Serializer/JsonJobExecutionSerializer.php
262-

src/batch/src/Failure.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ final class Failure implements \Stringable
1515
public function __construct(
1616
/**
1717
* The exception class
18+
* @var class-string<\Throwable> $class
1819
*/
1920
private string $class,
2021
/**
@@ -58,6 +59,9 @@ public function __toString(): string
5859
return \strtr($this->message, $this->parameters);
5960
}
6061

62+
/**
63+
* @return class-string<\Throwable>
64+
*/
6165
public function getClass(): string
6266
{
6367
return $this->class;

src/batch/src/Serializer/JobExecutionSerializerTrait.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,27 @@
2020
* id: string,
2121
* jobName: string,
2222
* status: int,
23-
* parameters: array<string, mixed>|empty,
23+
* parameters: array<string, mixed>,
2424
* startTime: string|null,
2525
* endTime: string|null,
26-
* summary: array<string, mixed>|empty,
27-
* failures: list<FailureDefinition>|empty,
28-
* warnings: list<WarningDefinition>|empty,
29-
* childExecutions: list<JobExecutionDefinition>|empty,
26+
* summary: array<string, mixed>,
27+
* failures: list<FailureDefinition>,
28+
* warnings: list<WarningDefinition>,
29+
* childExecutions: iterable<mixed>,
3030
* logs?: string,
3131
* }
3232
*
3333
* @phpstan-type FailureDefinition array{
3434
* class: class-string<\Throwable>,
3535
* message: string,
3636
* code: int,
37-
* parameters: array<string, mixed>,
38-
* trace: string
37+
* parameters: array<string, string>,
38+
* trace: string|null
3939
* }
4040
*
4141
* @phpstan-type WarningDefinition array{
4242
* message: string,
43-
* parameters: array<string, mixed>,
43+
* parameters: array<string, string>,
4444
* context: array<string, mixed>
4545
* }
4646
*/
@@ -100,6 +100,7 @@ private function fromArray(array $jobExecutionData, JobExecution|null $parentExe
100100
$jobExecution->addWarning($this->warningFromArray($warningData), false);
101101
}
102102

103+
/** @var JobExecutionDefinition $childExecutionData */
103104
foreach ($jobExecutionData['childExecutions'] as $childExecutionData) {
104105
$jobExecution->addChildExecution($this->fromArray($childExecutionData, $jobExecution));
105106
}

src/batch/src/Serializer/JsonJobExecutionSerializer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
/**
1515
* This {@see JobExecutionStorageInterface} will (un)serialise any {@see JobExecution} to/from json,
1616
* using internal (de)normalisation and PHP {@see json_encode} and {@see json_decode} functions.
17+
*
18+
* @phpstan-import-type JobExecutionDefinition from JobExecutionSerializerTrait
1719
*/
1820
final class JsonJobExecutionSerializer implements JobExecutionSerializerInterface
1921
{
@@ -44,6 +46,7 @@ public function unserialize(string $serializedJobExecution): JobExecution
4446
throw UnexpectedValueException::type('array', $data);
4547
}
4648

49+
/** @var JobExecutionDefinition $data */
4750
return $this->fromArray($data);
4851
} catch (Throwable $exception) {
4952
throw RuntimeException::error($exception, 'Cannot unserialize job execution from JSON.');

src/batch/src/Warning.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getMessage(): string
4040
}
4141

4242
/**
43-
* @return array<string, mixed>
43+
* @return array<string, string>
4444
*/
4545
public function getParameters(): array
4646
{

0 commit comments

Comments
 (0)