@@ -171,11 +171,17 @@ public function execute($params = null)
171171 /**
172172 * {@inheritdoc}
173173 */
174- public function setFetchMode ($ fetchMode , $ arg2 = null , $ arg3 = null )
174+ public function setFetchMode ($ fetchMode , ... $ args )
175175 {
176- $ this ->_defaultFetchMode = $ fetchMode ;
177- $ this ->defaultFetchClass = $ arg2 ? $ arg2 : $ this ->defaultFetchClass ;
178- $ this ->defaultFetchClassCtorArgs = $ arg3 ? (array ) $ arg3 : $ this ->defaultFetchClassCtorArgs ;
176+ $ this ->_defaultFetchMode = $ fetchMode ;
177+
178+ if (isset ($ args [0 ])) {
179+ $ this ->defaultFetchClass = $ args [0 ];
180+ }
181+
182+ if (isset ($ args [1 ])) {
183+ $ this ->defaultFetchClassCtorArgs = (array ) $ args [2 ];
184+ }
179185
180186 return true ;
181187 }
@@ -191,7 +197,7 @@ public function getIterator()
191197 /**
192198 * {@inheritdoc}
193199 */
194- public function fetch ($ fetchMode = null , $ cursorOrientation = \ PDO :: FETCH_ORI_NEXT , $ cursorOffset = 0 )
200+ public function fetch ($ fetchMode = null , ... $ args )
195201 {
196202 // do not try fetching from the statement if it's not expected to contain result
197203 // in order to prevent exceptional situation
@@ -214,10 +220,9 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
214220 $ className = $ this ->defaultFetchClass ;
215221 $ ctorArgs = $ this ->defaultFetchClassCtorArgs ;
216222
217- if (func_num_args () >= 2 ) {
218- $ args = func_get_args ();
219- $ className = $ args [1 ];
220- $ ctorArgs = $ args [2 ] ?? [];
223+ if (count ($ args ) > 0 ) {
224+ $ className = $ args [0 ];
225+ $ ctorArgs = $ args [1 ] ?? [];
221226 }
222227
223228 $ result = db2_fetch_object ($ this ->_stmt );
@@ -242,23 +247,23 @@ public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NE
242247 /**
243248 * {@inheritdoc}
244249 */
245- public function fetchAll ($ fetchMode = null , $ fetchArgument = null , $ ctorArgs = null )
250+ public function fetchAll ($ fetchMode = null , ... $ args )
246251 {
247252 $ rows = [];
248253
249254 switch ($ fetchMode ) {
250255 case FetchMode::CUSTOM_OBJECT :
251- while ($ row = call_user_func_array ([ $ this , ' fetch ' ], func_get_args ()) ) {
256+ while (( $ row = $ this -> fetch ( $ fetchMode , ... $ args )) !== false ) {
252257 $ rows [] = $ row ;
253258 }
254259 break ;
255260 case FetchMode::COLUMN :
256- while ($ row = $ this ->fetchColumn ()) {
261+ while (( $ row = $ this ->fetchColumn ()) !== false ) {
257262 $ rows [] = $ row ;
258263 }
259264 break ;
260265 default :
261- while ($ row = $ this ->fetch ($ fetchMode )) {
266+ while (( $ row = $ this ->fetch ($ fetchMode )) !== false ) {
262267 $ rows [] = $ row ;
263268 }
264269 }
0 commit comments