Fix 5 PHPStan errors
This commit is contained in:
parent
35d95b991b
commit
1820bfc2b3
4 changed files with 47 additions and 26 deletions
|
@ -474,7 +474,7 @@ class Database
|
|||
*
|
||||
* @param string $sql SQL statement
|
||||
*
|
||||
* @return bool|object statement object or result object
|
||||
* @return bool|mysqli_result|mysqli_stmt|object|PDOStatement statement object or result object
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function p(string $sql)
|
||||
|
|
|
@ -8,36 +8,50 @@
|
|||
namespace Friendica\Navigation\Notifications\Collection;
|
||||
|
||||
use Friendica\BaseCollection;
|
||||
use Friendica\Navigation\Notifications\Entity;
|
||||
use Friendica\Navigation\Notifications\Entity\Notification as NotificationEntity;
|
||||
|
||||
class Notifications extends BaseCollection
|
||||
{
|
||||
/**
|
||||
* @return Entity\Notification
|
||||
*/
|
||||
public function current(): Entity\Notification
|
||||
public function current(): NotificationEntity
|
||||
{
|
||||
return parent::current();
|
||||
}
|
||||
|
||||
public function setSeen(): Notifications
|
||||
{
|
||||
return $this->map(function (Entity\Notification $Notification) {
|
||||
$Notification->setSeen();
|
||||
});
|
||||
$class = get_class($this);
|
||||
|
||||
return new $class(
|
||||
array_map(
|
||||
function (NotificationEntity $notification) {
|
||||
$notification->setSeen();
|
||||
},
|
||||
$this->getArrayCopy()
|
||||
),
|
||||
$this->getTotalCount(),
|
||||
);
|
||||
}
|
||||
|
||||
public function setDismissed(): Notifications
|
||||
{
|
||||
return $this->map(function (Entity\Notification $Notification) {
|
||||
$Notification->setDismissed();
|
||||
});
|
||||
$class = get_class($this);
|
||||
|
||||
return new $class(
|
||||
array_map(
|
||||
function (NotificationEntity $notification) {
|
||||
$notification->setDismissed();
|
||||
},
|
||||
$this->getArrayCopy(),
|
||||
),
|
||||
$this->getTotalCount(),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function countUnseen(): int
|
||||
{
|
||||
return array_reduce($this->getArrayCopy(), function (int $carry, Entity\Notification $Notification) {
|
||||
return $carry + ($Notification->seen ? 0 : 1);
|
||||
return array_reduce($this->getArrayCopy(), function (int $carry, NotificationEntity $notification) {
|
||||
return $carry + ($notification->seen ? 0 : 1);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,22 +8,24 @@
|
|||
namespace Friendica\Navigation\Notifications\Collection;
|
||||
|
||||
use Friendica\BaseCollection;
|
||||
use Friendica\Navigation\Notifications\Entity;
|
||||
use Friendica\Navigation\Notifications\Entity\Notify as NotifyEntity;
|
||||
|
||||
class Notifies extends BaseCollection
|
||||
{
|
||||
/**
|
||||
* @return Entity\Notify
|
||||
*/
|
||||
public function current(): Entity\Notify
|
||||
public function current(): NotifyEntity
|
||||
{
|
||||
return parent::current();
|
||||
}
|
||||
|
||||
public function setSeen(): Notifies
|
||||
{
|
||||
return $this->map(function (Entity\Notify $Notify) {
|
||||
$Notify->setSeen();
|
||||
});
|
||||
$class = get_class($this);
|
||||
|
||||
return new $class(array_map(
|
||||
function (NotifyEntity $notify) {
|
||||
$notify->setSeen();
|
||||
},
|
||||
$this->getArrayCopy()), $this->getTotalCount(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,12 +162,17 @@ class Notification extends BaseRepository
|
|||
LIMIT 50
|
||||
", ...$values);
|
||||
|
||||
$Entities = new NotificationsCollection();
|
||||
foreach ($rows as $fields) {
|
||||
$Entities[] = $this->factory->createFromTableRow($fields);
|
||||
$entities = new NotificationsCollection();
|
||||
|
||||
if (!is_iterable($rows)) {
|
||||
return $entities;
|
||||
}
|
||||
|
||||
return $Entities;
|
||||
foreach ($rows as $fields) {
|
||||
$entities[] = $this->factory->createFromTableRow($fields);
|
||||
}
|
||||
|
||||
return $entities;
|
||||
}
|
||||
|
||||
public function selectAllForUser(int $uid): NotificationsCollection
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue