auraphp/Aura.SqlQuery

Scrutinizer and data types

pavarnos opened this issue · 7 comments

So i've been fiddling with Scrutinizer a bit. Got an interesting message I don't know how to resolve.

scrutinizer

where $this->database is an instance of

class Database {
    /**
     * @return QueryFactory
     */
    protected function getQueryFactory()
    {
        if (empty($this->queryFactory)) {
            $this->queryFactory = new QueryFactory($this->isSqlite() ? 'sqlite' : 'mysql');
        }
        return $this->queryFactory;
    }

    /**
     * @return UpdateInterface
     */
    public function update()
    {
        return $this->getQueryFactory()->newUpdate();
    }

Seems like Scrutinizer is looking through the @return type declaration of Auras newUpdate() to the @return type declaration of newInstance('Update').

Is this a scrutiniser problem or something Aura can fix by changing type declarations?

Hey @pavarnos ,

You have already found the problem.

* @return AbstractQuery

The QueryFactory is having @return AbstractQuery , but it can be an instance of Insert, Update, Delete or Select interfaces. So the return type declared is wrong. I guess if we fix the return type, it will work as expected.

OK. What should the return type be?

@pavarnos I am not sure whether we can write something like this.

@return Common\SelectInterface|Common\InsertInterface|Common\UpdateInterface|Common\DeleteInterface

There is multiple return type in this case, ie why. . This will work, I have tested with phpdocumentator and apigen .

@pavarnos if you have time, do send a PR. Else I will look sending one.

Thank you.

@harikt @pavarnos Any PRs as a result of this issue?

PR : #135