From 0a561179c7c1a74d4eba7f1124bfb9fa31621df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albin=20H=C3=BCbsch?= Date: Mon, 9 Dec 2019 09:47:24 +0100 Subject: [PATCH] Fix type error when electricity_collection is null Billogram recently updated the api in a silent upgrade. The `electricity_collection` can now return null which made the `CollectionForElectricityInvoices::createFromArray` crash. This commit is not a complete fix but solves the current crash caused by Billogram returning null values. According to the Billogram documentation `electricity_collection` is deprecated and should no longer be defined at the billogram level, but instead defined at item level. --- src/Model/Invoice/RegionalInformation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Invoice/RegionalInformation.php b/src/Model/Invoice/RegionalInformation.php index efce739..5bc7703 100644 --- a/src/Model/Invoice/RegionalInformation.php +++ b/src/Model/Invoice/RegionalInformation.php @@ -537,7 +537,7 @@ public static function createFromArray(array $data) $regionalInfo->efakturaRecipientBankCode = $data['efaktura_recipient_bank_code'] ?? null; $regionalInfo->rotavdragPersonalNumber = $data['efaktura_recipient_id_number'] ?? null; $regionalInfo->efakturaRequestedAmount = $data['efaktura_requested_amount'] ?? null; - $regionalInfo->collectionForElectricityInvoices = CollectionForElectricityInvoices::createFromArray($data['electricity_collection']); + $regionalInfo->collectionForElectricityInvoices = CollectionForElectricityInvoices::createFromArray($data['electricity_collection'] ?? []); return $regionalInfo; }