| 1 | <?php |
||
| 13 | abstract class SimplePaginatedList extends LazyResourceList |
||
| 14 | { |
||
| 15 | use PaginatedList; |
||
| 16 | |||
| 17 | /* @var integer */ |
||
| 18 | protected $offset = 0; |
||
| 19 | |||
| 20 | /* @var integer */ |
||
| 21 | protected $limit = 10; |
||
| 22 | |||
| 23 | |||
| 24 | protected function fetchBatch() |
||
| 25 | { |
||
| 26 | if (!is_null($this->totalRecordCount) && $this->offset >= $this->totalRecordCount) { |
||
| 27 | return; |
||
| 28 | } |
||
| 29 | |||
| 30 | $response = $this->client->getJSON($this->url('', [ |
||
| 31 | 'offset' => $this->offset, |
||
| 32 | 'limit' => $this->limit, |
||
| 33 | ])); |
||
| 34 | return $this->onData($response); |
||
| 35 | } |
||
| 36 | |||
| 37 | protected function fetchData() |
||
| 38 | { |
||
| 39 | do { |
||
| 40 | $this->fetchBatch(); |
||
| 41 | } while (!$this->isInitialized($this->resources)); |
||
|
|
|||
| 42 | return null; |
||
| 43 | } |
||
| 44 | |||
| 45 | protected function onData($data) |
||
| 46 | { |
||
| 47 | parent::onData($data); |
||
| 48 | $this->offset = count($this->resources); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * Check if we have the full representation of our data object. |
||
| 53 | * |
||
| 54 | * @param \stdClass $data |
||
| 55 | * @return boolean |
||
| 56 | */ |
||
| 57 | protected function isInitialized($data) |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Total number of resources. |
||
| 64 | * @link http://php.net/manual/en/countable.count.php |
||
| 65 | * @return int |
||
| 66 | */ |
||
| 67 | public function count() |
||
| 75 | } |
||
| 76 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: