Example #1
0
 /**
  * @return array|\ArrayObject|null
  */
 public function current()
 {
     $data = parent::current();
     if (is_array($data)) {
         $result = $this->resultPrototype;
         $result->populate(array());
         $result->exchangeArray($data);
         return $result;
     }
     return $data;
 }
Example #2
0
 /**
  * @return array|\ArrayObject|null
  */
 public function current()
 {
     $data = parent::current();
     if ($this->returnType === self::TYPE_ARRAYOBJECT && is_array($data)) {
         /** @var $ao ArrayObject */
         $ao = clone $this->arrayObjectPrototype;
         if ($ao instanceof ArrayObject || method_exists($ao, 'exchangeArray')) {
             $ao->exchangeArray($data);
         }
         return $ao;
     }
     return $data;
 }
Example #3
0
 /**
  * @return array|mixed|ObjectInterface
  */
 public function current()
 {
     $data = parent::current();
     if (is_array($data)) {
         $instance = clone $this->objectPrototype;
         if ($instance instanceof ObjectInterface || method_exists($instance, 'fromArray')) {
             $instance->fromArray($data);
             $instance->isNew(false);
             return $instance;
         } else {
             return $data;
         }
     } else {
         return $data;
     }
 }
 /**
  * @covers Zend\Db\ResultSet\AbstractResultSet::current
  */
 public function testCurrentCallsDataSourceCurrentOnceWithBuffer()
 {
     $result = $this->getMock('Zend\\Db\\Adapter\\Driver\\ResultInterface');
     $this->resultSet->buffer();
     $this->resultSet->initialize($result);
     $result->expects($this->once())->method('current')->will($this->returnValue(array('foo' => 'bar')));
     $value1 = $this->resultSet->current();
     $value2 = $this->resultSet->current();
     $this->resultSet->current();
     $this->assertEquals($value1, $value2);
 }