From 3e502db772e9eb6b9e39aebaf820967fa306c10b Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 10 Feb 2016 16:23:37 +0100 Subject: [PATCH] Various code fixes. --- app/Export/Collector/AttachmentCollector.php | 2 +- app/Http/Controllers/Auth/AuthController.php | 2 +- app/Http/breadcrumbs.php | 14 +++++++------- app/Support/Migration/TestData.php | 3 +-- app/Support/Navigation.php | 2 +- app/Support/Twig/General.php | 3 +-- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/Export/Collector/AttachmentCollector.php b/app/Export/Collector/AttachmentCollector.php index 9ae2410339..706fc12ab8 100644 --- a/app/Export/Collector/AttachmentCollector.php +++ b/app/Export/Collector/AttachmentCollector.php @@ -89,7 +89,7 @@ class AttachmentCollector extends BasicCollector implements CollectorInterface 'type' => strtolower($journal->transactionType->type), 'description' => $journal->description, 'journal_id' => $journal->id, - 'date' => $journal->date->formatLocalized(trans('config.month_and_day')), + 'date' => $journal->date->formatLocalized(strval(trans('config.month_and_day'))), 'amount' => Amount::formatJournal($journal, false), ]; $string = trans('firefly.attachment_explanation', $args) . "\n"; diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 10912a0eda..7bf7a47d82 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -80,7 +80,7 @@ class AuthController extends Controller if (strlen($code) == 0) { $code = 'general_blocked'; } - $message = trans('firefly.' . $code . '_error', ['email' => $credentials['email']]); + $message = strval(trans('firefly.' . $code . '_error', ['email' => $credentials['email']])); } if ($throttles) { diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index 21f7644d01..d28342e1ab 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -87,7 +87,7 @@ Breadcrumbs::register( $object = $attachment->attachable; if ($object instanceof TransactionJournal) { $breadcrumbs->parent('transactions.show', $object); - $breadcrumbs->push($attachment->filename, route('attachments.edit', $attachment)); + $breadcrumbs->push($attachment->filename, route('attachments.edit', [$attachment])); } else { throw new FireflyException('Cannot make breadcrumb for attachment connected to object of type ' . get_class($object)); @@ -101,7 +101,7 @@ Breadcrumbs::register( $object = $attachment->attachable; if ($object instanceof TransactionJournal) { $breadcrumbs->parent('transactions.show', $object); - $breadcrumbs->push(trans('firefly.delete_attachment', ['name' => $attachment->filename]), route('attachments.edit', $attachment)); + $breadcrumbs->push(trans('firefly.delete_attachment', ['name' => $attachment->filename]), route('attachments.edit', [$attachment])); } else { throw new FireflyException('Cannot make breadcrumb for attachment connected to object of type ' . get_class($object)); @@ -440,19 +440,19 @@ Breadcrumbs::register( Breadcrumbs::register( 'rules.rule.create', function (BreadCrumbGenerator $breadcrumbs, RuleGroup $ruleGroup) { $breadcrumbs->parent('rules.index'); - $breadcrumbs->push(trans('firefly.make_new_rule', ['title' => $ruleGroup->title]), route('rules.rule.create', $ruleGroup)); + $breadcrumbs->push(trans('firefly.make_new_rule', ['title' => $ruleGroup->title]), route('rules.rule.create', [$ruleGroup])); } ); Breadcrumbs::register( 'rules.rule.edit', function (BreadCrumbGenerator $breadcrumbs, Rule $rule) { $breadcrumbs->parent('rules.index'); - $breadcrumbs->push(trans('firefly.edit_rule', ['title' => $rule->title]), route('rules.rule.edit', $rule)); + $breadcrumbs->push(trans('firefly.edit_rule', ['title' => $rule->title]), route('rules.rule.edit', [$rule])); } ); Breadcrumbs::register( 'rules.rule.delete', function (BreadCrumbGenerator $breadcrumbs, Rule $rule) { $breadcrumbs->parent('rules.index'); - $breadcrumbs->push(trans('firefly.delete_rule', ['title' => $rule->title]), route('rules.rule.delete', $rule)); + $breadcrumbs->push(trans('firefly.delete_rule', ['title' => $rule->title]), route('rules.rule.delete', [$rule])); } ); Breadcrumbs::register( @@ -464,13 +464,13 @@ Breadcrumbs::register( Breadcrumbs::register( 'rules.rule-group.edit', function (BreadCrumbGenerator $breadcrumbs, RuleGroup $ruleGroup) { $breadcrumbs->parent('rules.index'); - $breadcrumbs->push(trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]), route('rules.rule-group.edit', $ruleGroup)); + $breadcrumbs->push(trans('firefly.edit_rule_group', ['title' => $ruleGroup->title]), route('rules.rule-group.edit', [$ruleGroup])); } ); Breadcrumbs::register( 'rules.rule-group.delete', function (BreadCrumbGenerator $breadcrumbs, RuleGroup $ruleGroup) { $breadcrumbs->parent('rules.index'); - $breadcrumbs->push(trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]), route('rules.rule-group.delete', $ruleGroup)); + $breadcrumbs->push(trans('firefly.delete_rule_group', ['title' => $ruleGroup->title]), route('rules.rule-group.delete', [$ruleGroup])); } ); diff --git a/app/Support/Migration/TestData.php b/app/Support/Migration/TestData.php index 8731dd1cac..4ea67bbeff 100644 --- a/app/Support/Migration/TestData.php +++ b/app/Support/Migration/TestData.php @@ -228,7 +228,7 @@ class TestData Budget::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]); // some empty budgets. - foreach (['A', 'B', 'C', 'D', "E"] as $letter) { + foreach (['A', 'B', 'C', 'D', 'E'] as $letter) { Budget::firstOrCreateEncrypted(['name' => 'Empty budget ' . $letter, 'user_id' => $user->id]); } @@ -984,7 +984,6 @@ class TestData foreach (Budget::get() as $budget) { if ($budget->name == $name && $user->id == $budget->user_id) { return $budget; - break; } } diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index ee028cdf22..51cb6091bc 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -185,7 +185,7 @@ class Navigation if (isset($formatMap[$repeatFrequency])) { - return $date->formatLocalized($formatMap[$repeatFrequency]); + return $date->formatLocalized(strval($formatMap[$repeatFrequency])); } throw new FireflyException('No date formats for frequency "' . $repeatFrequency . '"!'); } diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.php index 1ae282f199..8de911f5f1 100644 --- a/app/Support/Twig/General.php +++ b/app/Support/Twig/General.php @@ -17,7 +17,6 @@ use Twig_SimpleFunction; * @codeCoverageIgnore * * Class TwigSupport - * @todo these functions should be parameterized. * * @package FireflyIII\Support */ @@ -99,7 +98,7 @@ class General extends Twig_Extension protected function activeRoutePartialWhat(): Twig_SimpleFunction { return new Twig_SimpleFunction( - 'activeRoutePartialWhat', function ($context) : string { + 'activeRoutePartialWhat', function ($context) : string { $args = func_get_args(); $route = $args[1]; // name of the route. $what = $args[2]; // name of the route.