Skip to content

Commit 1a27b42

Browse files
authored
Updated codebase to PHP 8.0 (#53)
1 parent a0b377a commit 1a27b42

File tree

2 files changed

+22
-40
lines changed

2 files changed

+22
-40
lines changed

src/SkipInvalidItemProcessor.php

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,23 @@
1616
*/
1717
final class SkipInvalidItemProcessor implements ItemProcessorInterface
1818
{
19-
private ValidatorInterface $validator;
20-
21-
/**
22-
* @var Constraint[]|null
23-
*/
24-
private ?array $contraints;
25-
26-
/**
27-
* @var string[]|null
28-
*/
29-
private ?array $groups;
30-
31-
/**
32-
* @param Constraint[]|null $contraints
33-
* @param string[]|null $groups
34-
*/
35-
public function __construct(ValidatorInterface $validator, array $contraints = null, array $groups = null)
36-
{
37-
$this->validator = $validator;
38-
$this->contraints = $contraints;
39-
$this->groups = $groups;
19+
public function __construct(
20+
private ValidatorInterface $validator,
21+
/**
22+
* @var Constraint[]|null
23+
*/
24+
private ?array $contraints = null,
25+
/**
26+
* @var string[]|null
27+
*/
28+
private ?array $groups = null,
29+
) {
4030
}
4131

4232
/**
4333
* @inheritDoc
4434
*/
45-
public function process($item)
35+
public function process(mixed $item): mixed
4636
{
4737
$violations = $this->validator->validate($item, $this->contraints, $this->groups);
4838
if (\count($violations) === 0) {
@@ -63,7 +53,7 @@ public function process($item)
6353
private function normalizeConstraints(?array $constraints): Iterator
6454
{
6555
foreach ($constraints ?? [] as $constraint) {
66-
yield \get_class($constraint);
56+
yield $constraint::class;
6757
}
6858
}
6959
}

src/SkipItemOnViolations.php

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,18 @@
1616
*/
1717
final class SkipItemOnViolations implements SkipItemCauseInterface
1818
{
19-
/**
20-
* @phpstan-var ConstraintViolationListInterface<ConstraintViolationInterface>
21-
*/
22-
private ConstraintViolationListInterface $violations;
23-
24-
/**
25-
* @phpstan-param ConstraintViolationListInterface<ConstraintViolationInterface> $violations
26-
*/
27-
public function __construct(ConstraintViolationListInterface $violations)
28-
{
29-
$this->violations = $violations;
19+
public function __construct(
20+
/**
21+
* @phpstan-var ConstraintViolationListInterface<ConstraintViolationInterface>
22+
*/
23+
private ConstraintViolationListInterface $violations
24+
) {
3025
}
3126

3227
/**
3328
* @inheritdoc
3429
*/
35-
public function report(JobExecution $execution, $index, $item): void
30+
public function report(JobExecution $execution, int|string $index, mixed $item): void
3631
{
3732
$execution->getSummary()->increment('invalid');
3833
$violations = [];
@@ -63,10 +58,7 @@ public function getViolations(): ConstraintViolationListInterface
6358
return $this->violations;
6459
}
6560

66-
/**
67-
* @param mixed $invalidValue
68-
*/
69-
private function normalizeInvalidValue($invalidValue): string
61+
private function normalizeInvalidValue(mixed $invalidValue): string
7062
{
7163
if ($invalidValue === '') {
7264
return '""';
@@ -96,7 +88,7 @@ private function normalizeInvalidValue($invalidValue): string
9688
return (string)$invalidValue;
9789
}
9890

99-
return \get_class($invalidValue);
91+
return $invalidValue::class;
10092
}
10193

10294
return \gettype($invalidValue);

0 commit comments

Comments
 (0)