Skip to content

Commit 72eb97f

Browse files
committed
used is_iterable
1 parent 48f39d4 commit 72eb97f

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/Forms/Container.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ public function validate(array $controls = NULL): void
136136
}
137137
}
138138
if ($this->onValidate !== NULL) {
139-
if (!is_array($this->onValidate) && !$this->onValidate instanceof \Traversable) {
140-
throw new Nette\UnexpectedValueException('Property Form::$onValidate must be array or Traversable, ' . gettype($this->onValidate) . ' given.');
139+
if (!is_iterable($this->onValidate)) {
140+
throw new Nette\UnexpectedValueException('Property Form::$onValidate must be iterable, ' . gettype($this->onValidate) . ' given.');
141141
}
142142
foreach ($this->onValidate as $handler) {
143143
$params = Nette\Utils\Callback::toReflection($handler)->getParameters();

src/Forms/ControlGroup.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function add(...$items)
4545
foreach ($item->getComponents() as $component) {
4646
$this->add($component);
4747
}
48-
} elseif ($item instanceof \Traversable || is_array($item)) {
48+
} elseif (is_iterable($item)) {
4949
$this->add(...$item);
5050

5151
} else {

src/Forms/Form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ public function fireEvents(): void
407407
$this->onError($this);
408408

409409
} elseif ($this->onSuccess !== NULL) {
410-
if (!is_array($this->onSuccess) && !$this->onSuccess instanceof \Traversable) {
411-
throw new Nette\UnexpectedValueException('Property Form::$onSuccess must be array or Traversable, ' . gettype($this->onSuccess) . ' given.');
410+
if (!is_iterable($this->onSuccess)) {
411+
throw new Nette\UnexpectedValueException('Property Form::$onSuccess must be iterable, ' . gettype($this->onSuccess) . ' given.');
412412
}
413413
foreach ($this->onSuccess as $handler) {
414414
$params = Nette\Utils\Callback::toReflection($handler)->getParameters();

tests/Forms/Container.validate().phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ Assert::exception(function () {
4040
$form = new Form;
4141
$form->onValidate = TRUE;
4242
$form->validate();
43-
}, Nette\UnexpectedValueException::class, 'Property Form::$onValidate must be array or Traversable, boolean given.');
43+
}, Nette\UnexpectedValueException::class, 'Property Form::$onValidate must be iterable, boolean given.');

tests/Forms/Forms.onSuccess.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ Assert::exception(function () {
6161
$form = new Form;
6262
$form->onSuccess = TRUE;
6363
$form->fireEvents();
64-
}, Nette\UnexpectedValueException::class, 'Property Form::$onSuccess must be array or Traversable, boolean given.');
64+
}, Nette\UnexpectedValueException::class, 'Property Form::$onSuccess must be iterable, boolean given.');

0 commit comments

Comments
 (0)