digitick / php-sepa-xml

* THIS PROJECT IS NO LONGER MAINTAINED* SEPA file generator in PHP
107 stars 63 forks source link

Removing warning on empty SEPA #7

Closed Geompse closed 11 years ago

Geompse commented 11 years ago

When creating a $stf = new SepaTransferFile() and calling $stf->asXML() without any $stf->addPaymentInfo(), the following warning occurs : SepaTransferFile.php:139 [PhpWarning] Invalid argument supplied for foreach()

While there is no real use of making an empty SEPA, the case should be handled, eventually throwing an exception.

Here under this only patches the warning.

diff --git a/SepaTransferFile.php b/SepaTransferFile.php
index f442af7..5c15d74 100644
--- a/SepaTransferFile.php
+++ b/SepaTransferFile.php
@@ -75,5 +75,5 @@ class SepaTransferFile extends SepaFileBlock
        /**
         * @var SepaPaymentInfo[]
         */
-       protected $payments;
+       protected $payments = array();

I tried using GIT to push a request but I did not succeed.