Skip to content

Commit

Permalink
fix phpstan issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dododedodonl committed Nov 27, 2024
1 parent ef5cefe commit 8262cbd
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions packages/forms/src/Components/Concerns/CanLimitItemsLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ public function maxItems(int | Closure | null $count): static
{
$this->maxItems = $count;

$this->rule('array', static fn (Component $component): bool => $component->getMaxItems() !== null);
$this->rule('array', static function (Component $component): bool {
/** @var static $component */
$count = $component->getMaxItems();

return $count !== null;
});
$this->rule(static function (Component $component): string {
/** @var static $component */
$count = $component->getMaxItems();

return "max:{$count}";
}, static fn (Component $component): bool => $component->getMaxItems() !== null);
}, static function (Component $component): bool {
/** @var static $component */
$count = $component->getMaxItems();

return $count !== null;
});

return $this;
}
Expand All @@ -30,13 +40,23 @@ public function minItems(int | Closure | null $count): static
{
$this->minItems = $count;

$this->rule('array', static fn (Component $component): bool => $component->getMinItems() !== null);
$this->rule('array', static function (Component $component): bool {
/** @var static $component */
$count = $component->getMinItems();

return $count !== null;
});
$this->rule(static function (Component $component): string {
/** @var static $component */
$count = $component->getMinItems();

return "min:{$count}";
}, static fn (Component $component): bool => $component->getMinItems() !== null);
}, static function (Component $component): bool {
/** @var static $component */
$count = $component->getMinItems();

return $count !== null;
});

return $this;
}
Expand Down

0 comments on commit 8262cbd

Please sign in to comment.