Fix: Parameter must be an array or an object that implements Countable

This commit is contained in:
Regis Houssin 2017-06-11 06:54:40 +02:00
parent 3445c9d329
commit 6cac4b15d3

View File

@ -49,7 +49,7 @@ function dol_json_encode($elements)
{ {
dol_syslog('dol_json_encode() is deprecated. Please update your code to use native json_encode().', LOG_WARNING); dol_syslog('dol_json_encode() is deprecated. Please update your code to use native json_encode().', LOG_WARNING);
$num=count($elements); $num = (is_null($elements) ? 0 : count($elements)); // for avoid phpunit error : "Parameter must be an array or an object that implements Countable"
if (is_object($elements)) // Count number of properties for an object if (is_object($elements)) // Count number of properties for an object
{ {
$num=0; $num=0;