From 5d05372f4f59d27fdd93249d813970fcf181a4af Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 20 Oct 2016 13:40:57 +0300 Subject: FV: throw BadMethodCallException when set_rules() called without --- system/libraries/Form_validation.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 86a569ced..4380dd276 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -164,7 +164,7 @@ class CI_Form_validation { * @param array $errors * @return CI_Form_validation */ - public function set_rules($field, $label = '', $rules = array(), $errors = array()) + public function set_rules($field, $label = null, $rules = null, $errors = array()) { // No reason to set rules if we have no POST data // or a validation array has not been specified @@ -197,6 +197,10 @@ class CI_Form_validation { return $this; } + elseif ( ! isset($rules)) + { + throw new BadMethodCallException('Form_validation: set_rules() called without a $rules parameter'); + } // No fields or no rules? Nothing to do... if ( ! is_string($field) OR $field === '' OR empty($rules)) -- cgit v1.2.3-24-g4f1b