From bee172c4b762bde8dd4e876026d41c71a5c72d0f Mon Sep 17 00:00:00 2001 From: MDW Date: Mon, 18 Mar 2024 13:00:51 +0100 Subject: [PATCH] Fix: Initialise $x to fix PhanUndeclaredVariableAssignOp & optimize --- htdocs/core/lib/functions2.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index cfe406a7684..36cb26e4b6d 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1589,8 +1589,9 @@ function check_value($mask, $value) function binhex($bin, $pad = false, $upper = false) { $last = dol_strlen($bin) - 1; + $x = 0; for ($i = 0; $i <= $last; $i++) { - $x += $bin[$last - $i] * pow(2, $i); + $x += ($bin[$last - $i] ? 1 : 0) << $i; } $x = dechex($x); if ($pad) {