WIP on PHP 8.4 conversion

This commit is contained in:
2024-12-05 18:23:11 -05:00
parent 9110643383
commit 3bb4be3127
16 changed files with 204 additions and 157 deletions

View File

@@ -2,6 +2,7 @@
namespace MyPrayerJournal\Domain;
use BitBadger\InspiredByFSharp\Option;
use BitBadger\PDODocument\DocumentException;
/**
@@ -24,7 +25,6 @@ class Note
*/
public static function byRequestId(string $id): array
{
$req = Request::byId($id);
return $req->isDefined() ? $req->get()->notes : [];
return Request::byId($id)->map(fn(Request $it) => Option::Some($it->notes))->getOrDefault([]);
}
}

View File

@@ -2,13 +2,13 @@
namespace MyPrayerJournal\Domain;
use BitBadger\InspiredByFSharp\Option;
use BitBadger\PDODocument\{Custom, DocumentException, DocumentList, Find};
use BitBadger\PDODocument\Mapper\DocumentMapper;
use DateTimeImmutable;
use Exception;
use JsonSerializable;
use MyPrayerJournal\Table;
use PhpOption\{None, Option};
/**
* A prayer request
@@ -111,8 +111,8 @@ class Request implements JsonSerializable
*/
public static function byId(string $id): Option
{
$req = Find::byId(Table::REQUEST, $id, self::class);
return ($req->getOrElse(new Request('x'))->userId == $_SESSION['user_id']) ? $req : None::create();
return Find::byId(Table::REQUEST, $id, self::class)
->map(fn(Request $it) => $it->userId === $_SESSION['user_id'] ? Option::Some($it) : Option::None());
}
/**
@@ -187,7 +187,7 @@ class Request implements JsonSerializable
*/
public static function answered(): DocumentList
{
return self::forUser(false);
return self::forUser(active: false);
}
/**