Hi,
You can solve this problem by casting the variable $post into an array.
Replace the line 508 $totalPostCount=count($posts);
With these line here below
$arrayFoo = (array) $posts;
$totalPostCount=count($arrayFoo);
My PHP version is 7.2
Hope this help some people.