Remove safe methods.

This commit is contained in:
James Cole
2025-05-11 14:08:32 +02:00
parent 145e8d23f0
commit 84779b8d02
65 changed files with 166 additions and 166 deletions

View File

@@ -273,7 +273,7 @@ class ExportsData extends Command
*/ */
private function exportData(array $options, array $data): void private function exportData(array $options, array $data): void
{ {
$date = \Safe\date('Y_m_d'); $date = date('Y_m_d');
foreach ($data as $key => $content) { foreach ($data as $key => $content) {
$file = sprintf('%s%s_%s.csv', $options['directory'], $date, $key); $file = sprintf('%s%s_%s.csv', $options['directory'], $date, $key);
if (false === $options['force'] && file_exists($file)) { if (false === $options['force'] && file_exists($file)) {
@@ -283,7 +283,7 @@ class ExportsData extends Command
$this->friendlyWarning(sprintf('File "%s" exists already but will be replaced.', $file)); $this->friendlyWarning(sprintf('File "%s" exists already but will be replaced.', $file));
} }
// continue to write to file. // continue to write to file.
\Safe\file_put_contents($file, $content); file_put_contents($file, $content);
$this->friendlyPositive(sprintf('Wrote %s-export to file "%s".', $key, $file)); $this->friendlyPositive(sprintf('Wrote %s-export to file "%s".', $key, $file));
} }
} }

View File

@@ -130,7 +130,7 @@ class ForcesDecimalSize extends Command
// if sqlite, add function? // if sqlite, add function?
if ('sqlite' === (string) config('database.default')) { if ('sqlite' === (string) config('database.default')) {
DB::connection()->getPdo()->sqliteCreateFunction('REGEXP', static function ($pattern, $value) { DB::connection()->getPdo()->sqliteCreateFunction('REGEXP', static function ($pattern, $value) {
\Safe\mb_regex_encoding('UTF-8'); mb_regex_encoding('UTF-8');
$pattern = trim($pattern, '"'); $pattern = trim($pattern, '"');
return (false !== mb_ereg($pattern, (string) $value)) ? 1 : 0; return (false !== mb_ereg($pattern, (string) $value)) ? 1 : 0;
@@ -234,7 +234,7 @@ class ForcesDecimalSize extends Command
/** @var Builder $query */ /** @var Builder $query */
$query = Account::leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id') $query = Account::leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('account_meta.name', 'currency_id') ->where('account_meta.name', 'currency_id')
->where('account_meta.data', \Safe\json_encode((string) $currency->id)) ->where('account_meta.data', json_encode((string) $currency->id))
; ;
$query->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void { $query->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
foreach ($fields as $field) { foreach ($fields as $field) {
@@ -338,7 +338,7 @@ class ForcesDecimalSize extends Command
->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id') ->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id') ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('account_meta.name', 'currency_id') ->where('account_meta.name', 'currency_id')
->where('account_meta.data', \Safe\json_encode((string) $currency->id)) ->where('account_meta.data', json_encode((string) $currency->id))
->where(static function (Builder $q) use ($fields, $currency, $cast, $operator, $regularExpression): void { ->where(static function (Builder $q) use ($fields, $currency, $cast, $operator, $regularExpression): void {
foreach ($fields as $field) { foreach ($fields as $field) {
$q->orWhere( $q->orWhere(
@@ -394,7 +394,7 @@ class ForcesDecimalSize extends Command
->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id') ->leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id') ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('account_meta.name', 'currency_id') ->where('account_meta.name', 'currency_id')
->where('account_meta.data', \Safe\json_encode((string) $currency->id)) ->where('account_meta.data', json_encode((string) $currency->id))
->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void { ->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
foreach ($fields as $field) { foreach ($fields as $field) {
$q->orWhere( $q->orWhere(
@@ -448,7 +448,7 @@ class ForcesDecimalSize extends Command
$query = PiggyBank::leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id') $query = PiggyBank::leftJoin('accounts', 'piggy_banks.account_id', '=', 'accounts.id')
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id') ->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
->where('account_meta.name', 'currency_id') ->where('account_meta.name', 'currency_id')
->where('account_meta.data', \Safe\json_encode((string) $currency->id)) ->where('account_meta.data', json_encode((string) $currency->id))
->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void { ->where(static function (Builder $q) use ($fields, $currency, $operator, $cast, $regularExpression): void {
foreach ($fields as $field) { foreach ($fields as $field) {
$q->orWhere( $q->orWhere(

View File

@@ -111,8 +111,8 @@ class OutputsInstructions extends Command
*/ */
private function showLogo(): void private function showLogo(): void
{ {
$today = \Safe\date('m-d'); $today = date('m-d');
$month = \Safe\date('m'); $month = date('m');
// variation in colors and effects just because I can! // variation in colors and effects just because I can!
// default is Ukraine flag: // default is Ukraine flag:
$colors = ['blue', 'blue', 'blue', 'yellow', 'yellow', 'yellow', 'default', 'default']; $colors = ['blue', 'blue', 'blue', 'yellow', 'yellow', 'yellow', 'default', 'default'];

View File

@@ -63,15 +63,15 @@ class ScansAttachments extends Command
app('log')->error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage())); app('log')->error(sprintf('Could not decrypt data of attachment #%d: %s', $attachment->id, $e->getMessage()));
$decryptedContent = $encryptedContent; $decryptedContent = $encryptedContent;
} }
$tempFileName = \Safe\tempnam(sys_get_temp_dir(), 'FireflyIII'); $tempFileName = tempnam(sys_get_temp_dir(), 'FireflyIII');
if (false === $tempFileName) { if (false === $tempFileName) {
app('log')->error(sprintf('Could not create temporary file for attachment #%d', $attachment->id)); app('log')->error(sprintf('Could not create temporary file for attachment #%d', $attachment->id));
exit(1); exit(1);
} }
\Safe\file_put_contents($tempFileName, $decryptedContent); file_put_contents($tempFileName, $decryptedContent);
$attachment->md5 = (string) \Safe\md5_file($tempFileName); $attachment->md5 = (string) md5_file($tempFileName);
$attachment->mime = (string) \Safe\mime_content_type($tempFileName); $attachment->mime = (string) mime_content_type($tempFileName);
$attachment->save(); $attachment->save();
$this->friendlyInfo(sprintf('Fixed attachment #%d', $attachment->id)); $this->friendlyInfo(sprintf('Fixed attachment #%d', $attachment->id));
} }

View File

@@ -57,7 +57,7 @@ class VerifySecurityAlerts extends Command
return 0; return 0;
} }
$content = $disk->get('alerts.json'); $content = $disk->get('alerts.json');
$json = \Safe\json_decode($content, true, 10); $json = json_decode($content, true, 10);
/** @var array $array */ /** @var array $array */
foreach ($json as $array) { foreach ($json as $array) {

View File

@@ -167,7 +167,7 @@ class RemovesDatabaseDecryption extends Command
{ {
// try to json_decrypt the value. // try to json_decrypt the value.
try { try {
$newValue = \Safe\json_decode($value, true, 512, JSON_THROW_ON_ERROR) ?? $value; $newValue = json_decode($value, true, 512, JSON_THROW_ON_ERROR) ?? $value;
} catch (\JsonException $e) { } catch (\JsonException $e) {
$message = sprintf('Could not JSON decode preference row #%d: %s. This does not have to be a problem.', $id, $e->getMessage()); $message = sprintf('Could not JSON decode preference row #%d: %s. This does not have to be a problem.', $id, $e->getMessage());
$this->friendlyError($message); $this->friendlyError($message);

View File

@@ -100,7 +100,7 @@ class UpgradesRecurrenceMetaData extends Command
if ('tags' === $meta->name) { if ('tags' === $meta->name) {
$array = explode(',', $meta->value); $array = explode(',', $meta->value);
$value = \Safe\json_encode($array, JSON_THROW_ON_ERROR); $value = json_encode($array, JSON_THROW_ON_ERROR);
} }
RecurrenceTransactionMeta::create( RecurrenceTransactionMeta::create(

View File

@@ -366,8 +366,8 @@ class UpgradesToGroups extends Command
{ {
$groupId = DB::table('transaction_groups')->insertGetId( $groupId = DB::table('transaction_groups')->insertGetId(
[ [
'created_at' => \Safe\date('Y-m-d H:i:s'), 'created_at' => date('Y-m-d H:i:s'),
'updated_at' => \Safe\date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'),
'title' => null, 'title' => null,
'user_id' => $array['user_id'], 'user_id' => $array['user_id'],
] ]

View File

@@ -284,7 +284,7 @@ class PiggyBankFactory
Log::debug(sprintf('Will link account #%d with info: ', $account->id), $toBeLinked[$account->id]); Log::debug(sprintf('Will link account #%d with info: ', $account->id), $toBeLinked[$account->id]);
} }
} }
Log::debug(sprintf('Link information: %s', \Safe\json_encode($toBeLinked))); Log::debug(sprintf('Link information: %s', json_encode($toBeLinked)));
if (0 !== count($toBeLinked)) { if (0 !== count($toBeLinked)) {
$piggyBank->accounts()->sync($toBeLinked); $piggyBank->accounts()->sync($toBeLinked);
} }

View File

@@ -323,7 +323,7 @@ class TransactionJournalFactory
unset($dataRow['import_hash_v2'], $dataRow['original_source']); unset($dataRow['import_hash_v2'], $dataRow['original_source']);
try { try {
$json = \Safe\json_encode($dataRow, JSON_THROW_ON_ERROR); $json = json_encode($dataRow, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) { } catch (\JsonException $e) {
Log::error(sprintf('Could not encode dataRow: %s', $e->getMessage())); Log::error(sprintf('Could not encode dataRow: %s', $e->getMessage()));
$json = microtime(); $json = microtime();
@@ -352,7 +352,7 @@ class TransactionJournalFactory
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
->whereNotNull('transaction_journals.id') ->whereNotNull('transaction_journals.id')
->where('transaction_journals.user_id', $this->user->id) ->where('transaction_journals.user_id', $this->user->id)
->where('data', \Safe\json_encode($hash, JSON_THROW_ON_ERROR)) ->where('data', json_encode($hash, JSON_THROW_ON_ERROR))
->with(['transactionJournal', 'transactionJournal.transactionGroup']) ->with(['transactionJournal', 'transactionJournal.transactionGroup'])
->first(['journal_meta.*']) ->first(['journal_meta.*'])
; ;

View File

@@ -73,7 +73,7 @@ class VersionCheckEventHandler
$diff = $now - $lastCheckTime->data; $diff = $now - $lastCheckTime->data;
Log::debug(sprintf('Last check time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff)); Log::debug(sprintf('Last check time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
if ($diff < 604800) { if ($diff < 604800) {
Log::debug(sprintf('Checked for updates less than a week ago (on %s).', \Safe\date('Y-m-d H:i:s', $lastCheckTime->data))); Log::debug(sprintf('Checked for updates less than a week ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
return; return;
} }
@@ -105,7 +105,7 @@ class VersionCheckEventHandler
$diff = $now - $lastCheckTime->data; $diff = $now - $lastCheckTime->data;
Log::debug(sprintf('Last warning time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff)); Log::debug(sprintf('Last warning time is %d, current time is %d, difference is %d', $lastCheckTime->data, $now, $diff));
if ($diff < 604800 * 4) { if ($diff < 604800 * 4) {
Log::debug(sprintf('Warned about updates less than four weeks ago (on %s).', \Safe\date('Y-m-d H:i:s', $lastCheckTime->data))); Log::debug(sprintf('Warned about updates less than four weeks ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data)));
return; return;
} }

View File

@@ -118,7 +118,7 @@ class AttachmentHelper implements AttachmentHelperInterface
public function saveAttachmentFromApi(Attachment $attachment, string $content): bool public function saveAttachmentFromApi(Attachment $attachment, string $content): bool
{ {
Log::debug(sprintf('Now in %s', __METHOD__)); Log::debug(sprintf('Now in %s', __METHOD__));
$resource = \Safe\tmpfile(); $resource = tmpfile();
if (false === $resource) { if (false === $resource) {
Log::error('Cannot create temp-file for file upload.'); Log::error('Cannot create temp-file for file upload.');
@@ -133,17 +133,17 @@ class AttachmentHelper implements AttachmentHelperInterface
$path = stream_get_meta_data($resource)['uri']; $path = stream_get_meta_data($resource)['uri'];
Log::debug(sprintf('Path is %s', $path)); Log::debug(sprintf('Path is %s', $path));
$result = \Safe\fwrite($resource, $content); $result = fwrite($resource, $content);
if (false === $result) { if (false === $result) {
Log::error('Could not write temp file.'); Log::error('Could not write temp file.');
return false; return false;
} }
Log::debug(sprintf('Wrote %d bytes to temp file.', $result)); Log::debug(sprintf('Wrote %d bytes to temp file.', $result));
$finfo = \Safe\finfo_open(FILEINFO_MIME_TYPE); $finfo = finfo_open(FILEINFO_MIME_TYPE);
if (false === $finfo) { if (false === $finfo) {
Log::error('Could not open finfo.'); Log::error('Could not open finfo.');
\Safe\fclose($resource); fclose($resource);
return false; return false;
} }
@@ -151,7 +151,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$allowedMime = config('firefly.allowedMimes'); $allowedMime = config('firefly.allowedMimes');
if (!in_array($mime, $allowedMime, true)) { if (!in_array($mime, $allowedMime, true)) {
Log::error(sprintf('Mime type %s is not allowed for API file upload.', $mime)); Log::error(sprintf('Mime type %s is not allowed for API file upload.', $mime));
\Safe\fclose($resource); fclose($resource);
return false; return false;
} }
@@ -163,7 +163,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$this->uploadDisk->put($file, $content); $this->uploadDisk->put($file, $content);
// update attachment. // update attachment.
$attachment->md5 = (string) \Safe\md5_file($path); $attachment->md5 = (string) md5_file($path);
$attachment->mime = $mime; $attachment->mime = $mime;
$attachment->size = strlen($content); $attachment->size = strlen($content);
$attachment->uploaded = true; $attachment->uploaded = true;
@@ -225,7 +225,7 @@ class AttachmentHelper implements AttachmentHelperInterface
$attachment = new Attachment(); // create Attachment object. $attachment = new Attachment(); // create Attachment object.
$attachment->user()->associate($user); $attachment->user()->associate($user);
$attachment->attachable()->associate($model); $attachment->attachable()->associate($model);
$attachment->md5 = (string) \Safe\md5_file($file->getRealPath()); $attachment->md5 = (string) md5_file($file->getRealPath());
$attachment->filename = $file->getClientOriginalName(); $attachment->filename = $file->getClientOriginalName();
$attachment->mime = $file->getMimeType(); $attachment->mime = $file->getMimeType();
$attachment->size = $file->getSize(); $attachment->size = $file->getSize();
@@ -333,7 +333,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*/ */
protected function hasFile(UploadedFile $file, Model $model): bool protected function hasFile(UploadedFile $file, Model $model): bool
{ {
$md5 = \Safe\md5_file($file->getRealPath()); $md5 = md5_file($file->getRealPath());
$name = $file->getClientOriginalName(); $name = $file->getClientOriginalName();
$class = $model::class; $class = $model::class;
$count = 0; $count = 0;

View File

@@ -167,7 +167,7 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id'); $this->query->where('journal_meta.name', '=', 'external_id');
$this->query->where('journal_meta.data', '!=', sprintf('%s', \Safe\json_encode($externalId))); $this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($externalId)));
$this->query->whereNull('journal_meta.deleted_at'); $this->query->whereNull('journal_meta.deleted_at');
return $this; return $this;
@@ -190,14 +190,14 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_url'); $this->query->where('journal_meta.name', '=', 'external_url');
$this->query->where('journal_meta.data', '!=', \Safe\json_encode($url)); $this->query->where('journal_meta.data', '!=', json_encode($url));
return $this; return $this;
} }
public function excludeInternalReference(string $internalReference): GroupCollectorInterface public function excludeInternalReference(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) \Safe\json_encode($internalReference); $internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -211,14 +211,14 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'recurrence_id'); $this->query->where('journal_meta.name', '=', 'recurrence_id');
$this->query->where('journal_meta.data', '!=', sprintf('%s', \Safe\json_encode($recurringId))); $this->query->where('journal_meta.data', '!=', sprintf('%s', json_encode($recurringId)));
return $this; return $this;
} }
public function externalIdContains(string $externalId): GroupCollectorInterface public function externalIdContains(string $externalId): GroupCollectorInterface
{ {
$externalId = (string) \Safe\json_encode($externalId); $externalId = (string) json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"')); $externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -230,7 +230,7 @@ trait MetaCollection
public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface public function externalIdDoesNotContain(string $externalId): GroupCollectorInterface
{ {
$externalId = (string) \Safe\json_encode($externalId); $externalId = (string) json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"')); $externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -242,7 +242,7 @@ trait MetaCollection
public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface public function externalIdDoesNotEnd(string $externalId): GroupCollectorInterface
{ {
$externalId = (string) \Safe\json_encode($externalId); $externalId = (string) json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"')); $externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -254,7 +254,7 @@ trait MetaCollection
public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface public function externalIdDoesNotStart(string $externalId): GroupCollectorInterface
{ {
$externalId = (string) \Safe\json_encode($externalId); $externalId = (string) json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"')); $externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -266,7 +266,7 @@ trait MetaCollection
public function externalIdEnds(string $externalId): GroupCollectorInterface public function externalIdEnds(string $externalId): GroupCollectorInterface
{ {
$externalId = (string) \Safe\json_encode($externalId); $externalId = (string) json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"')); $externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -278,7 +278,7 @@ trait MetaCollection
public function externalIdStarts(string $externalId): GroupCollectorInterface public function externalIdStarts(string $externalId): GroupCollectorInterface
{ {
$externalId = (string) \Safe\json_encode($externalId); $externalId = (string) json_encode($externalId);
$externalId = str_replace('\\', '\\\\', trim($externalId, '"')); $externalId = str_replace('\\', '\\\\', trim($externalId, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -291,7 +291,7 @@ trait MetaCollection
public function externalUrlContains(string $url): GroupCollectorInterface public function externalUrlContains(string $url): GroupCollectorInterface
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$url = (string) \Safe\json_encode($url); $url = (string) json_encode($url);
$url = str_replace('\\', '\\\\', trim($url, '"')); $url = str_replace('\\', '\\\\', trim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url'); $this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereLike('journal_meta.data', sprintf('%%%s%%', $url)); $this->query->whereLike('journal_meta.data', sprintf('%%%s%%', $url));
@@ -302,7 +302,7 @@ trait MetaCollection
public function externalUrlDoesNotContain(string $url): GroupCollectorInterface public function externalUrlDoesNotContain(string $url): GroupCollectorInterface
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$url = (string) \Safe\json_encode($url); $url = (string) json_encode($url);
$url = str_replace('\\', '\\\\', trim($url, '"')); $url = str_replace('\\', '\\\\', trim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url'); $this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s%%', $url)); $this->query->whereNotLike('journal_meta.data', sprintf('%%%s%%', $url));
@@ -313,7 +313,7 @@ trait MetaCollection
public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface public function externalUrlDoesNotEnd(string $url): GroupCollectorInterface
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$url = (string) \Safe\json_encode($url); $url = (string) json_encode($url);
$url = str_replace('\\', '\\\\', ltrim($url, '"')); $url = str_replace('\\', '\\\\', ltrim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url'); $this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereNotLike('journal_meta.data', sprintf('%%%s', $url)); $this->query->whereNotLike('journal_meta.data', sprintf('%%%s', $url));
@@ -324,7 +324,7 @@ trait MetaCollection
public function externalUrlDoesNotStart(string $url): GroupCollectorInterface public function externalUrlDoesNotStart(string $url): GroupCollectorInterface
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$url = (string) \Safe\json_encode($url); $url = (string) json_encode($url);
$url = str_replace('\\', '\\\\', rtrim($url, '"')); $url = str_replace('\\', '\\\\', rtrim($url, '"'));
// var_dump($url); // var_dump($url);
@@ -337,7 +337,7 @@ trait MetaCollection
public function externalUrlEnds(string $url): GroupCollectorInterface public function externalUrlEnds(string $url): GroupCollectorInterface
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$url = (string) \Safe\json_encode($url); $url = (string) json_encode($url);
$url = str_replace('\\', '\\\\', ltrim($url, '"')); $url = str_replace('\\', '\\\\', ltrim($url, '"'));
$this->query->where('journal_meta.name', '=', 'external_url'); $this->query->where('journal_meta.name', '=', 'external_url');
$this->query->whereLike('journal_meta.data', sprintf('%%%s', $url)); $this->query->whereLike('journal_meta.data', sprintf('%%%s', $url));
@@ -348,7 +348,7 @@ trait MetaCollection
public function externalUrlStarts(string $url): GroupCollectorInterface public function externalUrlStarts(string $url): GroupCollectorInterface
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$url = (string) \Safe\json_encode($url); $url = (string) json_encode($url);
$url = str_replace('\\', '\\\\', rtrim($url, '"')); $url = str_replace('\\', '\\\\', rtrim($url, '"'));
// var_dump($url); // var_dump($url);
@@ -399,7 +399,7 @@ trait MetaCollection
public function internalReferenceContains(string $internalReference): GroupCollectorInterface public function internalReferenceContains(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) \Safe\json_encode($internalReference); $internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
// var_dump($internalReference); // var_dump($internalReference);
// exit; // exit;
@@ -414,7 +414,7 @@ trait MetaCollection
public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface public function internalReferenceDoesNotContain(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) \Safe\json_encode($internalReference); $internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -427,7 +427,7 @@ trait MetaCollection
public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface public function internalReferenceDoesNotEnd(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) \Safe\json_encode($internalReference); $internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -440,7 +440,7 @@ trait MetaCollection
public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface public function internalReferenceDoesNotStart(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) \Safe\json_encode($internalReference); $internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -453,7 +453,7 @@ trait MetaCollection
public function internalReferenceEnds(string $internalReference): GroupCollectorInterface public function internalReferenceEnds(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) \Safe\json_encode($internalReference); $internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -466,7 +466,7 @@ trait MetaCollection
public function internalReferenceStarts(string $internalReference): GroupCollectorInterface public function internalReferenceStarts(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) \Safe\json_encode($internalReference); $internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
@@ -704,7 +704,7 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_id'); $this->query->where('journal_meta.name', '=', 'external_id');
$this->query->where('journal_meta.data', '=', sprintf('%s', \Safe\json_encode($externalId))); $this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($externalId)));
$this->query->whereNull('journal_meta.deleted_at'); $this->query->whereNull('journal_meta.deleted_at');
return $this; return $this;
@@ -714,7 +714,7 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'external_url'); $this->query->where('journal_meta.name', '=', 'external_url');
$this->query->where('journal_meta.data', '=', \Safe\json_encode($url)); $this->query->where('journal_meta.data', '=', json_encode($url));
$this->query->whereNull('journal_meta.deleted_at'); $this->query->whereNull('journal_meta.deleted_at');
return $this; return $this;
@@ -722,12 +722,12 @@ trait MetaCollection
public function setInternalReference(string $internalReference): GroupCollectorInterface public function setInternalReference(string $internalReference): GroupCollectorInterface
{ {
$internalReference = (string) \Safe\json_encode($internalReference); $internalReference = (string) json_encode($internalReference);
$internalReference = str_replace('\\', '\\\\', trim($internalReference, '"')); $internalReference = str_replace('\\', '\\\\', trim($internalReference, '"'));
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'internal_reference'); $this->query->where('journal_meta.name', '=', 'internal_reference');
$this->query->where('journal_meta.data', '=', sprintf('%s', \Safe\json_encode($internalReference))); $this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($internalReference)));
$this->query->whereNull('journal_meta.deleted_at'); $this->query->whereNull('journal_meta.deleted_at');
return $this; return $this;
@@ -737,7 +737,7 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'recurrence_id'); $this->query->where('journal_meta.name', '=', 'recurrence_id');
$this->query->where('journal_meta.data', '=', sprintf('%s', \Safe\json_encode($recurringId))); $this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($recurringId)));
$this->query->whereNull('journal_meta.deleted_at'); $this->query->whereNull('journal_meta.deleted_at');
return $this; return $this;
@@ -747,7 +747,7 @@ trait MetaCollection
{ {
$this->joinMetaDataTables(); $this->joinMetaDataTables();
$this->query->where('journal_meta.name', '=', 'sepa_ct_id'); $this->query->where('journal_meta.name', '=', 'sepa_ct_id');
$this->query->where('journal_meta.data', '=', sprintf('%s', \Safe\json_encode($sepaCT))); $this->query->where('journal_meta.data', '=', sprintf('%s', json_encode($sepaCT)));
$this->query->whereNull('journal_meta.deleted_at'); $this->query->whereNull('journal_meta.deleted_at');
return $this; return $this;

View File

@@ -593,7 +593,7 @@ class GroupCollector implements GroupCollectorInterface
if (array_key_exists('meta_name', $result) && in_array($result['meta_name'], $dates, true)) { if (array_key_exists('meta_name', $result) && in_array($result['meta_name'], $dates, true)) {
$name = $result['meta_name']; $name = $result['meta_name'];
if (array_key_exists('meta_data', $result) && '' !== (string) $result['meta_data']) { if (array_key_exists('meta_data', $result) && '' !== (string) $result['meta_data']) {
$result[$name] = Carbon::createFromFormat('!Y-m-d', substr((string) \Safe\json_decode($result['meta_data']), 0, 10)); $result[$name] = Carbon::createFromFormat('!Y-m-d', substr((string) json_decode($result['meta_data']), 0, 10));
} }
} }

View File

@@ -46,7 +46,7 @@ class Sha3SignatureGenerator implements SignatureGeneratorInterface
$json = ''; $json = '';
try { try {
$json = \Safe\json_encode($message->message, JSON_THROW_ON_ERROR); $json = json_encode($message->message, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) { } catch (\JsonException $e) {
app('log')->error('Could not generate hash.'); app('log')->error('Could not generate hash.');
app('log')->error(sprintf('JSON value: %s', $json)); app('log')->error(sprintf('JSON value: %s', $json));

View File

@@ -101,7 +101,7 @@ class ForgotPasswordController extends Controller
*/ */
private function validateHost(): void private function validateHost(): void
{ {
$configuredHost = \Safe\parse_url((string) config('app.url'), PHP_URL_HOST); $configuredHost = parse_url((string) config('app.url'), PHP_URL_HOST);
if (false === $configuredHost || null === $configuredHost) { if (false === $configuredHost || null === $configuredHost) {
throw new FireflyException('Please set a valid and correct Firefly III URL in the APP_URL environment variable.'); throw new FireflyException('Please set a valid and correct Firefly III URL in the APP_URL environment variable.');
} }

View File

@@ -468,14 +468,14 @@ class AccountController extends Controller
Log::debug('Balances exist at:'); Log::debug('Balances exist at:');
foreach ($range as $key => $value) { foreach ($range as $key => $value) {
$newRange[] = ['date' => $key, 'info' => $value]; $newRange[] = ['date' => $key, 'info' => $value];
Log::debug(sprintf('%d - %s (%s)', count($newRange) - 1, $key, \Safe\json_encode($value))); Log::debug(sprintf('%d - %s (%s)', count($newRange) - 1, $key, json_encode($value)));
} }
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[0]['date'])->endOfDay(); $carbon = Carbon::createFromFormat('Y-m-d', $newRange[0]['date'])->endOfDay();
Log::debug(sprintf('Start of loop, $carbon is %s', $carbon->format('Y-m-d H:i:s'))); Log::debug(sprintf('Start of loop, $carbon is %s', $carbon->format('Y-m-d H:i:s')));
while ($end->gte($current)) { while ($end->gte($current)) {
$momentBalance = $previous; $momentBalance = $previous;
// $theDate = $current->format('Y-m-d'); // $theDate = $current->format('Y-m-d');
Log::debug(sprintf('Now at %s, with momentBalance %s', $current->format('Y-m-d H:i:s'), \Safe\json_encode($momentBalance))); Log::debug(sprintf('Now at %s, with momentBalance %s', $current->format('Y-m-d H:i:s'), json_encode($momentBalance)));
// loop over the array with balances, find one that is earlier or on the same day. // loop over the array with balances, find one that is earlier or on the same day.
while ($carbon->lte($current) && array_key_exists($expectedIndex, $newRange)) { while ($carbon->lte($current) && array_key_exists($expectedIndex, $newRange)) {
@@ -490,7 +490,7 @@ class AccountController extends Controller
$carbon = Carbon::createFromFormat('Y-m-d', $newRange[$expectedIndex]['date'])->endOfDay(); $carbon = Carbon::createFromFormat('Y-m-d', $newRange[$expectedIndex]['date'])->endOfDay();
} }
} }
Log::debug(sprintf('momentBalance is now %s', \Safe\json_encode($momentBalance))); Log::debug(sprintf('momentBalance is now %s', json_encode($momentBalance)));
$return = $this->updateChartKeys($return, $momentBalance); $return = $this->updateChartKeys($return, $momentBalance);
$previous = $momentBalance; $previous = $momentBalance;

View File

@@ -83,15 +83,15 @@ abstract class Controller extends BaseController
if ('true' === request()->get('force_default_layout') && 'v2' === config('view.layout')) { if ('true' === request()->get('force_default_layout') && 'v2' === config('view.layout')) {
//config('view.layout','v1'); //config('view.layout','v1');
Config::set('view.layout', 'v1'); Config::set('view.layout', 'v1');
View::getFinder()->setPaths([\Safe\realpath(base_path('resources/views'))]); // @phpstan-ignore-line View::getFinder()->setPaths([realpath(base_path('resources/views'))]); // @phpstan-ignore-line
} }
View::share('authGuard', $authGuard); View::share('authGuard', $authGuard);
View::share('logoutUrl', $logoutUrl); View::share('logoutUrl', $logoutUrl);
// upload size // upload size
$maxFileSize = Steam::phpBytes((string) \Safe\ini_get('upload_max_filesize')); $maxFileSize = Steam::phpBytes((string) ini_get('upload_max_filesize'));
$maxPostSize = Steam::phpBytes((string) \Safe\ini_get('post_max_size')); $maxPostSize = Steam::phpBytes((string) ini_get('post_max_size'));
$uploadSize = min($maxFileSize, $maxPostSize); $uploadSize = min($maxFileSize, $maxPostSize);
View::share('uploadSize', $uploadSize); View::share('uploadSize', $uploadSize);

View File

@@ -139,7 +139,7 @@ class DebugController extends Controller
if ($handler instanceof RotatingFileHandler) { if ($handler instanceof RotatingFileHandler) {
$logFile = $handler->getUrl(); $logFile = $handler->getUrl();
if (null !== $logFile && file_exists($logFile)) { if (null !== $logFile && file_exists($logFile)) {
$logContent = \Safe\file_get_contents($logFile); $logContent = file_get_contents($logFile);
} }
} }
} }
@@ -164,8 +164,8 @@ class DebugController extends Controller
private function getSystemInformation(): array private function getSystemInformation(): array
{ {
$maxFileSize = Steam::phpBytes((string) \Safe\ini_get('upload_max_filesize')); $maxFileSize = Steam::phpBytes((string) ini_get('upload_max_filesize'));
$maxPostSize = Steam::phpBytes((string) \Safe\ini_get('post_max_size')); $maxPostSize = Steam::phpBytes((string) ini_get('post_max_size'));
$drivers = DB::availableDrivers(); $drivers = DB::availableDrivers();
$currentDriver = DB::getDriverName(); $currentDriver = DB::getDriverName();
@@ -177,8 +177,8 @@ class DebugController extends Controller
'interface' => \PHP_SAPI, 'interface' => \PHP_SAPI,
'bits' => \PHP_INT_SIZE * 8, 'bits' => \PHP_INT_SIZE * 8,
'bcscale' => bcscale(), 'bcscale' => bcscale(),
'display_errors' => \Safe\ini_get('display_errors'), 'display_errors' => ini_get('display_errors'),
'error_reporting' => $this->errorReporting((int) \Safe\ini_get('error_reporting')), 'error_reporting' => $this->errorReporting((int) ini_get('error_reporting')),
'upload_size' => min($maxFileSize, $maxPostSize), 'upload_size' => min($maxFileSize, $maxPostSize),
'all_drivers' => $drivers, 'all_drivers' => $drivers,
'current_driver' => $currentDriver, 'current_driver' => $currentDriver,
@@ -197,7 +197,7 @@ class DebugController extends Controller
try { try {
if (file_exists('/var/www/counter-main.txt')) { if (file_exists('/var/www/counter-main.txt')) {
$return['build'] = trim((string) \Safe\file_get_contents('/var/www/counter-main.txt')); $return['build'] = trim((string) file_get_contents('/var/www/counter-main.txt'));
app('log')->debug(sprintf('build is now "%s"', $return['build'])); app('log')->debug(sprintf('build is now "%s"', $return['build']));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -207,7 +207,7 @@ class DebugController extends Controller
try { try {
if (file_exists('/var/www/build-date-main.txt')) { if (file_exists('/var/www/build-date-main.txt')) {
$return['build_date'] = trim((string) \Safe\file_get_contents('/var/www/build-date-main.txt')); $return['build_date'] = trim((string) file_get_contents('/var/www/build-date-main.txt'));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
app('log')->debug('Could not check build date, but thats ok.'); app('log')->debug('Could not check build date, but thats ok.');

View File

@@ -91,7 +91,7 @@ class IndexController extends Controller
$generator->setStart($firstDate); $generator->setStart($firstDate);
$result = $generator->export(); $result = $generator->export();
$name = sprintf('%s_transaction_export.csv', \Safe\date('Y_m_d')); $name = sprintf('%s_transaction_export.csv', date('Y_m_d'));
$quoted = sprintf('"%s"', addcslashes($name, '"\\')); $quoted = sprintf('"%s"', addcslashes($name, '"\\'));
// headers for CSV file. // headers for CSV file.

View File

@@ -153,7 +153,7 @@ class RecurrenceController extends Controller
*/ */
public function suggest(Request $request): JsonResponse public function suggest(Request $request): JsonResponse
{ {
$string = '' === (string) $request->get('date') ? \Safe\date('Y-m-d') : (string) $request->get('date'); $string = '' === (string) $request->get('date') ? date('Y-m-d') : (string) $request->get('date');
$today = today(config('app.timezone'))->startOfDay(); $today = today(config('app.timezone'))->startOfDay();
try { try {

View File

@@ -110,7 +110,7 @@ class PreferencesController extends Controller
if (is_array($fiscalYearStartStr)) { if (is_array($fiscalYearStartStr)) {
$fiscalYearStartStr = '01-01'; $fiscalYearStartStr = '01-01';
} }
$fiscalYearStart = sprintf('%s-%s', \Safe\date('Y'), (string) $fiscalYearStartStr); $fiscalYearStart = sprintf('%s-%s', date('Y'), (string) $fiscalYearStartStr);
$tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data; $tjOptionalFields = Preferences::get('transaction_journal_optional_fields', [])->data;
$availableDarkModes = config('firefly.available_dark_modes'); $availableDarkModes = config('firefly.available_dark_modes');
@@ -149,7 +149,7 @@ class PreferencesController extends Controller
// list of locales also has "equal" which makes it equal to whatever the language is. // list of locales also has "equal" which makes it equal to whatever the language is.
try { try {
$locales = \Safe\json_decode((string) \Safe\file_get_contents(resource_path(sprintf('locales/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR); $locales = json_decode((string) file_get_contents(resource_path(sprintf('locales/%s/locales.json', $language))), true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) { } catch (\JsonException $e) {
app('log')->error($e->getMessage()); app('log')->error($e->getMessage());
$locales = []; $locales = [];
@@ -271,9 +271,9 @@ class PreferencesController extends Controller
// custom fiscal year // custom fiscal year
$customFiscalYear = 1 === (int) $request->get('customFiscalYear'); $customFiscalYear = 1 === (int) $request->get('customFiscalYear');
$string = \Safe\strtotime((string) $request->get('fiscalYearStart')); $string = strtotime((string) $request->get('fiscalYearStart'));
if (false !== $string) { if (false !== $string) {
$fiscalYearStart = \Safe\date('m-d', $string); $fiscalYearStart = date('m-d', $string);
Preferences::set('customFiscalYear', $customFiscalYear); Preferences::set('customFiscalYear', $customFiscalYear);
Preferences::set('fiscalYearStart', $fiscalYearStart); Preferences::set('fiscalYearStart', $fiscalYearStart);
} }

View File

@@ -169,7 +169,7 @@ class InstallController extends Controller
return; return;
} }
\Safe\file_put_contents($publicKey, (string) $key->getPublicKey()); file_put_contents($publicKey, (string) $key->getPublicKey());
\Safe\file_put_contents($privateKey, $key->toString('PKCS1')); file_put_contents($privateKey, $key->toString('PKCS1'));
} }
} }

View File

@@ -116,7 +116,7 @@ class CreateController extends Controller
$accountToTypes = config('firefly.account_to_transaction'); $accountToTypes = config('firefly.account_to_transaction');
$defaultCurrency = $this->defaultCurrency; $defaultCurrency = $this->defaultCurrency;
$previousUrl = $this->rememberPreviousUrl('transactions.create.url'); $previousUrl = $this->rememberPreviousUrl('transactions.create.url');
$parts = \Safe\parse_url($previousUrl); $parts = parse_url($previousUrl);
$search = sprintf('?%s', $parts['query'] ?? ''); $search = sprintf('?%s', $parts['query'] ?? '');
$previousUrl = str_replace($search, '', $previousUrl); $previousUrl = str_replace($search, '', $previousUrl);
if (!is_array($optionalFields)) { if (!is_array($optionalFields)) {

View File

@@ -85,7 +85,7 @@ class EditController extends Controller
$defaultCurrency = $this->defaultCurrency; $defaultCurrency = $this->defaultCurrency;
$cash = $repository->getCashAccount(); $cash = $repository->getCashAccount();
$previousUrl = $this->rememberPreviousUrl('transactions.edit.url'); $previousUrl = $this->rememberPreviousUrl('transactions.edit.url');
$parts = \Safe\parse_url($previousUrl); $parts = parse_url($previousUrl);
$search = sprintf('?%s', $parts['query'] ?? ''); $search = sprintf('?%s', $parts['query'] ?? '');
$previousUrl = str_replace($search, '', $previousUrl); $previousUrl = str_replace($search, '', $previousUrl);

View File

@@ -71,7 +71,7 @@ class AcceptHeaders
// throw bad request if trace id is not a UUID // throw bad request if trace id is not a UUID
$uuid = $request->header('X-Trace-Id'); $uuid = $request->header('X-Trace-Id');
if (is_string($uuid) && '' !== trim($uuid) && (1 !== \Safe\preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)))) { if (is_string($uuid) && '' !== trim($uuid) && (1 !== preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)))) {
throw new BadRequestHttpException('Bad X-Trace-Id header.'); throw new BadRequestHttpException('Bad X-Trace-Id header.');
} }

View File

@@ -143,7 +143,7 @@ class ReportFormRequest extends FormRequest
// validate as date // validate as date
// if regex for YYYY-MM-DD: // if regex for YYYY-MM-DD:
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/'; $pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/';
$result = \Safe\preg_match($pattern, $string); $result = preg_match($pattern, $string);
if (false !== $result && 0 !== $result) { if (false !== $result && 0 !== $result) {
try { try {
$date = new Carbon($parts[1]); $date = new Carbon($parts[1]);
@@ -181,7 +181,7 @@ class ReportFormRequest extends FormRequest
// validate as date // validate as date
// if regex for YYYY-MM-DD: // if regex for YYYY-MM-DD:
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/'; $pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/';
$result = \Safe\preg_match($pattern, $string); $result = preg_match($pattern, $string);
if (false !== $result && 0 !== $result) { if (false !== $result && 0 !== $result) {
try { try {
$date = new Carbon($parts[0]); $date = new Carbon($parts[0]);

View File

@@ -113,7 +113,7 @@ class DownloadExchangeRates implements ShouldQueue
return; return;
} }
$body = (string) $res->getBody(); $body = (string) $res->getBody();
$json = \Safe\json_decode($body, true); $json = json_decode($body, true);
if (false === $json || null === $json) { if (false === $json || null === $json) {
app('log')->warning(sprintf('Trying to grab "%s" resulted in bad JSON.', $url)); app('log')->warning(sprintf('Trying to grab "%s" resulted in bad JSON.', $url));

View File

@@ -46,7 +46,7 @@ class MailError extends Job implements ShouldQueue
$debug = $this->exception; $debug = $this->exception;
unset($debug['stackTrace'], $debug['headers']); unset($debug['stackTrace'], $debug['headers']);
app('log')->error(sprintf('Exception is: %s', \Safe\json_encode($debug))); app('log')->error(sprintf('Exception is: %s', json_encode($debug)));
} }
/** /**
@@ -117,11 +117,11 @@ class MailError extends Job implements ShouldQueue
if (!file_exists($file)) { if (!file_exists($file)) {
Log::debug(sprintf('Wrote new file in "%s"', $file)); Log::debug(sprintf('Wrote new file in "%s"', $file));
\Safe\file_put_contents($file, \Safe\json_encode($limits, JSON_PRETTY_PRINT)); file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));
} }
if (file_exists($file)) { if (file_exists($file)) {
Log::debug(sprintf('Read file in "%s"', $file)); Log::debug(sprintf('Read file in "%s"', $file));
$limits = \Safe\json_decode((string) \Safe\file_get_contents($file), true); $limits = json_decode((string) file_get_contents($file), true);
} }
// limit reached? // limit reached?
foreach ($types as $type => $info) { foreach ($types as $type => $info) {
@@ -149,7 +149,7 @@ class MailError extends Job implements ShouldQueue
} }
++$limits[$type]['sent']; ++$limits[$type]['sent'];
} }
\Safe\file_put_contents($file, \Safe\json_encode($limits, JSON_PRETTY_PRINT)); file_put_contents($file, json_encode($limits, JSON_PRETTY_PRINT));
Log::debug('No limits reached, return FALSE.'); Log::debug('No limits reached, return FALSE.');
return false; return false;

View File

@@ -43,7 +43,7 @@ class InvitationMail extends Mailable
*/ */
public function __construct(public string $invitee, public string $admin, public string $url) public function __construct(public string $invitee, public string $admin, public string $url)
{ {
$this->host = (string) \Safe\parse_url($this->url, PHP_URL_HOST); $this->host = (string) parse_url($this->url, PHP_URL_HOST);
} }
/** /**

View File

@@ -47,11 +47,11 @@ class AccountMeta extends Model
public function getDataAttribute(mixed $value): string public function getDataAttribute(mixed $value): string
{ {
return (string) \Safe\json_decode($value, true); return (string) json_decode($value, true);
} }
public function setDataAttribute(mixed $value): void public function setDataAttribute(mixed $value): void
{ {
$this->attributes['data'] = \Safe\json_encode($value); $this->attributes['data'] = json_encode($value);
} }
} }

View File

@@ -50,7 +50,7 @@ class Configuration extends Model
*/ */
public function getDataAttribute($value) public function getDataAttribute($value)
{ {
return \Safe\json_decode($value); return json_decode($value);
} }
/** /**
@@ -58,6 +58,6 @@ class Configuration extends Model
*/ */
public function setDataAttribute($value): void public function setDataAttribute($value): void
{ {
$this->attributes['data'] = \Safe\json_encode($value); $this->attributes['data'] = json_encode($value);
} }
} }

View File

@@ -52,7 +52,7 @@ class TransactionJournalMeta extends Model
*/ */
public function getDataAttribute($value) public function getDataAttribute($value)
{ {
return \Safe\json_decode($value, false); return json_decode($value, false);
} }
/** /**
@@ -60,7 +60,7 @@ class TransactionJournalMeta extends Model
*/ */
public function setDataAttribute($value): void public function setDataAttribute($value): void
{ {
$data = \Safe\json_encode($value); $data = json_encode($value);
$this->attributes['data'] = $data; $this->attributes['data'] = $data;
$this->attributes['hash'] = hash('sha256', (string) $data); $this->attributes['hash'] = hash('sha256', (string) $data);
} }

View File

@@ -46,7 +46,7 @@ class AppServiceProvider extends ServiceProvider
'Cache-Control' => 'no-store', 'Cache-Control' => 'no-store',
]; ];
$uuid = (string) request()->header('X-Trace-Id'); $uuid = (string) request()->header('X-Trace-Id');
if ('' !== trim($uuid) && (1 === \Safe\preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)))) { if ('' !== trim($uuid) && (1 === preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)))) {
$headers['X-Trace-Id'] = $uuid; $headers['X-Trace-Id'] = $uuid;
} }

View File

@@ -108,7 +108,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
->where('accounts.active', true) ->where('accounts.active', true)
->where( ->where(
static function (EloquentBuilder $q1) use ($number): void { static function (EloquentBuilder $q1) use ($number): void {
$json = \Safe\json_encode($number); $json = json_encode($number);
$q1->where('account_meta.name', '=', 'account_number'); $q1->where('account_meta.name', '=', 'account_number');
$q1->where('account_meta.data', '=', $json); $q1->where('account_meta.data', '=', $json);
} }

View File

@@ -81,7 +81,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
} }
// is being used in accounts: // is being used in accounts:
$meta = AccountMeta::where('name', 'currency_id')->where('data', \Safe\json_encode((string) $currency->id))->count(); $meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((string) $currency->id))->count();
if ($meta > 0) { if ($meta > 0) {
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta)); Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
@@ -89,7 +89,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
} }
// second search using integer check. // second search using integer check.
$meta = AccountMeta::where('name', 'currency_id')->where('data', \Safe\json_encode((int) $currency->id))->count(); $meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((int) $currency->id))->count();
if ($meta > 0) { if ($meta > 0) {
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta)); Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
@@ -117,7 +117,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
// is being used in accounts (as integer) // is being used in accounts (as integer)
$meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id') $meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
->whereNull('accounts.deleted_at') ->whereNull('accounts.deleted_at')
->where('account_meta.name', 'currency_id')->where('account_meta.data', \Safe\json_encode($currency->id))->count() ->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode($currency->id))->count()
; ;
if ($meta > 0) { if ($meta > 0) {
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta)); Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));

View File

@@ -68,16 +68,16 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
$set $set
= TransactionJournalMeta::where(static function (Builder $q1) use ($recurrence): void { = TransactionJournalMeta::where(static function (Builder $q1) use ($recurrence): void {
$q1->where('name', 'recurrence_id'); $q1->where('name', 'recurrence_id');
$q1->where('data', \Safe\json_encode((string) $recurrence->id)); $q1->where('data', json_encode((string) $recurrence->id));
})->get(['journal_meta.transaction_journal_id']); })->get(['journal_meta.transaction_journal_id']);
// there are X journals made for this recurrence. Any of them meant for today? // there are X journals made for this recurrence. Any of them meant for today?
foreach ($set as $journalMeta) { foreach ($set as $journalMeta) {
$count = TransactionJournalMeta::where(static function (Builder $q2) use ($date): void { $count = TransactionJournalMeta::where(static function (Builder $q2) use ($date): void {
$string = (string) $date; $string = (string) $date;
app('log')->debug(sprintf('Search for date: %s', \Safe\json_encode($string))); app('log')->debug(sprintf('Search for date: %s', json_encode($string)));
$q2->where('name', 'recurrence_date'); $q2->where('name', 'recurrence_date');
$q2->where('data', \Safe\json_encode($string)); $q2->where('data', json_encode($string));
}) })
->where('transaction_journal_id', $journalMeta->transaction_journal_id) ->where('transaction_journal_id', $journalMeta->transaction_journal_id)
->count() ->count()
@@ -232,7 +232,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
return TransactionJournalMeta::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') return TransactionJournalMeta::leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id')
->where('transaction_journals.user_id', $this->user->id) ->where('transaction_journals.user_id', $this->user->id)
->where('journal_meta.name', '=', 'recurrence_id') ->where('journal_meta.name', '=', 'recurrence_id')
->where('journal_meta.data', '=', \Safe\json_encode((string) $recurrence->id)) ->where('journal_meta.data', '=', json_encode((string) $recurrence->id))
->get(['journal_meta.transaction_journal_id'])->pluck('transaction_journal_id')->toArray() ->get(['journal_meta.transaction_journal_id'])->pluck('transaction_journal_id')->toArray()
; ;
} }
@@ -272,7 +272,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
/** @var RecurrenceMeta $meta */ /** @var RecurrenceMeta $meta */
foreach ($transaction->recurrenceTransactionMeta as $meta) { foreach ($transaction->recurrenceTransactionMeta as $meta) {
if ('tags' === $meta->name && '' !== $meta->value) { if ('tags' === $meta->name && '' !== $meta->value) {
$tags = \Safe\json_decode($meta->value, true, 512, JSON_THROW_ON_ERROR); $tags = json_decode($meta->value, true, 512, JSON_THROW_ON_ERROR);
} }
} }
@@ -285,7 +285,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
->whereNull('transaction_journals.deleted_at') ->whereNull('transaction_journals.deleted_at')
->where('transaction_journals.user_id', $this->user->id) ->where('transaction_journals.user_id', $this->user->id)
->where('name', 'recurrence_id') ->where('name', 'recurrence_id')
->where('data', \Safe\json_encode((string) $recurrence->id)) ->where('data', json_encode((string) $recurrence->id))
->get()->pluck('transaction_journal_id')->toArray() ->get()->pluck('transaction_journal_id')->toArray()
; ;
$search = []; $search = [];
@@ -311,7 +311,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte
->whereNull('transaction_journals.deleted_at') ->whereNull('transaction_journals.deleted_at')
->where('transaction_journals.user_id', $this->user->id) ->where('transaction_journals.user_id', $this->user->id)
->where('name', 'recurrence_id') ->where('name', 'recurrence_id')
->where('data', \Safe\json_encode((string) $recurrence->id)) ->where('data', json_encode((string) $recurrence->id))
->get()->pluck('transaction_journal_id')->toArray() ->get()->pluck('transaction_journal_id')->toArray()
; ;
$search = []; $search = [];

View File

@@ -304,7 +304,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
$return = []; $return = [];
foreach ($query as $row) { foreach ($query as $row) {
$return[$row->name] = new Carbon(\Safe\json_decode($row->data, true, 512, JSON_THROW_ON_ERROR)); $return[$row->name] = new Carbon(json_decode($row->data, true, 512, JSON_THROW_ON_ERROR));
} }
return new NullArrayObject($return); return new NullArrayObject($return);
@@ -324,7 +324,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
$return = []; $return = [];
foreach ($query as $row) { foreach ($query as $row) {
$return[$row->name] = \Safe\json_decode($row->data); $return[$row->name] = json_decode($row->data);
} }
return new NullArrayObject($return); return new NullArrayObject($return);

View File

@@ -54,7 +54,7 @@ class UserRepository implements UserRepositoryInterface
// save old email as pref // save old email as pref
app('preferences')->setForUser($user, 'previous_email_latest', $oldEmail); app('preferences')->setForUser($user, 'previous_email_latest', $oldEmail);
app('preferences')->setForUser($user, 'previous_email_'.\Safe\date('Y-m-d-H-i-s'), $oldEmail); app('preferences')->setForUser($user, 'previous_email_'.date('Y-m-d-H-i-s'), $oldEmail);
// set undo and confirm token: // set undo and confirm token:
app('preferences')->setForUser($user, 'email_change_undo_token', bin2hex(random_bytes(16))); app('preferences')->setForUser($user, 'email_change_undo_token', bin2hex(random_bytes(16)));
@@ -389,7 +389,7 @@ class UserRepository implements UserRepositoryInterface
// save old email as pref // save old email as pref
app('preferences')->setForUser($user, 'admin_previous_email_latest', $oldEmail); app('preferences')->setForUser($user, 'admin_previous_email_latest', $oldEmail);
app('preferences')->setForUser($user, 'admin_previous_email_'.\Safe\date('Y-m-d-H-i-s'), $oldEmail); app('preferences')->setForUser($user, 'admin_previous_email_'.date('Y-m-d-H-i-s'), $oldEmail);
$user->email = $newEmail; $user->email = $newEmail;
$user->save(); $user->save();

View File

@@ -66,7 +66,7 @@ class AccountRepository implements AccountRepositoryInterface
->where('accounts.active', true) ->where('accounts.active', true)
->where( ->where(
static function (EloquentBuilder $q1) use ($number): void { static function (EloquentBuilder $q1) use ($number): void {
$json = \Safe\json_encode($number); $json = json_encode($number);
$q1->where('account_meta.name', '=', 'account_number'); $q1->where('account_meta.name', '=', 'account_number');
$q1->where('account_meta.data', '=', $json); $q1->where('account_meta.data', '=', $json);
} }

View File

@@ -81,7 +81,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
} }
// is being used in accounts: // is being used in accounts:
$meta = AccountMeta::where('name', 'currency_id')->where('data', \Safe\json_encode((string) $currency->id))->count(); $meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((string) $currency->id))->count();
if ($meta > 0) { if ($meta > 0) {
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta)); Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
@@ -89,7 +89,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
} }
// second search using integer check. // second search using integer check.
$meta = AccountMeta::where('name', 'currency_id')->where('data', \Safe\json_encode((int) $currency->id))->count(); $meta = AccountMeta::where('name', 'currency_id')->where('data', json_encode((int) $currency->id))->count();
if ($meta > 0) { if ($meta > 0) {
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta)); Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
@@ -117,7 +117,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
// is being used in accounts (as integer) // is being used in accounts (as integer)
$meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id') $meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
->whereNull('accounts.deleted_at') ->whereNull('accounts.deleted_at')
->where('account_meta.name', 'currency_id')->where('account_meta.data', \Safe\json_encode($currency->id))->count() ->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode($currency->id))->count()
; ;
if ($meta > 0) { if ($meta > 0) {
Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta)); Log::info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));

View File

@@ -63,7 +63,7 @@ class IsValidBulkClause implements ValidationRule
private function basicValidation(string $value): bool private function basicValidation(string $value): bool
{ {
try { try {
$array = \Safe\json_decode($value, true, 8, JSON_THROW_ON_ERROR); $array = json_decode($value, true, 8, JSON_THROW_ON_ERROR);
} catch (\JsonException) { } catch (\JsonException) {
$this->error = (string) trans('validation.json'); $this->error = (string) trans('validation.json');

View File

@@ -40,7 +40,7 @@ class IsValidPositiveAmount implements ValidationRule
{ {
if (is_array($value)) { if (is_array($value)) {
$fail('validation.numeric')->translate(); $fail('validation.numeric')->translate();
$message = sprintf('IsValidPositiveAmount: "%s" is not a number.', \Safe\json_encode($value)); $message = sprintf('IsValidPositiveAmount: "%s" is not a number.', json_encode($value));
Log::debug($message); Log::debug($message);
Log::channel('audit')->info($message); Log::channel('audit')->info($message);

View File

@@ -133,7 +133,7 @@ class UniqueAccountNumber implements ValidationRule
->where('accounts.user_id', auth()->user()->id) ->where('accounts.user_id', auth()->user()->id)
->where('account_types.type', $type) ->where('account_types.type', $type)
->where('account_meta.name', '=', 'account_number') ->where('account_meta.name', '=', 'account_number')
->where('account_meta.data', \Safe\json_encode($accountNumber)) ->where('account_meta.data', json_encode($accountNumber))
; ;
if (null !== $this->account) { if (null !== $this->account) {

View File

@@ -99,7 +99,7 @@ class UpdateRequest implements UpdateRequestInterface
$body = (string) $res->getBody(); $body = (string) $res->getBody();
try { try {
$json = \Safe\json_decode($body, true, 512, JSON_THROW_ON_ERROR); $json = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
} catch (\JsonException) { } catch (\JsonException) {
Log::error('Body is not valid JSON'); Log::error('Body is not valid JSON');
Log::error($body); Log::error($body);

View File

@@ -260,7 +260,7 @@ trait JournalServiceTrait
if (null === $account) { if (null === $account) {
// final attempt, create it. // final attempt, create it.
if (AccountTypeEnum::ASSET->value === $preferredType) { if (AccountTypeEnum::ASSET->value === $preferredType) {
throw new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s', \Safe\json_encode($data))); throw new FireflyException(sprintf('TransactionFactory: Cannot create asset account with these values: %s', json_encode($data)));
} }
// fix name of account if only IBAN is given: // fix name of account if only IBAN is given:
if ('' === (string) $data['name'] && '' !== (string) $data['iban']) { if ('' === (string) $data['name'] && '' !== (string) $data['iban']) {

View File

@@ -307,9 +307,9 @@ trait RecurringTransactionTrait
/** @var null|RecurrenceMeta $entry */ /** @var null|RecurrenceMeta $entry */
$entry = $transaction->recurrenceTransactionMeta()->where('name', 'tags')->first(); $entry = $transaction->recurrenceTransactionMeta()->where('name', 'tags')->first();
if (null === $entry) { if (null === $entry) {
$entry = RecurrenceTransactionMeta::create(['rt_id' => $transaction->id, 'name' => 'tags', 'value' => \Safe\json_encode($tags)]); $entry = RecurrenceTransactionMeta::create(['rt_id' => $transaction->id, 'name' => 'tags', 'value' => json_encode($tags)]);
} }
$entry->value = \Safe\json_encode($tags); $entry->value = json_encode($tags);
$entry->save(); $entry->save();
} }
if (0 === count($tags)) { if (0 === count($tags)) {

View File

@@ -80,7 +80,7 @@ class StandardWebhookSender implements WebhookSenderInterface
app('log')->debug(sprintf('Trying to send webhook message #%d', $this->message->id)); app('log')->debug(sprintf('Trying to send webhook message #%d', $this->message->id));
try { try {
$json = \Safe\json_encode($this->message->message, JSON_THROW_ON_ERROR); $json = json_encode($this->message->message, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) { } catch (\JsonException $e) {
app('log')->error('Did not send message because of a JSON error.'); app('log')->error('Did not send message because of a JSON error.');
app('log')->error($e->getMessage()); app('log')->error($e->getMessage());

View File

@@ -67,7 +67,7 @@ class RemoteUserGuard implements Guard
if (function_exists('apache_request_headers')) { if (function_exists('apache_request_headers')) {
Log::debug('Use apache_request_headers to find user ID.'); Log::debug('Use apache_request_headers to find user ID.');
$userID = request()->server($header) ?? \Safe\apache_request_headers()[$header] ?? null; $userID = request()->server($header) ?? apache_request_headers()[$header] ?? null;
} }
if (null === $userID || '' === $userID) { if (null === $userID || '' === $userID) {
@@ -85,7 +85,7 @@ class RemoteUserGuard implements Guard
$header = config('auth.guard_email'); $header = config('auth.guard_email');
if (null !== $header) { if (null !== $header) {
$emailAddress = (string) (request()->server($header) ?? \Safe\apache_request_headers()[$header] ?? null); $emailAddress = (string) (request()->server($header) ?? apache_request_headers()[$header] ?? null);
$preference = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email'); $preference = app('preferences')->getForUser($retrievedUser, 'remote_guard_alt_email');
if ('' !== $emailAddress && null === $preference && $emailAddress !== $userID) { if ('' !== $emailAddress && null === $preference && $emailAddress !== $userID) {

View File

@@ -79,7 +79,7 @@ class CacheProperties
$content = ''; $content = '';
foreach ($this->properties as $property) { foreach ($this->properties as $property) {
try { try {
$content = sprintf('%s%s', $content, \Safe\json_encode($property, JSON_THROW_ON_ERROR)); $content = sprintf('%s%s', $content, json_encode($property, JSON_THROW_ON_ERROR));
} catch (\JsonException) { } catch (\JsonException) {
// @ignoreException // @ignoreException
$content = sprintf('%s%s', $content, hash('sha256', (string) time())); $content = sprintf('%s%s', $content, hash('sha256', (string) time()));

View File

@@ -63,7 +63,7 @@ class UpdateCheckCronjob extends AbstractCronjob
$this->jobFired = false; $this->jobFired = false;
$this->jobErrored = false; $this->jobErrored = false;
$this->jobSucceeded = true; $this->jobSucceeded = true;
$this->message = sprintf('Checked for updates less than a week ago (on %s).', \Safe\date('Y-m-d H:i:s', $lastCheckTime->data)); $this->message = sprintf('Checked for updates less than a week ago (on %s).', date('Y-m-d H:i:s', $lastCheckTime->data));
return; return;
} }

View File

@@ -106,8 +106,8 @@ trait CreateStuff
Log::alert('NO OAuth keys were found. They have been created.'); Log::alert('NO OAuth keys were found. They have been created.');
\Safe\file_put_contents($publicKey, (string) $key->getPublicKey()); file_put_contents($publicKey, (string) $key->getPublicKey());
\Safe\file_put_contents($privateKey, $key->toString('PKCS1')); file_put_contents($privateKey, $key->toString('PKCS1'));
} }
/** /**

View File

@@ -46,7 +46,7 @@ trait RequestInformation
final protected function getDomain(): string // get request info final protected function getDomain(): string // get request info
{ {
$url = url()->to('/'); $url = url()->to('/');
$parts = \Safe\parse_url($url); $parts = parse_url($url);
return $parts['host'] ?? ''; return $parts['host'] ?? '';
} }

View File

@@ -85,7 +85,7 @@ class ParseDateString
// if regex for YYYY-MM-DD: // if regex for YYYY-MM-DD:
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/'; $pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/';
$result = \Safe\preg_match($pattern, $date); $result = preg_match($pattern, $date);
if (false !== $result && 0 !== $result) { if (false !== $result && 0 !== $result) {
return $this->parseDefaultDate($date); return $this->parseDefaultDate($date);
} }
@@ -182,7 +182,7 @@ class ParseDateString
// verify if correct // verify if correct
$pattern = '/[+-]\d+[wqmdy]/'; $pattern = '/[+-]\d+[wqmdy]/';
$result = \Safe\preg_match($pattern, $part); $result = preg_match($pattern, $part);
if (0 === $result || false === $result) { if (0 === $result || false === $result) {
app('log')->error(sprintf('Part "%s" does not match regular expression. Will be skipped.', $part)); app('log')->error(sprintf('Part "%s" does not match regular expression. Will be skipped.', $part));
@@ -256,7 +256,7 @@ class ParseDateString
protected function isDayRange(string $date): bool protected function isDayRange(string $date): bool
{ {
$pattern = '/^xxxx-xx-(0[1-9]|[12]\d|3[01])$/'; $pattern = '/^xxxx-xx-(0[1-9]|[12]\d|3[01])$/';
$result = \Safe\preg_match($pattern, $date); $result = preg_match($pattern, $date);
if (false !== $result && 0 !== $result) { if (false !== $result && 0 !== $result) {
app('log')->debug(sprintf('"%s" is a day range.', $date)); app('log')->debug(sprintf('"%s" is a day range.', $date));
@@ -283,7 +283,7 @@ class ParseDateString
{ {
// if regex for xxxx-MM-xx: // if regex for xxxx-MM-xx:
$pattern = '/^xxxx-(0[1-9]|1[012])-xx$/'; $pattern = '/^xxxx-(0[1-9]|1[012])-xx$/';
$result = \Safe\preg_match($pattern, $date); $result = preg_match($pattern, $date);
if (false !== $result && 0 !== $result) { if (false !== $result && 0 !== $result) {
app('log')->debug(sprintf('"%s" is a month range.', $date)); app('log')->debug(sprintf('"%s" is a month range.', $date));
@@ -311,7 +311,7 @@ class ParseDateString
{ {
// if regex for YYYY-xx-xx: // if regex for YYYY-xx-xx:
$pattern = '/^(19|20)\d\d-xx-xx$/'; $pattern = '/^(19|20)\d\d-xx-xx$/';
$result = \Safe\preg_match($pattern, $date); $result = preg_match($pattern, $date);
if (false !== $result && 0 !== $result) { if (false !== $result && 0 !== $result) {
app('log')->debug(sprintf('"%s" is a year range.', $date)); app('log')->debug(sprintf('"%s" is a year range.', $date));
@@ -339,7 +339,7 @@ class ParseDateString
{ {
// if regex for xxxx-MM-DD: // if regex for xxxx-MM-DD:
$pattern = '/^xxxx-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/'; $pattern = '/^xxxx-(0[1-9]|1[012])-(0[1-9]|[12]\d|3[01])$/';
$result = \Safe\preg_match($pattern, $date); $result = preg_match($pattern, $date);
if (false !== $result && 0 !== $result) { if (false !== $result && 0 !== $result) {
app('log')->debug(sprintf('"%s" is a month/day range.', $date)); app('log')->debug(sprintf('"%s" is a month/day range.', $date));
@@ -368,7 +368,7 @@ class ParseDateString
{ {
// if regex for YYYY-xx-DD: // if regex for YYYY-xx-DD:
$pattern = '/^(19|20)\d\d-xx-(0[1-9]|[12]\d|3[01])$/'; $pattern = '/^(19|20)\d\d-xx-(0[1-9]|[12]\d|3[01])$/';
$result = \Safe\preg_match($pattern, $date); $result = preg_match($pattern, $date);
if (false !== $result && 0 !== $result) { if (false !== $result && 0 !== $result) {
app('log')->debug(sprintf('"%s" is a day/year range.', $date)); app('log')->debug(sprintf('"%s" is a day/year range.', $date));
@@ -397,7 +397,7 @@ class ParseDateString
{ {
// if regex for YYYY-MM-xx: // if regex for YYYY-MM-xx:
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-xx$/'; $pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-xx$/';
$result = \Safe\preg_match($pattern, $date); $result = preg_match($pattern, $date);
if (false !== $result && 0 !== $result) { if (false !== $result && 0 !== $result) {
app('log')->debug(sprintf('"%s" is a month/year range.', $date)); app('log')->debug(sprintf('"%s" is a month/year range.', $date));

View File

@@ -125,7 +125,7 @@ trait ConvertsDataTypes
$string = str_replace($this->characters, "\x20", $string); $string = str_replace($this->characters, "\x20", $string);
// clear zalgo text (TODO also in API v2) // clear zalgo text (TODO also in API v2)
$string = \Safe\preg_replace('/(\pM{2})\pM+/u', '\1', $string); $string = preg_replace('/(\pM{2})\pM+/u', '\1', $string);
return trim((string) $string); return trim((string) $string);
} }

View File

@@ -81,7 +81,7 @@ class AccountSearch implements GenericSearchInterface
// meta data: // meta data:
$searchQuery->orWhere( $searchQuery->orWhere(
static function (Builder $q) use ($originalQuery): void { static function (Builder $q) use ($originalQuery): void {
$json = \Safe\json_encode($originalQuery, JSON_THROW_ON_ERROR); $json = json_encode($originalQuery, JSON_THROW_ON_ERROR);
$q->where('account_meta.name', '=', 'account_number'); $q->where('account_meta.name', '=', 'account_number');
$q->whereLike('account_meta.data', $json); $q->whereLike('account_meta.data', $json);
} }
@@ -108,7 +108,7 @@ class AccountSearch implements GenericSearchInterface
// meta data: // meta data:
$searchQuery->Where( $searchQuery->Where(
static function (Builder $q) use ($originalQuery): void { static function (Builder $q) use ($originalQuery): void {
$json = \Safe\json_encode($originalQuery, JSON_THROW_ON_ERROR); $json = json_encode($originalQuery, JSON_THROW_ON_ERROR);
$q->where('account_meta.name', 'account_number'); $q->where('account_meta.name', 'account_number');
$q->where('account_meta.data', $json); $q->where('account_meta.data', $json);
} }

View File

@@ -54,7 +54,7 @@ class GdbotsQueryParser implements QueryParserInterface
return new NodeGroup($nodes); return new NodeGroup($nodes);
} catch (\LogicException|\TypeError $e) { } catch (\LogicException|\TypeError $e) {
\Safe\fwrite(STDERR, "Setting up GdbotsQueryParserTest\n"); fwrite(STDERR, "Setting up GdbotsQueryParserTest\n");
app('log')->error($e->getMessage()); app('log')->error($e->getMessage());
app('log')->error(sprintf('Could not parse search: "%s".', $query)); app('log')->error(sprintf('Could not parse search: "%s".', $query));

View File

@@ -184,8 +184,8 @@ class Steam
]; ];
// clear zalgo text // clear zalgo text
$string = \Safe\preg_replace('/(\pM{2})\pM+/u', '\1', $string); $string = preg_replace('/(\pM{2})\pM+/u', '\1', $string);
$string = \Safe\preg_replace('/\s+/', '', $string); $string = preg_replace('/\s+/', '', $string);
return str_replace($search, '', $string); return str_replace($search, '', $string);
} }
@@ -566,8 +566,8 @@ class Steam
{ {
// Log::debug(sprintf('getSafeUrl(%s, %s)', $unknownUrl, $safeUrl)); // Log::debug(sprintf('getSafeUrl(%s, %s)', $unknownUrl, $safeUrl));
$returnUrl = $safeUrl; $returnUrl = $safeUrl;
$unknownHost = \Safe\parse_url($unknownUrl, PHP_URL_HOST); $unknownHost = parse_url($unknownUrl, PHP_URL_HOST);
$safeHost = \Safe\parse_url($safeUrl, PHP_URL_HOST); $safeHost = parse_url($safeUrl, PHP_URL_HOST);
if (null !== $unknownHost && $unknownHost === $safeHost) { if (null !== $unknownHost && $unknownHost === $safeHost) {
$returnUrl = $unknownUrl; $returnUrl = $unknownUrl;

View File

@@ -96,8 +96,8 @@ class OAuthKeys
{ {
$private = storage_path('oauth-private.key'); $private = storage_path('oauth-private.key');
$public = storage_path('oauth-public.key'); $public = storage_path('oauth-public.key');
app('fireflyconfig')->set(self::PRIVATE_KEY, Crypt::encrypt(\Safe\file_get_contents($private))); app('fireflyconfig')->set(self::PRIVATE_KEY, Crypt::encrypt(file_get_contents($private)));
app('fireflyconfig')->set(self::PUBLIC_KEY, Crypt::encrypt(\Safe\file_get_contents($public))); app('fireflyconfig')->set(self::PUBLIC_KEY, Crypt::encrypt(file_get_contents($public)));
} }
/** /**
@@ -123,8 +123,8 @@ class OAuthKeys
} }
$private = storage_path('oauth-private.key'); $private = storage_path('oauth-private.key');
$public = storage_path('oauth-public.key'); $public = storage_path('oauth-public.key');
\Safe\file_put_contents($private, $privateContent); file_put_contents($private, $privateContent);
\Safe\file_put_contents($public, $publicContent); file_put_contents($public, $publicContent);
return true; return true;
} }

View File

@@ -179,8 +179,8 @@ class General extends AbstractExtension
return new TwigFilter( return new TwigFilter(
'phphost', 'phphost',
static function (string $string): string { static function (string $string): string {
$proto = (string) \Safe\parse_url($string, PHP_URL_SCHEME); $proto = (string) parse_url($string, PHP_URL_SCHEME);
$host = (string) \Safe\parse_url($string, PHP_URL_HOST); $host = (string) parse_url($string, PHP_URL_HOST);
return e(sprintf('%s://%s', $proto, $host)); return e(sprintf('%s://%s', $proto, $host));
} }
@@ -211,7 +211,7 @@ class General extends AbstractExtension
{ {
return new TwigFunction( return new TwigFunction(
'phpdate', 'phpdate',
static fn (string $str): string => \Safe\date($str) static fn (string $str): string => date($str)
); );
} }

View File

@@ -255,7 +255,7 @@ class TransactionGroupTwig extends AbstractExtension
return today(config('app.timezone')); return today(config('app.timezone'));
} }
return new Carbon(\Safe\json_decode($entry->data, false)); return new Carbon(json_decode($entry->data, false));
} }
); );
} }
@@ -276,7 +276,7 @@ class TransactionGroupTwig extends AbstractExtension
return ''; return '';
} }
return \Safe\json_decode($entry->data, true); return json_decode($entry->data, true);
} }
); );
} }

View File

@@ -264,7 +264,7 @@ class RecurrenceTransformer extends AbstractTransformer
break; break;
case 'tags': case 'tags':
$array['tags'] = \Safe\json_decode($transactionMeta->value); $array['tags'] = json_decode($transactionMeta->value);
break; break;

View File

@@ -39,7 +39,7 @@ class WebhookMessageTransformer extends AbstractTransformer
$json = '{}'; $json = '{}';
try { try {
$json = \Safe\json_encode($message->message, JSON_THROW_ON_ERROR); $json = json_encode($message->message, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) { } catch (\JsonException $e) {
app('log')->error(sprintf('Could not encode webhook message #%d: %s', $message->id, $e->getMessage())); app('log')->error(sprintf('Could not encode webhook message #%d: %s', $message->id, $e->getMessage()));
} }

View File

@@ -34,7 +34,7 @@ trait ValidatesBulkTransactionQuery
$data = $validator->getData(); $data = $validator->getData();
// assumption is all validation has already taken place and the query key exists. // assumption is all validation has already taken place and the query key exists.
$query = $data['query'] ?? '[]'; $query = $data['query'] ?? '[]';
$json = \Safe\json_decode($query, true, 8, JSON_THROW_ON_ERROR); $json = json_decode($query, true, 8, JSON_THROW_ON_ERROR);
if ( if (
array_key_exists('where', $json) array_key_exists('where', $json)

View File

@@ -110,7 +110,7 @@ class FireflyValidator extends Validator
return false; return false;
} }
$regex = '/^[a-z]{6}[0-9a-z]{2}([0-9a-z]{3})?\z/i'; $regex = '/^[a-z]{6}[0-9a-z]{2}([0-9a-z]{3})?\z/i';
$result = \Safe\preg_match($regex, $value); $result = preg_match($regex, $value);
if (false === $result || 0 === $result) { if (false === $result || 0 === $result) {
return false; return false;
} }
@@ -200,7 +200,7 @@ class FireflyValidator extends Validator
$value = strtoupper($value); $value = strtoupper($value);
// replace characters outside of ASCI range. // replace characters outside of ASCI range.
$value = (string) \Safe\iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $value); $value = (string) iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $value);
$search = [' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; $search = [' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
$replace = ['', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35']; $replace = ['', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35'];
@@ -634,7 +634,7 @@ class FireflyValidator extends Validator
->whereNull('accounts.deleted_at') ->whereNull('accounts.deleted_at')
->where('accounts.user_id', auth()->user()->id) ->where('accounts.user_id', auth()->user()->id)
->where('account_meta.name', 'account_number') ->where('account_meta.name', 'account_number')
->where('account_meta.data', \Safe\json_encode($value)) ->where('account_meta.data', json_encode($value))
; ;
if ($accountId > 0) { if ($accountId > 0) {