zf1-future
zf1-future copied to clipboard
Incorrect doctype annotation
According to the interface
https://github.com/Shardj/zf1-future/blob/master/library/Zend/Db/Statement/Interface.php#L134
Method fetchAll should always return array
But in the abstraction class https://github.com/Shardj/zf1-future/blob/master/library/Zend/Db/Adapter/Abstract.php#L731 there is a union with null, which is incorrect
/**
* Fetches all SQL result rows as a sequential array.
* Uses the current fetchMode for the adapter.
*
* @param string|Zend_Db_Select $sql An SQL SELECT statement.
* @param mixed $bind Data to bind into SELECT placeholders.
* @param mixed $fetchMode Override current fetch mode.
* @return array|null <-- should be just @return array
*/
public function fetchAll($sql, $bind = [], $fetchMode = null)
Are we sure it's not returning NULL, when nothing is found?
Yes,
Original ZF1 repo also has array as only one return type:
https://github.com/zendframework/zf1/blob/136735e776f520b081cd374012852cb88cef9a88/library/Zend/Db/Statement/Interface.php#L134
https://github.com/zendframework/zf1/blob/136735e776f520b081cd374012852cb88cef9a88/library/Zend/Db/Adapter/Abstract.php#L732
I seem to recall it returning NULL when there are no rows, instead of an empty array. Though for some reason, that doesn't always happen... I think (but haven't fully tested this) this seems to happen only when the query features only aggregate functions, and maybe only on MySQL. A normal query like "SELECT * FROM table WHERE myColumn = 'non-existent-value'" would still return an empty array either way.
Either way, the doc block is a reflection of this reality, rather than trying to fix the method to fallback to an empty array in those cases.