mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-22 20:16:22 +00:00 
			
		
		
		
	Various PSR12 code cleanup
This commit is contained in:
		| @@ -106,7 +106,7 @@ class StoreRequest extends FormRequest | ||||
|         $type           = $this->convertString('type'); | ||||
|         $rules          = [ | ||||
|             'name'                 => 'required|min:1|uniqueAccountForUser', | ||||
|             'type'                 => 'required|min:1|' . sprintf('in:%s', $types), | ||||
|             'type'                 => 'required|min:1|'.sprintf('in:%s', $types), | ||||
|             'iban'                 => ['iban', 'nullable', new UniqueIban(null, $type)], | ||||
|             'bic'                  => 'bic|nullable', | ||||
|             'account_number'       => ['between:1,255', 'nullable', new UniqueAccountNumber(null, $type)], | ||||
|   | ||||
| @@ -123,7 +123,7 @@ class UpdateRequest extends FormRequest | ||||
|             'include_net_worth'    => [new IsBoolean()], | ||||
|             'account_role'         => sprintf('in:%s|nullable|required_if:type,asset', $accountRoles), | ||||
|             'credit_card_type'     => sprintf('in:%s|nullable|required_if:account_role,ccAsset', $ccPaymentTypes), | ||||
|             'monthly_payment_date' => 'date' . '|nullable|required_if:account_role,ccAsset|required_if:credit_card_type,monthlyFull', | ||||
|             'monthly_payment_date' => 'date'.'|nullable|required_if:account_role,ccAsset|required_if:credit_card_type,monthlyFull', | ||||
|             'liability_type'       => 'required_if:type,liability|in:loan,debt,mortgage', | ||||
|             'liability_direction'  => 'required_if:type,liability|in:credit,debit', | ||||
|             'interest'             => 'required_if:type,liability|between:0,100|numeric', | ||||
|   | ||||
| @@ -77,7 +77,7 @@ class Request extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance with special rules for after the basic validation rules. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
| @@ -91,7 +91,7 @@ class Request extends FormRequest | ||||
|                     $start = new Carbon($data['start']); | ||||
|                     $end   = new Carbon($data['end']); | ||||
|                     if ($end->isBefore($start)) { | ||||
|                         $validator->errors()->add('end', (string) trans('validation.date_after')); | ||||
|                         $validator->errors()->add('end', (string)trans('validation.date_after')); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|   | ||||
| @@ -96,7 +96,7 @@ class StoreRequest extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
| @@ -109,7 +109,7 @@ class StoreRequest extends FormRequest | ||||
|                 $max  = $data['amount_max'] ?? '0'; | ||||
|  | ||||
|                 if (1 === bccomp($min, $max)) { | ||||
|                     $validator->errors()->add('amount_min', (string) trans('validation.amount_min_over_max')); | ||||
|                     $validator->errors()->add('amount_min', (string)trans('validation.amount_min_over_max')); | ||||
|                 } | ||||
|             } | ||||
|         ); | ||||
|   | ||||
| @@ -98,7 +98,7 @@ class UpdateRequest extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
| @@ -108,11 +108,11 @@ class UpdateRequest extends FormRequest | ||||
|             static function (Validator $validator) { | ||||
|                 $data = $validator->getData(); | ||||
|                 if (array_key_exists('amount_min', $data) && array_key_exists('amount_max', $data)) { | ||||
|                     $min  = $data['amount_min'] ?? '0'; | ||||
|                     $max  = $data['amount_max'] ?? '0'; | ||||
|                     $min = $data['amount_min'] ?? '0'; | ||||
|                     $max = $data['amount_max'] ?? '0'; | ||||
|  | ||||
|                     if (1 === bccomp($min, $max)) { | ||||
|                         $validator->errors()->add('amount_min', (string) trans('validation.amount_min_over_max')); | ||||
|                         $validator->errors()->add('amount_min', (string)trans('validation.amount_min_over_max')); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|   | ||||
| @@ -88,7 +88,7 @@ class StoreRequest extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance with special rules for after the basic validation rules. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|   | ||||
| @@ -99,7 +99,7 @@ class UpdateRequest extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance with special rules for after the basic validation rules. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|   | ||||
| @@ -76,7 +76,7 @@ class UpdateRequest extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance with special rules for after the basic validation rules. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * TODO duplicate code | ||||
|      * | ||||
|      * @return void | ||||
| @@ -91,7 +91,7 @@ class UpdateRequest extends FormRequest | ||||
|                     $start = new Carbon($data['start']); | ||||
|                     $end   = new Carbon($data['end']); | ||||
|                     if ($end->isBefore($start)) { | ||||
|                         $validator->errors()->add('end', (string) trans('validation.date_after')); | ||||
|                         $validator->errors()->add('end', (string)trans('validation.date_after')); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|   | ||||
| @@ -74,7 +74,7 @@ class UpdateRequest extends FormRequest | ||||
|         $piggyBank = $this->route()->parameter('piggyBank'); | ||||
|  | ||||
|         return [ | ||||
|             'name'           => 'between:1,255|uniquePiggyBankForUser:' . $piggyBank->id, | ||||
|             'name'           => 'between:1,255|uniquePiggyBankForUser:'.$piggyBank->id, | ||||
|             'current_amount' => ['numeric', 'gte:0', new LessThanPiggyTarget()], | ||||
|             'target_amount'  => 'numeric|gt:0', | ||||
|             'start_date'     => 'date|nullable', | ||||
|   | ||||
| @@ -120,10 +120,10 @@ class StoreRequest extends FormRequest | ||||
|                 $current['moment'] = $repetition['moment']; | ||||
|             } | ||||
|             if (array_key_exists('skip', $repetition)) { | ||||
|                 $current['skip'] = (int) $repetition['skip']; | ||||
|                 $current['skip'] = (int)$repetition['skip']; | ||||
|             } | ||||
|             if (array_key_exists('weekend', $repetition)) { | ||||
|                 $current['weekend'] = (int) $repetition['weekend']; | ||||
|                 $current['weekend'] = (int)$repetition['weekend']; | ||||
|             } | ||||
|  | ||||
|             $return[] = $current; | ||||
| @@ -180,7 +180,7 @@ class StoreRequest extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|   | ||||
| @@ -102,15 +102,15 @@ class UpdateRequest extends FormRequest | ||||
|             } | ||||
|  | ||||
|             if (array_key_exists('moment', $repetition)) { | ||||
|                 $current['moment'] = (string) $repetition['moment']; | ||||
|                 $current['moment'] = (string)$repetition['moment']; | ||||
|             } | ||||
|  | ||||
|             if (array_key_exists('skip', $repetition)) { | ||||
|                 $current['skip'] = (int) $repetition['skip']; | ||||
|                 $current['skip'] = (int)$repetition['skip']; | ||||
|             } | ||||
|  | ||||
|             if (array_key_exists('weekend', $repetition)) { | ||||
|                 $current['weekend'] = (int) $repetition['weekend']; | ||||
|                 $current['weekend'] = (int)$repetition['weekend']; | ||||
|             } | ||||
|             $return[] = $current; | ||||
|         } | ||||
| @@ -195,7 +195,7 @@ class UpdateRequest extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|   | ||||
| @@ -79,8 +79,8 @@ class StoreRequest extends FormRequest | ||||
|                 $return[] = [ | ||||
|                     'type'            => $trigger['type'], | ||||
|                     'value'           => $trigger['value'], | ||||
|                     'active'          => $this->convertBoolean((string) ($trigger['active'] ?? 'false')), | ||||
|                     'stop_processing' => $this->convertBoolean((string) ($trigger['stop_processing'] ?? 'false')), | ||||
|                     'active'          => $this->convertBoolean((string)($trigger['active'] ?? 'false')), | ||||
|                     'stop_processing' => $this->convertBoolean((string)($trigger['stop_processing'] ?? 'false')), | ||||
|                 ]; | ||||
|             } | ||||
|         } | ||||
| @@ -100,8 +100,8 @@ class StoreRequest extends FormRequest | ||||
|                 $return[] = [ | ||||
|                     'type'            => $action['type'], | ||||
|                     'value'           => $action['value'], | ||||
|                     'active'          => $this->convertBoolean((string) ($action['active'] ?? 'false')), | ||||
|                     'stop_processing' => $this->convertBoolean((string) ($action['stop_processing'] ?? 'false')), | ||||
|                     'active'          => $this->convertBoolean((string)($action['active'] ?? 'false')), | ||||
|                     'stop_processing' => $this->convertBoolean((string)($action['stop_processing'] ?? 'false')), | ||||
|                 ]; | ||||
|             } | ||||
|         } | ||||
| @@ -129,12 +129,12 @@ class StoreRequest extends FormRequest | ||||
|             'rule_group_id'              => 'belongsToUser:rule_groups|required_without:rule_group_title', | ||||
|             'rule_group_title'           => 'nullable|between:1,255|required_without:rule_group_id|belongsToUser:rule_groups,title', | ||||
|             'trigger'                    => 'required|in:store-journal,update-journal', | ||||
|             'triggers.*.type'            => 'required|in:' . implode(',', $validTriggers), | ||||
|             'triggers.*.value'           => 'required_if:actions.*.type,' . $contextTriggers . '|min:1|ruleTriggerValue', | ||||
|             'triggers.*.type'            => 'required|in:'.implode(',', $validTriggers), | ||||
|             'triggers.*.value'           => 'required_if:actions.*.type,'.$contextTriggers.'|min:1|ruleTriggerValue', | ||||
|             'triggers.*.stop_processing' => [new IsBoolean()], | ||||
|             'triggers.*.active'          => [new IsBoolean()], | ||||
|             'actions.*.type'             => 'required|in:' . implode(',', $validActions), | ||||
|             'actions.*.value'            => 'required_if:actions.*.type,' . $contextActions . '|ruleActionValue', | ||||
|             'actions.*.type'             => 'required|in:'.implode(',', $validActions), | ||||
|             'actions.*.value'            => 'required_if:actions.*.type,'.$contextActions.'|ruleActionValue', | ||||
|             'actions.*.stop_processing'  => [new IsBoolean()], | ||||
|             'actions.*.active'           => [new IsBoolean()], | ||||
|             'strict'                     => [new IsBoolean()], | ||||
| @@ -146,7 +146,7 @@ class StoreRequest extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
| @@ -165,7 +165,7 @@ class StoreRequest extends FormRequest | ||||
|     /** | ||||
|      * Adds an error to the validator when there are no triggers in the array of data. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      */ | ||||
|     protected function atLeastOneTrigger(Validator $validator): void | ||||
|     { | ||||
| @@ -173,14 +173,14 @@ class StoreRequest extends FormRequest | ||||
|         $triggers = $data['triggers'] ?? []; | ||||
|         // need at least one trigger | ||||
|         if (!is_countable($triggers) || 0 === count($triggers)) { | ||||
|             $validator->errors()->add('title', (string) trans('validation.at_least_one_trigger')); | ||||
|             $validator->errors()->add('title', (string)trans('validation.at_least_one_trigger')); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Adds an error to the validator when there are no repetitions in the array of data. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      */ | ||||
|     protected function atLeastOneAction(Validator $validator): void | ||||
|     { | ||||
| @@ -188,14 +188,14 @@ class StoreRequest extends FormRequest | ||||
|         $actions = $data['actions'] ?? []; | ||||
|         // need at least one trigger | ||||
|         if (!is_countable($actions) || 0 === count($actions)) { | ||||
|             $validator->errors()->add('title', (string) trans('validation.at_least_one_action')); | ||||
|             $validator->errors()->add('title', (string)trans('validation.at_least_one_action')); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Adds an error to the validator when there are no ACTIVE triggers in the array of data. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      */ | ||||
|     protected function atLeastOneActiveTrigger(Validator $validator): void | ||||
|     { | ||||
| @@ -217,14 +217,14 @@ class StoreRequest extends FormRequest | ||||
|             } | ||||
|         } | ||||
|         if (true === $allInactive) { | ||||
|             $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger')); | ||||
|             $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_trigger')); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Adds an error to the validator when there are no ACTIVE actions in the array of data. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      */ | ||||
|     protected function atLeastOneActiveAction(Validator $validator): void | ||||
|     { | ||||
| @@ -246,7 +246,7 @@ class StoreRequest extends FormRequest | ||||
|             } | ||||
|         } | ||||
|         if (true === $allInactive) { | ||||
|             $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action')); | ||||
|             $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_action')); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -56,11 +56,11 @@ class TestRequest extends FormRequest | ||||
|      */ | ||||
|     private function getPage(): int | ||||
|     { | ||||
|         return 0 === (int) $this->query('page') ? 1 : (int) $this->query('page'); | ||||
|         return 0 === (int)$this->query('page') ? 1 : (int)$this->query('page'); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param string $field | ||||
|      * @param  string  $field | ||||
|      * | ||||
|      * @return Carbon|null | ||||
|      */ | ||||
|   | ||||
| @@ -50,7 +50,7 @@ class TriggerRequest extends FormRequest | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param string $field | ||||
|      * @param  string  $field | ||||
|      * | ||||
|      * @return Carbon|null | ||||
|      */ | ||||
|   | ||||
| @@ -114,8 +114,8 @@ class UpdateRequest extends FormRequest | ||||
|                 $return[] = [ | ||||
|                     'type'            => $action['type'], | ||||
|                     'value'           => $action['value'], | ||||
|                     'active'          => $this->convertBoolean((string) ($action['active'] ?? 'false')), | ||||
|                     'stop_processing' => $this->convertBoolean((string) ($action['stop_processing'] ?? 'false')), | ||||
|                     'active'          => $this->convertBoolean((string)($action['active'] ?? 'false')), | ||||
|                     'stop_processing' => $this->convertBoolean((string)($action['stop_processing'] ?? 'false')), | ||||
|                 ]; | ||||
|             } | ||||
|         } | ||||
| @@ -134,7 +134,7 @@ class UpdateRequest extends FormRequest | ||||
|         $validActions  = array_keys(config('firefly.rule-actions')); | ||||
|  | ||||
|         /** @var Rule $rule */ | ||||
|         $rule          = $this->route()->parameter('rule'); | ||||
|         $rule = $this->route()->parameter('rule'); | ||||
|  | ||||
|         // some triggers and actions require text: | ||||
|         $contextTriggers = implode(',', $this->getTriggersWithContext()); | ||||
| @@ -146,12 +146,12 @@ class UpdateRequest extends FormRequest | ||||
|             'rule_group_id'              => 'belongsToUser:rule_groups', | ||||
|             'rule_group_title'           => 'nullable|between:1,255|belongsToUser:rule_groups,title', | ||||
|             'trigger'                    => 'in:store-journal,update-journal', | ||||
|             'triggers.*.type'            => 'required|in:' . implode(',', $validTriggers), | ||||
|             'triggers.*.value'           => 'required_if:actions.*.type,' . $contextTriggers . '|min:1|ruleTriggerValue', | ||||
|             'triggers.*.type'            => 'required|in:'.implode(',', $validTriggers), | ||||
|             'triggers.*.value'           => 'required_if:actions.*.type,'.$contextTriggers.'|min:1|ruleTriggerValue', | ||||
|             'triggers.*.stop_processing' => [new IsBoolean()], | ||||
|             'triggers.*.active'          => [new IsBoolean()], | ||||
|             'actions.*.type'             => 'required|in:' . implode(',', $validActions), | ||||
|             'actions.*.value'            => 'required_if:actions.*.type,' . $contextActions . '|ruleActionValue', | ||||
|             'actions.*.type'             => 'required|in:'.implode(',', $validActions), | ||||
|             'actions.*.value'            => 'required_if:actions.*.type,'.$contextActions.'|ruleActionValue', | ||||
|             'actions.*.stop_processing'  => [new IsBoolean()], | ||||
|             'actions.*.active'           => [new IsBoolean()], | ||||
|             'strict'                     => [new IsBoolean()], | ||||
| @@ -164,7 +164,7 @@ class UpdateRequest extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
| @@ -183,7 +183,7 @@ class UpdateRequest extends FormRequest | ||||
|     /** | ||||
|      * Adds an error to the validator when there are no repetitions in the array of data. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      */ | ||||
|     protected function atLeastOneTrigger(Validator $validator): void | ||||
|     { | ||||
| @@ -191,14 +191,14 @@ class UpdateRequest extends FormRequest | ||||
|         $triggers = $data['triggers'] ?? null; | ||||
|         // need at least one trigger | ||||
|         if (is_array($triggers) && 0 === count($triggers)) { | ||||
|             $validator->errors()->add('title', (string) trans('validation.at_least_one_trigger')); | ||||
|             $validator->errors()->add('title', (string)trans('validation.at_least_one_trigger')); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Adds an error to the validator when there are no repetitions in the array of data. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      */ | ||||
|     protected function atLeastOneValidTrigger(Validator $validator): void | ||||
|     { | ||||
| @@ -220,14 +220,14 @@ class UpdateRequest extends FormRequest | ||||
|             } | ||||
|         } | ||||
|         if (true === $allInactive) { | ||||
|             $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger')); | ||||
|             $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_trigger')); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Adds an error to the validator when there are no repetitions in the array of data. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      */ | ||||
|     protected function atLeastOneAction(Validator $validator): void | ||||
|     { | ||||
| @@ -235,14 +235,14 @@ class UpdateRequest extends FormRequest | ||||
|         $actions = $data['actions'] ?? null; | ||||
|         // need at least one action | ||||
|         if (is_array($actions) && 0 === count($actions)) { | ||||
|             $validator->errors()->add('title', (string) trans('validation.at_least_one_action')); | ||||
|             $validator->errors()->add('title', (string)trans('validation.at_least_one_action')); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Adds an error to the validator when there are no repetitions in the array of data. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      */ | ||||
|     protected function atLeastOneValidAction(Validator $validator): void | ||||
|     { | ||||
| @@ -265,7 +265,7 @@ class UpdateRequest extends FormRequest | ||||
|             } | ||||
|         } | ||||
|         if (true === $allInactive) { | ||||
|             $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action')); | ||||
|             $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_action')); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -50,7 +50,7 @@ class TestRequest extends FormRequest | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param string $field | ||||
|      * @param  string  $field | ||||
|      * | ||||
|      * @return Carbon|null | ||||
|      */ | ||||
|   | ||||
| @@ -50,7 +50,7 @@ class TriggerRequest extends FormRequest | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param string $field | ||||
|      * @param  string  $field | ||||
|      * | ||||
|      * @return Carbon|null | ||||
|      */ | ||||
|   | ||||
| @@ -67,7 +67,7 @@ class UpdateRequest extends FormRequest | ||||
|         $ruleGroup = $this->route()->parameter('ruleGroup'); | ||||
|  | ||||
|         return [ | ||||
|             'title'       => 'between:1,100|uniqueObjectForUser:rule_groups,title,' . $ruleGroup->id, | ||||
|             'title'       => 'between:1,100|uniqueObjectForUser:rule_groups,title,'.$ruleGroup->id, | ||||
|             'description' => 'between:1,5000|nullable', | ||||
|             'active'      => [new IsBoolean()], | ||||
|         ]; | ||||
|   | ||||
| @@ -71,7 +71,7 @@ class UpdateRequest extends FormRequest | ||||
|         $tag = $this->route()->parameter('tagOrId'); | ||||
|         // TODO check if uniqueObjectForUser is obsolete | ||||
|         $rules = [ | ||||
|             'tag'         => 'min:1|uniqueObjectForUser:tags,tag,' . $tag->id, | ||||
|             'tag'         => 'min:1|uniqueObjectForUser:tags,tag,'.$tag->id, | ||||
|             'description' => 'min:1|nullable', | ||||
|             'date'        => 'date|nullable', | ||||
|         ]; | ||||
|   | ||||
| @@ -85,73 +85,73 @@ class StoreRequest extends FormRequest | ||||
|             $return[] = [ | ||||
|                 'type'  => $this->clearString($object['type'], false), | ||||
|                 'date'  => $this->dateFromValue($object['date']), | ||||
|                 'order' => $this->integerFromValue((string) $object['order']), | ||||
|                 'order' => $this->integerFromValue((string)$object['order']), | ||||
|  | ||||
|                 'currency_id'           => $this->integerFromValue((string) $object['currency_id']), | ||||
|                 'currency_code'         => $this->clearString((string) $object['currency_code'], false), | ||||
|                 'currency_id'           => $this->integerFromValue((string)$object['currency_id']), | ||||
|                 'currency_code'         => $this->clearString((string)$object['currency_code'], false), | ||||
|  | ||||
|                 // foreign currency info: | ||||
|                 'foreign_currency_id'   => $this->integerFromValue((string) $object['foreign_currency_id']), | ||||
|                 'foreign_currency_code' => $this->clearString((string) $object['foreign_currency_code'], false), | ||||
|                 'foreign_currency_id'   => $this->integerFromValue((string)$object['foreign_currency_id']), | ||||
|                 'foreign_currency_code' => $this->clearString((string)$object['foreign_currency_code'], false), | ||||
|  | ||||
|                 // amount and foreign amount. Cannot be 0. | ||||
|                 'amount'                => $this->clearString((string) $object['amount'], false), | ||||
|                 'foreign_amount'        => $this->clearString((string) $object['foreign_amount'], false), | ||||
|                 'amount'                => $this->clearString((string)$object['amount'], false), | ||||
|                 'foreign_amount'        => $this->clearString((string)$object['foreign_amount'], false), | ||||
|  | ||||
|                 // description. | ||||
|                 'description'           => $this->clearString($object['description'], false), | ||||
|  | ||||
|                 // source of transaction. If everything is null, assume cash account. | ||||
|                 'source_id'             => $this->integerFromValue((string) $object['source_id']), | ||||
|                 'source_name'           => $this->clearString((string) $object['source_name'], false), | ||||
|                 'source_iban'           => $this->clearString((string) $object['source_iban'], false), | ||||
|                 'source_number'         => $this->clearString((string) $object['source_number'], false), | ||||
|                 'source_bic'            => $this->clearString((string) $object['source_bic'], false), | ||||
|                 'source_id'             => $this->integerFromValue((string)$object['source_id']), | ||||
|                 'source_name'           => $this->clearString((string)$object['source_name'], false), | ||||
|                 'source_iban'           => $this->clearString((string)$object['source_iban'], false), | ||||
|                 'source_number'         => $this->clearString((string)$object['source_number'], false), | ||||
|                 'source_bic'            => $this->clearString((string)$object['source_bic'], false), | ||||
|  | ||||
|                 // destination of transaction. If everything is null, assume cash account. | ||||
|                 'destination_id'        => $this->integerFromValue((string) $object['destination_id']), | ||||
|                 'destination_name'      => $this->clearString((string) $object['destination_name'], false), | ||||
|                 'destination_iban'      => $this->clearString((string) $object['destination_iban'], false), | ||||
|                 'destination_number'    => $this->clearString((string) $object['destination_number'], false), | ||||
|                 'destination_bic'       => $this->clearString((string) $object['destination_bic'], false), | ||||
|                 'destination_id'        => $this->integerFromValue((string)$object['destination_id']), | ||||
|                 'destination_name'      => $this->clearString((string)$object['destination_name'], false), | ||||
|                 'destination_iban'      => $this->clearString((string)$object['destination_iban'], false), | ||||
|                 'destination_number'    => $this->clearString((string)$object['destination_number'], false), | ||||
|                 'destination_bic'       => $this->clearString((string)$object['destination_bic'], false), | ||||
|  | ||||
|                 // budget info | ||||
|                 'budget_id'             => $this->integerFromValue((string) $object['budget_id']), | ||||
|                 'budget_name'           => $this->clearString((string) $object['budget_name'], false), | ||||
|                 'budget_id'             => $this->integerFromValue((string)$object['budget_id']), | ||||
|                 'budget_name'           => $this->clearString((string)$object['budget_name'], false), | ||||
|  | ||||
|                 // category info | ||||
|                 'category_id'           => $this->integerFromValue((string) $object['category_id']), | ||||
|                 'category_name'         => $this->clearString((string) $object['category_name'], false), | ||||
|                 'category_id'           => $this->integerFromValue((string)$object['category_id']), | ||||
|                 'category_name'         => $this->clearString((string)$object['category_name'], false), | ||||
|  | ||||
|                 // journal bill reference. Optional. Will only work for withdrawals | ||||
|                 'bill_id'               => $this->integerFromValue((string) $object['bill_id']), | ||||
|                 'bill_name'             => $this->clearString((string) $object['bill_name'], false), | ||||
|                 'bill_id'               => $this->integerFromValue((string)$object['bill_id']), | ||||
|                 'bill_name'             => $this->clearString((string)$object['bill_name'], false), | ||||
|  | ||||
|                 // piggy bank reference. Optional. Will only work for transfers | ||||
|                 'piggy_bank_id'         => $this->integerFromValue((string) $object['piggy_bank_id']), | ||||
|                 'piggy_bank_name'       => $this->clearString((string) $object['piggy_bank_name'], false), | ||||
|                 'piggy_bank_id'         => $this->integerFromValue((string)$object['piggy_bank_id']), | ||||
|                 'piggy_bank_name'       => $this->clearString((string)$object['piggy_bank_name'], false), | ||||
|  | ||||
|                 // some other interesting properties | ||||
|                 'reconciled'            => $this->convertBoolean((string) $object['reconciled']), | ||||
|                 'notes'                 => $this->clearString((string) $object['notes']), | ||||
|                 'reconciled'            => $this->convertBoolean((string)$object['reconciled']), | ||||
|                 'notes'                 => $this->clearString((string)$object['notes']), | ||||
|                 'tags'                  => $this->arrayFromValue($object['tags']), | ||||
|  | ||||
|                 // all custom fields: | ||||
|                 'internal_reference'    => $this->clearString((string) $object['internal_reference'], false), | ||||
|                 'external_id'           => $this->clearString((string) $object['external_id'], false), | ||||
|                 'internal_reference'    => $this->clearString((string)$object['internal_reference'], false), | ||||
|                 'external_id'           => $this->clearString((string)$object['external_id'], false), | ||||
|                 'original_source'       => sprintf('ff3-v%s|api-v%s', config('firefly.version'), config('firefly.api_version')), | ||||
|                 'recurrence_id'         => $this->integerFromValue($object['recurrence_id']), | ||||
|                 'bunq_payment_id'       => $this->clearString((string) $object['bunq_payment_id'], false), | ||||
|                 'external_url'          => $this->clearString((string) $object['external_url'], false), | ||||
|                 'bunq_payment_id'       => $this->clearString((string)$object['bunq_payment_id'], false), | ||||
|                 'external_url'          => $this->clearString((string)$object['external_url'], false), | ||||
|  | ||||
|                 'sepa_cc'       => $this->clearString((string) $object['sepa_cc'], false), | ||||
|                 'sepa_ct_op'    => $this->clearString((string) $object['sepa_ct_op'], false), | ||||
|                 'sepa_ct_id'    => $this->clearString((string) $object['sepa_ct_id'], false), | ||||
|                 'sepa_db'       => $this->clearString((string) $object['sepa_db'], false), | ||||
|                 'sepa_country'  => $this->clearString((string) $object['sepa_country'], false), | ||||
|                 'sepa_ep'       => $this->clearString((string) $object['sepa_ep'], false), | ||||
|                 'sepa_ci'       => $this->clearString((string) $object['sepa_ci'], false), | ||||
|                 'sepa_batch_id' => $this->clearString((string) $object['sepa_batch_id'], false), | ||||
|                 'sepa_cc'       => $this->clearString((string)$object['sepa_cc'], false), | ||||
|                 'sepa_ct_op'    => $this->clearString((string)$object['sepa_ct_op'], false), | ||||
|                 'sepa_ct_id'    => $this->clearString((string)$object['sepa_ct_id'], false), | ||||
|                 'sepa_db'       => $this->clearString((string)$object['sepa_db'], false), | ||||
|                 'sepa_country'  => $this->clearString((string)$object['sepa_country'], false), | ||||
|                 'sepa_ep'       => $this->clearString((string)$object['sepa_ep'], false), | ||||
|                 'sepa_ci'       => $this->clearString((string)$object['sepa_ci'], false), | ||||
|                 'sepa_batch_id' => $this->clearString((string)$object['sepa_batch_id'], false), | ||||
|                 // custom date fields. Must be Carbon objects. Presence is optional. | ||||
|                 'interest_date' => $this->dateFromValue($object['interest_date']), | ||||
|                 'book_date'     => $this->dateFromValue($object['book_date']), | ||||
| @@ -258,7 +258,7 @@ class StoreRequest extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
|   | ||||
| @@ -49,9 +49,9 @@ class UpdateRequest extends FormRequest | ||||
|     private array $arrayFields; | ||||
|     private array $booleanFields; | ||||
|     private array $dateFields; | ||||
|     private array $floatFields; | ||||
|     private array $integerFields; | ||||
|     private array $stringFields; | ||||
|     private array $floatFields; | ||||
|     private array $textareaFields; | ||||
|  | ||||
|     /** | ||||
| @@ -89,8 +89,8 @@ class UpdateRequest extends FormRequest | ||||
|         ]; | ||||
|  | ||||
|         $this->floatFields = [ // not really floats, for validation. | ||||
|             'amount', | ||||
|             'foreign_amount', | ||||
|                                'amount', | ||||
|                                'foreign_amount', | ||||
|         ]; | ||||
|  | ||||
|         $this->stringFields  = [ | ||||
| @@ -180,8 +180,8 @@ class UpdateRequest extends FormRequest | ||||
|     /** | ||||
|      * For each field, add it to the array if a reference is present in the request: | ||||
|      * | ||||
|      * @param array $current | ||||
|      * @param array $transaction | ||||
|      * @param  array  $current | ||||
|      * @param  array  $transaction | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
| @@ -189,7 +189,7 @@ class UpdateRequest extends FormRequest | ||||
|     { | ||||
|         foreach ($this->integerFields as $fieldName) { | ||||
|             if (array_key_exists($fieldName, $transaction)) { | ||||
|                 $current[$fieldName] = $this->integerFromValue((string) $transaction[$fieldName]); | ||||
|                 $current[$fieldName] = $this->integerFromValue((string)$transaction[$fieldName]); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -197,8 +197,8 @@ class UpdateRequest extends FormRequest | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param array $current | ||||
|      * @param array $transaction | ||||
|      * @param  array  $current | ||||
|      * @param  array  $transaction | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
| @@ -206,7 +206,7 @@ class UpdateRequest extends FormRequest | ||||
|     { | ||||
|         foreach ($this->stringFields as $fieldName) { | ||||
|             if (array_key_exists($fieldName, $transaction)) { | ||||
|                 $current[$fieldName] = $this->clearString((string) $transaction[$fieldName], false); | ||||
|                 $current[$fieldName] = $this->clearString((string)$transaction[$fieldName], false); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -214,8 +214,8 @@ class UpdateRequest extends FormRequest | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param array $current | ||||
|      * @param array $transaction | ||||
|      * @param  array  $current | ||||
|      * @param  array  $transaction | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
| @@ -223,7 +223,7 @@ class UpdateRequest extends FormRequest | ||||
|     { | ||||
|         foreach ($this->textareaFields as $fieldName) { | ||||
|             if (array_key_exists($fieldName, $transaction)) { | ||||
|                 $current[$fieldName] = $this->clearString((string) $transaction[$fieldName]); | ||||
|                 $current[$fieldName] = $this->clearString((string)$transaction[$fieldName]); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -231,8 +231,8 @@ class UpdateRequest extends FormRequest | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param array $current | ||||
|      * @param array $transaction | ||||
|      * @param  array  $current | ||||
|      * @param  array  $transaction | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
| @@ -241,8 +241,8 @@ class UpdateRequest extends FormRequest | ||||
|         foreach ($this->dateFields as $fieldName) { | ||||
|             Log::debug(sprintf('Now at date field %s', $fieldName)); | ||||
|             if (array_key_exists($fieldName, $transaction)) { | ||||
|                 Log::debug(sprintf('New value: "%s"', (string) $transaction[$fieldName])); | ||||
|                 $current[$fieldName] = $this->dateFromValue((string) $transaction[$fieldName]); | ||||
|                 Log::debug(sprintf('New value: "%s"', (string)$transaction[$fieldName])); | ||||
|                 $current[$fieldName] = $this->dateFromValue((string)$transaction[$fieldName]); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -250,8 +250,8 @@ class UpdateRequest extends FormRequest | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param array $current | ||||
|      * @param array $transaction | ||||
|      * @param  array  $current | ||||
|      * @param  array  $transaction | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
| @@ -259,7 +259,7 @@ class UpdateRequest extends FormRequest | ||||
|     { | ||||
|         foreach ($this->booleanFields as $fieldName) { | ||||
|             if (array_key_exists($fieldName, $transaction)) { | ||||
|                 $current[$fieldName] = $this->convertBoolean((string) $transaction[$fieldName]); | ||||
|                 $current[$fieldName] = $this->convertBoolean((string)$transaction[$fieldName]); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -267,8 +267,8 @@ class UpdateRequest extends FormRequest | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param array $current | ||||
|      * @param array $transaction | ||||
|      * @param  array  $current | ||||
|      * @param  array  $transaction | ||||
|      * | ||||
|      * @return array | ||||
|      */ | ||||
| @@ -283,6 +283,28 @@ class UpdateRequest extends FormRequest | ||||
|         return $current; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param  array  $current | ||||
|      * @param  array  $transaction | ||||
|      * @return array | ||||
|      */ | ||||
|     private function getFloatData(array $current, array $transaction): array | ||||
|     { | ||||
|         foreach ($this->floatFields as $fieldName) { | ||||
|             if (array_key_exists($fieldName, $transaction)) { | ||||
|                 $value = $transaction[$fieldName]; | ||||
|                 if (is_float($value)) { | ||||
|                     $current[$fieldName] = sprintf('%.24f', $value); | ||||
|                 } | ||||
|                 if (!is_float($value)) { | ||||
|                     $current[$fieldName] = (string)$value; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return $current; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * The rules that the incoming request must be matched against. | ||||
|      * | ||||
| @@ -368,7 +390,7 @@ class UpdateRequest extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
| @@ -396,26 +418,4 @@ class UpdateRequest extends FormRequest | ||||
|             } | ||||
|         ); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param array $current | ||||
|      * @param array $transaction | ||||
|      * @return array | ||||
|      */ | ||||
|     private function getFloatData(array $current, array $transaction): array | ||||
|     { | ||||
|         foreach ($this->floatFields as $fieldName) { | ||||
|             if (array_key_exists($fieldName, $transaction)) { | ||||
|                 $value = $transaction[$fieldName]; | ||||
|                 if (is_float($value)) { | ||||
|                     $current[$fieldName] = sprintf('%.24f', $value); | ||||
|                 } | ||||
|                 if (!is_float($value)) { | ||||
|                     $current[$fieldName] = (string) $value; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return $current; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -74,7 +74,7 @@ class StoreRequest extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
| @@ -88,7 +88,7 @@ class StoreRequest extends FormRequest | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      */ | ||||
|     private function validateExistingLink(Validator $validator): void | ||||
|     { | ||||
| @@ -103,8 +103,8 @@ class StoreRequest extends FormRequest | ||||
|         $journalRepos->setUser($user); | ||||
|  | ||||
|         $data      = $validator->getData(); | ||||
|         $inwardId  = (int) ($data['inward_id'] ?? 0); | ||||
|         $outwardId = (int) ($data['outward_id'] ?? 0); | ||||
|         $inwardId  = (int)($data['inward_id'] ?? 0); | ||||
|         $outwardId = (int)($data['outward_id'] ?? 0); | ||||
|         $inward    = $journalRepos->find($inwardId); | ||||
|         $outward   = $journalRepos->find($outwardId); | ||||
|  | ||||
|   | ||||
| @@ -74,7 +74,7 @@ class UpdateRequest extends FormRequest | ||||
|     /** | ||||
|      * Configure the validator instance. | ||||
|      * | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      * | ||||
|      * @return void | ||||
|      */ | ||||
| @@ -88,7 +88,7 @@ class UpdateRequest extends FormRequest | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param Validator $validator | ||||
|      * @param  Validator  $validator | ||||
|      */ | ||||
|     private function validateUpdate(Validator $validator): void | ||||
|     { | ||||
| @@ -105,8 +105,8 @@ class UpdateRequest extends FormRequest | ||||
|  | ||||
|         $inwardId  = $data['inward_id'] ?? $existing->source_id; | ||||
|         $outwardId = $data['outward_id'] ?? $existing->destination_id; | ||||
|         $inward    = $journalRepos->find((int) $inwardId); | ||||
|         $outward   = $journalRepos->find((int) $outwardId); | ||||
|         $inward    = $journalRepos->find((int)$inwardId); | ||||
|         $outward   = $journalRepos->find((int)$outwardId); | ||||
|         if (null === $inward) { | ||||
|             $inward = $existing->source; | ||||
|         } | ||||
|   | ||||
| @@ -24,7 +24,6 @@ declare(strict_types=1); | ||||
| namespace FireflyIII\Api\V1\Requests\Models\TransactionLinkType; | ||||
|  | ||||
| use FireflyIII\Models\LinkType; | ||||
| use FireflyIII\Models\TransactionJournalLink; | ||||
| use FireflyIII\Support\Request\ChecksLogin; | ||||
| use FireflyIII\Support\Request\ConvertsDataTypes; | ||||
| use Illuminate\Foundation\Http\FormRequest; | ||||
|   | ||||
| @@ -86,7 +86,7 @@ class UpdateRequest extends FormRequest | ||||
|         $deliveries = implode(',', array_keys(Webhook::getDeliveriesForValidation())); | ||||
|  | ||||
|         /** @var Webhook $webhook */ | ||||
|         $webhook    = $this->route()->parameter('webhook'); | ||||
|         $webhook = $this->route()->parameter('webhook'); | ||||
|  | ||||
|         return [ | ||||
|             'title'    => sprintf('between:1,512|uniqueObjectForUser:webhooks,title,%d', $webhook->id), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user