diff --git a/src/PhpGenerator/Traits/FunctionLike.php b/src/PhpGenerator/Traits/FunctionLike.php index f446bd8b..32e43312 100644 --- a/src/PhpGenerator/Traits/FunctionLike.php +++ b/src/PhpGenerator/Traits/FunctionLike.php @@ -69,9 +69,11 @@ public function addBody(string $code, array $args = null): self */ public function setParameters(array $val): self { - (function (Parameter ...$val) {})(...$val); $this->parameters = []; foreach ($val as $v) { + if (!$v instanceof Parameter) { + throw new Nette\InvalidArgumentException('Argument must be Nette\PhpGenerator\Parameter[].'); + } $this->parameters[$v->getName()] = $v; } return $this;