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.
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.
Aura.SqlQuery/src/QueryFactory.php
Line 191 in dd81b57
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 .