| 1 | <?php |
||
| 13 | class PageCollection implements \ArrayAccess, \IteratorAggregate, \Countable |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var callback A function to be used for loading the pages. |
||
| 17 | */ |
||
| 18 | private $loader; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var array of \Phile\Model\Page |
||
| 22 | */ |
||
| 23 | private $pages; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Constructor. |
||
| 27 | * |
||
| 28 | * @param callable $loader pages loader |
||
| 29 | */ |
||
| 30 | 9 | public function __construct(callable $loader) |
|
| 31 | { |
||
| 32 | 9 | $this->loader = $loader; |
|
| 33 | 9 | } |
|
| 34 | |||
| 35 | /** |
||
| 36 | * Perform page loading. |
||
| 37 | * |
||
| 38 | * @return void |
||
| 39 | */ |
||
| 40 | 9 | private function load() |
|
| 41 | { |
||
| 42 | 9 | if ($this->pages === null) { |
|
| 43 | 9 | $this->pages = call_user_func($this->loader); |
|
|
|
|||
| 44 | } |
||
| 45 | 8 | } |
|
| 46 | |||
| 47 | /** |
||
| 48 | * Get pages in a array. |
||
| 49 | * |
||
| 50 | * @return array of \Phile\Model\Page |
||
| 51 | */ |
||
| 52 | 2 | public function toArray() |
|
| 57 | |||
| 58 | 4 | public function getIterator() |
|
| 63 | |||
| 64 | public function offsetExists($offset) |
||
| 69 | |||
| 70 | 2 | public function offsetGet($offset) |
|
| 75 | |||
| 76 | public function offsetSet($offset, $value) |
||
| 81 | |||
| 82 | public function offsetUnset($offset) |
||
| 87 | |||
| 88 | 2 | public function count() |
|
| 93 | } |
||
| 94 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..