From 43436ae942292bf48b0f2939bbd4e162e727f19c Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 19 Apr 2020 06:00:11 +0200 Subject: [PATCH] Fix issue with casting. --- app/Factory/TransactionJournalFactory.php | 4 ++-- app/Http/Controllers/Transaction/ConvertController.php | 4 ++-- app/Validation/TransactionValidation.php | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index 91e1cdaf18..e40043e593 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -607,7 +607,7 @@ class TransactionJournalFactory // validate source account. $sourceId = isset($data['source_id']) ? (int) $data['source_id'] : null; - $sourceName = $data['source_name'] ?? null; + $sourceName = isset($data['source_name']) ? (string) $data['source_name'] : null; $validSource = $this->accountValidator->validateSource($sourceId, $sourceName, null); // do something with result: @@ -617,7 +617,7 @@ class TransactionJournalFactory Log::debug('Source seems valid.'); // validate destination account $destinationId = isset($data['destination_id']) ? (int) $data['destination_id'] : null; - $destinationName = (string)($data['destination_name'] ?? null); + $destinationName = isset($data['destination_name']) ? (string) $data['destination_name'] : null; $validDestination = $this->accountValidator->validateDestination($destinationId, $destinationName, null); // do something with result: if (false === $validDestination) { diff --git a/app/Http/Controllers/Transaction/ConvertController.php b/app/Http/Controllers/Transaction/ConvertController.php index ffdb367ae6..42c0cee6a2 100644 --- a/app/Http/Controllers/Transaction/ConvertController.php +++ b/app/Http/Controllers/Transaction/ConvertController.php @@ -206,9 +206,9 @@ class ConvertController extends Controller // double check its not an empty string. $sourceId = '' === $sourceId || null === $sourceId ? null : (int) $sourceId; - $sourceName = '' === $sourceName ? null : $sourceName; + $sourceName = '' === $sourceName ? null : (string) $sourceName; $destinationId = '' === $destinationId || null === $destinationId ? null : (int) $destinationId; - $destinationName = (string)('' === $destinationName ? null : $destinationName); + $destinationName = '' === $destinationName ? null : (string) $destinationName; $validSource = $validator->validateSource($sourceId, $sourceName, null); $validDestination = $validator->validateDestination($destinationId, $destinationName, null); diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php index eaca941da1..457bf4fa3e 100644 --- a/app/Validation/TransactionValidation.php +++ b/app/Validation/TransactionValidation.php @@ -73,8 +73,8 @@ trait TransactionValidation // validate source account. $sourceId = isset($transaction['source_id']) ? (int) $transaction['source_id'] : null; - $sourceName = $transaction['source_name'] ?? null; - $sourceIban = $transaction['source_iban'] ?? null; + $sourceName = isset($transaction['source_name']) ? (string) $transaction['source_name'] : null; + $sourceIban = isset($transaction['source_iban']) ? (string) $transaction['source_iban'] : null; $validSource = $accountValidator->validateSource($sourceId, $sourceName, $sourceIban); // do something with result: @@ -86,8 +86,8 @@ trait TransactionValidation } // validate destination account $destinationId = isset($transaction['destination_id']) ? (int) $transaction['destination_id'] : null; - $destinationName = $transaction['destination_name'] ?? null; - $destinationIban = $transaction['destination_iban'] ?? null; + $destinationName = isset($transaction['destination_name']) ? (string) $transaction['destination_name'] : null; + $destinationIban = isset($transaction['destination_iban']) ? (string) $transaction['destination_iban'] : null; $validDestination = $accountValidator->validateDestination($destinationId, $destinationName, $destinationIban); // do something with result: if (false === $validDestination) {