diff --git a/composer.json b/composer.json index 526de4a..36a0e4a 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ "webchemistry/testing-helpers": "~2.0.0" }, "conflict": { - "latte/latte": "<3.0.0" + "latte/latte": "<3.0.0", + "nette/component-model": "<3.1.0" }, "autoload": { "psr-4": { diff --git a/src/Multiplier.php b/src/Multiplier.php index 20d3c38..c08678a 100644 --- a/src/Multiplier.php +++ b/src/Multiplier.php @@ -170,7 +170,7 @@ public function addCreateButton(?string $caption = null, int $copyCount = 1): Cr public function validate(?array $controls = null): void { /** @var Control[] $components */ - $components = $controls ?? iterator_to_array($this->getComponents()); + $components = $controls ?? $this->getComponents(); foreach ($components as $index => $control) { foreach ($this->noValidate as $item) { @@ -307,14 +307,14 @@ public function getControls(): Iterator } /** - * @return Iterator + * @return array */ - public function getContainers(): Iterator + public function getContainers(): iterable { $this->createCopies(); - /** @var Iterator $containers */ - $containers = $this->getComponents(false, Container::class); + /** @var array $containers */ + $containers = array_filter($this->getComponents(), fn ($component) => $component instanceof Container); return $containers; } @@ -393,7 +393,7 @@ protected function loadHttpData(): void protected function createNumber(): int { - $count = iterator_count($this->getComponents(false, Form::class)); + $count = count(array_filter($this->getComponents(), fn ($component) => $component instanceof Form)); while ($this->getComponent((string) $count, false)) { $count++; } @@ -428,7 +428,7 @@ protected function createContainer(): Container */ protected function getFirstSubmit(): ?string { - $submits = iterator_to_array($this->getComponents(false, SubmitButton::class)); + $submits = array_filter($this->getComponents(), fn ($component) => $component instanceof SubmitButton); if ($submits) { return reset($submits)->getName(); }