Skip to content

RFC: Proposal for next major #155

@PowerKiKi

Description

@PowerKiKi

Model closer to spec

While maintaining this lib in the past few months, I noticed its model is sometimes a simplification of the specification. While it makes using the lib somewhat easier, it also prevent to access some data that exists in the XML but cannot be modelized (without twisting even more the model).

In order to fix that I'd like to introduce breaking changes by re-modeling the entire thing to stick much closer to the specification (while retaining a few simplification if it does not prevent supporting more data).

So instead of this:

// access to BkToCstmrDbtCdtNtfctn->Ntfctn->Ntry->NtryDtls->TxDtls->AmtDtls->TxAmt->Amt
$amount = $message->getRecords()[0]->getEntries()[0]->getTransactionDetail()->getAmountDetails();

We would get something closer to this:

// access to BkToCstmrDbtCdtNtfctn->Ntfctn->Ntry->NtryDtls->TxDtls->AmtDtls->TxAmt->Amt
$amount = $message->getRecords()[0]->getEntries()[0]->getTransactionDetails()[0]->getAmountDetails()->getTransactionAmount();

// New possibility: access to until-now hidden data InstdAmt !
// access to BkToCstmrDbtCdtNtfctn->Ntfctn->Ntry->NtryDtls->TxDtls->AmtDtls->InstdAmt>Amt
$amount = $message->getRecords()[0]->getEntries()[0]->getTransactionDetails()[0]->getAmountDetails()->getInstructedAmount();

Notice how new data are available because we follow more closely the structure of the spec. And notice also that the singular getTransactionDetail() disappear entirely.

This would also mean to rename a few things to be closer to spec. Sometimes the spec has a lot of different terms, but in the end all of those terms exists for a reason. Renaming things to be closer to the spec would help developers understand the spec better and thus allow them to better choose which data they should access.

The limitations described in 5de970a would also be lifted.

Readonly model

Since we would be introducing breaking changes, I would also like to explore the possibility to have an entirely readonly model, based on public properties, instead of getters. So the final result would be:

// access to BkToCstmrDbtCdtNtfctn->Ntfctn->Ntry->NtryDtls->TxDtls->AmtDtls->TxAmt->Amt
$amount = $message->records[0]->entries[0]->transactionDetails[0]->amountDetails->transactionAmount;

The reasoning being that, first of all, the library users are never meant to update data, because the library cannot write back to XML. And keeping only readonly properties reduce maintenance burden by drastically reducing code quantity, and avoiding type declaration duplications.

This is a quick sample of what I had in mind:

image

PHP support

All of this would most likely target PHP 8.2, because it brings the nice-to-have readonly classes. So we might drop support for PHP 8.1 a bit before it becomes EOL, but not by much. I guess that should be fine

RFC ?

@frederikbosch, @localheinz, and everybody else, does all of this sound reasonable to you ? would you foresee trouble further down the line ? or did you have different ideas altogether ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions