Warning: count(): Parameter must be an array or an object that implements Countable

Hi everyone,

Since I update my PHP version to 7.2, I'm having warnings on class mpgCustInfo (mpgClasses.php) 

"Warning: count(): Parameter must be an array or an object that implements Countable in"

function toXML_low($template, $txnType)
{

for ($x = 0; $x < count($this->level3data[$txnType]); $x++) {
if ($x > 0) {
$xmlString .= "</$txnType><$txnType>";
}
$keys = array_keys($template);
for ($i = 0; $i < count($keys); $i++) {
$tag = $keys[$i];

if (is_array($template[$keys[$i]])) {
$data = $template[$tag];

if (! count($this->level3data[$tag])) {
continue;
}
$beginTag = "<$tag>";
$endTag = "</$tag>";

$xmlString .= $beginTag;
if (is_array($data)) {
$returnString = $this->toXML_low($data, $tag);
$xmlString .= $returnString;
}
$xmlString .= $endTag;
} else {
$tag = $template[$keys[$i]];
$beginTag = "<$tag>";
$endTag = "</$tag>";
$data = $this->level3data[$txnType][$x][$tag];

$xmlString .= $beginTag . $data . $endTag;
}

}//end inner for

}//end outer for

return $xmlString;
}//end toXML_low

Anyone having same issues?