Skip to content

Commit

Permalink
Fix tests with nette/component-model
Browse files Browse the repository at this point in the history
`Container::getComponents()` returns array when `$deep` is false:
nette/component-model@7f613ee
  • Loading branch information
jtojnar committed Feb 17, 2024
1 parent 9b4e600 commit d351457
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 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
10 changes: 5 additions & 5 deletions src/Multiplier.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@ 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 */
/** @var array<int|string,Container> $containers */
$containers = $this->getComponents(false, Container::class);

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($this->getComponents(false, Form::class));

Check failure on line 396 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

Parameter #1 $value of function count expects array|Countable, 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 = $this->getComponents(false, SubmitButton::class);
if ($submits) {

Check failure on line 432 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

If condition is always true.
return reset($submits)->getName();

Check failure on line 433 in src/Multiplier.php

View workflow job for this annotation

GitHub Actions / Phpstan / Phpstan (8.1)

Cannot call method getName() on Nette\ComponentModel\IComponent|false.
}
Expand Down

0 comments on commit d351457

Please sign in to comment.