Various code cleanup.

This commit is contained in:
James Cole
2021-04-07 07:28:43 +02:00
parent 4ddcb0c965
commit f12744ad8c
180 changed files with 714 additions and 721 deletions

View File

@@ -106,7 +106,7 @@ class CreateRecurringTransactions implements ShouldQueue
Log::debug(sprintf('Left after filtering is %d', $filtered->count()));
/** @var Recurrence $recurrence */
foreach ($filtered as $recurrence) {
if (!isset($result[$recurrence->user_id])) {
if (!array_key_exists($recurrence->user_id, $result)) {
$result[$recurrence->user_id] = new Collection;
}
$this->repository->setUser($recurrence->user);
@@ -373,10 +373,10 @@ class CreateRecurringTransactions implements ShouldQueue
$groupTitle = null;
if ($recurrence->recurrenceTransactions->count() > 1) {
/** @var RecurrenceTransaction $first */
// @codeCoverageIgnoreStart
$first = $recurrence->recurrenceTransactions()->first();
$groupTitle = $first->description;
// @codeCoverageIgnoreEnd
}
$array = [

View File

@@ -39,14 +39,10 @@ class MailError extends Job implements ShouldQueue
{
use InteractsWithQueue, SerializesModels;
/** @var string Destination */
protected $destination;
/** @var array Exception information */
protected $exception;
/** @var string IP address */
protected $ipAddress;
/** @var array User information */
protected $userData;
protected string $destination;
protected array $exception;
protected string $ipAddress;
protected array $userData;
/**
* MailError constructor.
@@ -89,7 +85,7 @@ class MailError extends Job implements ShouldQueue
}
}
);
} catch (Exception $e) {
} catch (Exception $e) { // @phpstan-ignore-line
Log::error('Exception when mailing: ' . $e->getMessage());
}
}

View File

@@ -46,10 +46,8 @@ class SubmitTelemetryData implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/** @var Carbon The current date */
private $date;
/** @var bool Force the transaction to be created no matter what. */
private $force;
private Carbon $date;
private bool $force;
/**
* Create a new job instance.
@@ -86,7 +84,7 @@ class SubmitTelemetryData implements ShouldQueue
} catch (JsonException $e) {
Log::error($e->getMessage());
Log::error('Could not parse JSON.');
throw new FireflyException(sprintf('Could not parse telemetry JSON: %s', $e->getMessage()));
throw new FireflyException(sprintf('Could not parse telemetry JSON: %s', $e->getMessage()), 0, $e);
}
$client = new Client;
@@ -105,7 +103,7 @@ class SubmitTelemetryData implements ShouldQueue
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
Log::error('Could not submit telemetry.');
throw new FireflyException(sprintf('Could not submit telemetry: %s', $e->getMessage()));
throw new FireflyException(sprintf('Could not submit telemetry: %s', $e->getMessage()), 0, $e);
}
$body = (string)$result->getBody();
$statusCode = $result->getStatusCode();