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
21 changes: 8 additions & 13 deletions lib/Fhp/BaseAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,24 @@
abstract class BaseAction implements \Serializable
{
/** @var int[] Stores segment numbers that were assigned to the segments returned from {@link createRequest()}. */
protected $requestSegmentNumbers;
protected ?array $requestSegmentNumbers = null;

/**
* @var string|null Contains the name of the segment, that might need a tan, used by FinTs::execute to signal
* Contains the name of the segment, that might need a tan, used by FinTs::execute to signal
* to the bank that supplying a tan is supported.
*/
protected $needTanForSegment = null;
protected ?string $needTanForSegment = null;

/**
* If set, the last response from the server regarding this action asked for a TAN from the user.
* @var TanRequest|null
*/
protected $tanRequest;
/** If set, the last response from the server regarding this action asked for a TAN from the user. */
protected ?TanRequest $tanRequest = null;

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

/**
* Will be populated with the message the bank sent along with the success indication, can be used to show to
* the user.
* @var string
*/
public $successMessage;
public ?string $successMessage = null;

/**
* @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
Expand Down Expand Up @@ -231,7 +226,7 @@ public function processResponse(Message $response)
/** @return int[] */
public function getRequestSegmentNumbers(): array
{
return $this->requestSegmentNumbers;
return $this->requestSegmentNumbers ?? [];
}

/**
Expand Down
34 changes: 11 additions & 23 deletions lib/Fhp/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,10 @@
*/
class Connection
{
/**
* @var string
*/
protected $url;

/**
* @var resource
*/
protected $curlHandle;

/**
* @var int
*/
protected $timeoutConnect = 15;

/**
* @var int
*/
protected $timeoutResponse = 30;
protected string $url;
protected ?\CurlHandle $curlHandle = null;
protected int $timeoutConnect = 15;
protected int $timeoutResponse = 30;

public function __construct(string $url, int $timeoutConnect = 15, int $timeoutResponse = 30)
{
Expand All @@ -34,9 +19,12 @@ public function __construct(string $url, int $timeoutConnect = 15, int $timeoutR
$this->timeoutResponse = $timeoutResponse;
}

private function connect()
/**
* @throws CurlException When initializing cURL fails.
*/
private function connect(): void
{
$this->curlHandle = curl_init();
$this->curlHandle = curl_init() ?: throw new CurlException('Failed initializing cURL.');

curl_setopt($this->curlHandle, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($this->curlHandle, CURLOPT_SSL_VERIFYHOST, 2);
Expand All @@ -52,7 +40,7 @@ private function connect()
curl_setopt($this->curlHandle, CURLOPT_HTTPHEADER, ['cache-control: no-cache', 'Content-Type: text/plain']);
}

public function disconnect()
public function disconnect(): void
{
if ($this->curlHandle !== null) {
curl_close($this->curlHandle);
Expand All @@ -76,7 +64,7 @@ public function send(string $message): string

if (false === $response) {
throw new CurlException(
'Failed connection to ' . $this->url . ': ' . curl_error($this->curlHandle),
'Failed sending to ' . $this->url . ': ' . curl_error($this->curlHandle),
null,
curl_errno($this->curlHandle),
curl_getinfo($this->curlHandle),
Expand Down
30 changes: 6 additions & 24 deletions lib/Fhp/Model/StatementOfAccount/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,12 @@ class Statement
public const CD_CREDIT = 'credit';
public const CD_DEBIT = 'debit';

/**
* @var array of Transaction
*/
protected $transactions = [];

/**
* @var float
*/
protected $startBalance = 0.0;

/**
* @var float|null
*/
protected $endBalance = null;

/**
* @var string|null
*/
protected $creditDebit = null;

/**
* @var \DateTime|null
*/
protected $date;
/** @var Transaction[] */
protected array $transactions = [];
protected float $startBalance = 0.0;
protected ?float $endBalance = null;
protected ?string $creditDebit = null;
protected ?\DateTime $date = null;

/**
* Get transactions
Expand Down
6 changes: 2 additions & 4 deletions lib/Fhp/Model/StatementOfAccount/StatementOfAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

class StatementOfAccount
{
/**
* @var Statement[]
*/
protected $statements = [];
/** @var Statement[] */
protected array $statements = [];

/**
* Get statements
Expand Down
Loading