zendframework / zend-db

Db component from Zend Framework
BSD 3-Clause "New" or "Revised" License
101 stars 122 forks source link

AdapterInterface does not define query as a method #398

Open dfelton opened 4 years ago

dfelton commented 4 years ago

Description of what I am trying to accomplish:

Code to reproduce the issue

class FooBar
{
    /**
     * @var \Zend\Db\Adapter\AdapterInterface
     */
    private $adapter;

    public function  __construct(
        \Zend\Db\Adapter\AdapterInterface $adapter
    ) {
        $this->adapter = $adapter
    }

    public function getRecordById(int $id): \ArrayObject
    {
        /**
         * @var \Zend\Db\ResultSet\ResultSet $resultSet
         */
        $resultSet = $this->adapter->query('SELECT * FROM foo_bar WHERE id = :id FOR UPDATE', ['id' => $id]);
        return $resultSet->current();
    }
}

Expected results

Actual results

Since (in my application) \Zend\Db\Adapter\Adapter is the concrete class that is injected at run time, the method still works. However this leads to:

weierophinney commented 4 years ago

This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at https://github.com/laminas/laminas-db/issues/1.