Replace string operators.

This commit is contained in:
James Cole
2025-05-04 12:20:54 +02:00
parent cda90df995
commit d5240f7afd
5 changed files with 19 additions and 24 deletions

View File

@@ -147,10 +147,7 @@ class OutputsInstructions extends Command
*/
private function showLine(): void
{
$line = '+';
$line .= str_repeat('-', 78);
$line .= '+';
$this->line($line);
$this->line(sprintf('+%s+', str_repeat('-', 78)));
}
/**

View File

@@ -41,7 +41,7 @@ class IntroController extends Controller
public function getIntroSteps(string $route, ?string $specificPage = null): JsonResponse
{
app('log')->debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage));
$specificPage ??= '';
$specificPage ??= '';
$steps = $this->getBasicSteps($route);
$specificSteps = $this->getSpecificSteps($route, $specificPage);
if (0 === count($specificSteps)) {
@@ -55,8 +55,8 @@ class IntroController extends Controller
// remove last step:
array_pop($steps);
// merge arrays and add last step again
$steps = array_merge($steps, $specificSteps);
$steps[] = $lastStep;
$steps = array_merge($steps, $specificSteps);
$steps[] = $lastStep;
}
if (!$this->hasOutroStep($route)) {
$steps = array_merge($steps, $specificSteps);
@@ -77,7 +77,7 @@ class IntroController extends Controller
return false;
}
$hasStep = array_key_exists('outro', $elements);
$hasStep = array_key_exists('outro', $elements);
app('log')->debug('Elements is array', $elements);
app('log')->debug('Keys is', array_keys($elements));
@@ -94,10 +94,10 @@ class IntroController extends Controller
public function postEnable(string $route, ?string $specialPage = null): JsonResponse
{
$specialPage ??= '';
$route = str_replace('.', '_', $route);
$key = 'shown_demo_'.$route;
$route = str_replace('.', '_', $route);
$key = sprintf('shown_demo_%s', $route);
if ('' !== $specialPage) {
$key .= '_'.$specialPage;
$key = sprintf('%s_%s', $key, $specialPage);
}
app('log')->debug(sprintf('Going to mark the following route as NOT done: %s with special "%s" (%s)', $route, $specialPage, $key));
app('preferences')->set($key, false);
@@ -114,9 +114,9 @@ class IntroController extends Controller
public function postFinished(string $route, ?string $specialPage = null): JsonResponse
{
$specialPage ??= '';
$key = 'shown_demo_'.$route;
$key = sprintf('shown_demo_%s', $route);
if ('' !== $specialPage) {
$key .= '_'.$specialPage;
$key = sprintf('%s_%s', $key, $specialPage);
}
app('log')->debug(sprintf('Going to mark the following route as done: %s with special "%s" (%s)', $route, $specialPage, $key));
app('preferences')->set($key, true);

View File

@@ -104,7 +104,7 @@ class EditController extends Controller
$repetition = $recurrence->recurrenceRepetitions()->first();
$currentRepType = $repetition->repetition_type;
if ('' !== $repetition->repetition_moment) {
$currentRepType .= ','.$repetition->repetition_moment;
$currentRepType = sprintf('%s,%s', $currentRepType,$repetition->repetition_moment);
}
// put previous url in session if not redirect from store (not "return_to_edit").

View File

@@ -117,10 +117,7 @@ class GroupCloneService
private function cloneNote(Note $note, TransactionJournal $newJournal, int $oldGroupId): void
{
$newNote = $note->replicate();
$newNote->text .= sprintf(
"\n\n%s",
trans('firefly.clones_journal_x', ['description' => $newJournal->description, 'id' => $oldGroupId])
);
$newNote->text = sprintf("%s\n\n%s",$newNote->text, trans('firefly.clones_journal_x', ['description' => $newJournal->description, 'id' => $oldGroupId]));
$newNote->noteable_id = $newJournal->id;
$newNote->save();
}

View File

@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Support;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
/**
* Class CacheProperties.
@@ -55,7 +56,7 @@ class CacheProperties
*/
public function get()
{
return \Cache::get($this->hash);
return Cache::get($this->hash);
}
public function getHash(): string
@@ -70,18 +71,18 @@ class CacheProperties
}
$this->hash();
return \Cache::has($this->hash);
return Cache::has($this->hash);
}
private function hash(): void
{
$content = '';
$content = '';
foreach ($this->properties as $property) {
try {
$content .= \Safe\json_encode($property, JSON_THROW_ON_ERROR);
$content = sprintf('%s%s', $content, \Safe\json_encode($property, JSON_THROW_ON_ERROR));
} catch (\JsonException $e) {
// @ignoreException
$content .= hash('sha256', (string) time());
$content = sprintf('%s%s', $content, hash('sha256', (string) time()));
}
}
$this->hash = substr(hash('sha256', $content), 0, 16);
@@ -92,6 +93,6 @@ class CacheProperties
*/
public function store($data): void
{
\Cache::forever($this->hash, $data);
Cache::forever($this->hash, $data);
}
}