mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-17 15:59:06 +01:00
Clean PHP8 compatibility errors detected by PHPstan
This commit is contained in:
parent
7f862c9765
commit
38fa02619d
32 changed files with 60 additions and 60 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ upgrade.log
|
|||
*~
|
||||
vendor
|
||||
/src/local.*
|
||||
tests-report.xml
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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.");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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}]+$/';
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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'");
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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)");
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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'));
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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 != '');
|
||||
}
|
||||
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue