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
2 changes: 1 addition & 1 deletion lib/Fhp/Action/GetBalance.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
class GetBalance extends PaginateableAction
{
// Request (not available after serialization, i.e. not available in processResponse()).
// Request (if you add a field here, update __serialize() and __unserialize() as well).
/** @var SEPAAccount */
private $account;
/** @var bool */
Expand Down
2 changes: 1 addition & 1 deletion lib/Fhp/Action/GetDepotAufstellung.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
class GetDepotAufstellung extends PaginateableAction
{
// Request (not available after serialization, i.e. not available in processResponse()).
// Request (if you add a field here, update __serialize() and __unserialize() as well).
/** @var SEPAAccount */
private $account;

Expand Down
42 changes: 40 additions & 2 deletions lib/Fhp/Action/GetSEPADirectDebitParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ class GetSEPADirectDebitParameters extends BaseAction
public const SEQUENCE_TYPES = ['FRST', 'OOFF', 'FNAL', 'RCUR'];
public const DIRECT_DEBIT_TYPES = ['CORE', 'COR1', 'B2B'];

// Request (if you add a field here, update __serialize() and __unserialize() as well).
/** @var string */
private $directDebitType;

/** @var string */
private $seqType;

/** @var bool */
private $singleDirectDebit;

Expand All @@ -43,6 +42,45 @@ public static function create(string $seqType, bool $singleDirectDebit, string $
return $result;
}

/**
* @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023
Copy link
Contributor

Choose a reason for hiding this comment

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

Accordings to the comment this should have been removed long ago?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. But it's a breaking change. It's in my stack of commits for v4.

*/
public function serialize(): string
{
return serialize($this->__serialize());
}

public function __serialize(): array
{
return [
parent::__serialize(),
$this->directDebitType, $this->seqType, $this->singleDirectDebit,
];
}

/**
* @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023
*
* @param string $serialized
* @return void
*/
public function unserialize($serialized)
{
self::__unserialize(unserialize($serialized));
}

public function __unserialize(array $serialized): void
{
list(
$parentSerialized,
$this->directDebitType, $this->seqType, $this->singleDirectDebit,
) = $serialized;

is_array($parentSerialized) ?
parent::__unserialize($parentSerialized) :
parent::unserialize($parentSerialized);
}

public static function getHixxesSegmentName(string $directDebitType, bool $singleDirectDebit): string
{
switch ($directDebitType) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Fhp/Action/GetStatementOfAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
class GetStatementOfAccount extends PaginateableAction
{
// Request (not available after serialization, i.e. not available in processResponse()).
// Request (if you add a field here, update __serialize() and __unserialize() as well).
/** @var SEPAAccount */
private $account;
/** @var \DateTime */
Expand Down Expand Up @@ -93,7 +93,7 @@ public function __serialize(): array
{
return [
parent::__serialize(),
$this->account, $this->from, $this->to, $this->allAccounts,
$this->account, $this->from, $this->to, $this->allAccounts, $this->includeUnbooked,
$this->bankName,
];
}
Expand All @@ -113,7 +113,7 @@ public function __unserialize(array $serialized): void
{
list(
$parentSerialized,
$this->account, $this->from, $this->to, $this->allAccounts,
$this->account, $this->from, $this->to, $this->allAccounts, $this->includeUnbooked,
$this->bankName,
) = $serialized;

Expand Down
2 changes: 1 addition & 1 deletion lib/Fhp/Action/GetStatementOfAccountXML.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
class GetStatementOfAccountXML extends PaginateableAction
{
// Request (not available after serialization, i.e. not available in processResponse()).
// Request (if you add a field here, update __serialize() and __unserialize() as well).
/** @var SEPAAccount */
private $account;
/** @var \DateTime */
Expand Down
42 changes: 40 additions & 2 deletions lib/Fhp/Action/SendInternationalCreditTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@

class SendInternationalCreditTransfer extends BaseAction
{
// Request (if you add a field here, update __serialize() and __unserialize() as well).
/** @var SEPAAccount */
protected $account;

/** @var string */
protected $dtavzData;

/** @var string|null */
protected $dtavzVersion;

Expand All @@ -36,6 +35,45 @@ public static function create(SEPAAccount $account, string $dtavzData, ?string $
return $result;
}

/**
* @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023
*/
public function serialize(): string
{
return serialize($this->__serialize());
}

public function __serialize(): array
{
return [
parent::__serialize(),
$this->account, $this->dtavzData, $this->dtavzVersion,
];
}

/**
* @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023
*
* @param string $serialized
* @return void
*/
public function unserialize($serialized)
{
self::__unserialize(unserialize($serialized));
}

public function __unserialize(array $serialized): void
{
list(
$parentSerialized,
$this->account, $this->dtavzData, $this->dtavzVersion,
) = $serialized;

is_array($parentSerialized) ?
parent::__unserialize($parentSerialized) :
parent::unserialize($parentSerialized);
}

protected function createRequest(BPD $bpd, ?UPD $upd)
{
/** @var HIAUBSv9 $hiaubs */
Expand Down
9 changes: 3 additions & 6 deletions lib/Fhp/Action/SendSEPADirectDebit.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,24 @@
*/
class SendSEPADirectDebit extends BaseAction
{
// Request (if you add a field here, update __serialize() and __unserialize() as well).
/** @var SEPAAccount */
protected $account;

/** @var string */
protected $painMessage;

/** @var string */
protected $painNamespace;

/** @var float */
protected $ctrlSum;

/** @var bool */
protected $singleDirectDebit = false;

/** @var bool */
protected $tryToUseControlSumForSingleTransactions = false;

/** @var string */
private $coreType;

// There are no result fields. This action is simply marked as done to indicate that the transfer was executed.

public static function create(SEPAAccount $account, string $painMessage, bool $tryToUseControlSumForSingleTransactions = false): SendSEPADirectDebit
{
if (preg_match('/xmlns="(?<namespace>[^"]+)"/s', $painMessage, $matches) === 1) {
Expand Down
43 changes: 42 additions & 1 deletion lib/Fhp/Action/SendSEPARealtimeTransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@
*/
class SendSEPARealtimeTransfer extends BaseAction
{
// Request (if you add a field here, update __serialize() and __unserialize() as well).
/** @var SEPAAccount */
private $account;
/** @var string */
private $painMessage;
/** @var string */
private $xmlSchema;

private bool $allowConversionToSEPATransfer = true;

// There are no result fields. This action is simply marked as done to indicate that the transfer was executed.

/**
* @param SEPAAccount $account The account from which the transfer will be sent.
* @param string $painMessage An XML-formatted ISO 20022 message. You may want to use github.com/nemiah/phpSepaXml
Expand All @@ -52,6 +54,45 @@ public static function create(SEPAAccount $account, string $painMessage, bool $a
return $result;
}

/**
* @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023
*/
public function serialize(): string
{
return serialize($this->__serialize());
}

public function __serialize(): array
{
return [
parent::__serialize(),
$this->account, $this->painMessage, $this->xmlSchema, $this->allowConversionToSEPATransfer,
];
}

/**
* @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023
*
* @param string $serialized
* @return void
*/
public function unserialize($serialized)
{
self::__unserialize(unserialize($serialized));
}

public function __unserialize(array $serialized): void
{
list(
$parentSerialized,
$this->account, $this->painMessage, $this->xmlSchema, $this->allowConversionToSEPATransfer,
) = $serialized;

is_array($parentSerialized) ?
parent::__unserialize($parentSerialized) :
parent::unserialize($parentSerialized);
}

protected function createRequest(BPD $bpd, ?UPD $upd)
{
/** @var HIIPZSv1|HIIPZSv2 $hiipzs */
Expand Down
42 changes: 42 additions & 0 deletions lib/Fhp/Action/SendSEPATransfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
*/
class SendSEPATransfer extends BaseAction
{
// Request (if you add a field here, update __serialize() and __unserialize() as well).
/** @var SEPAAccount */
private $account;
/** @var string */
private $painMessage;
/** @var string */
private $xmlSchema;

// There are no result fields. This action is simply marked as done to indicate that the transfer was executed.

/**
* @param SEPAAccount $account The account from which the transfer will be sent.
* @param string $painMessage An XML-formatted ISO 20022 message. You may want to use github.com/nemiah/phpSepaXml
Expand All @@ -44,6 +47,45 @@ public static function create(SEPAAccount $account, string $painMessage): SendSE
return $result;
}

/**
* @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023
*/
public function serialize(): string
{
return serialize($this->__serialize());
}

public function __serialize(): array
{
return [
parent::__serialize(),
$this->account, $this->painMessage, $this->xmlSchema,
];
}

/**
* @deprecated Beginning from PHP7.4 __unserialize is used for new generated strings, then this method is only used for previously generated strings - remove after May 2023
*
* @param string $serialized
* @return void
*/
public function unserialize($serialized)
{
self::__unserialize(unserialize($serialized));
}

public function __unserialize(array $serialized): void
{
list(
$parentSerialized,
$this->account, $this->painMessage, $this->xmlSchema,
) = $serialized;

is_array($parentSerialized) ?
parent::__unserialize($parentSerialized) :
parent::unserialize($parentSerialized);
}

protected function createRequest(BPD $bpd, ?UPD $upd)
{
// ANALYSE XML FOR RECEIPTS AND PAYMENT DATE
Expand Down
8 changes: 2 additions & 6 deletions lib/Fhp/Protocol/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,7 @@ public function findRueckmeldungen(int $code): array
*/
public function serialize(): string
{
$result = '';
foreach ($this->wrapperSegments as $segment) {
$result .= Serializer::serializeSegment($segment);
}
return $result;
return Serializer::serializeSegments($this->wrapperSegments);
}

/**
Expand Down Expand Up @@ -351,7 +347,7 @@ public static function parse(string $rawMessage): Message
* @param int $segmentNumber The number for the *first* segment, subsequent segment get the subsequent integers.
* @return BaseSegment[] The same array, for chaining.
*/
private static function setSegmentNumbers(array $segments, int $segmentNumber): array
public static function setSegmentNumbers(array $segments, int $segmentNumber): array
{
foreach ($segments as $segment) {
$segment->segmentkopf->segmentnummer = $segmentNumber;
Expand Down
9 changes: 9 additions & 0 deletions lib/Fhp/Syntax/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ public static function serializeSegment(BaseSegment $segment): string
return implode(Delimiter::ELEMENT, static::flattenAndTrimEnd($serializedElements)) . Delimiter::SEGMENT;
}

/**
* @param BaseSegment[] $segments The segments to be serialized.
* @return string The concatenated HBCI wire format representation of the segments.
*/
public static function serializeSegments(array $segments): string
{
return implode(array_map(['self', 'serializeSegment'], $segments));
}

/**
* @param BaseSegment|BaseDeg|null $obj An object to be serialized. If null, all fields are implicitly null.
* @param BaseDescriptor $descriptor The descriptor for the object to be serialized.
Expand Down
Loading