Fix a bunch of phpstan issues.

This commit is contained in:
James Cole
2023-11-28 18:57:10 +01:00
parent b0a39c00ba
commit 1c3cb85a46
31 changed files with 197 additions and 137 deletions

View File

@@ -51,8 +51,9 @@ class ListController extends Controller
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v2)#/budgets/listBudgetLimitByBudget
* // DateRequest $request, Budget $budget
*/
public function index(DateRequest $request, Budget $budget): JsonResponse
public function index(): JsonResponse
{
return response()->json([]);
// throw new FireflyException('Needs refactoring, move to IndexController.');

View File

@@ -60,13 +60,11 @@ class IndexController extends Controller
}
/**
* @param Request $request
*
* TODO see autocomplete/accountcontroller for list.
*
* @return JsonResponse
*/
public function index(Request $request): JsonResponse
public function index(): JsonResponse
{
$piggies = $this->repository->getPiggyBanks();
$pageSize = $this->parameters->get('limit');

View File

@@ -100,6 +100,7 @@ class BasicController extends Controller
*
* @return JsonResponse
* @throws Exception
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function basic(DateRequest $request): JsonResponse
{

View File

@@ -57,12 +57,11 @@ class DestroyController extends Controller
}
/**
* @param Request $request
* @param UserGroup $userGroup
*
* @return JsonResponse
*/
public function destroy(Request $request, UserGroup $userGroup): JsonResponse
public function destroy(UserGroup $userGroup): JsonResponse
{
/** @var User $user */
$user = auth()->user();

View File

@@ -57,11 +57,9 @@ class ShowController extends Controller
}
/**
* @param Request $request
*
* @return JsonResponse
*/
public function index(Request $request): JsonResponse
public function index(): JsonResponse
{
$collection = new Collection();
$pageSize = $this->parameters->get('limit');
@@ -85,12 +83,11 @@ class ShowController extends Controller
}
/**
* @param Request $request
* @param UserGroup $userGroup
*
* @return JsonResponse
*/
public function show(Request $request, UserGroup $userGroup): JsonResponse
public function show(UserGroup $userGroup): JsonResponse
{
$transformer = new UserGroupTransformer();
$transformer->setParameters($this->parameters);

View File

@@ -55,8 +55,6 @@ class AutocompleteRequest extends FormRequest
// remove 'initial balance' and another from allowed types. its internal
$array = array_diff($array, [AccountType::INITIAL_BALANCE, AccountType::RECONCILIATION]);
/** @var User $user */
$user = auth()->user();
return [
'types' => $array,

View File

@@ -55,7 +55,6 @@ class CreateDatabase extends Command
}
// try to set up a raw connection:
$exists = false;
$checked = false; // checked for existence of DB?
$dsn = sprintf('mysql:host=%s;port=%d;charset=utf8mb4', env('DB_HOST', 'localhost'), env('DB_PORT', '3306'));
if ('' !== env('DB_SOCKET', '')) {

View File

@@ -110,19 +110,17 @@ class AccountCurrencies extends Command
private function updateAccountCurrencies(): void
{
$users = $this->userRepos->all();
$defaultCurrencyCode = (string)config('firefly.default_currency', 'EUR');
foreach ($users as $user) {
$this->updateCurrenciesForUser($user, $defaultCurrencyCode);
$this->updateCurrenciesForUser($user);
}
}
/**
* @param User $user
* @param string $systemCurrencyCode
*
* @throws FireflyException
*/
private function updateCurrenciesForUser(User $user, string $systemCurrencyCode): void
private function updateCurrenciesForUser(User $user): void
{
$this->accountRepos->setUser($user);
$accounts = $this->accountRepos->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);

View File

@@ -26,7 +26,6 @@ namespace FireflyIII\Console\Commands\Upgrade;
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
use FireflyIII\Models\TransactionType;
@@ -230,24 +229,26 @@ class UpgradeLiabilitiesEight extends Command
->where('transactions.account_id', $account->id)->get(['transaction_journals.*']);
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
$delete = false;
/** @var Transaction $source */
$source = $journal->transactions()->where('amount', '<', 0)->first();
/** @var Transaction $dest */
$dest = $journal->transactions()->where('amount', '>', 0)->first();
// $delete = false;
// /** @var Transaction $source */
// $source = $journal->transactions()->where('amount', '<', 0)->first();
// /** @var Transaction $dest */
// $dest = $journal->transactions()->where('amount', '>', 0)->first();
// if source is this liability and destination is expense, remove transaction.
// if source is revenue and destination is liability, remove transaction.
if ($source->account_id === $account->id && $dest->account->accountType->type === AccountType::EXPENSE) {
$delete = true;
}
if ($dest->account_id === $account->id && $source->account->accountType->type === AccountType::REVENUE) {
$delete = true;
}
// overruled. No transaction will be deleted, ever.
// code is kept in place so I can revisit my reasoning.
$delete = false;
/**
* // if source is this liability and destination is expense, remove transaction.
* // if source is revenue and destination is liability, remove transaction.
* if ($source->account_id === $account->id && $dest->account->accountType->type === AccountType::EXPENSE) {
* $delete = true;
* }
* if ($dest->account_id === $account->id && $source->account->accountType->type === AccountType::REVENUE) {
* $delete = true;
* }
*
* // overruled. No transaction will be deleted, ever.
* // code is kept in place, so I can revisit my reasoning.
* $delete = false;
*/
// if ($delete) {
$service = app(TransactionGroupDestroyService::class);

View File

@@ -254,8 +254,7 @@ class TransactionFactory
/**
* @param User $user
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function setUser(User $user): void
{

View File

@@ -45,7 +45,6 @@ use FireflyIII\Notifications\User\UserLogin;
use FireflyIII\Notifications\User\UserNewPassword;
use FireflyIII\Notifications\User\UserRegistration as UserRegistrationNotification;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use FireflyIII\Support\Facades\FireflyConfig;
use FireflyIII\User;
use Illuminate\Auth\Events\Login;
use Illuminate\Support\Facades\Notification;
@@ -109,6 +108,7 @@ class UserEventHandler
/**
* @param RegisteredUser $event
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function createExchangeRates(RegisteredUser $event): void
{
@@ -131,7 +131,8 @@ class UserEventHandler
$group = null;
// create a new group.
while (true === $groupExists) { /** @phpstan-ignore-line */
while (true === $groupExists) {
/** @phpstan-ignore-line */
$groupExists = UserGroup::where('title', $groupTitle)->count() > 0;
if (false === $groupExists) {
$group = UserGroup::create(['title' => $groupTitle]);
@@ -189,7 +190,6 @@ class UserEventHandler
public function notifyNewIPAddress(DetectedNewIPAddress $event): void
{
$user = $event->user;
$email = $user->email;
$ipAddress = $event->ipAddress;
if ($user->hasRole('demo')) {
@@ -197,7 +197,7 @@ class UserEventHandler
}
$list = app('preferences')->getForUser($user, 'login_ip_history', [])->data;
if(!is_array($list)) {
if (!is_array($list)) {
$list = [];
}
@@ -206,7 +206,8 @@ class UserEventHandler
if (false === $entry['notified']) {
try {
Notification::send($user, new UserLogin($ipAddress));
} catch (Exception $e) { /** @phpstan-ignore-line */
} catch (Exception $e) {
/** @phpstan-ignore-line */
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
@@ -231,7 +232,7 @@ class UserEventHandler
*/
public function sendAdminRegistrationNotification(RegisteredUser $event): void
{
$sendMail = (bool) app('fireflyconfig')->get('notification_admin_new_reg', true)->data;
$sendMail = (bool)app('fireflyconfig')->get('notification_admin_new_reg', true)->data;
if ($sendMail) {
/** @var UserRepositoryInterface $repository */
$repository = app(UserRepositoryInterface::class);
@@ -240,7 +241,8 @@ class UserEventHandler
if ($repository->hasRole($user, 'owner')) {
try {
Notification::send($user, new AdminRegistrationNotification($event->user));
} catch (Exception $e) { /** @phpstan-ignore-line */
} catch (Exception $e) {
/** @phpstan-ignore-line */
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
@@ -317,7 +319,8 @@ class UserEventHandler
{
try {
Notification::send($event->user, new UserNewPassword(route('password.reset', [$event->token])));
} catch (Exception $e) { /** @phpstan-ignore-line */
} catch (Exception $e) {
/** @phpstan-ignore-line */
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');
@@ -361,11 +364,12 @@ class UserEventHandler
*/
public function sendRegistrationMail(RegisteredUser $event): void
{
$sendMail = (bool) app('fireflyconfig')->get('notification_user_new_reg', true)->data;
$sendMail = (bool)app('fireflyconfig')->get('notification_user_new_reg', true)->data;
if ($sendMail) {
try {
Notification::send($event->user, new UserRegistrationNotification());
} catch (Exception $e) { /** @phpstan-ignore-line */
} catch (Exception $e) {
/** @phpstan-ignore-line */
$message = $e->getMessage();
if (str_contains($message, 'Bcc')) {
app('log')->warning('[Bcc] Could not send notification. Please validate your email settings, use the .env.example file as a guide.');

View File

@@ -36,6 +36,7 @@ use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\MessageBag;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use const DIRECTORY_SEPARATOR;
/**
* Class AttachmentHelper.
@@ -95,7 +96,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*/
public function getAttachmentLocation(Attachment $attachment): string
{
return sprintf('%sat-%d.data', \DIRECTORY_SEPARATOR, $attachment->id);
return sprintf('%sat-%d.data', DIRECTORY_SEPARATOR, $attachment->id);
}
/**
@@ -166,7 +167,7 @@ class AttachmentHelper implements AttachmentHelperInterface
fclose($resource);
return false;
}
$mime = (string) finfo_file($finfo, $path);
$mime = (string)finfo_file($finfo, $path);
$allowedMime = config('firefly.allowedMimes');
if (!in_array($mime, $allowedMime, true)) {
Log::error(sprintf('Mime type %s is not allowed for API file upload.', $mime));
@@ -182,7 +183,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$this->uploadDisk->put($file, $content);
// update attachment.
$attachment->md5 = (string) md5_file($path);
$attachment->md5 = (string)md5_file($path);
$attachment->mime = $mime;
$attachment->size = strlen($content);
$attachment->uploaded = true;
@@ -251,7 +252,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$attachment = new Attachment(); // create Attachment object.
$attachment->user()->associate($user);
$attachment->attachable()->associate($model);
$attachment->md5 = (string) md5_file($file->getRealPath());
$attachment->md5 = (string)md5_file($file->getRealPath());
$attachment->filename = $file->getClientOriginalName();
$attachment->mime = $file->getMimeType();
$attachment->size = $file->getSize();
@@ -266,7 +267,7 @@ class AttachmentHelper implements AttachmentHelperInterface
throw new FireflyException('Cannot upload empty or non-existent file.');
}
$content = (string) $fileObject->fread($file->getSize());
$content = (string)$fileObject->fread($file->getSize());
Log::debug(sprintf('Full file length is %d and upload size is %d.', strlen($content), $file->getSize()));
// store it without encryption.

View File

@@ -44,15 +44,21 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($name): bool {
/**
* @param int $index
* @param array $object
*
* @return bool
*/
$filter = static function (array $object) use ($name): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
$result = str_contains(strtolower($attachment['filename']), strtolower($name)) || str_contains(
strtolower($attachment['title']),
strtolower($name)
);
strtolower($attachment['title']),
strtolower($name)
);
if (true === $result) {
return true;
}
@@ -123,15 +129,22 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($name): bool {
/**
* @param int $index
* @param array $object
*
* @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
$filter = static function (array $object) use ($name): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
$result = !str_contains(strtolower($attachment['filename']), strtolower($name)) && !str_contains(
strtolower($attachment['title']),
strtolower($name)
);
strtolower($attachment['title']),
strtolower($name)
);
if (true === $result) {
return true;
}
@@ -153,15 +166,22 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($name): bool {
/**
* @param int $index
* @param array $object
*
* @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
$filter = static function (array $object) use ($name): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
$result = !str_ends_with(strtolower($attachment['filename']), strtolower($name)) && !str_ends_with(
strtolower($attachment['title']),
strtolower($name)
);
strtolower($attachment['title']),
strtolower($name)
);
if (true === $result) {
return true;
}
@@ -183,15 +203,22 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($name): bool {
/**
* @param int $index
* @param array $object
*
* @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
$filter = static function (array $object) use ($name): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
$result = !str_starts_with(strtolower($attachment['filename']), strtolower($name)) && !str_starts_with(
strtolower($attachment['title']),
strtolower($name)
);
strtolower($attachment['title']),
strtolower($name)
);
if (true === $result) {
return true;
}
@@ -213,15 +240,15 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($name): bool {
$filter = static function (array $object) use ($name): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
$result = str_ends_with(strtolower($attachment['filename']), strtolower($name)) || str_ends_with(
strtolower($attachment['title']),
strtolower($name)
);
strtolower($attachment['title']),
strtolower($name)
);
if (true === $result) {
return true;
}
@@ -243,7 +270,7 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($name): bool {
$filter = static function (array $object) use ($name): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
@@ -270,7 +297,7 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($name): bool {
$filter = static function (array $object) use ($name): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
@@ -297,15 +324,15 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($name): bool {
$filter = static function (array $object) use ($name): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
foreach ($transaction['attachments'] as $attachment) {
$result = str_starts_with(strtolower($attachment['filename']), strtolower($name)) || str_starts_with(
strtolower($attachment['title']),
strtolower($name)
);
strtolower($attachment['title']),
strtolower($name)
);
if (true === $result) {
return true;
}
@@ -327,7 +354,7 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($value): bool {
$filter = static function (array $object) use ($value): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
@@ -354,7 +381,7 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($value): bool {
$filter = static function (array $object) use ($value): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
@@ -381,7 +408,7 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($value): bool {
$filter = static function (array $object) use ($value): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
@@ -408,7 +435,7 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($value): bool {
$filter = static function (array $object) use ($value): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
@@ -435,7 +462,7 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($value): bool {
$filter = static function (array $object) use ($value): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
@@ -462,7 +489,7 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($value): bool {
$filter = static function (array $object) use ($value): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
@@ -489,7 +516,7 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($value): bool {
$filter = static function (array $object) use ($value): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */
@@ -516,7 +543,7 @@ trait AttachmentCollection
{
$this->hasAttachments();
$this->withAttachmentInformation();
$filter = static function (int $index, array $object) use ($value): bool {
$filter = static function (array $object) use ($value): bool {
/** @var array $transaction */
foreach ($object['transactions'] as $transaction) {
/** @var array $attachment */

View File

@@ -226,7 +226,7 @@ trait MetaCollection
*/
public function excludeInternalReference(string $internalReference): GroupCollectorInterface
{
$internalReference = (string) json_encode($internalReference);
$internalReference = (string)json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -253,7 +253,7 @@ trait MetaCollection
*/
public function externalIdContains(string $externalId): GroupCollectorInterface
{
$externalId = (string) json_encode($externalId);
$externalId = (string)json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -268,7 +268,7 @@ trait MetaCollection
*/
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface
{
$externalId = (string) json_encode($externalId);
$externalId = (string)json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -283,7 +283,7 @@ trait MetaCollection
*/
public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface
{
$externalId = (string) json_encode($externalId);
$externalId = (string)json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -298,7 +298,7 @@ trait MetaCollection
*/
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface
{
$externalId = (string) json_encode($externalId);
$externalId = (string)json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -313,7 +313,7 @@ trait MetaCollection
*/
public function externalIdEnds(string $externalId): GroupCollectorInterface
{
$externalId = (string) json_encode($externalId);
$externalId = (string)json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -328,7 +328,7 @@ trait MetaCollection
*/
public function externalIdStarts(string $externalId): GroupCollectorInterface
{
$externalId = (string) json_encode($externalId);
$externalId = (string)json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables();
@@ -346,7 +346,7 @@ trait MetaCollection
public function externalUrlContains(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
$url = (string) json_encode($url);
$url = (string)json_encode($url);
$url = str_replace('\\', '\\\\', trim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s%%', $url));
@@ -362,7 +362,7 @@ trait MetaCollection
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
$url = (string) json_encode($url);
$url = (string)json_encode($url);
$url = str_replace('\\', '\\\\', trim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s%%', $url));
@@ -378,7 +378,7 @@ trait MetaCollection
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
$url = (string) json_encode($url);
$url = (string)json_encode($url);
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->where('journal_meta.data', 'NOT LIKE', sprintf('%%%s', $url));
@@ -394,7 +394,7 @@ trait MetaCollection
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
$url = (string) json_encode($url);
$url = (string)json_encode($url);
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
//var_dump($url);
@@ -412,7 +412,7 @@ trait MetaCollection
public function externalUrlEnds(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
$url = (string) json_encode($url);
$url = (string)json_encode($url);
$url = str_replace('\\', '\\\\', ltrim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url');
$this->query->where('journal_meta.data', 'LIKE', sprintf('%%%s', $url));
@@ -428,7 +428,7 @@ trait MetaCollection
public function externalUrlStarts(string $url): GroupCollectorInterface
{
$this->joinMetaDataTables();
$url = (string) json_encode($url);
$url = (string)json_encode($url);
$url = str_replace('\\', '\\\\', rtrim($url, '"'));
//var_dump($url);
@@ -487,7 +487,7 @@ trait MetaCollection
*/
public function internalReferenceContains(string $internalReference): GroupCollectorInterface
{
$internalReference = (string) json_encode($internalReference);
$internalReference = (string)json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
//var_dump($internalReference);
//exit;
@@ -504,7 +504,7 @@ trait MetaCollection
*/
public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface
{
$internalReference = (string) json_encode($internalReference);
$internalReference = (string)json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -519,7 +519,7 @@ trait MetaCollection
*/
public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface
{
$internalReference = (string) json_encode($internalReference);
$internalReference = (string)json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -534,7 +534,7 @@ trait MetaCollection
*/
public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface
{
$internalReference = (string) json_encode($internalReference);
$internalReference = (string)json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -549,7 +549,7 @@ trait MetaCollection
*/
public function internalReferenceEnds(string $internalReference): GroupCollectorInterface
{
$internalReference = (string) json_encode($internalReference);
$internalReference = (string)json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -564,7 +564,7 @@ trait MetaCollection
*/
public function internalReferenceStarts(string $internalReference): GroupCollectorInterface
{
$internalReference = (string) json_encode($internalReference);
$internalReference = (string)json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -836,7 +836,7 @@ trait MetaCollection
*/
public function setInternalReference(string $internalReference): GroupCollectorInterface
{
$internalReference = (string) json_encode($internalReference);
$internalReference = (string)json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables();
@@ -915,7 +915,7 @@ trait MetaCollection
// this method adds a "postFilter" to the collector.
$list = $tags->pluck('tag')->toArray();
$filter = static function (int $index, array $object) use ($list): bool {
$filter = static function (array $object) use ($list): bool {
foreach ($object['transactions'] as $transaction) {
foreach ($transaction['tags'] as $tag) {
if (in_array($tag['name'], $list, true)) {

View File

@@ -93,7 +93,7 @@ trait TimeCollection
$start->startOfDay();
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $start, $end): bool {
$filter = static function (array $object) use ($field, $start, $end): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon) {
return $transaction[$field]->lt($start) || $transaction[$field]->gt($end);
@@ -166,7 +166,7 @@ trait TimeCollection
public function metaDayAfter(string $day, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $day): bool {
$filter = static function (array $object) use ($field, $day): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -190,7 +190,7 @@ trait TimeCollection
public function metaDayBefore(string $day, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $day): bool {
$filter = static function (array $object) use ($field, $day): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -214,7 +214,7 @@ trait TimeCollection
public function metaDayIs(string $day, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $day): bool {
$filter = static function (array $object) use ($field, $day): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -237,7 +237,7 @@ trait TimeCollection
public function metaDayIsNot(string $day, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $day): bool {
$filter = static function (array $object) use ($field, $day): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -260,7 +260,7 @@ trait TimeCollection
public function metaMonthAfter(string $month, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $month): bool {
$filter = static function (array $object) use ($field, $month): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -284,7 +284,7 @@ trait TimeCollection
public function metaMonthBefore(string $month, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $month): bool {
$filter = static function (array $object) use ($field, $month): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -308,7 +308,7 @@ trait TimeCollection
public function metaMonthIs(string $month, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $month): bool {
$filter = static function (array $object) use ($field, $month): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -331,7 +331,7 @@ trait TimeCollection
public function metaMonthIsNot(string $month, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $month): bool {
$filter = static function (array $object) use ($field, $month): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -354,7 +354,7 @@ trait TimeCollection
public function metaYearAfter(string $year, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $year): bool {
$filter = static function (array $object) use ($field, $year): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -378,7 +378,7 @@ trait TimeCollection
public function metaYearBefore(string $year, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $year): bool {
$filter = static function (array $object) use ($field, $year): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -402,7 +402,7 @@ trait TimeCollection
public function metaYearIs(string $year, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $year): bool {
$filter = static function (array $object) use ($field, $year): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -426,7 +426,7 @@ trait TimeCollection
public function metaYearIsNot(string $year, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $year): bool {
$filter = static function (array $object) use ($field, $year): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -702,7 +702,7 @@ trait TimeCollection
{
$this->withMetaDate($field);
$date->startOfDay();
$filter = static function (int $index, array $object) use ($field, $date): bool {
$filter = static function (array $object) use ($field, $date): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -726,7 +726,7 @@ trait TimeCollection
public function setMetaBefore(Carbon $date, string $field): GroupCollectorInterface
{
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $date): bool {
$filter = static function (array $object) use ($field, $date): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {
@@ -758,7 +758,7 @@ trait TimeCollection
$start->startOfDay();
$this->withMetaDate($field);
$filter = static function (int $index, array $object) use ($field, $start, $end): bool {
$filter = static function (array $object) use ($field, $start, $end): bool {
foreach ($object['transactions'] as $transaction) {
if (array_key_exists($field, $transaction) && $transaction[$field] instanceof Carbon
) {

View File

@@ -782,7 +782,7 @@ class GroupCollector implements GroupCollectorInterface
/** @var array $transaction */
foreach ($group['transactions'] as $transaction) {
$currencyId = (int)$transaction['currency_id'];
if(null === $transaction['amount']) {
if (null === $transaction['amount']) {
throw new FireflyException(sprintf('Amount is NULL for a transaction in group #%d, please investigate.', $groudId));
}
@@ -835,8 +835,8 @@ class GroupCollector implements GroupCollectorInterface
* @var int $ii
* @var array $item
*/
foreach ($currentCollection as $ii => $item) {
$result = $function($ii, $item);
foreach ($currentCollection as $item) {
$result = $function($item);
if (false === $result) {
// skip other filters, continue to next item.
continue;

View File

@@ -80,10 +80,10 @@ class FiscalHelper implements FiscalHelperInterface
$startDate = clone $date;
if (true === $this->useCustomFiscalYear) {
$prefStartStr = app('preferences')->get('fiscalYearStart', '01-01')->data;
if(is_array($prefStartStr)) {
if (is_array($prefStartStr)) {
$prefStartStr = '01-01';
}
$prefStartStr = (string) $prefStartStr;
$prefStartStr = (string)$prefStartStr;
[$mth, $day] = explode('-', $prefStartStr);
$startDate->day((int)$day)->month((int)$mth);

View File

@@ -111,11 +111,9 @@ class HomeController extends Controller
/**
* Send a test message to the admin.
*
* @param Request $request
*
* @return RedirectResponse|Redirector
*/
public function testMessage(Request $request)
public function testMessage()
{
Log::channel('audit')->info('User sends test message.');
/** @var User $user */

View File

@@ -209,14 +209,13 @@ class AttachmentController extends Controller
/**
* View attachment in browser.
*
* @param Request $request
* @param Attachment $attachment
*
* @return LaravelResponse
* @throws FireflyException
* @throws BindingResolutionException
*/
public function view(Request $request, Attachment $attachment): LaravelResponse
public function view(Attachment $attachment): LaravelResponse
{
if ($this->repository->exists($attachment)) {
$content = $this->repository->getContent($attachment);

View File

@@ -148,7 +148,7 @@ class LoginController extends Controller
* @param Request $request
*
* @return void
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @throws ValidationException
*/
protected function sendFailedLoginResponse(Request $request)

View File

@@ -53,6 +53,7 @@ class TestNotification extends Notification
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return array
*/
@@ -67,6 +68,7 @@ class TestNotification extends Notification
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return MailMessage
*/
@@ -81,6 +83,7 @@ class TestNotification extends Notification
* Get the Slack representation of the notification.
*
* @param mixed $notifiable
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return SlackMessage
*/
@@ -91,6 +94,7 @@ class TestNotification extends Notification
/**
* Get the notification's delivery channels.
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param mixed $notifiable
*

View File

@@ -56,6 +56,7 @@ class UserInvitation extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
@@ -70,6 +71,7 @@ class UserInvitation extends Notification
* @param mixed $notifiable
*
* @return MailMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
@@ -84,6 +86,7 @@ class UserInvitation extends Notification
* @param mixed $notifiable
*
* @return SlackMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack($notifiable)
{
@@ -98,6 +101,7 @@ class UserInvitation extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{

View File

@@ -56,6 +56,7 @@ class UserRegistration extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
@@ -70,6 +71,7 @@ class UserRegistration extends Notification
* @param mixed $notifiable
*
* @return MailMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
@@ -84,6 +86,7 @@ class UserRegistration extends Notification
* @param mixed $notifiable
*
* @return SlackMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack($notifiable)
{
@@ -96,6 +99,7 @@ class UserRegistration extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{

View File

@@ -56,6 +56,7 @@ class VersionCheckResult extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
@@ -70,6 +71,7 @@ class VersionCheckResult extends Notification
* @param mixed $notifiable
*
* @return MailMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
@@ -84,6 +86,7 @@ class VersionCheckResult extends Notification
* @param mixed $notifiable
*
* @return SlackMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack($notifiable)
{
@@ -99,6 +102,7 @@ class VersionCheckResult extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{

View File

@@ -61,6 +61,7 @@ class BillReminder extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
@@ -75,6 +76,7 @@ class BillReminder extends Notification
* @param mixed $notifiable
*
* @return MailMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
@@ -94,6 +96,7 @@ class BillReminder extends Notification
* @param mixed $notifiable
*
* @return SlackMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack($notifiable)
{
@@ -117,6 +120,7 @@ class BillReminder extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{
@@ -126,7 +130,7 @@ class BillReminder extends Notification
if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string) $slackUrl)) {
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];

View File

@@ -53,6 +53,7 @@ class NewAccessToken extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
@@ -67,6 +68,7 @@ class NewAccessToken extends Notification
* @param mixed $notifiable
*
* @return MailMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
@@ -81,6 +83,7 @@ class NewAccessToken extends Notification
* @param mixed $notifiable
*
* @return SlackMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack($notifiable)
{
@@ -93,6 +96,7 @@ class NewAccessToken extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{

View File

@@ -66,6 +66,7 @@ class RuleActionFailed extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
@@ -80,6 +81,7 @@ class RuleActionFailed extends Notification
* @param mixed $notifiable
*
* @return SlackMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack($notifiable)
{
@@ -101,6 +103,7 @@ class RuleActionFailed extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{

View File

@@ -53,6 +53,7 @@ class TransactionCreation extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
@@ -67,6 +68,7 @@ class TransactionCreation extends Notification
* @param mixed $notifiable
*
* @return MailMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
@@ -81,6 +83,7 @@ class TransactionCreation extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{

View File

@@ -57,6 +57,7 @@ class UserLogin extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
@@ -71,6 +72,7 @@ class UserLogin extends Notification
* @param mixed $notifiable
*
* @return MailMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
@@ -97,6 +99,7 @@ class UserLogin extends Notification
* @param mixed $notifiable
*
* @return SlackMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toSlack($notifiable)
{
@@ -120,6 +123,7 @@ class UserLogin extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{
@@ -129,7 +133,7 @@ class UserLogin extends Notification
if (is_array($slackUrl)) {
$slackUrl = '';
}
if (UrlValidator::isValidWebhookURL((string) $slackUrl)) {
if (UrlValidator::isValidWebhookURL((string)$slackUrl)) {
return ['mail', 'slack'];
}
return ['mail'];

View File

@@ -53,6 +53,7 @@ class UserNewPassword extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
@@ -67,6 +68,7 @@ class UserNewPassword extends Notification
* @param mixed $notifiable
*
* @return MailMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
@@ -81,6 +83,7 @@ class UserNewPassword extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{

View File

@@ -50,6 +50,7 @@ class UserRegistration extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toArray($notifiable)
{
@@ -64,6 +65,7 @@ class UserRegistration extends Notification
* @param mixed $notifiable
*
* @return MailMessage
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function toMail($notifiable)
{
@@ -78,6 +80,7 @@ class UserRegistration extends Notification
* @param mixed $notifiable
*
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function via($notifiable)
{