This repository was archived by the owner on Jan 29, 2020. It is now read-only.
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()
90
90
/**
91
91
* Iterator: get current item
92
92
*
93
- * @return object
93
+ * @return object|null
94
94
*/
95
95
public function current ()
96
96
{
@@ -99,14 +99,14 @@ public function current()
99
99
} elseif (is_array ($ this ->buffer ) && isset ($ this ->buffer [$ this ->position ])) {
100
100
return $ this ->buffer [$ this ->position ];
101
101
}
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 ;
104
104
105
105
if (is_array ($ this ->buffer )) {
106
- $ this ->buffer [$ this ->position ] = $ object ;
106
+ $ this ->buffer [$ this ->position ] = $ current ;
107
107
}
108
108
109
- return $ object ;
109
+ return $ current ;
110
110
}
111
111
112
112
/**
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ public function testGetHydrator()
56
56
/**
57
57
* @covers \Zend\Db\ResultSet\HydratingResultSet::current
58
58
*/
59
- public function testCurrent ()
59
+ public function testCurrentHasData ()
60
60
{
61
61
$ hydratingRs = new HydratingResultSet ;
62
62
$ hydratingRs ->initialize ([
@@ -66,6 +66,17 @@ public function testCurrent()
66
66
self ::assertInstanceOf ('ArrayObject ' , $ obj );
67
67
}
68
68
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
+
69
80
/**
70
81
* @covers \Zend\Db\ResultSet\HydratingResultSet::toArray
71
82
* @todo Implement testToArray().
You can’t perform that action at this time.
0 commit comments