Skip to content

Commit

Permalink
Fix tests with nette/component-model 3.1.0
Browse files Browse the repository at this point in the history
`Container::getComponents()` returns array when `$deep` is false (by default):
nette/component-model@7f613ee

The method also no longer takes any arguments:
nette/component-model@4e0946a
  • Loading branch information
jtojnar authored and f3l1x committed Feb 19, 2024
1 parent 9b4e600 commit bde2503
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
14 changes: 7 additions & 7 deletions src/Multiplier.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -307,14 +307,14 @@ public function getControls(): Iterator
}

/**
* @return Iterator<int|string,Container>
* @return array<int|string,Container>
*/
public function getContainers(): Iterator
public function getContainers(): iterable
{
$this->createCopies();

/** @var Iterator<int|string,Container> $containers */
$containers = $this->getComponents(false, Container::class);
/** @var array<int|string,Container> $containers */
$containers = array_filter($this->getComponents(), fn ($component) => $component instanceof Container);

Check failure on line 317 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

Parameter #1 $array of function array_filter expects array, Iterator<int|string, Nette\ComponentModel\IComponent> given.

return $containers;
}
Expand Down Expand Up @@ -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));

Check failure on line 396 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

Parameter #1 $array of function array_filter expects array, Iterator<int|string, Nette\ComponentModel\IComponent> given.
while ($this->getComponent((string) $count, false)) {
$count++;
}
Expand Down Expand Up @@ -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);

Check failure on line 431 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

Parameter #1 $array of function array_filter expects array, Iterator<int|string, Nette\ComponentModel\IComponent> given.
if ($submits) {
return reset($submits)->getName();
}
Expand Down

0 comments on commit bde2503

Please sign in to comment.