Merge pull request #12177 from MrPetovan/bug/warnings
Ensure Post::toArray returns an array
This commit is contained in:
commit
c3cae0ae96
|
@ -102,26 +102,25 @@ class Post
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills an array with data from an post query
|
* Fills an array with data from a post query
|
||||||
*
|
*
|
||||||
* @param object $stmt statement object
|
* @param object|bool $stmt Return value from Database->select
|
||||||
* @param bool $do_close
|
|
||||||
* @return array Data array
|
* @return array Data array
|
||||||
* @todo Find proper type-hint for $stmt and maybe avoid boolean
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function toArray($stmt, bool $do_close = true)
|
public static function toArray($stmt): array
|
||||||
{
|
{
|
||||||
if (is_bool($stmt)) {
|
if (is_bool($stmt)) {
|
||||||
return $stmt;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
while ($row = self::fetch($stmt)) {
|
while ($row = self::fetch($stmt)) {
|
||||||
$data[] = $row;
|
$data[] = $row;
|
||||||
}
|
}
|
||||||
if ($do_close) {
|
|
||||||
DBA::close($stmt);
|
DBA::close($stmt);
|
||||||
}
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user