Fix various code.

This commit is contained in:
James Cole
2023-12-21 05:15:46 +01:00
parent a445bc53cd
commit ebf4b00288
6 changed files with 66 additions and 46 deletions

View File

@@ -162,7 +162,7 @@ class RemoteUserGuard implements Guard
app('log')->error(sprintf('Did not set user at %s', __METHOD__));
}
public function validate(array $credentials = []): void
public function validate(array $credentials = []): bool
{
app('log')->debug(sprintf('Now at %s', __METHOD__));

View File

@@ -36,13 +36,21 @@ use Illuminate\Contracts\Auth\UserProvider;
*/
class RemoteUserProvider implements UserProvider
{
public function retrieveByCredentials(array $credentials): void
/**
* @throws FireflyException
*/
public function retrieveByCredentials(array $credentials): null|Authenticatable
{
app('log')->debug(sprintf('Now at %s', __METHOD__));
throw new FireflyException(sprintf('Did not implement %s', __METHOD__));
}
/**
* @param mixed $identifier
*
* @throws FireflyException
*/
public function retrieveById($identifier): User
{
app('log')->debug(sprintf('Now at %s(%s)', __METHOD__, $identifier));
@@ -70,7 +78,13 @@ class RemoteUserProvider implements UserProvider
return $user;
}
public function retrieveByToken($identifier, $token): void
/**
* @param mixed $identifier
* @param mixed $token
*
* @throws FireflyException
*/
public function retrieveByToken($identifier, $token): null|Authenticatable
{
app('log')->debug(sprintf('Now at %s', __METHOD__));
@@ -84,7 +98,10 @@ class RemoteUserProvider implements UserProvider
throw new FireflyException(sprintf('B) Did not implement %s', __METHOD__));
}
public function validateCredentials(Authenticatable $user, array $credentials): void
/**
* @throws FireflyException
*/
public function validateCredentials(Authenticatable $user, array $credentials): bool
{
app('log')->debug(sprintf('Now at %s', __METHOD__));

View File

@@ -249,14 +249,9 @@ class ParseDateString
/**
* Returns true if this matches regex for xxxx-xx-DD:
*
* @param string $date
*
* @return bool
*/
protected function isDayRange(string $date): bool
{
$pattern = '/^xxxx-xx-(0[1-9]|[12]\d|3[01])$/';
$result = preg_match($pattern, $date);
if (false !== $result && 0 !== $result) {

View File

@@ -697,10 +697,6 @@ class Steam
/**
* Get user's locale.
*
* @throws FireflyException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function getLocale(): string // get preference
{

View File

@@ -510,7 +510,8 @@ class FireflyValidator extends Validator
->whereNull('accounts.deleted_at')
->where('accounts.user_id', auth()->user()->id)
->where('account_meta.name', 'account_number')
->where('account_meta.data', json_encode($value));
->where('account_meta.data', json_encode($value))
;
if ($accountId > 0) {
// exclude current account from check.
@@ -617,7 +618,8 @@ class FireflyValidator extends Validator
->where('response', $response)
->where('delivery', $delivery)
->where('id', '!=', $existingId)
->where('url', $url)->count();
->where('url', $url)->count()
;
}
return false;
@@ -653,7 +655,8 @@ class FireflyValidator extends Validator
$result = \DB::table($table)->where('user_id', auth()->user()->id)->whereNull('deleted_at')
->where('id', '!=', $exclude)
->where($field, $value)
->first([$field]);
->first([$field])
;
if (null === $result) {
return true; // not found, so true.
}
@@ -675,7 +678,8 @@ class FireflyValidator extends Validator
$query = \DB::table('object_groups')
->whereNull('object_groups.deleted_at')
->where('object_groups.user_id', auth()->user()->id)
->where('object_groups.title', $value);
->where('object_groups.title', $value)
;
if (null !== $exclude) {
$query->where('object_groups.id', '!=', (int) $exclude);
}
@@ -694,7 +698,8 @@ class FireflyValidator extends Validator
{
$exclude = $parameters[0] ?? null;
$query = \DB::table('piggy_banks')->whereNull('piggy_banks.deleted_at')
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', auth()->user()->id);
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', auth()->user()->id)
;
if (null !== $exclude) {
$query->where('piggy_banks.id', '!=', (int) $exclude);
}
@@ -727,7 +732,8 @@ class FireflyValidator extends Validator
->where('trigger', $trigger)
->where('response', $response)
->where('delivery', $delivery)
->where('url', $url)->count();
->where('url', $url)->count()
;
}
return false;
@@ -766,7 +772,8 @@ class FireflyValidator extends Validator
/** @var null|Account $result */
$result = auth()->user()->accounts()->whereIn('account_type_id', $accountTypeIds)->where('id', '!=', $ignore)
->where('name', $value)
->first();
->first()
;
return null === $result;
}
@@ -783,7 +790,8 @@ class FireflyValidator extends Validator
/** @var null|Account $result */
$result = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
->where('name', $value)
->first();
->first()
;
return null === $result;
}
@@ -801,7 +809,8 @@ class FireflyValidator extends Validator
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
->where('name', $value)
->first();
->first()
;
return null === $entry;
}
@@ -819,7 +828,8 @@ class FireflyValidator extends Validator
$entry = auth()->user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)
->where('name', $value)
->first();
->first()
;
return null === $entry;
}

View File

@@ -291,6 +291,7 @@ Breadcrumbs::for(
Breadcrumbs::for(
'attachments.edit',
static function (Generator $breadcrumbs, Attachment $attachment): void {
/** @var Account|Bill|TransactionJournal $object */
$object = $attachment->attachable;
if ($object instanceof TransactionJournal) {
$group = $object->transactionGroup;
@@ -311,6 +312,7 @@ Breadcrumbs::for(
Breadcrumbs::for(
'attachments.delete',
static function (Generator $breadcrumbs, Attachment $attachment): void {
/** @var Account|Bill|TransactionJournal $object */
$object = $attachment->attachable;
if ($object instanceof TransactionJournal) {
$breadcrumbs->parent('transactions.show', $object->transactionGroup);