From 168630ade7b84da0329d222c7bee6620b2dd08f3 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 | 4 ++-- include/simpleplugin/class_simplePlugin.inc | 6 +++--- 6 files changed, 14 insertions(+), 24 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 963d99a9d..038a697d0 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -677,9 +677,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 f1eb2b2a9..dfbc1f44f 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 69a27b106..4f6716d26 100644 --- a/include/class_objects.inc +++ b/include/class_objects.inc @@ -74,8 +74,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 f1155cb12..90c37abe1 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -739,7 +739,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)) { @@ -1410,7 +1410,7 @@ function netmask_to_bits($netmask) /*! * \brief Recursion helper for gen_uids() */ -function _recurse_gen_uids($rule, $variables) +function _recurse_gen_uids($rule, array $variables) { $result = array(); diff --git a/include/simpleplugin/class_simplePlugin.inc b/include/simpleplugin/class_simplePlugin.inc index 2a607334c..20a94870e 100644 --- a/include/simpleplugin/class_simplePlugin.inc +++ b/include/simpleplugin/class_simplePlugin.inc @@ -1153,7 +1153,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]; @@ -1161,7 +1161,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; @@ -1171,7 +1171,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