From f8482edc0eccf5d20232d8d3fe5a500e333290d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be> Date: Thu, 17 Jan 2019 14:56:53 +0100 Subject: [PATCH] :ambulance: Fix count method usage for PHP>=7.2 issue #5942 --- include/class_Combinations.inc | 2 +- include/class_ldap.inc | 4 ++-- include/class_msgPool.inc | 19 +++++-------------- include/class_objects.inc | 3 +-- include/functions.inc | 2 +- include/simpleplugin/class_simplePlugin.inc | 6 +++--- 6 files changed, 13 insertions(+), 23 deletions(-) diff --git a/include/class_Combinations.inc b/include/class_Combinations.inc index d0ef2ac59..2821f6df5 100644 --- a/include/class_Combinations.inc +++ b/include/class_Combinations.inc @@ -28,7 +28,7 @@ class Combinations implements Iterator protected $size = 0; protected $pos = 0; - function __construct($input, $size) + function __construct(array $input, $size) { $this->input = array_values($input); $this->n = count($this->input); diff --git a/include/class_ldap.inc b/include/class_ldap.inc index a3cdde57f..8f3dbfc1a 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -673,9 +673,9 @@ class LDAP /*! * \brief Modify a entry of the directory LDAP * - * \param string $attrs The new entry + * \param array $attrs The new entry */ - function modify($attrs) + function modify(array $attrs) { if (count($attrs) == 0) { return 0; diff --git a/include/class_msgPool.inc b/include/class_msgPool.inc index d98e1a5b6..75b56b8ab 100644 --- a/include/class_msgPool.inc +++ b/include/class_msgPool.inc @@ -577,24 +577,15 @@ class msgPool { * * \param array $depends Contains all the settings enabled */ - public static function featuresEnabled($name, $depends = "") + public static function featuresEnabled($name, $depends = '') { - if (($depends == "") || (is_array($depends) && count($depends) == 0)) { + if (($depends == "") || (is_array($depends) && (count($depends) == 0))) { return sprintf(_("This account has %s settings enabled. You can disable them by clicking below."), $name); } else { - if (count($depends) == 1) { - if (is_array($depends)) { - $depends = $depends[0]; - } - return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $depends); - } else { - $deps = ""; - foreach ($depends as $dep) { - $deps .= "$dep / "; - } - $deps = preg_replace("/ \/ $/", "", $deps); - return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $deps); + if (is_array($depends)) { + $depends = implode(' / ', $depends); } + return sprintf(_("This account has %s settings enabled. To disable them, you'll need to remove the %s settings first!"), $name, $depends); } } diff --git a/include/class_objects.inc b/include/class_objects.inc index e93415b0c..d4646291a 100644 --- a/include/class_objects.inc +++ b/include/class_objects.inc @@ -75,8 +75,7 @@ class objects $attrs = array_unique($attrs); if (count($attrs) == 1) { $attrs = $attrs[0]; - } - if (count($attrs) == 0) { + } elseif (count($attrs) == 0) { $attrs = array('dn' => 'raw'); } } elseif ($checkAcl) { diff --git a/include/functions.inc b/include/functions.inc index 8d0656e19..757762ae6 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -714,7 +714,7 @@ function get_locks($objects, $allow_readonly = FALSE) { global $config; - if (is_array($objects) && count($objects == 1)) { + if (is_array($objects) && (count($objects) == 1)) { $objects = reset($objects); } if (is_array($objects)) { diff --git a/include/simpleplugin/class_simplePlugin.inc b/include/simpleplugin/class_simplePlugin.inc index a302778aa..26e204eef 100644 --- a/include/simpleplugin/class_simplePlugin.inc +++ b/include/simpleplugin/class_simplePlugin.inc @@ -1157,7 +1157,7 @@ class simplePlugin /* Convert arrays with one element to non arrays, if the saved attributes are no array, too */ if (is_array($this->attrs[$index]) && - count ($this->attrs[$index]) == 1 && + (count($this->attrs[$index]) == 1) && isset($this->saved_attributes[$index]) && !is_array($this->saved_attributes[$index])) { $this->attrs[$index] = $this->attrs[$index][0]; @@ -1165,7 +1165,7 @@ class simplePlugin /* Remove emtpy arrays if they do not differ */ if (is_array($this->attrs[$index]) && - count($this->attrs[$index]) == 0 && + (count($this->attrs[$index]) == 0) && !isset($this->saved_attributes[$index])) { unset ($this->attrs[$index]); continue; @@ -1175,7 +1175,7 @@ class simplePlugin if (!is_array($this->attrs[$index]) && isset($this->saved_attributes[$index]) && !is_array($this->saved_attributes[$index]) && - $this->attrs[$index] == $this->saved_attributes[$index]) { + ($this->attrs[$index] == $this->saved_attributes[$index])) { unset ($this->attrs[$index]); continue; } -- GitLab