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

@@ -1,5 +1,5 @@
{ {
"require": { "require": {
"friendsofphp/php-cs-fixer": "^3.12" "friendsofphp/php-cs-fixer": "^3.12"
} }
} }

View File

@@ -19,9 +19,9 @@
~ along with this program. If not, see <https://www.gnu.org/licenses/>. ~ along with this program. If not, see <https://www.gnu.org/licenses/>.
--> -->
<ruleset name="pcsg-generated-ruleset" <ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="pcsg-generated-ruleset"
xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"> xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>Firefly III ruleset.</description> <description>Firefly III ruleset.</description>

View File

@@ -3,7 +3,7 @@ name: "Issues - Command to close duplicate issues"
# the workflow to execute on is comments that are newly created # the workflow to execute on is comments that are newly created
on: on:
issue_comment: issue_comment:
types: [created] types: [ created ]
permissions: permissions:
issues: write issues: write

View File

@@ -3,9 +3,9 @@ name: 'Issues - Respond to hidden commands'
# the workflow to execute on is comments that are newly created # the workflow to execute on is comments that are newly created
on: on:
issues: issues:
types: [opened, edited] types: [ opened, edited ]
issue_comment: issue_comment:
types: [created] types: [ created ]
# permissions needed for reacting to IssueOps commands on issues and PRs # permissions needed for reacting to IssueOps commands on issues and PRs
permissions: permissions:

View File

@@ -2,11 +2,11 @@ name: 'Issues - Reply to specific labels'
on: on:
issues: issues:
types: [labeled, unlabeled] types: [ labeled, unlabeled ]
pull_request_target: pull_request_target:
types: [labeled, unlabeled] types: [ labeled, unlabeled ]
discussion: discussion:
types: [labeled, unlabeled] types: [ labeled, unlabeled ]
permissions: permissions:
contents: read contents: read

View File

@@ -8,7 +8,7 @@ on:
required: true required: true
default: 'develop' default: 'develop'
schedule: schedule:
- cron: '0 3 * * MON,THU' - cron: '0 3 * * MON,THU'
jobs: jobs:
build: build:

View File

@@ -54,17 +54,13 @@ class TestRequest extends FormRequest
private function getDate(string $field): ?Carbon private function getDate(string $field): ?Carbon
{ {
$value = $this->query($field); $value = $this->query($field);
if (is_array($value)) { if (is_array($value)) {
return null; return null;
} }
$value = (string)$value; $value = (string)$value;
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
if (false === $result) {
return null;
}
return $result; return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
} }
private function getAccounts(): array private function getAccounts(): array

View File

@@ -48,17 +48,13 @@ class TriggerRequest extends FormRequest
private function getDate(string $field): ?Carbon private function getDate(string $field): ?Carbon
{ {
$value = $this->query($field); $value = $this->query($field);
if (is_array($value)) { if (is_array($value)) {
return null; return null;
} }
$value = (string)$value; $value = (string)$value;
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
if (false === $result) {
return null;
}
return $result; return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
} }
private function getAccounts(): array private function getAccounts(): array

View File

@@ -48,17 +48,13 @@ class TestRequest extends FormRequest
private function getDate(string $field): ?Carbon private function getDate(string $field): ?Carbon
{ {
$value = $this->query($field); $value = $this->query($field);
if (is_array($value)) { if (is_array($value)) {
return null; return null;
} }
$value = (string)$value; $value = (string)$value;
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
if (false === $result) {
return null;
}
return $result; return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
} }
private function getAccounts(): array private function getAccounts(): array

View File

@@ -48,17 +48,13 @@ class TriggerRequest extends FormRequest
private function getDate(string $field): ?Carbon private function getDate(string $field): ?Carbon
{ {
$value = $this->query($field); $value = $this->query($field);
if (is_array($value)) { if (is_array($value)) {
return null; return null;
} }
$value = (string)$value; $value = (string)$value;
$result = null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
if (false === $result) {
return null;
}
return $result; return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
} }
private function getAccounts(): array private function getAccounts(): array

View File

@@ -298,7 +298,7 @@ class BasicController extends Controller
app('log')->debug(sprintf('Amount left is %s', $left)); app('log')->debug(sprintf('Amount left is %s', $left));
// how much left per day? // how much left per day?
$days = (int) $today->diffInDays($end, true) + 1; $days = (int)$today->diffInDays($end, true) + 1;
$perDay = '0'; $perDay = '0';
$perDayNative = '0'; $perDayNative = '0';
if (0 !== $days && bccomp($left, '0') > -1) { if (0 !== $days && bccomp($left, '0') > -1) {

View File

@@ -54,14 +54,6 @@ class UpdateController extends Controller
); );
} }
public function useUserGroup(UserGroup $userGroup): JsonResponse
{
// group validation is already in place, so can just update the user.
$this->repository->useUserGroup($userGroup);
return response()->json([], 204);
}
public function update(UpdateRequest $request, UserGroup $userGroup): JsonResponse public function update(UpdateRequest $request, UserGroup $userGroup): JsonResponse
{ {
$all = $request->getAll(); $all = $request->getAll();
@@ -87,4 +79,12 @@ class UpdateController extends Controller
->header('Content-Type', self::CONTENT_TYPE) ->header('Content-Type', self::CONTENT_TYPE)
; ;
} }
public function useUserGroup(UserGroup $userGroup): JsonResponse
{
// group validation is already in place, so can just update the user.
$this->repository->useUserGroup($userGroup);
return response()->json([], 204);
}
} }

View File

@@ -30,20 +30,10 @@ use Symfony\Component\Console\Command\Command as CommandAlias;
class MigratePreferences extends Command class MigratePreferences extends Command
{ {
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'firefly-iii:migrate-preferences';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Give Firefly III preferences a user group ID so they can be made administration specific.'; protected $description = 'Give Firefly III preferences a user group ID so they can be made administration specific.';
protected $signature = 'firefly-iii:migrate-preferences';
/** /**
* Execute the console command. * Execute the console command.
*/ */

View File

@@ -191,7 +191,7 @@ class ExportData extends Command
$this->friendlyError(sprintf('%s date "%s" must be formatted YYYY-MM-DD. Field will be ignored.', $field, $this->option('start'))); $this->friendlyError(sprintf('%s date "%s" must be formatted YYYY-MM-DD. Field will be ignored.', $field, $this->option('start')));
$error = true; $error = true;
} }
if (false === $date) { if (null === $date) {
$this->friendlyError(sprintf('%s date "%s" must be formatted YYYY-MM-DD.', $field, $this->option('start'))); $this->friendlyError(sprintf('%s date "%s" must be formatted YYYY-MM-DD.', $field, $this->option('start')));
throw new FireflyException(sprintf('%s date "%s" must be formatted YYYY-MM-DD.', $field, $this->option('start'))); throw new FireflyException(sprintf('%s date "%s" must be formatted YYYY-MM-DD.', $field, $this->option('start')));

View File

@@ -32,24 +32,13 @@ class LaravelPassportKeys extends Command
{ {
use ShowsFriendlyMessages; use ShowsFriendlyMessages;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'firefly-iii:laravel-passport-keys';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Calls the Laravel "passport:keys" but doesn\'t exit 1.'; protected $description = 'Calls the Laravel "passport:keys" but doesn\'t exit 1.';
protected $signature = 'firefly-iii:laravel-passport-keys';
/** /**
* Execute the console command. * Execute the console command.
*/ */
public function handle() public function handle(): int
{ {
Artisan::call('passport:keys --no-interaction', []); Artisan::call('passport:keys --no-interaction', []);
$result = Artisan::output(); $result = Artisan::output();

View File

@@ -285,7 +285,7 @@ class ApplyRules extends Command
if (null !== $endString && '' !== $endString) { if (null !== $endString && '' !== $endString) {
$inputEnd = Carbon::createFromFormat('Y-m-d', $endString); $inputEnd = Carbon::createFromFormat('Y-m-d', $endString);
} }
if (false === $inputEnd || false === $inputStart) { if (null === $inputEnd || null === $inputStart) {
Log::error('Could not parse start or end date in verifyInputDate().'); Log::error('Could not parse start or end date in verifyInputDate().');
return; return;

View File

@@ -405,7 +405,7 @@ class UserEventHandler
} }
// clean up old entries (6 months) // clean up old entries (6 months)
$carbon = Carbon::createFromFormat('Y-m-d H:i:s', $preference[$index]['time']); $carbon = Carbon::createFromFormat('Y-m-d H:i:s', $preference[$index]['time']);
if (false !== $carbon && $carbon->diffInMonths(today(), true) > 6) { if (null !== $carbon && $carbon->diffInMonths(today(), true) > 6) {
app('log')->debug(sprintf('Entry for %s is very old, remove it.', $row['ip'])); app('log')->debug(sprintf('Entry for %s is very old, remove it.', $row['ip']));
unset($preference[$index]); unset($preference[$index]);
} }

View File

@@ -128,7 +128,7 @@ class BudgetLimitController extends Controller
$start = Carbon::createFromFormat('Y-m-d', $request->get('start')); $start = Carbon::createFromFormat('Y-m-d', $request->get('start'));
$end = Carbon::createFromFormat('Y-m-d', $request->get('end')); $end = Carbon::createFromFormat('Y-m-d', $request->get('end'));
if (false === $start || false === $end) { if (null === $start || null === $end) {
return response()->json([]); return response()->json([]);
} }

View File

@@ -79,10 +79,10 @@ class HomeController extends Controller
app('log')->error(sprintf('End could not parse date string "%s" so ignore it.', $stringEnd)); app('log')->error(sprintf('End could not parse date string "%s" so ignore it.', $stringEnd));
$end = Carbon::now()->endOfMonth(); $end = Carbon::now()->endOfMonth();
} }
if (false === $start) { if (null === $start) {
$start = Carbon::now()->startOfMonth(); $start = Carbon::now()->startOfMonth();
} }
if (false === $end) { if (null === $end) {
$end = Carbon::now()->endOfMonth(); $end = Carbon::now()->endOfMonth();
} }

View File

@@ -130,7 +130,7 @@ class BoxController extends Controller
$boxTitle = (string)trans('firefly.left_to_spend'); $boxTitle = (string)trans('firefly.left_to_spend');
$activeDaysLeft = $this->activeDaysLeft($start, $end); // see method description. $activeDaysLeft = $this->activeDaysLeft($start, $end); // see method description.
$display = 1; // not overspent $display = 1; // not overspent
$leftPerDayAmount = 0 === (int) $activeDaysLeft ? $leftToSpendAmount : bcdiv($leftToSpendAmount, (string)$activeDaysLeft); $leftPerDayAmount = 0 === $activeDaysLeft ? $leftToSpendAmount : bcdiv($leftToSpendAmount, (string)$activeDaysLeft);
app('log')->debug(sprintf('Left to spend per day is %s', $leftPerDayAmount)); app('log')->debug(sprintf('Left to spend per day is %s', $leftPerDayAmount));
} }
} }

View File

@@ -81,7 +81,7 @@ class RecurrenceController extends Controller
$skip = $skip < 0 || $skip > 31 ? 0 : $skip; $skip = $skip < 0 || $skip > 31 ? 0 : $skip;
$weekend = $weekend < 1 || $weekend > 4 ? 1 : $weekend; $weekend = $weekend < 1 || $weekend > 4 ? 1 : $weekend;
if (false === $start || false === $end || false === $firstDate || false === $endDate) { if (null === $start || null === $end || null === $firstDate || null === $endDate) {
return response()->json(); return response()->json();
} }
@@ -112,7 +112,7 @@ class RecurrenceController extends Controller
$actualEnd = clone $end; $actualEnd = clone $end;
if ('until_date' === $endsAt) { if ('until_date' === $endsAt) {
$actualEnd = $endDate ?? clone $end; $actualEnd = $endDate;
$occurrences = $this->recurring->getOccurrencesInRange($repetition, $actualStart, $actualEnd); $occurrences = $this->recurring->getOccurrencesInRange($repetition, $actualStart, $actualEnd);
} }
if ('times' === $endsAt) { if ('times' === $endsAt) {
@@ -155,7 +155,7 @@ class RecurrenceController extends Controller
} catch (InvalidFormatException $e) { } catch (InvalidFormatException $e) {
$date = Carbon::today(config('app.timezone')); $date = Carbon::today(config('app.timezone'));
} }
if (false === $date) { if (null === $date) {
return response()->json(); return response()->json();
} }
$date->startOfDay(); $date->startOfDay();

View File

@@ -223,8 +223,8 @@ class PreferencesController extends Controller
// same for locale: // same for locale:
if (!auth()->user()->hasRole('demo')) { if (!auth()->user()->hasRole('demo')) {
/** @var Preference $locale */ $locale = (string) $request->get('locale');
$locale = $request->get('locale'); $locale = '' === $locale ? null : $locale;
app('preferences')->set('locale', $locale); app('preferences')->set('locale', $locale);
} }

View File

@@ -23,7 +23,6 @@ declare(strict_types=1);
namespace FireflyIII\Http\Controllers; namespace FireflyIII\Http\Controllers;
use Auth;
use FireflyIII\Events\UserChangedEmail; use FireflyIII\Events\UserChangedEmail;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Exceptions\ValidationException; use FireflyIII\Exceptions\ValidationException;
@@ -467,9 +466,7 @@ class ProfileController extends Controller
if (is_array($secret)) { if (is_array($secret)) {
$secret = null; $secret = null;
} }
if (is_int($secret)) { $secret = (string)$secret;
$secret = (string)$secret;
}
$repository->setMFACode($user, $secret); $repository->setMFACode($user, $secret);

View File

@@ -119,7 +119,7 @@ class DownloadExchangeRates implements ShouldQueue
return; return;
} }
$date = Carbon::createFromFormat('Y-m-d', $json['date'], config('app.timezone')); $date = Carbon::createFromFormat('Y-m-d', $json['date'], config('app.timezone'));
if (false === $date) { if (null === $date) {
return; return;
} }
$this->saveRates($currency, $date, $json['rates']); $this->saveRates($currency, $date, $json['rates']);

View File

@@ -128,7 +128,7 @@ class WarnAboutBills implements ShouldQueue
$today = clone $this->date; $today = clone $this->date;
$carbon = clone $bill->{$field}; $carbon = clone $bill->{$field};
return (int) $today->diffInDays($carbon); return (int)$today->diffInDays($carbon);
} }
private function sendWarning(Bill $bill, string $field): void private function sendWarning(Bill $bill, string $field): void

View File

@@ -36,13 +36,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* FireflyIII\Models\Preference * FireflyIII\Models\Preference
* *
* @property int $id * @property int $id
* @property null|Carbon $created_at * @property null|Carbon $created_at
* @property null|Carbon $updated_at * @property null|Carbon $updated_at
* @property int $user_id * @property int $user_id
* @property string $name * @property string $name
* @property null|array|int|string $data * @property null|array|bool|int|string $data
* @property User $user * @property User $user
* *
* @method static Builder|Preference newModelQuery() * @method static Builder|Preference newModelQuery()
* @method static Builder|Preference newQuery() * @method static Builder|Preference newQuery()

View File

@@ -69,7 +69,10 @@ class AppServiceProvider extends ServiceProvider
if ('' === $firstParam && str_contains($name, $route)) { if ('' === $firstParam && str_contains($name, $route)) {
return true; return true;
} }
$params = Route::getCurrentRoute()->parameters() ?? [];
/** @var null|array $params */
$params = Route::getCurrentRoute()->parameters();
$params ??= [];
$objectType = $params['objectType'] ?? ''; $objectType = $params['objectType'] ?? '';
if ($objectType === $firstParam && str_contains($name, $route)) { if ($objectType === $firstParam && str_contains($name, $route)) {
return true; return true;

View File

@@ -183,21 +183,21 @@ class BudgetRepository implements BudgetRepositoryInterface
// |-----------| // |-----------|
// |----------------| // |----------------|
if ($start->gte($limit->start_date) && $end->lte($limit->end_date)) { if ($start->gte($limit->start_date) && $end->lte($limit->end_date)) {
return (int) $start->diffInDays($end, true) + 1; // add one day return (int)$start->diffInDays($end, true) + 1; // add one day
} }
// limit starts earlier and limit ends first: // limit starts earlier and limit ends first:
// |-----------| // |-----------|
// |-------| // |-------|
if ($limit->start_date->lte($start) && $limit->end_date->lte($end)) { if ($limit->start_date->lte($start) && $limit->end_date->lte($end)) {
// return days in the range $start-$limit_end // return days in the range $start-$limit_end
return (int) $start->diffInDays($limit->end_date, true) + 1; // add one day, the day itself return (int)$start->diffInDays($limit->end_date, true) + 1; // add one day, the day itself
} }
// limit starts later and limit ends earlier // limit starts later and limit ends earlier
// |-----------| // |-----------|
// |-------| // |-------|
if ($limit->start_date->gte($start) && $limit->end_date->gte($end)) { if ($limit->start_date->gte($start) && $limit->end_date->gte($end)) {
// return days in the range $limit_start - $end // return days in the range $limit_start - $end
return (int) $limit->start_date->diffInDays($end, true) + 1; // add one day, the day itself return (int)$limit->start_date->diffInDays($end, true) + 1; // add one day, the day itself
} }
return 0; return 0;

View File

@@ -51,7 +51,7 @@ class OperationsRepository implements OperationsRepositoryInterface
$total = '0'; $total = '0';
$count = 0; $count = 0;
foreach ($budget->budgetlimits as $limit) { foreach ($budget->budgetlimits as $limit) {
$diff = (int) $limit->start_date->diffInDays($limit->end_date, true); $diff = (int)$limit->start_date->diffInDays($limit->end_date, true);
$diff = 0 === $diff ? 1 : $diff; $diff = 0 === $diff ? 1 : $diff;
$amount = $limit->amount; $amount = $limit->amount;
$perDay = bcdiv($amount, (string)$diff); $perDay = bcdiv($amount, (string)$diff);

View File

@@ -301,7 +301,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
if (null !== $piggyBank->targetdate && $repetition->currentamount < $piggyBank->targetamount) { if (null !== $piggyBank->targetdate && $repetition->currentamount < $piggyBank->targetamount) {
$now = today(config('app.timezone')); $now = today(config('app.timezone'));
$startDate = null !== $piggyBank->startdate && $piggyBank->startdate->gte($now) ? $piggyBank->startdate : $now; $startDate = null !== $piggyBank->startdate && $piggyBank->startdate->gte($now) ? $piggyBank->startdate : $now;
$diffInMonths = (int) $startDate->diffInMonths($piggyBank->targetdate); $diffInMonths = (int)$startDate->diffInMonths($piggyBank->targetdate);
$remainingAmount = bcsub($piggyBank->targetamount, $repetition->currentamount); $remainingAmount = bcsub($piggyBank->targetamount, $repetition->currentamount);
// more than 1 month to go and still need money to save: // more than 1 month to go and still need money to save:

View File

@@ -473,10 +473,10 @@ class RecurringRepository implements RecurringRepositoryInterface
if ('yearly' === $repetition->repetition_type) { if ('yearly' === $repetition->repetition_type) {
$today = today(config('app.timezone'))->endOfYear(); $today = today(config('app.timezone'))->endOfYear();
$repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment); $repDate = Carbon::createFromFormat('Y-m-d', $repetition->repetition_moment);
if (false === $repDate) { if (null === $repDate) {
$repDate = clone $today; $repDate = clone $today;
} }
$diffInYears = (int) $today->diffInYears($repDate, true); $diffInYears = (int)$today->diffInYears($repDate, true);
$repDate->addYears($diffInYears); // technically not necessary. $repDate->addYears($diffInYears); // technically not necessary.
$string = $repDate->isoFormat((string)trans('config.month_and_day_no_year_js')); $string = $repDate->isoFormat((string)trans('config.month_and_day_no_year_js'));

View File

@@ -242,6 +242,30 @@ class UserRepository implements UserRepositoryInterface
return false; return false;
} }
#[\Override]
public function getUserGroups(User $user): Collection
{
$memberships = $user->groupMemberships()->get();
$set = [];
$collection = new Collection();
/** @var GroupMembership $membership */
foreach ($memberships as $membership) {
/** @var null|UserGroup $group */
$group = $membership->userGroup()->first();
if (null !== $group) {
$groupId = $group->id;
if (in_array($groupId, array_keys($set), true)) {
continue;
}
$set[$groupId] = $group;
}
}
$collection->push(...$set);
return $collection;
}
public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser
{ {
$now = today(config('app.timezone')); $now = today(config('app.timezone'));
@@ -392,28 +416,4 @@ class UserRepository implements UserRepositoryInterface
return null !== $invitee; return null !== $invitee;
} }
#[\Override]
public function getUserGroups(User $user): Collection
{
$memberships = $user->groupMemberships()->get();
$set = [];
$collection = new Collection();
/** @var GroupMembership $membership */
foreach ($memberships as $membership) {
/** @var null|UserGroup $group */
$group = $membership->userGroup()->first();
if (null !== $group) {
$groupId = (int)$group->id;
if (in_array($groupId, $set, true)) {
continue;
}
$set[$groupId] = $group;
}
}
$collection->push(...$set);
return $collection;
}
} }

View File

@@ -59,8 +59,6 @@ interface UserRepositoryInterface
public function changeStatus(User $user, bool $isBlocked, string $code): bool; public function changeStatus(User $user, bool $isBlocked, string $code): bool;
public function getUserGroups(User $user): Collection;
/** /**
* Returns a count of all users. * Returns a count of all users.
*/ */
@@ -96,6 +94,8 @@ interface UserRepositoryInterface
*/ */
public function getUserData(User $user): array; public function getUserData(User $user): array;
public function getUserGroups(User $user): Collection;
public function hasRole(null|Authenticatable|User $user, string $role): bool; public function hasRole(null|Authenticatable|User $user, string $role): bool;
public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser; public function inviteUser(null|Authenticatable|User $user, string $email): InvitedUser;

View File

@@ -106,8 +106,8 @@ class UserGroupRepository implements UserGroupRepositoryInterface
/** @var null|UserGroup $group */ /** @var null|UserGroup $group */
$group = $membership->userGroup()->first(); $group = $membership->userGroup()->first();
if (null !== $group) { if (null !== $group) {
$groupId = (int)$group->id; $groupId = $group->id;
if (in_array($groupId, $set, true)) { if (in_array($groupId, array_keys($set), true)) {
continue; continue;
} }
$set[$groupId] = $group; $set[$groupId] = $group;

View File

@@ -38,8 +38,6 @@ interface UserGroupRepositoryInterface
public function get(): Collection; public function get(): Collection;
public function useUserGroup(UserGroup $userGroup): void;
public function getAll(): Collection; public function getAll(): Collection;
public function setUser(null|Authenticatable|User $user): void; public function setUser(null|Authenticatable|User $user): void;
@@ -49,4 +47,6 @@ interface UserGroupRepositoryInterface
public function update(UserGroup $userGroup, array $data): UserGroup; public function update(UserGroup $userGroup, array $data): UserGroup;
public function updateMembership(UserGroup $userGroup, array $data): UserGroup; public function updateMembership(UserGroup $userGroup, array $data): UserGroup;
public function useUserGroup(UserGroup $userGroup): void;
} }

View File

@@ -63,6 +63,8 @@ interface AccountRepositoryInterface
*/ */
public function getMetaValue(Account $account, string $field): ?string; public function getMetaValue(Account $account, string $field): ?string;
public function getUserGroup(): UserGroup;
/** /**
* Reset order types of the mentioned accounts. * Reset order types of the mentioned accounts.
*/ */
@@ -74,7 +76,5 @@ interface AccountRepositoryInterface
public function setUserGroup(UserGroup $userGroup): void; public function setUserGroup(UserGroup $userGroup): void;
public function getUserGroup(): UserGroup;
public function update(Account $account, array $data): Account; public function update(Account $account, array $data): Account;
} }

View File

@@ -117,7 +117,7 @@ class UpdateRequest implements UpdateRequestInterface
// parse response a bit. No message yet. // parse response a bit. No message yet.
$response = $json['firefly_iii'][$channel]; $response = $json['firefly_iii'][$channel];
$date = Carbon::createFromFormat('Y-m-d', $response['date']); $date = Carbon::createFromFormat('Y-m-d', $response['date']);
if (false === $date) { if (null === $date) {
$date = today(config('app.timezone')); $date = today(config('app.timezone'));
} }
$return['version'] = $response['version']; $return['version'] = $response['version'];

View File

@@ -146,7 +146,7 @@ class RemoteUserGuard implements Guard
return $this->user?->id; return $this->user?->id;
} }
public function setUser(null|Authenticatable|User $user): void public function setUser(null|Authenticatable|User $user): void // @phpstan-ignore-line
{ {
app('log')->debug(sprintf('Now at %s', __METHOD__)); app('log')->debug(sprintf('Now at %s', __METHOD__));
if ($user instanceof User) { if ($user instanceof User) {

View File

@@ -36,6 +36,14 @@ use Illuminate\Contracts\Auth\UserProvider;
*/ */
class RemoteUserProvider implements UserProvider class RemoteUserProvider implements UserProvider
{ {
#[\Override]
public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false): void
{
app('log')->debug(sprintf('Now at %s', __METHOD__));
throw new FireflyException(sprintf('Did not implement %s', __METHOD__));
}
/** /**
* @throws FireflyException * @throws FireflyException
* *
@@ -120,12 +128,4 @@ class RemoteUserProvider implements UserProvider
throw new FireflyException(sprintf('C) Did not implement %s', __METHOD__)); throw new FireflyException(sprintf('C) Did not implement %s', __METHOD__));
} }
#[\Override]
public function rehashPasswordIfRequired(Authenticatable $user, array $credentials, bool $force = false): void
{
app('log')->debug(sprintf('Now at %s', __METHOD__));
throw new FireflyException(sprintf('Did not implement %s', __METHOD__));
}
} }

View File

@@ -46,7 +46,7 @@ trait DateCalculation
$difference = $today->diffInDays($end); $difference = $today->diffInDays($end);
} }
return (int) (0 === $difference ? 1 : $difference); return (int)(0 === $difference ? 1 : $difference);
} }
/** /**
@@ -63,7 +63,7 @@ trait DateCalculation
$difference = $start->diffInDays($today, true) + 1; $difference = $start->diffInDays($today, true) + 1;
} }
return (int) $difference; return (int)$difference;
} }
protected function calculateStep(Carbon $start, Carbon $end): string protected function calculateStep(Carbon $start, Carbon $end): string

View File

@@ -145,14 +145,14 @@ trait RequestInformation
$attributes['location'] ??= ''; $attributes['location'] ??= '';
$attributes['accounts'] = AccountList::routeBinder($attributes['accounts'] ?? '', new Route('get', '', [])); $attributes['accounts'] = AccountList::routeBinder($attributes['accounts'] ?? '', new Route('get', '', []));
$date = Carbon::createFromFormat('Ymd', $attributes['startDate']); $date = Carbon::createFromFormat('Ymd', $attributes['startDate']);
if (false === $date) { if (null === $date) {
$date = today(config('app.timezone')); $date = today(config('app.timezone'));
} }
$date->startOfMonth(); $date->startOfMonth();
$attributes['startDate'] = $date; $attributes['startDate'] = $date;
$date2 = Carbon::createFromFormat('Ymd', $attributes['endDate']); $date2 = Carbon::createFromFormat('Ymd', $attributes['endDate']);
if (false === $date2) { if (null === $date2) {
$date2 = today(config('app.timezone')); $date2 = today(config('app.timezone'));
} }
$date2->endOfDay(); $date2->endOfDay();

View File

@@ -188,7 +188,7 @@ class Navigation
Log::debug(sprintf('Function is ->%s()', $function)); Log::debug(sprintf('Function is ->%s()', $function));
if (array_key_exists($function, $parameterMap)) { if (array_key_exists($function, $parameterMap)) {
Log::debug(sprintf('Parameter map, function becomes ->%s(%s)', $function, implode(', ', $parameterMap[$function]))); Log::debug(sprintf('Parameter map, function becomes ->%s(%s)', $function, implode(', ', $parameterMap[$function])));
$date->{$function}($parameterMap[$function][0]); $date->{$function}($parameterMap[$function][0]); // @phpstan-ignore-line
Log::debug(sprintf('Result is "%s"', $date->toIso8601String())); Log::debug(sprintf('Result is "%s"', $date->toIso8601String()));
return $date; return $date;
@@ -274,7 +274,7 @@ class Navigation
/** @var Carbon $tEnd */ /** @var Carbon $tEnd */
$tEnd = session('end', today(config('app.timezone'))->endOfMonth()); $tEnd = session('end', today(config('app.timezone'))->endOfMonth());
$diffInDays = (int) $tStart->diffInDays($tEnd, true); $diffInDays = (int)$tStart->diffInDays($tEnd, true);
} }
Log::debug(sprintf('Diff in days is %d', $diffInDays)); Log::debug(sprintf('Diff in days is %d', $diffInDays));
$currentEnd->addDays($diffInDays); $currentEnd->addDays($diffInDays);
@@ -327,7 +327,7 @@ class Navigation
{ {
$endOfMonth = $date->copy()->endOfMonth(); $endOfMonth = $date->copy()->endOfMonth();
return (int) $date->diffInDays($endOfMonth, true); return (int)$date->diffInDays($endOfMonth, true);
} }
public function diffInPeriods(string $period, int $skip, Carbon $beginning, Carbon $end): int public function diffInPeriods(string $period, int $skip, Carbon $beginning, Carbon $end): int
@@ -677,7 +677,7 @@ class Navigation
/** @var Carbon $tEnd */ /** @var Carbon $tEnd */
$tEnd = session('end', today(config('app.timezone'))->endOfMonth()); $tEnd = session('end', today(config('app.timezone'))->endOfMonth());
$diffInDays = (int) $tStart->diffInDays($tEnd, true); $diffInDays = (int)$tStart->diffInDays($tEnd, true);
$date->subDays($diffInDays * $subtract); $date->subDays($diffInDays * $subtract);
return $date; return $date;

View File

@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Support; namespace FireflyIII\Support;
use Carbon\Carbon; use Carbon\Carbon;
use Carbon\CarbonInterface;
use Carbon\Exceptions\InvalidFormatException; use Carbon\Exceptions\InvalidFormatException;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
@@ -122,12 +123,12 @@ class ParseDateString
{ {
$today = today(config('app.timezone'))->startOfDay(); $today = today(config('app.timezone'))->startOfDay();
return match ($keyword) { return match ($keyword) { // @phpstan-ignore-line
default => $today, default => $today,
'yesterday' => $today->subDay(), 'yesterday' => $today->subDay(),
'tomorrow' => $today->addDay(), 'tomorrow' => $today->addDay(),
'start of this week' => $today->startOfWeek(Carbon::MONDAY), 'start of this week' => $today->startOfWeek(CarbonInterface::MONDAY),
'end of this week' => $today->endOfWeek(Carbon::SUNDAY), 'end of this week' => $today->endOfWeek(CarbonInterface::SUNDAY),
'start of this month' => $today->startOfMonth(), 'start of this month' => $today->startOfMonth(),
'end of this month' => $today->endOfMonth(), 'end of this month' => $today->endOfMonth(),
'start of this quarter' => $today->startOfQuarter(), 'start of this quarter' => $today->startOfQuarter(),

View File

@@ -89,6 +89,17 @@ class Preferences
return $this->setForUser($user, $name, $default); return $this->setForUser($user, $name, $default);
} }
private function getUserGroupId(User $user, string $preferenceName): ?int
{
$groupId = null;
$items = config('firefly.admin_specific_prefs') ?? [];
if (in_array($preferenceName, $items, true)) {
$groupId = (int)$user->user_group_id;
}
return $groupId;
}
public function delete(string $name): bool public function delete(string $name): bool
{ {
$fullName = sprintf('preference%s%s', auth()->user()->id, $name); $fullName = sprintf('preference%s%s', auth()->user()->id, $name);
@@ -215,7 +226,7 @@ class Preferences
public function set(string $name, null|array|bool|int|string $value): Preference public function set(string $name, null|array|bool|int|string $value): Preference
{ {
/** @var User $user */ /** @var null|User $user */
$user = auth()->user(); $user = auth()->user();
if (null === $user) { if (null === $user) {
// make new preference, return it: // make new preference, return it:
@@ -228,15 +239,4 @@ class Preferences
return $this->setForUser($user, $name, $value); return $this->setForUser($user, $name, $value);
} }
private function getUserGroupId(User $user, string $preferenceName): ?int
{
$groupId = null;
$items = config('firefly.admin_specific_prefs') ?? [];
if (in_array($preferenceName, $items, true)) {
$groupId = (int)$user->user_group_id;
}
return $groupId;
}
} }

View File

@@ -250,7 +250,7 @@ trait ConvertsDataTypes
return null; return null;
} }
if (false === $carbon) { if (null === $carbon) {
app('log')->error(sprintf('[2] "%s" is of an invalid format.', $value)); app('log')->error(sprintf('[2] "%s" is of an invalid format.', $value));
return null; return null;

View File

@@ -29,7 +29,7 @@ use Symfony\Component\ExpressionLanguage\SyntaxError;
class ActionExpression class ActionExpression
{ {
private static array $NAMES private static array $NAMES
= [ = [
// 'transaction_group_id', // 'transaction_group_id',
// 'user_id', // 'user_id',

View File

@@ -185,7 +185,7 @@ class AccountTransformer extends AbstractTransformer
// try classic date: // try classic date:
if (10 === strlen($monthlyPaymentDate)) { if (10 === strlen($monthlyPaymentDate)) {
$object = Carbon::createFromFormat('!Y-m-d', $monthlyPaymentDate, config('app.timezone')); $object = Carbon::createFromFormat('!Y-m-d', $monthlyPaymentDate, config('app.timezone'));
if (false === $object) { if (null === $object) {
$object = today(config('app.timezone')); $object = today(config('app.timezone'));
} }
$monthlyPaymentDate = $object->toAtomString(); $monthlyPaymentDate = $object->toAtomString();
@@ -212,7 +212,7 @@ class AccountTransformer extends AbstractTransformer
} }
if (null !== $openingBalanceDate) { if (null !== $openingBalanceDate) {
$object = Carbon::createFromFormat('Y-m-d H:i:s', $openingBalanceDate, config('app.timezone')); $object = Carbon::createFromFormat('Y-m-d H:i:s', $openingBalanceDate, config('app.timezone'));
if (false === $object) { if (null === $object) {
$object = today(config('app.timezone')); $object = today(config('app.timezone'));
} }
$openingBalanceDate = $object->toAtomString(); $openingBalanceDate = $object->toAtomString();

View File

@@ -82,7 +82,7 @@ class BillTransformer extends AbstractTransformer
$payDatesFormatted = []; $payDatesFormatted = [];
foreach ($paidData as $object) { foreach ($paidData as $object) {
$date = Carbon::createFromFormat('!Y-m-d', $object['date'], config('app.timezone')); $date = Carbon::createFromFormat('!Y-m-d', $object['date'], config('app.timezone'));
if (false === $date) { if (null === $date) {
$date = today(config('app.timezone')); $date = today(config('app.timezone'));
} }
$object['date'] = $date->toAtomString(); $object['date'] = $date->toAtomString();
@@ -91,7 +91,7 @@ class BillTransformer extends AbstractTransformer
foreach ($payDates as $string) { foreach ($payDates as $string) {
$date = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone')); $date = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone'));
if (false === $date) { if (null === $date) {
$date = today(config('app.timezone')); $date = today(config('app.timezone'));
} }
$payDatesFormatted[] = $date->toAtomString(); $payDatesFormatted[] = $date->toAtomString();
@@ -104,7 +104,7 @@ class BillTransformer extends AbstractTransformer
if (null !== $firstPayDate) { if (null !== $firstPayDate) {
$nemDate = Carbon::createFromFormat('!Y-m-d', $firstPayDate, config('app.timezone')); $nemDate = Carbon::createFromFormat('!Y-m-d', $firstPayDate, config('app.timezone'));
if (false === $nemDate) { if (null === $nemDate) {
$nemDate = today(config('app.timezone')); $nemDate = today(config('app.timezone'));
} }
$nem = $nemDate->toAtomString(); $nem = $nemDate->toAtomString();
@@ -129,7 +129,7 @@ class BillTransformer extends AbstractTransformer
$current = $payDatesFormatted[0] ?? null; $current = $payDatesFormatted[0] ?? null;
if (null !== $current && !$nemDate->isToday()) { if (null !== $current && !$nemDate->isToday()) {
$temp2 = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current); $temp2 = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current);
if (false === $temp2) { if (null === $temp2) {
$temp2 = today(config('app.timezone')); $temp2 = today(config('app.timezone'));
} }
$nemDiff = trans('firefly.bill_expected_date', ['date' => $temp2->diffForHumans(today(config('app.timezone')), CarbonInterface::DIFF_RELATIVE_TO_NOW)]); $nemDiff = trans('firefly.bill_expected_date', ['date' => $temp2->diffForHumans(today(config('app.timezone')), CarbonInterface::DIFF_RELATIVE_TO_NOW)]);

View File

@@ -248,7 +248,7 @@ class PiggyBankTransformer extends AbstractTransformer
if (bccomp($currentAmount, $targetAmount) < 1) { if (bccomp($currentAmount, $targetAmount) < 1) {
$now = today(config('app.timezone')); $now = today(config('app.timezone'));
$startDate = null !== $startDate && $startDate->gte($now) ? $startDate : $now; $startDate = null !== $startDate && $startDate->gte($now) ? $startDate : $now;
$diffInMonths = (int) $startDate->diffInMonths($targetDate); $diffInMonths = (int)$startDate->diffInMonths($targetDate);
$remainingAmount = bcsub($targetAmount, $currentAmount); $remainingAmount = bcsub($targetAmount, $currentAmount);
// more than 1 month to go and still need money to save: // 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)); // app('log')->debug(sprintf('Now in date("%s")', $string));
if (10 === strlen($string)) { if (10 === strlen($string)) {
$res = Carbon::createFromFormat('Y-m-d', $string, config('app.timezone')); $res = Carbon::createFromFormat('Y-m-d', $string, config('app.timezone'));
if (false === $res) { if (null === $res) {
return null; return null;
} }
@@ -473,7 +473,7 @@ class TransactionGroupTransformer extends AbstractTransformer
} }
if (19 === strlen($string) && str_contains($string, 'T')) { if (19 === strlen($string) && str_contains($string, 'T')) {
$res = Carbon::createFromFormat('Y-m-d\TH:i:s', substr($string, 0, 19), config('app.timezone')); $res = Carbon::createFromFormat('Y-m-d\TH:i:s', substr($string, 0, 19), config('app.timezone'));
if (false === $res) { if (null === $res) {
return null; return null;
} }
@@ -482,7 +482,7 @@ class TransactionGroupTransformer extends AbstractTransformer
// 2022-01-01 01:01:01 // 2022-01-01 01:01:01
$res = Carbon::createFromFormat('Y-m-d H:i:s', substr($string, 0, 19), config('app.timezone')); $res = Carbon::createFromFormat('Y-m-d H:i:s', substr($string, 0, 19), config('app.timezone'));
if (false === $res) { if (null === $res) {
return null; return null;
} }

View File

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

View File

@@ -21,7 +21,6 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -46,7 +45,7 @@ class ExpandTransactionsTable extends Migration
$table->dropColumn('identifier'); $table->dropColumn('identifier');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column "identifier": %s', $e->getMessage())); app('log')->error(sprintf('Could not drop column "identifier": %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -21,7 +21,6 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -74,7 +73,7 @@ class ChangesForV431 extends Migration
$table->renameColumn('start_date', 'startdate'); $table->renameColumn('start_date', 'startdate');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -89,7 +88,7 @@ class ChangesForV431 extends Migration
$table->dropColumn('end_date'); $table->dropColumn('end_date');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -103,7 +102,7 @@ class ChangesForV431 extends Migration
$table->dropColumn('decimal_places'); $table->dropColumn('decimal_places');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -141,7 +140,7 @@ class ChangesForV431 extends Migration
$table->renameColumn('startdate', 'start_date'); $table->renameColumn('startdate', 'start_date');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -171,7 +170,7 @@ class ChangesForV431 extends Migration
$table->dropColumn('repeats'); $table->dropColumn('repeats');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -184,7 +183,7 @@ class ChangesForV431 extends Migration
$table->dropColumn('repeat_freq'); $table->dropColumn('repeat_freq');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -21,7 +21,6 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -53,7 +52,7 @@ class ChangesForV440 extends Migration
} }
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -21,7 +21,6 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -47,7 +46,7 @@ class ChangesForV450 extends Migration
$table->dropColumn('foreign_amount'); $table->dropColumn('foreign_amount');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -75,7 +74,7 @@ class ChangesForV450 extends Migration
$table->dropColumn('foreign_currency_id'); $table->dropColumn('foreign_currency_id');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -21,7 +21,6 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -47,7 +46,7 @@ class ChangesForV470a extends Migration
$table->dropColumn('reconciled'); $table->dropColumn('reconciled');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -22,7 +22,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -61,7 +60,7 @@ class ChangesForV472 extends Migration
$table->dropColumn('order'); $table->dropColumn('order');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -83,7 +82,7 @@ class ChangesForV472 extends Migration
$table->dropColumn('notes'); $table->dropColumn('notes');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -22,7 +22,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -52,7 +51,7 @@ class ChangesForV473 extends Migration
$table->dropColumn('transaction_currency_id'); $table->dropColumn('transaction_currency_id');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -66,7 +65,7 @@ class ChangesForV473 extends Migration
$table->dropColumn('strict'); $table->dropColumn('strict');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -22,7 +22,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -52,7 +51,7 @@ class ChangesForV477 extends Migration
$table->dropColumn(['transaction_currency_id']); $table->dropColumn(['transaction_currency_id']);
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -22,7 +22,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -47,7 +46,7 @@ class ChangesForV479 extends Migration
$table->dropColumn(['enabled']); $table->dropColumn(['enabled']);
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -21,7 +21,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -47,7 +46,7 @@ class FixLdapConfiguration extends Migration
$table->dropColumn(['objectguid']); $table->dropColumn(['objectguid']);
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -21,7 +21,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -57,7 +56,7 @@ class ChangesForV480 extends Migration
try { try {
$table->dropColumn('transaction_group_id'); $table->dropColumn('transaction_group_id');
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column: %s', $e->getMessage())); app('log')->error(sprintf('Could not drop column: %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -77,7 +76,7 @@ class ChangesForV480 extends Migration
static function (Blueprint $table): void { static function (Blueprint $table): void {
try { try {
$table->dropColumn('stop_processing'); $table->dropColumn('stop_processing');
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column: %s', $e->getMessage())); app('log')->error(sprintf('Could not drop column: %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -97,7 +96,7 @@ class ChangesForV480 extends Migration
static function (Blueprint $table): void { static function (Blueprint $table): void {
try { try {
$table->dropColumn('mfa_secret'); $table->dropColumn('mfa_secret');
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column: %s', $e->getMessage())); app('log')->error(sprintf('Could not drop column: %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -22,7 +22,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -48,7 +47,7 @@ class ChangesForV530a extends Migration
$table->dropColumn('order'); $table->dropColumn('order');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -22,7 +22,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -48,7 +47,7 @@ class ChangesForV540 extends Migration
$table->dropColumn('provider'); $table->dropColumn('provider');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -62,7 +61,7 @@ class ChangesForV540 extends Migration
$table->dropColumn('order'); $table->dropColumn('order');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -76,7 +75,7 @@ class ChangesForV540 extends Migration
$table->dropColumn('end_date'); $table->dropColumn('end_date');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -89,7 +88,7 @@ class ChangesForV540 extends Migration
$table->dropColumn('extension_date'); $table->dropColumn('extension_date');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -22,7 +22,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -76,7 +75,7 @@ class ChangesForV550 extends Migration
$table->dropColumn('budget_limit_id'); $table->dropColumn('budget_limit_id');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -95,7 +94,7 @@ class ChangesForV550 extends Migration
$table->dropColumn('period'); $table->dropColumn('period');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -108,7 +107,7 @@ class ChangesForV550 extends Migration
$table->dropColumn('generated'); $table->dropColumn('generated');
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -22,7 +22,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -51,7 +50,7 @@ class ChangesForV550b2 extends Migration
} }
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -22,7 +22,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -43,7 +42,7 @@ class AddLdapColumnsToUsersTable extends Migration
$table->dropColumn(['domain']); $table->dropColumn(['domain']);
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -22,7 +22,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -72,7 +71,7 @@ class UserGroups extends Migration
} }
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
@@ -92,7 +91,7 @@ class UserGroups extends Migration
} }
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -22,7 +22,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -69,7 +68,7 @@ return new class () extends Migration {
} }
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

View File

@@ -22,7 +22,6 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -71,7 +70,7 @@ return new class () extends Migration {
} }
} }
); );
} catch (ColumnDoesNotExist|QueryException $e) { } catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage())); app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }

File diff suppressed because it is too large Load Diff

View File

@@ -68,6 +68,20 @@ final class CalculatorTest extends TestCase
} }
} }
private static function convert(Periodicity $periodicity, array $intervals): array
{
$periodicityIntervals = [];
/** @var IntervalProvider $interval */
foreach ($intervals as $index => $interval) {
$calculator = CalculatorProvider::from($periodicity, $interval);
$periodicityIntervals["#{$index} {$calculator->label}"] = [$calculator];
}
return $periodicityIntervals;
}
public static function provideSkippedIntervals(): iterable public static function provideSkippedIntervals(): iterable
{ {
return CalculatorProvider::providePeriodicityWithSkippedIntervals(); return CalculatorProvider::providePeriodicityWithSkippedIntervals();
@@ -96,18 +110,4 @@ final class CalculatorTest extends TestCase
$period = $calculator->nextDateByInterval($provider->epoch(), $provider->periodicity, $provider->skip); $period = $calculator->nextDateByInterval($provider->epoch(), $provider->periodicity, $provider->skip);
self::assertSame($provider->expected()->toDateString(), $period->toDateString()); self::assertSame($provider->expected()->toDateString(), $period->toDateString());
} }
private static function convert(Periodicity $periodicity, array $intervals): array
{
$periodicityIntervals = [];
/** @var IntervalProvider $interval */
foreach ($intervals as $index => $interval) {
$calculator = CalculatorProvider::from($periodicity, $interval);
$periodicityIntervals["#{$index} {$calculator->label}"] = [$calculator];
}
return $periodicityIntervals;
}
} }

View File

@@ -77,15 +77,6 @@ final class NavigationEndOfPeriodTest extends TestCase
]; ];
} }
/**
* @dataProvider provideDates
*/
public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
{
$period = clone $this->navigation->endOfPeriod($from, $frequency);
self::assertSame($expected->toDateString(), $period->toDateString());
}
public static function provideUnknownFrequencies(): iterable public static function provideUnknownFrequencies(): iterable
{ {
return [ return [
@@ -95,6 +86,15 @@ final class NavigationEndOfPeriodTest extends TestCase
]; ];
} }
/**
* @dataProvider provideDates
*/
public function testGivenADateAndFrequencyWhenCalculateTheDateThenReturnsTheExpectedDateSuccessful(string $frequency, Carbon $from, Carbon $expected): void
{
$period = clone $this->navigation->endOfPeriod($from, $frequency);
self::assertSame($expected->toDateString(), $period->toDateString());
}
/** /**
* @dataProvider provideUnknownFrequencies * @dataProvider provideUnknownFrequencies
*/ */