1 | <?php |
||
33 | class CommandCursor implements Iterator |
||
34 | { |
||
35 | /** |
||
36 | * The CommandCursor instance being wrapped. |
||
37 | * |
||
38 | * @var BaseCommandCursor |
||
39 | */ |
||
40 | private $commandCursor; |
||
41 | |||
42 | /** |
||
43 | * @var UnitOfWork |
||
44 | */ |
||
45 | private $unitOfWork; |
||
46 | |||
47 | /** |
||
48 | * @var ClassMetadata |
||
49 | */ |
||
50 | private $class; |
||
51 | |||
52 | /** |
||
53 | * @param BaseCommandCursor $commandCursor The ComamndCursor instance being wrapped |
||
54 | * @param UnitOfWork $unitOfWork |
||
55 | * @param ClassMetadata $class The class to use for hydration or null if results should not be hydrated |
||
56 | */ |
||
57 | 2 | public function __construct(BaseCommandCursor $commandCursor, UnitOfWork $unitOfWork, ClassMetadata $class = null) |
|
63 | |||
64 | /** |
||
65 | * Wrapper method for MongoCommandCursor::batchSize(). |
||
66 | * |
||
67 | * @see http://php.net/manual/en/mongocommandcursor.batchsize.php |
||
68 | * @param integer $num |
||
69 | * @return self |
||
70 | */ |
||
71 | public function batchSize($num) |
||
77 | |||
78 | /** |
||
79 | * Recreates the command cursor and counts its results. |
||
80 | * |
||
81 | * @see http://php.net/manual/en/countable.count.php |
||
82 | * @return integer |
||
83 | */ |
||
84 | 2 | public function count() |
|
88 | |||
89 | /** |
||
90 | * Wrapper method for MongoCommandCursor::current(). |
||
91 | * |
||
92 | * @see http://php.net/manual/en/iterator.current.php |
||
93 | * @see http://php.net/manual/en/mongocommandcursor.current.php |
||
94 | * @return object|array|null |
||
95 | */ |
||
96 | 1 | public function current() |
|
100 | |||
101 | /** |
||
102 | * Wrapper method for MongoCommandCursor::dead(). |
||
103 | * |
||
104 | * @see http://php.net/manual/en/mongocommandcursor.dead.php |
||
105 | * @return boolean |
||
106 | */ |
||
107 | public function dead() |
||
111 | |||
112 | /** |
||
113 | * Returns the MongoCommandCursor instance being wrapped. |
||
114 | * |
||
115 | * @return BaseCommandCursor |
||
116 | */ |
||
117 | public function getBaseCursor() |
||
121 | |||
122 | /** |
||
123 | * Rewinds the cursor and returns its first result. |
||
124 | * |
||
125 | * @see Iterator::getSingleResult() |
||
126 | * @return object|array|null |
||
127 | */ |
||
128 | public function getSingleResult() |
||
132 | |||
133 | /** |
||
134 | * @param array $document |
||
135 | * @return array|object|null |
||
136 | */ |
||
137 | 1 | private function hydrateDocument($document) |
|
138 | { |
||
139 | 1 | if ($document !== null && $this->class !== null) { |
|
140 | 1 | return $this->unitOfWork->getOrCreateDocument($this->class->name, $document); |
|
141 | } |
||
142 | |||
143 | return $document; |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * Wrapper method for MongoCommandCursor::info(). |
||
148 | * |
||
149 | * @see http://php.net/manual/en/mongocommandcursor.info.php |
||
150 | * @return array |
||
151 | */ |
||
152 | public function info() |
||
156 | |||
157 | /** |
||
158 | * Wrapper method for MongoCommandCursor::key(). |
||
159 | * |
||
160 | * @see http://php.net/manual/en/iterator.key.php |
||
161 | * @see http://php.net/manual/en/mongocommandcursor.key.php |
||
162 | * @return integer |
||
163 | */ |
||
164 | 1 | public function key() |
|
168 | |||
169 | /** |
||
170 | * Wrapper method for MongoCommandCursor::next(). |
||
171 | * |
||
172 | * @see http://php.net/manual/en/iterator.next.php |
||
173 | * @see http://php.net/manual/en/mongocommandcursor.next.php |
||
174 | */ |
||
175 | 1 | public function next() |
|
181 | |||
182 | /** |
||
183 | * Wrapper method for MongoCommandCursor::rewind(). |
||
184 | * |
||
185 | * @see http://php.net/manual/en/iterator.rewind.php |
||
186 | * @see http://php.net/manual/en/mongocommandcursor.rewind.php |
||
187 | * @return array |
||
188 | */ |
||
189 | 1 | public function rewind() |
|
193 | |||
194 | /** |
||
195 | * Wrapper method for MongoCommandCursor::timeout(). |
||
196 | * |
||
197 | * @see http://php.net/manual/en/mongocommandcursor.timeout.php |
||
198 | * @param integer $ms |
||
199 | * @return self |
||
200 | * @throws BadMethodCallException if MongoCommandCursor::timeout() is not available |
||
201 | */ |
||
202 | public function timeout($ms) |
||
208 | |||
209 | /** |
||
210 | * Return the cursor's results as an array. |
||
211 | * |
||
212 | * @see Iterator::toArray() |
||
213 | * @return array |
||
214 | */ |
||
215 | 1 | public function toArray() |
|
219 | |||
220 | /** |
||
221 | * Wrapper method for MongoCommandCursor::valid(). |
||
222 | * |
||
223 | * @see http://php.net/manual/en/iterator.valid.php |
||
224 | * @see http://php.net/manual/en/mongocommandcursor.valid.php |
||
225 | * @return boolean |
||
226 | */ |
||
227 | 1 | public function valid() |
|
231 | } |
||
232 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.