1 | <?php |
||
35 | class Cursor implements Iterator, Countable |
||
36 | { |
||
37 | |||
38 | /** |
||
39 | * MongoCursor returned by the query |
||
40 | * @var FinderCursorInterface|MongoCursor |
||
41 | * @since v1.3.4 |
||
42 | */ |
||
43 | private $cursor; |
||
44 | |||
45 | /** |
||
46 | * Model used for instantiating objects |
||
47 | * @var AnnotatedInterface |
||
48 | * @since v1.3.4 |
||
49 | */ |
||
50 | private $model; |
||
51 | |||
52 | /** |
||
53 | * Construct a new Cursor |
||
54 | * |
||
55 | * @param FinderCursorInterface|MongoCursor $cursor the cursor returned by the query |
||
56 | * @param AnnotatedInterface $model the model for instantiating objects |
||
57 | * @since v1.3.4 |
||
58 | */ |
||
59 | 1 | public function __construct(Iterator $cursor, AnnotatedInterface $model) |
|
65 | |||
66 | /** |
||
67 | * Return MongoCursor for additional tuning |
||
68 | * |
||
69 | * @return FinderCursorInterface|MongoCursor the cursor used for this query |
||
70 | * @since v1.3.4 |
||
71 | */ |
||
72 | public function getCursor() |
||
76 | |||
77 | /** |
||
78 | * Return the current element |
||
79 | * @return AnnotatedInterface|Document|null |
||
80 | * @since v1.3.4 |
||
81 | */ |
||
82 | 1 | public function current() |
|
92 | |||
93 | /** |
||
94 | * Return the key of the current element |
||
95 | * @return scalar |
||
96 | * @since v1.3.4 |
||
97 | */ |
||
98 | public function key() |
||
102 | |||
103 | /** |
||
104 | * Move forward to next element |
||
105 | * @return void |
||
106 | * @since v1.3.4 |
||
107 | */ |
||
108 | 1 | public function next() |
|
112 | |||
113 | /** |
||
114 | * Rewind the Iterator to the first element |
||
115 | * @return void |
||
116 | * @since v1.3.4 |
||
117 | */ |
||
118 | 1 | public function rewind() |
|
122 | |||
123 | /** |
||
124 | * Checks if current position is valid |
||
125 | * @return boolean |
||
126 | * @since v1.3.4 |
||
127 | */ |
||
128 | 1 | public function valid() |
|
132 | |||
133 | /** |
||
134 | * Returns the number of documents found |
||
135 | * {@see http://www.php.net/manual/en/mongocursor.count.php} |
||
136 | * @param boolean $foundOnly default FALSE |
||
137 | * @return integer count of documents found |
||
138 | * @since v1.3.4 |
||
139 | */ |
||
140 | 1 | public function count($foundOnly = false) |
|
144 | |||
145 | /** |
||
146 | * Apply a limit to this cursor |
||
147 | * {@see http://www.php.net/manual/en/mongocursor.limit.php} |
||
148 | * @param integer $limit new limit |
||
149 | * @since v1.3.4 |
||
150 | */ |
||
151 | public function limit($limit) |
||
155 | |||
156 | /** |
||
157 | * Skip a $offset records |
||
158 | * {@see http://www.php.net/manual/en/mongocursor.skip.php} |
||
159 | * @param integer $offset new skip |
||
160 | * @since v1.3.4 |
||
161 | */ |
||
162 | public function offset($offset) |
||
166 | |||
167 | /** |
||
168 | * Apply sorting directives |
||
169 | * {@see http://www.php.net/manual/en/mongocursor.sort.php} |
||
170 | * @param array $fields sorting directives |
||
171 | * @since v1.3.4 |
||
172 | */ |
||
173 | public function sort(array $fields) |
||
177 | |||
178 | } |
||
179 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: