Test code:
$paginator = Zend_Paginator::factory(2);
$paginator->setCurrentPageNumber(1);
$paginator->setItemCountPerPage(5);
$pages = $paginator->getPages();
var_dump($pages);
期望结果:
["currentItemCount"]=>2
["lastItemNumber"]=>2
实际结果:
["currentItemCount"]=>5
["lastItemNumber"]=>5
修正方法:
public function getItems($offset, $itemCountPerPage)
{
if ($this->_count <= $offset) return array();
$remainItemCount = $this->_count - $offset;
$currentItemCount = $remainItemCount > $itemCountPerPage ? $itemCountPerPage : $remainItemCount;
return array_fill(0, $currentItemCount, null);
}