Fix phpstan error courtesy of the laravel 11 upgrade (changed signatures and return types)

This commit is contained in:
James Cole
2024-04-02 15:40:33 +02:00
parent 87911c2438
commit a17bc7258f
73 changed files with 2772 additions and 2827 deletions

View File

@@ -248,7 +248,7 @@ class PiggyBankTransformer extends AbstractTransformer
if (bccomp($currentAmount, $targetAmount) < 1) {
$now = today(config('app.timezone'));
$startDate = null !== $startDate && $startDate->gte($now) ? $startDate : $now;
$diffInMonths = (int) $startDate->diffInMonths($targetDate);
$diffInMonths = (int)$startDate->diffInMonths($targetDate);
$remainingAmount = bcsub($targetAmount, $currentAmount);
// more than 1 month to go and still need money to save:

View File

@@ -462,7 +462,7 @@ class TransactionGroupTransformer extends AbstractTransformer
// app('log')->debug(sprintf('Now in date("%s")', $string));
if (10 === strlen($string)) {
$res = Carbon::createFromFormat('Y-m-d', $string, config('app.timezone'));
if (false === $res) {
if (null === $res) {
return null;
}
@@ -473,7 +473,7 @@ class TransactionGroupTransformer extends AbstractTransformer
}
if (19 === strlen($string) && str_contains($string, 'T')) {
$res = Carbon::createFromFormat('Y-m-d\TH:i:s', substr($string, 0, 19), config('app.timezone'));
if (false === $res) {
if (null === $res) {
return null;
}
@@ -482,7 +482,7 @@ class TransactionGroupTransformer extends AbstractTransformer
// 2022-01-01 01:01:01
$res = Carbon::createFromFormat('Y-m-d H:i:s', substr($string, 0, 19), config('app.timezone'));
if (false === $res) {
if (null === $res) {
return null;
}

View File

@@ -35,9 +35,9 @@ use Illuminate\Support\Collection;
*/
class UserGroupTransformer extends AbstractTransformer
{
private array $inUse;
private array $memberships;
private array $membershipsVisible;
private array $inUse;
public function __construct()
{
@@ -84,13 +84,13 @@ class UserGroupTransformer extends AbstractTransformer
public function transform(UserGroup $userGroup): array
{
return [
'id' => $userGroup->id,
'created_at' => $userGroup->created_at->toAtomString(),
'updated_at' => $userGroup->updated_at->toAtomString(),
'in_use' => $this->inUse[$userGroup->id] ?? false,
'title' => $userGroup->title,
'can_see_members' => $this->membershipsVisible[$userGroup->id] ?? false,
'members' => $this->memberships[$userGroup->id] ?? [],
'id' => $userGroup->id,
'created_at' => $userGroup->created_at->toAtomString(),
'updated_at' => $userGroup->updated_at->toAtomString(),
'in_use' => $this->inUse[$userGroup->id] ?? false,
'title' => $userGroup->title,
'can_see_members' => $this->membershipsVisible[$userGroup->id] ?? false,
'members' => $this->memberships[$userGroup->id] ?? [],
];
// if the user has a specific role in this group, then collect the memberships.
}