mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-25 21:16:47 +00:00
Fix a bunch of phpstan issues.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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
|
||||
) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user