Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorThomas Steur <tsteur@users.noreply.github.com>2018-12-06 03:24:24 +0300
committerdiosmosis <diosmosis@users.noreply.github.com>2018-12-06 03:24:24 +0300
commit2633c57395c5c5795d06ce45984e66d802e7074d (patch)
treebae84f60b75565e0db4677564e3867e0facfb7d8 /libs
parent0c72250d883a651a1d91263253533c460cdf35ec (diff)
Quickform2 throws warnings with PHP7.2 (#13463)
fixes #13272 Haven't actually tested it but should fix the issue. If tests pass, the logic would be still the same. I don't have a PHP 7.2 running here otherwise at the moment
Diffstat (limited to 'libs')
-rw-r--r--libs/HTML/QuickForm2/Rule/Compare.php39
1 files changed, 29 insertions, 10 deletions
diff --git a/libs/HTML/QuickForm2/Rule/Compare.php b/libs/HTML/QuickForm2/Rule/Compare.php
index 60dca9f5d3..ce42e9a06e 100644
--- a/libs/HTML/QuickForm2/Rule/Compare.php
+++ b/libs/HTML/QuickForm2/Rule/Compare.php
@@ -84,6 +84,20 @@ class HTML_QuickForm2_Rule_Compare extends HTML_QuickForm2_Rule
*/
protected $operators = array('==', '!=', '===', '!==', '<', '<=', '>', '>=');
+ protected function doOperation($a, $b, $operator)
+ {
+ switch ($operator) {
+ case "==": return $a == $b;
+ case "!=": return $a != $b;
+ case "===": return $a === $b;
+ case "!==": return $a !== $b;
+ case ">": return $a > $b;
+ case "<=": return $a <= $b;
+ case "<": return $a < $b;
+ case ">=": return $a >= $b;
+ default: return true;
+ }
+ }
/**
* Validates the owner element
@@ -94,17 +108,22 @@ class HTML_QuickForm2_Rule_Compare extends HTML_QuickForm2_Rule
{
$value = $this->owner->getValue();
$config = $this->getConfig();
+
+ if ($config['operand'] instanceof HTML_QuickForm2_Node) {
+ $b = $config['operand']->getValue();
+ } else {
+ $b = $config['operand'];
+ }
+
if (!in_array($config['operator'], array('===', '!=='))) {
- $compareFn = create_function(
- '$a, $b', 'return floatval($a) ' . $config['operator'] . ' floatval($b);'
- );
+ $a = floatval($value);
+ $b = floatval($b);
} else {
- $compareFn = create_function(
- '$a, $b', 'return strval($a) ' . $config['operator'] . ' strval($b);'
- );
+ $a = strval($value);
+ $b = strval($b);
}
- return $compareFn($value, $config['operand'] instanceof HTML_QuickForm2_Node
- ? $config['operand']->getValue(): $config['operand']);
+
+ return $this->doOperation($a, $b, $config['operator']);
}
protected function getJavascriptCallback()
@@ -156,10 +175,10 @@ class HTML_QuickForm2_Rule_Compare extends HTML_QuickForm2_Rule
public static function mergeConfig($localConfig, $globalConfig)
{
$config = null;
- if (0 < count($globalConfig)) {
+ if (is_array($globalConfig) && 0 < count($globalConfig)) {
$config = self::toCanonicalForm($globalConfig, 'operator');
}
- if (0 < count($localConfig)) {
+ if (is_array($localConfig) && 0 < count($localConfig)) {
$config = (isset($config)? $config: array())
+ self::toCanonicalForm($localConfig);
}