Minor - Format code

pull/2487/head
jmontoyaa 8 years ago
parent dcac4b43d2
commit 471872f676
  1. 7
      main/inc/lib/pear/HTML/QuickForm.php
  2. 10
      main/inc/lib/pear/HTML/QuickForm/Rule/Compare.php

@ -1489,7 +1489,12 @@ class HTML_QuickForm extends HTML_Common
} elseif (is_array($submitValue) && !isset($rule['howmany'])) {
$result = $registry->validate($rule['type'], $submitValue, $rule['format'], true);
} else {
$result = $registry->validate($rule['type'], $submitValue, $rule['format'], false);
$result = $registry->validate(
$rule['type'],
$submitValue,
$rule['format'],
false
);
}
if (!$result || (!empty($rule['howmany']) && $rule['howmany'] > (int)$result)) {

@ -1,5 +1,4 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Rule to compare two form fields
@ -40,7 +39,7 @@ class HTML_QuickForm_Rule_Compare extends HTML_QuickForm_Rule
* @var array
* @access private
*/
var $_operators = array(
public $_operators = array(
'eq' => '===',
'neq' => '!==',
'gt' => '>',
@ -72,16 +71,19 @@ class HTML_QuickForm_Rule_Compare extends HTML_QuickForm_Rule
}
}
/**
* @param array $values
* @param string $operator
* @return mixed
*/
function validate($values, $operator = null)
{
$operator = $this->_findOperator($operator);
if ('===' != $operator && '!==' != $operator) {
$compareFn = create_function('$a, $b', 'return floatval($a) ' . $operator . ' floatval($b);');
} else {
$compareFn = create_function('$a, $b', 'return strval($a) ' . $operator . ' strval($b);');
}
return $compareFn($values[0], $values[1]);
}

Loading…
Cancel
Save