From 38fa02619dd9b7709dedcf039631994844057cfd Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Sat, 31 Dec 2022 02:31:21 +0100 Subject: [PATCH] Clean PHP8 compatibility errors detected by PHPstan --- .gitignore | 1 + src/includes/class/class.LSform.php | 2 +- src/includes/class/class.LSformElement.php | 2 +- src/includes/class/class.LSformRule.php | 4 +- ...rmRule_LSformElement_select_validValue.php | 2 +- .../class/class.LSformRule_alphanumeric.php | 2 +- .../class/class.LSformRule_callable.php | 2 +- .../class/class.LSformRule_compare.php | 57 +++++++++---------- src/includes/class/class.LSformRule_date.php | 2 +- .../class.LSformRule_differentPassword.php | 2 +- src/includes/class/class.LSformRule_email.php | 2 +- .../class/class.LSformRule_filesize.php | 2 +- .../class/class.LSformRule_imagefile.php | 2 +- .../class/class.LSformRule_imagesize.php | 2 +- .../class/class.LSformRule_inarray.php | 2 +- .../class/class.LSformRule_integer.php | 2 +- .../class/class.LSformRule_ldapSearchURI.php | 2 +- .../class/class.LSformRule_lettersonly.php | 2 +- .../class/class.LSformRule_maxlength.php | 2 +- .../class/class.LSformRule_mimetype.php | 2 +- .../class/class.LSformRule_minlength.php | 2 +- .../class/class.LSformRule_nonzero.php | 2 +- .../class/class.LSformRule_nopunctuation.php | 2 +- .../class/class.LSformRule_numberOfValues.php | 2 +- .../class/class.LSformRule_numeric.php | 2 +- .../class/class.LSformRule_password.php | 2 +- .../class/class.LSformRule_rangelength.php | 2 +- src/includes/class/class.LSformRule_regex.php | 2 +- .../class/class.LSformRule_required.php | 2 +- .../class/class.LSformRule_ssh_pub_key.php | 2 +- .../class.LSformRule_telephonenumber.php | 2 +- .../class/class.LSformRule_zxcvbn.php | 2 +- 32 files changed, 60 insertions(+), 60 deletions(-) diff --git a/.gitignore b/.gitignore index 3e610631..be74bb0a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ upgrade.log *~ vendor /src/local.* +tests-report.xml diff --git a/src/includes/class/class.LSform.php b/src/includes/class/class.LSform.php index f2ff5041..1580492d 100644 --- a/src/includes/class/class.LSform.php +++ b/src/includes/class/class.LSform.php @@ -549,7 +549,7 @@ class LSform extends LSlog_staticLoggerClass { * * @retval LSformElement */ - public function addElement($type,$name,$label,$params=array(),&$attr_html) { + public function addElement($type,$name,$label,$params,&$attr_html) { $elementType='LSformElement_'.$type; LSsession :: loadLSclass($elementType); if (!class_exists($elementType)) { diff --git a/src/includes/class/class.LSformElement.php b/src/includes/class/class.LSformElement.php index 6f89afc3..a1b3eced 100644 --- a/src/includes/class/class.LSformElement.php +++ b/src/includes/class/class.LSformElement.php @@ -365,7 +365,7 @@ class LSformElement extends LSlog_staticLoggerClass { * * @retval boolean True on success, False otherwise */ - protected function split_autocomplete_attr_values($attr_value="", $multiple_value_delimiter="|", &$attr_values, &$last_attr_value) { + protected function split_autocomplete_attr_values($attr_value, $multiple_value_delimiter, &$attr_values, &$last_attr_value) { $attr_values = explode($multiple_value_delimiter, $attr_value); if (count($attr_values) > 1 && !$this -> getParam('multiple', false, 'bool')) { self :: log_error("The attribute ".$this -> name." is not multivalued."); diff --git a/src/includes/class/class.LSformRule.php b/src/includes/class/class.LSformRule.php index 24420e34..236f1577 100644 --- a/src/includes/class/class.LSformRule.php +++ b/src/includes/class/class.LSformRule.php @@ -50,7 +50,7 @@ class LSformRule extends LSlog_staticLoggerClass { * * @return boolean True if value is valid, False otherwise */ - public static function validate_values($rule_name, $values, $options=array(), &$formElement) { + public static function validate_values($rule_name, $values, $options, &$formElement) { // Compute PHP class name of the rule $rule_class = "LSformRule_".$rule_name; @@ -93,7 +93,7 @@ class LSformRule extends LSlog_staticLoggerClass { * * @return boolean True if value is valid, False otherwise */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { return false; } diff --git a/src/includes/class/class.LSformRule_LSformElement_select_validValue.php b/src/includes/class/class.LSformRule_LSformElement_select_validValue.php index feb661c7..ab6e24de 100644 --- a/src/includes/class/class.LSformRule_LSformElement_select_validValue.php +++ b/src/includes/class/class.LSformRule_LSformElement_select_validValue.php @@ -36,7 +36,7 @@ class LSformRule_LSformElement_select_validValue extends LSformRule { * * @return boolean true if the value is valide, false if not */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $ret = $formElement -> isValidValue($value); if ($ret===False) return False; return True; diff --git a/src/includes/class/class.LSformRule_alphanumeric.php b/src/includes/class/class.LSformRule_alphanumeric.php index aaacc875..2cfa9a0e 100644 --- a/src/includes/class/class.LSformRule_alphanumeric.php +++ b/src/includes/class/class.LSformRule_alphanumeric.php @@ -42,7 +42,7 @@ class LSformRule_alphanumeric extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { if (LSconfig :: get('params.withAccents', false, 'bool', $options)) { $regex = '/(*UTF8)^[0-9\p{L}]+$/'; diff --git a/src/includes/class/class.LSformRule_callable.php b/src/includes/class/class.LSformRule_callable.php index c1444a87..af242d85 100644 --- a/src/includes/class/class.LSformRule_callable.php +++ b/src/includes/class/class.LSformRule_callable.php @@ -46,7 +46,7 @@ class LSformRule_callable extends LSformRule { * * @return boolean true if the value is valid, false otherwise */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $callable = LSconfig :: get('params.callable', null, null, $options); if (is_callable($callable)) return call_user_func_array( diff --git a/src/includes/class/class.LSformRule_compare.php b/src/includes/class/class.LSformRule_compare.php index 873ad7e6..03a56ae7 100644 --- a/src/includes/class/class.LSformRule_compare.php +++ b/src/includes/class/class.LSformRule_compare.php @@ -35,34 +35,39 @@ class LSformRule_compare extends LSformRule { ); // Operators mapping - static protected $_operators = array( - 'eq' => '==', - 'neq' => '!=', - 'gt' => '>', - 'gte' => '>=', - 'lt' => '<', - 'lte' => '<=' + static protected $_operators_aliases = array( + '==' => 'eq', + '!=' => 'neq', + '>' => 'gt', + '>=' => 'gte', + '<' => 'lt', + '<=' => 'lte', + ); + static protected $_operators_to_compare_function = array( + 'eq' => function($a, $b) {return floatval($a) == floatval($b);}, + 'neq' => function($a, $b) {return floatval($a) != floatval($b);}, + 'gt' => function($a, $b) {return $a > $b;}, + 'gte' => function($a, $b) {return $a >= $b;}, + 'lt' => function($a, $b) {return $a < $b;}, + 'lte' => function($a, $b) {return $a <= $b;}, ); /** - * Retourne l'operateur de comparaison. + * Return the compare function associated with the specified operator * * @access private - * @param string Nom de l'operateur + * @param string The operator name * - * @return string Operateur à utiliser + * @return function The compare function */ - private static function _findOperator($operator_name) { - - if (empty(self :: $operator_name)) { - return '=='; - } elseif (isset(self :: $_operators[$operator_name])) { - return self :: $_operators[$operator_name]; - } elseif (in_array($operator_name, self :: $_operators)) { - return $operator_name; - } else { - return '=='; - } + private static function _findOperatorCompareFunction($operator_name) { + if (empty($operator_name)) + $operator_name = 'eq'; + elseif (isset(self :: $_operators_aliases[$operator_name])) + $operator_name = self :: $_operators_aliases[$operator_name]; + elseif (!isset(self :: $_operators_to_compare_function[$operator_name])) + $operator_name = 'eq'; + return self :: $_operators_to_compare_function[$operator_name]; } /** @@ -75,19 +80,13 @@ class LSformRule_compare extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($values, $options=array(), &$formElement) { + public static function validate($values, $options, &$formElement) { $operator = LSconfig :: get('params.operator', null, 'string', $options); if (!$operator) { LSerror :: addErrorCode('LSformRule_01',array('type' => 'compare', 'param' => 'operator')); return; } - $operator = self :: _findOperator($operator); - if ('==' != $operator && '!=' != $operator) { - $compareFn = create_function('$a, $b', 'return floatval($a) ' . $operator . ' floatval($b);'); - } - else { - $compareFn = create_function('$a, $b', 'return $a ' . $operator . ' $b;'); - } + $compareFn = self :: _findOperatorCompareFunction($operator); return $compareFn($values[0], $values[1]); } diff --git a/src/includes/class/class.LSformRule_date.php b/src/includes/class/class.LSformRule_date.php index e04a51d3..55043632 100644 --- a/src/includes/class/class.LSformRule_date.php +++ b/src/includes/class/class.LSformRule_date.php @@ -44,7 +44,7 @@ class LSformRule_date extends LSformRule { * * @return boolean True si les données sont valide, False sinon. */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $special_values = LSconfig :: get('params.special_values', array(), null, $options); if (in_array($value, $special_values)) return true; diff --git a/src/includes/class/class.LSformRule_differentPassword.php b/src/includes/class/class.LSformRule_differentPassword.php index 6cab20fe..614cd2a3 100644 --- a/src/includes/class/class.LSformRule_differentPassword.php +++ b/src/includes/class/class.LSformRule_differentPassword.php @@ -42,7 +42,7 @@ class LSformRule_differentPassword extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $otherPasswordAttributes = LSconfig :: get('params.otherPasswordAttributes', null, null, $options); if (!is_null($otherPasswordAttributes)) { // Load LSattr_ldap_password diff --git a/src/includes/class/class.LSformRule_email.php b/src/includes/class/class.LSformRule_email.php index 429ef7e1..6151b85d 100644 --- a/src/includes/class/class.LSformRule_email.php +++ b/src/includes/class/class.LSformRule_email.php @@ -43,7 +43,7 @@ class LSformRule_email extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { return checkEmail( $value, LSconfig :: get('params.domain', null, null, $options), diff --git a/src/includes/class/class.LSformRule_filesize.php b/src/includes/class/class.LSformRule_filesize.php index 15891e78..330f38ed 100644 --- a/src/includes/class/class.LSformRule_filesize.php +++ b/src/includes/class/class.LSformRule_filesize.php @@ -44,7 +44,7 @@ class LSformRule_filesize extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { // According to PHP doc, strlen() returns the number of bytes rather // than the number of characters in a string. // See: https://www.php.net/manual/en/function.strlen.php diff --git a/src/includes/class/class.LSformRule_imagefile.php b/src/includes/class/class.LSformRule_imagefile.php index 4f4ff439..63c8679b 100644 --- a/src/includes/class/class.LSformRule_imagefile.php +++ b/src/includes/class/class.LSformRule_imagefile.php @@ -40,7 +40,7 @@ class LSformRule_imagefile extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $file = LSsession :: getTmpFile($value); $mimetype = mime_content_type($file); diff --git a/src/includes/class/class.LSformRule_imagesize.php b/src/includes/class/class.LSformRule_imagesize.php index 151c6751..314684dd 100644 --- a/src/includes/class/class.LSformRule_imagesize.php +++ b/src/includes/class/class.LSformRule_imagesize.php @@ -48,7 +48,7 @@ class LSformRule_imagesize extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $file = LSsession :: getTmpFile($value); list($width, $height, $type, $attr) = getimagesize($file); self :: log_debug("validate(): image size is $width x $height, type=$type, attr='$attr'"); diff --git a/src/includes/class/class.LSformRule_inarray.php b/src/includes/class/class.LSformRule_inarray.php index a5cad5d6..e7047766 100644 --- a/src/includes/class/class.LSformRule_inarray.php +++ b/src/includes/class/class.LSformRule_inarray.php @@ -45,7 +45,7 @@ class LSformRule_inarray extends LSformRule { * * @return boolean true if the value is valid, false otherwise */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $possible_values = LSconfig :: get('params.possible_values', null, null, $options); $reverse = LSconfig :: get('params.reverse', false, 'bool', $options); if (!is_array($possible_values)) { diff --git a/src/includes/class/class.LSformRule_integer.php b/src/includes/class/class.LSformRule_integer.php index 50df9087..e33cdf07 100644 --- a/src/includes/class/class.LSformRule_integer.php +++ b/src/includes/class/class.LSformRule_integer.php @@ -48,7 +48,7 @@ class LSformRule_integer extends LSformRule{ * * @return boolean true if the value is valided, false otherwise */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $max = LSconfig :: get('params.max', null, 'int', $options); if(is_int($max) && $max != 0 && $value > $max) { self :: log_debug("value is too higth ($value > $max)"); diff --git a/src/includes/class/class.LSformRule_ldapSearchURI.php b/src/includes/class/class.LSformRule_ldapSearchURI.php index 7093fca5..70de9bee 100644 --- a/src/includes/class/class.LSformRule_ldapSearchURI.php +++ b/src/includes/class/class.LSformRule_ldapSearchURI.php @@ -46,7 +46,7 @@ class LSformRule_ldapSearchURI extends LSformRule { * * @return boolean true if the value is valid, false otherwise */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { self :: log_trace("validate($value): options = ".varDump($options)); $uri_parts = explode('?', $value); diff --git a/src/includes/class/class.LSformRule_lettersonly.php b/src/includes/class/class.LSformRule_lettersonly.php index 6866b8ce..c850eb6f 100644 --- a/src/includes/class/class.LSformRule_lettersonly.php +++ b/src/includes/class/class.LSformRule_lettersonly.php @@ -36,7 +36,7 @@ class LSformRule_lettersonly extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $regex = '/^[a-zA-Z]+$/'; LSsession :: loadLSclass('LSformRule_regex'); return LSformRule_regex :: validate($value,$regex,$formElement); diff --git a/src/includes/class/class.LSformRule_maxlength.php b/src/includes/class/class.LSformRule_maxlength.php index f1dec569..3b8aa818 100644 --- a/src/includes/class/class.LSformRule_maxlength.php +++ b/src/includes/class/class.LSformRule_maxlength.php @@ -42,7 +42,7 @@ class LSformRule_maxlength extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $limit = LSconfig :: get('params.limit', null, 'int', $options); if(is_null($limit)) { LSerror :: addErrorCode('LSformRule_01',array('type' => 'maxlength', 'param' => 'limit')); diff --git a/src/includes/class/class.LSformRule_mimetype.php b/src/includes/class/class.LSformRule_mimetype.php index e109a087..c7aebeed 100644 --- a/src/includes/class/class.LSformRule_mimetype.php +++ b/src/includes/class/class.LSformRule_mimetype.php @@ -44,7 +44,7 @@ class LSformRule_mimetype extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $file = LSsession :: getTmpFile($value); $real_mimetype = mime_content_type($file); diff --git a/src/includes/class/class.LSformRule_minlength.php b/src/includes/class/class.LSformRule_minlength.php index c01e44b3..92470e98 100644 --- a/src/includes/class/class.LSformRule_minlength.php +++ b/src/includes/class/class.LSformRule_minlength.php @@ -42,7 +42,7 @@ class LSformRule_minlength extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $limit = LSconfig :: get('params.limit', null, 'int', $options); if(is_null($limit)) { LSerror :: addErrorCode('LSformRule_01',array('type' => 'minlength', 'param' => 'limit')); diff --git a/src/includes/class/class.LSformRule_nonzero.php b/src/includes/class/class.LSformRule_nonzero.php index 47594fe1..e119a5ea 100644 --- a/src/includes/class/class.LSformRule_nonzero.php +++ b/src/includes/class/class.LSformRule_nonzero.php @@ -36,7 +36,7 @@ class LSformRule_nonzero extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $regex = '/^-?[1-9][0-9]*/'; LSsession :: loadLSclass('LSformRule_regex'); return LSformRule_regex :: validate($value,$regex,$formElement); diff --git a/src/includes/class/class.LSformRule_nopunctuation.php b/src/includes/class/class.LSformRule_nopunctuation.php index 4ffdfa7c..5f5837b2 100644 --- a/src/includes/class/class.LSformRule_nopunctuation.php +++ b/src/includes/class/class.LSformRule_nopunctuation.php @@ -36,7 +36,7 @@ class LSformRule_nopunctuation extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $regex = '/^[^().\/\*\^\?#!@$%+=,\"\'><~\[\]{}]+$/'; LSsession :: loadLSclass('LSformRule_regex'); return LSformRule_regex :: validate($value,$regex,$formElement); diff --git a/src/includes/class/class.LSformRule_numberOfValues.php b/src/includes/class/class.LSformRule_numberOfValues.php index e7272058..a4bc24cc 100644 --- a/src/includes/class/class.LSformRule_numberOfValues.php +++ b/src/includes/class/class.LSformRule_numberOfValues.php @@ -45,7 +45,7 @@ class LSformRule_numberOfValues extends LSformRule { * * @return boolean true if the value is valide, false if not */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $max_values = LSconfig :: get('params.max', null, 'int', $options); $min_values = LSconfig :: get('params.min', null, 'int', $options); if(is_null($max_values) && is_null($min_values)) { diff --git a/src/includes/class/class.LSformRule_numeric.php b/src/includes/class/class.LSformRule_numeric.php index a838d4d2..9c7249d2 100644 --- a/src/includes/class/class.LSformRule_numeric.php +++ b/src/includes/class/class.LSformRule_numeric.php @@ -36,7 +36,7 @@ class LSformRule_numeric extends LSformRule{ * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $regex = '/(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/'; LSsession :: loadLSclass('LSformRule_regex'); return LSformRule_regex :: validate($value,$regex,$formElement); diff --git a/src/includes/class/class.LSformRule_password.php b/src/includes/class/class.LSformRule_password.php index 2116cc88..25cbcce8 100644 --- a/src/includes/class/class.LSformRule_password.php +++ b/src/includes/class/class.LSformRule_password.php @@ -52,7 +52,7 @@ class LSformRule_password extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $errors = array(); $maxLength = LSconfig :: get('params.maxLength', null, 'int', $options); diff --git a/src/includes/class/class.LSformRule_rangelength.php b/src/includes/class/class.LSformRule_rangelength.php index 92792d3e..0e770d71 100644 --- a/src/includes/class/class.LSformRule_rangelength.php +++ b/src/includes/class/class.LSformRule_rangelength.php @@ -43,7 +43,7 @@ class LSformRule_rangelength extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $limits = LSconfig :: get('params.limits', null, null, $options); if(!is_array($limits) || count($limits) != 2) { LSerror :: addErrorCode('LSformRule_01',array('type' => 'rangelength', 'param' => 'limits')); diff --git a/src/includes/class/class.LSformRule_regex.php b/src/includes/class/class.LSformRule_regex.php index f38172ed..2be18264 100644 --- a/src/includes/class/class.LSformRule_regex.php +++ b/src/includes/class/class.LSformRule_regex.php @@ -42,7 +42,7 @@ class LSformRule_regex extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { if (is_array($options)) { $regex = LSconfig :: get('params.regex', null, 'string', $options); if (!is_string($regex)) { diff --git a/src/includes/class/class.LSformRule_required.php b/src/includes/class/class.LSformRule_required.php index bb093a0a..39317971 100644 --- a/src/includes/class/class.LSformRule_required.php +++ b/src/includes/class/class.LSformRule_required.php @@ -36,7 +36,7 @@ class LSformRule_required extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { return ((string)$value != ''); } diff --git a/src/includes/class/class.LSformRule_ssh_pub_key.php b/src/includes/class/class.LSformRule_ssh_pub_key.php index 36dbfb1c..98038ee0 100644 --- a/src/includes/class/class.LSformRule_ssh_pub_key.php +++ b/src/includes/class/class.LSformRule_ssh_pub_key.php @@ -36,7 +36,7 @@ class LSformRule_ssh_pub_key extends LSformRule { * * @return boolean true if the value is valide, false if not */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { if (preg_match('/^(ssh-[a-z0-9]+) +([^ ]+) +(.*)$/', $value, $m)) { $data=@base64_decode($m[2]); if (is_string($data)) diff --git a/src/includes/class/class.LSformRule_telephonenumber.php b/src/includes/class/class.LSformRule_telephonenumber.php index 78c8e5a7..4d5853b2 100644 --- a/src/includes/class/class.LSformRule_telephonenumber.php +++ b/src/includes/class/class.LSformRule_telephonenumber.php @@ -36,7 +36,7 @@ class LSformRule_telephonenumber extends LSformRule { * * @return boolean true si la valeur est valide, false sinon */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $regex = '/^(01|02|03|04|05|06|08|09)[0-9]{8}$/'; LSsession :: loadLSclass('LSformRule_regex'); return LSformRule_regex :: validate($value,$regex,$formElement); diff --git a/src/includes/class/class.LSformRule_zxcvbn.php b/src/includes/class/class.LSformRule_zxcvbn.php index 0555c818..2bb292de 100644 --- a/src/includes/class/class.LSformRule_zxcvbn.php +++ b/src/includes/class/class.LSformRule_zxcvbn.php @@ -54,7 +54,7 @@ class LSformRule_zxcvbn extends LSformRule { * * @return boolean True if value is valid, False otherwise */ - public static function validate($value, $options=array(), &$formElement) { + public static function validate($value, $options, &$formElement) { $zxcvbn = new Zxcvbn(); $userData = array(); $userDataAttrs = LSconfig :: get('params.userDataAttrs', array(), 'array', $options);