Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Fhp/Action/SendSEPADirectDebit.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ protected function createRequest(BPD $bpd, ?UPD $upd)

if ($hidxes->getVersion() === 2) {
/** @var HIDMESv2|HIDSESv2 $hidxes */
$supportedPainNamespaces = $hidxes->getParameter()->unterstuetzteSEPADatenformate;
$supportedPainNamespaces = $hidxes->getParameter()->getUnterstuetzteSEPADatenformate();
}

// If there are no SEPA formats available in the HIDXES Parameters, we look to the general formats
if (!is_array($supportedPainNamespaces) || count($supportedPainNamespaces) === 0) {
/** @var HISPAS $hispas */
$hispas = $bpd->requireLatestSupportedParameters('HISPAS');
$supportedPainNamespaces = $hispas->getParameter()->getUnterstuetzteSepaDatenformate();
$supportedPainNamespaces = $hispas->getParameter()->getUnterstuetzteSEPADatenformate();
}

// Sometimes the Bank reports supported schemas with a "_GBIC_X" postfix.
Expand Down
4 changes: 2 additions & 2 deletions lib/Fhp/Action/SendSEPARealtimeTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ protected function createRequest(BPD $bpd, ?UPD $upd)
/** @var HIIPZSv1|HIIPZSv2 $hiipzs */
$hiipzs = $bpd->requireLatestSupportedParameters('HIIPZS');

$supportedSchemas = $hiipzs->parameter->unterstuetzteSEPADatenformate;
$supportedSchemas = $hiipzs->parameter->getUnterstuetzteSEPADatenformate();

// If there are no SEPA formats available in the HIIPZS Parameters, we look to the general formats
if (is_null($supportedSchemas)) {
/** @var HISPAS $hispas */
$hispas = $bpd->requireLatestSupportedParameters('HISPAS');
$supportedSchemas = $hispas->getParameter()->getUnterstuetzteSepaDatenformate();
$supportedSchemas = $hispas->getParameter()->getUnterstuetzteSEPADatenformate();
}

// Sometimes the Bank reports supported schemas with a "_GBIC_X" postfix.
Expand Down
4 changes: 2 additions & 2 deletions lib/Fhp/Action/SendSEPATransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ protected function createRequest(BPD $bpd, ?UPD $upd)
}

/** @var HISPAS $hispas */
$parameters = $bpd->requireLatestSupportedParameters('HISPAS');
$supportedSchemas = $parameters->getParameter()->getUnterstuetzteSepaDatenformate();
$hispas = $bpd->requireLatestSupportedParameters('HISPAS');
$supportedSchemas = $hispas->getParameter()->getUnterstuetzteSEPADatenformate();

// Sometimes the Bank reports supported schemas with a "_GBIC_X" postfix.
// GIBC_X stands for German Banking Industry Committee and a version counter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
namespace Fhp\Segment\BME;

use Fhp\Segment\BSE\ParameterTerminierteSEPAFirmenLastschriftEinreichenV2;
use Fhp\Segment\UnterstuetzteSEPADatenformate;
use Fhp\Segment\UnterstuetzteSEPADatenformateTrait;

class ParameterTerminierteSEPAFirmenSammellastschriftEinreichenV2 extends ParameterTerminierteSEPAFirmenLastschriftEinreichenV2
class ParameterTerminierteSEPAFirmenSammellastschriftEinreichenV2 extends ParameterTerminierteSEPAFirmenLastschriftEinreichenV2 implements UnterstuetzteSEPADatenformate
{
use UnterstuetzteSEPADatenformateTrait;

public int $maximaleAnzahlDirectDebitTransferTransactionInformation;
public bool $summenfeldBenoetigt;
public bool $einzelbuchungErlaubt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

namespace Fhp\Segment\BSE;

class ParameterTerminierteSEPAFirmenEinzellastschriftEinreichenV2 extends ParameterTerminierteSEPAFirmenLastschriftEinreichenV2
use Fhp\Segment\UnterstuetzteSEPADatenformate;
use Fhp\Segment\UnterstuetzteSEPADatenformateTrait;

class ParameterTerminierteSEPAFirmenEinzellastschriftEinreichenV2 extends ParameterTerminierteSEPAFirmenLastschriftEinreichenV2 implements UnterstuetzteSEPADatenformate
{
use UnterstuetzteSEPADatenformateTrait;

/** Max Length: 4096 */
public ?string $zulaessigePurposecodes = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
namespace Fhp\Segment\DME;

use Fhp\Segment\DSE\ParameterTerminierteSEPALastschriftEinreichenV2;
use Fhp\Segment\UnterstuetzteSEPADatenformate;
use Fhp\Segment\UnterstuetzteSEPADatenformateTrait;

class ParameterTerminierteSEPASammellastschriftEinreichenV2 extends ParameterTerminierteSEPALastschriftEinreichenV2
class ParameterTerminierteSEPASammellastschriftEinreichenV2 extends ParameterTerminierteSEPALastschriftEinreichenV2 implements UnterstuetzteSEPADatenformate
{
use UnterstuetzteSEPADatenformateTrait;

public int $maximaleAnzahlDirectDebitTransferTransactionInformation;
public bool $summenfeldBenoetigt;
public bool $einzelbuchungErlaubt;
Expand Down
2 changes: 1 addition & 1 deletion lib/Fhp/Segment/DSE/HIDSESv1.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class HIDSESv1 extends BaseGeschaeftsvorfallparameter implements HIDXES
{
public ParameterTerminierteSEPAEinzellastschriftEinreichenV1 $parameter;

public function getParameter(): SEPADirectDebitMinimalLeadTimeProvider
public function getParameter(): ParameterTerminierteSEPAEinzellastschriftEinreichenV1
{
return $this->parameter;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Fhp/Segment/DSE/HIDSESv2.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class HIDSESv2 extends BaseGeschaeftsvorfallparameter implements HIDXES
{
public ParameterTerminierteSEPAEinzellastschriftEinreichenV2 $parameter;

public function getParameter(): SEPADirectDebitMinimalLeadTimeProvider
public function getParameter(): ParameterTerminierteSEPAEinzellastschriftEinreichenV2
{
return $this->parameter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

namespace Fhp\Segment\DSE;

class ParameterTerminierteSEPAEinzellastschriftEinreichenV2 extends ParameterTerminierteSEPALastschriftEinreichenV2
use Fhp\Segment\UnterstuetzteSEPADatenformate;
use Fhp\Segment\UnterstuetzteSEPADatenformateTrait;

class ParameterTerminierteSEPAEinzellastschriftEinreichenV2 extends ParameterTerminierteSEPALastschriftEinreichenV2 implements UnterstuetzteSEPADatenformate
{
use UnterstuetzteSEPADatenformateTrait;

/** Max Length: 4096 */
public ?string $zulaessigePurposecodes = null;

Expand Down
6 changes: 5 additions & 1 deletion lib/Fhp/Segment/IPZ/ParameterSEPAInstantPaymentZahlungV1.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
namespace Fhp\Segment\IPZ;

use Fhp\Segment\BaseDeg;
use Fhp\Segment\UnterstuetzteSEPADatenformate;
use Fhp\Segment\UnterstuetzteSEPADatenformateTrait;

/**
* Parameter SEPA-Instant Payment Zahlung (Version 1)
*
* @link https://www.hbci-zka.de/dokumente/spezifikation_deutsch/fintsv3/FinTS_3.0_Messages_Geschaeftsvorfaelle_2022-04-15_final_version.pdf
* Section D
*/
class ParameterSEPAInstantPaymentZahlungV1 extends BaseDeg
class ParameterSEPAInstantPaymentZahlungV1 extends BaseDeg implements UnterstuetzteSEPADatenformate
{
use UnterstuetzteSEPADatenformateTrait;

/** Max Length: 4096 */
public ?string $zulaessigePurposecodes = null;

Expand Down
6 changes: 5 additions & 1 deletion lib/Fhp/Segment/IPZ/ParameterSEPAInstantPaymentZahlungV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
namespace Fhp\lib\Fhp\Segment\IPZ;

use Fhp\Segment\BaseDeg;
use Fhp\Segment\UnterstuetzteSEPADatenformate;
use Fhp\Segment\UnterstuetzteSEPADatenformateTrait;

/**
* Parameter SEPA-Instant Payment Zahlung (Version 2)
*
* @link https://www.hbci-zka.de/dokumente/spezifikation_deutsch/fintsv3/FinTS_3.0_Messages_Geschaeftsvorfaelle_2022-04-15_final_version.pdf
* Section D
*/
class ParameterSEPAInstantPaymentZahlungV2 extends BaseDeg
class ParameterSEPAInstantPaymentZahlungV2 extends BaseDeg implements UnterstuetzteSEPADatenformate
{
use UnterstuetzteSEPADatenformateTrait;

public bool $umwandlungNachSEPAUeberweisungZulaessigErlaubt;

/** Max Length: 4096 */
Expand Down
7 changes: 4 additions & 3 deletions lib/Fhp/Segment/SPA/ParameterSepaKontoverbindungAnfordern.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@

namespace Fhp\Segment\SPA;

use Fhp\Segment\UnterstuetzteSEPADatenformate;

/**
* Data Element Group: Parameter SEPA-Kontoverbindung anfordern
*/
interface ParameterSepaKontoverbindungAnfordern
interface ParameterSepaKontoverbindungAnfordern extends UnterstuetzteSEPADatenformate
{
/** @return string[] */
public function getUnterstuetzteSepaDatenformate(): array;

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Fhp\Segment\SPA;

use Fhp\Segment\BaseDeg;
use Fhp\Segment\UnterstuetzteSEPADatenformateTrait;

/**
* Data Element Group: Parameter SEPA-Kontoverbindung anfordern (Version 1)
Expand All @@ -13,7 +14,7 @@
*/
class ParameterSepaKontoverbindungAnfordernV1 extends BaseDeg implements ParameterSepaKontoverbindungAnfordern
{
use GetUnterstuetzteSepaDatenformateTrait;
use UnterstuetzteSEPADatenformateTrait;

public bool $einzelkontenabrufErlaubt;
public bool $nationaleKontoverbindungErlaubt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Fhp\Segment\SPA;

use Fhp\Segment\BaseDeg;
use Fhp\Segment\UnterstuetzteSEPADatenformateTrait;

/**
* Data Element Group: Parameter SEPA-Kontoverbindung anfordern (Version 2)
Expand All @@ -13,7 +14,7 @@
*/
class ParameterSepaKontoverbindungAnfordernV2 extends BaseDeg implements ParameterSepaKontoverbindungAnfordern
{
use GetUnterstuetzteSepaDatenformateTrait;
use UnterstuetzteSEPADatenformateTrait;

public bool $einzelkontenabrufErlaubt;
public bool $nationaleKontoverbindungErlaubt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Fhp\Segment\SPA;

use Fhp\Segment\BaseDeg;
use Fhp\Segment\UnterstuetzteSEPADatenformateTrait;

/**
* Data Element Group: Parameter SEPA-Kontoverbindung anfordern (Version 3)
Expand All @@ -13,7 +14,7 @@
*/
class ParameterSepaKontoverbindungAnfordernV3 extends BaseDeg implements ParameterSepaKontoverbindungAnfordern
{
use GetUnterstuetzteSepaDatenformateTrait;
use UnterstuetzteSEPADatenformateTrait;

public bool $einzelkontenabrufErlaubt;
public bool $nationaleKontoverbindungErlaubt;
Expand Down
10 changes: 10 additions & 0 deletions lib/Fhp/Segment/UnterstuetzteSEPADatenformate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/** @noinspection PhpUnused */

namespace Fhp\Segment;

interface UnterstuetzteSEPADatenformate
{
/** @return string[] */
public function getUnterstuetzteSEPADatenformate(): array;
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace Fhp\Segment\SPA;
namespace Fhp\Segment;

/**
* @link https://www.hbci-zka.de/dokumente/spezifikation_deutsch/fintsv3/FinTS_3.0_Messages_Geschaeftsvorfaelle_2015-08-07_final_version.pdf
* Section: D ("Unterstützte SEPA-Datenformate")
*/
trait GetUnterstuetzteSepaDatenformateTrait
trait UnterstuetzteSEPADatenformateTrait
{
/** @return string[] */
public function getUnterstuetzteSepaDatenformate(): array
public function getUnterstuetzteSEPADatenformate(): array
{
// Something like "sepade.pain.00x.001.0y.xsd" is allowed here, which is not a valid SEPA XML URN / Namespace
return array_map(function ($sepaUrn) {
Expand All @@ -18,6 +18,6 @@ public function getUnterstuetzteSepaDatenformate(): array
'sepade:' => 'urn:iso:std:iso:20022:tech:xsd:',
'.xsd' => '',
]);
}, $this->unterstuetzteSepaDatenformate);
}, $this->unterstuetzteSepaDatenformate ?? $this->unterstuetzteSEPADatenformate ?? []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little odd that we have both spelling variants. Renaming one of them would be a breaking change, but I think we should still do it. Not only would that get rid of the weird fallback here, but it would also make the library's API more consistent for users.

I don't use this API myself, so I don't know whether typical users of this API would have ->unterstuetzteSEPADatenformate in their code. Though I suspect that accessing that field directly isn't generally necessary to use this API. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think we should change it to be consistent, but didn't want to break anything. Thinking about it further, I doubt that people are using ->unterstuetzteSepaDatenformate in their own code.

As the spec uses 'SEPA' (and not 'Sepa'), changing $unterstuetzteSepaDatenformate to $unterstuetzteSEPADatenformate should do to the trick.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" I doubt that people are using x" - famous last words. :)

I would suggest any breaking change to be released in a v4.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nemiah Is it easy to do v4? Are there release notes anywhere? Or is there a branch where we can store changes to enter the next breaking release?

It's surprising to me that this would be the first breaking change since v3 five (!) years ago. Maybe this library has a different policy for mildly breaking changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the spec uses 'SEPA' (and not 'Sepa')

While I'm not against using "SEPA" instead of "Sepa", the spec doesn't make for a relevant argument here. It's written as prose text, where acronyms are fully capitalized, of course. But here we have a camel-case identifier, where the general opinion out there is to treat acronyms like any other words, i.e. without internal capitalization. There's only some side discussions whether this should also apply to very short acronyms or not.

(((One argument I hear often is that transformation to e.g. snake case should be mechanical. So if we want unterstuetzte_sepa_datenformate and not unterstuetzte_s_e_p_a_datenformate, then the camel case must be unterstuetzteSepaDatenformate, or a typically dumb IDE would make mistakes when transforming automatically. Another argument is that lower-camel-case is otherwise tricky, e.g. should it be sEPAFoo or sepaFoo or sePAFoo. Personally, I don't give these arguments much weight because to a human it's clear what to do in each case; but I still see these cases as an indicator for what's the most proper solution if given no other signal.)))

That said, this library is currently not consistent at all: phpFinTS is the repo name, FinTs is the main class name. In terms of acronyms coming straight from the spec, MT940, segment classes like HITAN and BPD are all-caps, whereas Deg, Kti, Iban and such are not.

So while we can't realistically achieve total consistency across all identifiers in the library, if we want to make unterstuetzteS???Datenformate consistent, we should loook at how SEPA is typically spelled elsewhere in this library, to be self-consistent at least. (And ignore the spec.)

Some quick grepping shows that SEPA currently has the majority. So I'd err on that side to achieve eventual consistency. Another option (if we want to side-step the breaking change) is to punt on this for now (leave as is, non-breaking) and send a separate commit to a new v4 branch that fixes this plus the few remaining Sepa cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct with all your observations. I have no preferences how the names should be.
Right now I would just leave it handling both cases and maybe revisit the problem in a larger context, making everything more consistent.

}
}