File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ public function getHydrator()
9090 /**
9191 * Iterator: get current item
9292 *
93- * @return object
93+ * @return object|null
9494 */
9595 public function current ()
9696 {
@@ -99,14 +99,14 @@ public function current()
9999 } elseif (is_array ($ this ->buffer ) && isset ($ this ->buffer [$ this ->position ])) {
100100 return $ this ->buffer [$ this ->position ];
101101 }
102- $ data = $ this ->dataSource ->current ();
103- $ object = is_array ($ data ) ? $ this ->hydrator ->hydrate ($ data , clone $ this ->objectPrototype ) : false ;
102+ $ data = $ this ->dataSource ->current ();
103+ $ current = is_array ($ data ) ? $ this ->hydrator ->hydrate ($ data , clone $ this ->objectPrototype ) : null ;
104104
105105 if (is_array ($ this ->buffer )) {
106- $ this ->buffer [$ this ->position ] = $ object ;
106+ $ this ->buffer [$ this ->position ] = $ current ;
107107 }
108108
109- return $ object ;
109+ return $ current ;
110110 }
111111
112112 /**
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ public function testGetHydrator()
5656 /**
5757 * @covers \Zend\Db\ResultSet\HydratingResultSet::current
5858 */
59- public function testCurrent ()
59+ public function testCurrentHasData ()
6060 {
6161 $ hydratingRs = new HydratingResultSet ;
6262 $ hydratingRs ->initialize ([
@@ -66,6 +66,17 @@ public function testCurrent()
6666 self ::assertInstanceOf ('ArrayObject ' , $ obj );
6767 }
6868
69+ /**
70+ * @covers \Zend\Db\ResultSet\HydratingResultSet::current
71+ */
72+ public function testCurrentDoesnotHasData ()
73+ {
74+ $ hydratingRs = new HydratingResultSet ;
75+ $ hydratingRs ->initialize ([]);
76+ $ result = $ hydratingRs ->current ();
77+ self ::assertNull ($ result );
78+ }
79+
6980 /**
7081 * @covers \Zend\Db\ResultSet\HydratingResultSet::toArray
7182 * @todo Implement testToArray().
You can’t perform that action at this time.
0 commit comments