Skip to content

Commit

Permalink
Fix psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
xepozz committed Apr 29, 2023
1 parent 3a8a77d commit 2a93e5d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Debug/ValidatorCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@ public function getCollected(): array
return $this->validations;
}

public function collect(mixed $value, Result $result, ?iterable $rules = null): void
public function collect(mixed $value, Result $result, callable|iterable|object|string|null $rules = null): void
{
if (!$this->isActive()) {
return;
}

if ($rules instanceof Traversable) {
$rules = iterator_to_array($rules);
}


$this->validations[] = [
'value' => $value,
'rules' => $rules instanceof Traversable ? iterator_to_array($rules, true) : (array) $rules,
'rules' => $rules,
'result' => $result->isValid(),
'errors' => $result->getErrors(),
];
Expand All @@ -42,7 +47,7 @@ private function reset(): void
public function getSummary(): array
{
$count = count($this->validations);
$countValid = count(array_filter($this->validations, fn (array $data) => $data['result']));
$countValid = count(array_filter($this->validations, fn (array $data): bool => (bool)$data['result']));
$countInvalid = $count - $countValid;

return [
Expand Down

0 comments on commit 2a93e5d

Please sign in to comment.