From: Matthias Schmidt Date: Fri, 12 Apr 2019 17:11:15 +0000 (+0200) Subject: Throw if `IFormParentNode::appendChild()` called with multiple args X-Git-Tag: 5.2.0_Alpha_1~151 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5c3d7ea9f4519424a9bfd4d46ad4d61ac98d452f;p=GitHub%2FWoltLab%2FWCF.git Throw if `IFormParentNode::appendChild()` called with multiple args See #2509 --- diff --git a/wcfsetup/install/files/lib/system/form/builder/IFormParentNode.class.php b/wcfsetup/install/files/lib/system/form/builder/IFormParentNode.class.php index 38f49220e4..5fa7070800 100644 --- a/wcfsetup/install/files/lib/system/form/builder/IFormParentNode.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/IFormParentNode.class.php @@ -16,6 +16,8 @@ interface IFormParentNode extends \Countable, IFormNode, \RecursiveIterator { * * @param IFormChildNode $child appended child * @return static this node + * + * @throws \BadMethodCallException if method is called with multiple `IFormChildNode` as parameter (if mistakenly used instead of `appendChildren()`) */ public function appendChild(IFormChildNode $child); diff --git a/wcfsetup/install/files/lib/system/form/builder/TFormParentNode.class.php b/wcfsetup/install/files/lib/system/form/builder/TFormParentNode.class.php index 799f6c9a82..6416eb7414 100644 --- a/wcfsetup/install/files/lib/system/form/builder/TFormParentNode.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/TFormParentNode.class.php @@ -32,8 +32,14 @@ trait TFormParentNode { * * @param IFormChildNode $child appended child * @return static this node + * + * @throws \BadMethodCallException if method is called with more than one parameter (might be mistakenly used instead of `appendChildren()`) */ public function appendChild(IFormChildNode $child) { + if (func_num_args() > 1) { + throw new \BadMethodCallException("'" . IFormParentNode::class . "::appendChild()' only supports one argument. Use '" . IFormParentNode::class . "::appendChildren()' to append multiple children at once."); + } + $this->children[] = $child; $child->parent($this);