Skip to content

Commit 4de4487

Browse files
committed
ControlGroup::add() validation fixed; typos
1 parent 68318d9 commit 4de4487

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/Forms/ControlGroup.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,26 @@ public function __construct()
3131
/**
3232
* @return self
3333
*/
34-
public function add()
34+
public function add(...$items)
3535
{
36-
foreach (func_get_args() as $num => $item) {
36+
foreach ($items as $item) {
3737
if ($item instanceof IControl) {
3838
$this->controls->attach($item);
3939

4040
} elseif ($item instanceof \Traversable || is_array($item)) {
41-
foreach ($item as $control) {
42-
$this->controls->attach($control);
43-
}
41+
$this->add(...$item);
4442

4543
} else {
46-
throw new Nette\InvalidArgumentException("Only IFormControl items are allowed, the #$num parameter is invalid.");
44+
$type = is_object($item) ? get_class($item) : gettype($item);
45+
throw new Nette\InvalidArgumentException("IControl items expected, $type given.");
4746
}
4847
}
4948
return $this;
5049
}
5150

5251

5352
/**
54-
* @return array IFormControl
53+
* @return IControl[]
5554
*/
5655
public function getControls()
5756
{

src/Forms/Controls/BaseControl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function getHtmlName()
134134
}
135135

136136

137-
/********************* interface IFormControl ****************d*g**/
137+
/********************* interface IControl ****************d*g**/
138138

139139

140140
/**

0 commit comments

Comments
 (0)