PHPStan level 3 #1603

Merged
nupplaPhil merged 15 commits from Art4/friendica-addons:phpstan-level-3 into develop 2025-04-27 02:17:42 +02:00
Showing only changes of commit dda6710b10 - Show all commits

Fix error in notifyall addon

Art4 2025-03-13 09:36:34 +00:00

View file

@ -50,7 +50,7 @@ function notifyall_post()
$recipients = DBA::p("SELECT DISTINCT `email` FROM `user`" . DBA::buildCondition($condition), $condition);
if (! $recipients) {
if (! $recipients || !is_iterable($recipients)) {
Art4 marked this conversation as resolved Outdated

Instead of checking for this, $recipients should be assigned the result of DBA::toArray(DBA:p(...)) in order for the later foreach() to be valid. Normally, the DBA::p output requires the use of DBA::fetch() in a loop.

Sure, the PDOStatement is iterable, but the mysqli-produced result resource probably isn't.

Instead of checking for this, `$recipients` should be assigned the result of `DBA::toArray(DBA:p(...))` in order for the later `foreach()` to be valid. Normally, the `DBA::p` output requires the use of `DBA::fetch()` in a loop. Sure, the `PDOStatement` is iterable, but the `mysqli`-produced result resource probably isn't.

Done, thank you.

Done, thank you.
DI::sysmsg()->addNotice(DI::l10n()->t('No recipients found.'));
return;
}