Skip to content
Open
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 Samples/browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ function handleRequest(\stdClass $request, \Fhp\FinTs $fints)
case 'getTanMedia':
return array_map(function ($medium) {
return ['name' => $medium->getName(), 'phoneNumber' => $medium->getPhoneNumber()];
}, $fints->getTanMedia(intval($request->tanmode)));
}, $fints->getTanMedia((int)$request->tanmode));
case 'login':
$fints->selectTanMode(intval($request->tanmode), $request->tanmedium ?? null);
$fints->selectTanMode((int)$request->tanmode, $request->tanmedium ?? null);
$login = $fints->login();
if ($login->needsTan()) {
$tanRequest = $login->getTanRequest();
Expand Down
8 changes: 4 additions & 4 deletions Samples/tanModesAndMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

echo "Which one do you want to use? Index:\n";
$tanModeIndex = trim(fgets(STDIN));
if (!is_numeric($tanModeIndex) || !array_key_exists(intval($tanModeIndex), $tanModes)) {
if (!is_numeric($tanModeIndex) || !array_key_exists((int)$tanModeIndex, $tanModes)) {
echo 'Invalid index!';
return;
}
$tanMode = $tanModes[intval($tanModeIndex)];
$tanMode = $tanModes[(int)$tanModeIndex];
echo 'You selected ' . $tanMode->getName() . "\n";

// In case the selected TAN mode requires a TAN medium (e.g. if the user picked mTAN, they may have to pick the mobile
Expand All @@ -49,11 +49,11 @@

echo "Which one do you want to use? Index:\n";
$tanMediumIndex = trim(fgets(STDIN));
if (!is_numeric($tanMediumIndex) || !array_key_exists(intval($tanMediumIndex), $tanMedia)) {
if (!is_numeric($tanMediumIndex) || !array_key_exists((int)$tanMediumIndex, $tanMedia)) {
echo 'Invalid index!';
return;
}
$tanMedium = $tanMedia[intval($tanMediumIndex)];
$tanMedium = $tanMedia[(int)$tanMediumIndex];
echo 'You selected ' . $tanMedium->getName() . "\n";
} else {
$tanMedium = null;
Expand Down
8 changes: 4 additions & 4 deletions src/MT535/MT535.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function parseDepotWert(): float
{
preg_match('/:16R:ADDINFO(.*?):16S:ADDINFO/sm', $this->cleanedRawData, $block);
preg_match('/EUR(.*)/sm', $block[1], $matches);
return floatval(str_replace(',', '.', $matches[1]));
return (float) str_replace(',', '.', $matches[1]);
}

public function parseHoldings(): StatementOfHoldings
Expand Down Expand Up @@ -66,12 +66,12 @@ public function parseHoldings(): StatementOfHoldings
$holding->setCurrency($r[1]);
// Price
preg_match('/^.{14}(.*)/sm', $iwn[2], $r);
$holding->setPrice(floatval(str_replace(',', '.', $r[1])));
$holding->setPrice((float) str_replace(',', '.', $r[1]));
} elseif ($iwn[1] == 'A') {
$holding->setCurrency('%');
// Price
preg_match('/^.{11}(.*)/sm', $iwn[2], $r);
$holding->setPrice(floatval(str_replace(',', '.', $r[1])) / 100);
$holding->setPrice((float) str_replace(',', '.', $r[1]) / 100);
}
}

Expand All @@ -80,7 +80,7 @@ public function parseHoldings(): StatementOfHoldings
if (preg_match('/:93B::(.*?):/sm', $block, $iwn)) {
// Amount
preg_match('/^.{11}(.*)/sm', $iwn[1], $r);
$holding->setAmount(floatval(str_replace(',', '.', $r[1])));
$holding->setAmount((float) str_replace(',', '.', $r[1]));
}

if ($holding->getAmount() !== null && $holding->getPrice() !== null) {
Expand Down
4 changes: 2 additions & 2 deletions src/Model/StatementOfAccount/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function getPN(): int
*/
public function setPN($nr): static
{
$this->pn = intval($nr);
$this->pn = (int) $nr;
return $this;
}

Expand All @@ -370,7 +370,7 @@ public function getTextKeyAddition(): int
*/
public function setTextKeyAddition($textKeyAddition): static
{
$this->textKeyAddition = intval($textKeyAddition);
$this->textKeyAddition = (int) $textKeyAddition;
return $this;
}
}
2 changes: 1 addition & 1 deletion src/Protocol/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public static function createWrappedMessage($plainSegments, FinTsOptions $option
$message->plainSegments = $plainSegments instanceof MessageBuilder ? $plainSegments->segments : $plainSegments;

$tanMode = $tanMode instanceof NoPsd2TanMode ? null : $tanMode;
$randomReference = strval(rand(1000000, 9999999)); // Call unqualified rand() for unit test mocking to work.
$randomReference = (string) rand(1000000, 9999999); // Call unqualified rand() for unit test mocking to work.
$signature = BenutzerdefinierteSignaturV1::create($credentials->getPin(), $tan);
$numPlainSegments = count($message->plainSegments); // This is N, see $encryptedSegments.

Expand Down
2 changes: 1 addition & 1 deletion src/Segment/BaseDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private static function getIntAnnotation(string $name, string $docComment): ?int
if (!is_numeric($val)) {
throw new \InvalidArgumentException("Annotation $name has non-integer value $val");
}
return intval($val);
return (int) $val;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Segment/DegDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function __construct(string $class)

// Check if the name ends in V2 or so, implicitly assume V1.
if (preg_match('/^[A-Z]+[vV]([0-9]+)$/', $clazz->getShortName(), $match) === 1) {
$this->version = intval($match[1]);
$this->version = (int) $match[1];
}
} catch (\ReflectionException $e) {
throw new \RuntimeException($e);
Expand Down
2 changes: 1 addition & 1 deletion src/Segment/HNHBK/HNHBKv3.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class HNHBKv3 extends BaseSegment

public function getNachrichtengroesse(): int
{
return intval($this->nachrichtengroesse);
return (int) $this->nachrichtengroesse;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Segment/SegmentDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ protected function __construct(string $class)
if (preg_match('/^([A-Z]+)v([0-9]+)$/', $clazz->getShortName(), $match) !== 1) {
throw new \InvalidArgumentException("Invalid segment class name: $class");
}
$this->kennung = strval($match[1]);
$this->version = intval($match[2]);
$this->kennung = $match[1];
$this->version = (int) $match[2];
} catch (\ReflectionException $e) {
throw new \RuntimeException($e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Segment/VPP/VopHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static function checkVopConfirmationRequired(

// For a single transaction, we can do better than "CompletedPartialMatch",
// which can indicate either CompletedCloseMatch or CompletedNoMatch
if (intval($report->CstmrPmtStsRpt->OrgnlGrpInfAndSts->OrgnlNbOfTxs ?: 0) === 1
if ((int) ($report->CstmrPmtStsRpt->OrgnlGrpInfAndSts->OrgnlNbOfTxs ?: 0) === 1
&& $verificationResult === VopVerificationResult::CompletedPartialMatch
&& $verificationResultCode = $report->CstmrPmtStsRpt->OrgnlPmtInfAndSts->TxInfAndSts?->TxSts
) {
Expand Down
10 changes: 5 additions & 5 deletions src/Syntax/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function splitEscapedString(string $delimiter, string $str, bool $
break;
}
$matchedStr = $match[0][0]; // $match[0] refers to the entire matched string. [0] has the content
$matchedOffset = intval($match[0][1]); // and [1] has the offset within $str.
$matchedOffset = (int) $match[0][1]; // and [1] has the offset within $str.
if ($matchedStr === '?') {
// It's an escape character, so we should ignore this character and the next one.
$offset = $matchedOffset + 2;
Expand All @@ -79,7 +79,7 @@ public static function splitEscapedString(string $delimiter, string $str, bool $
// Note: The FinTS specification says that the length of the binary block is given in bytes (not
// characters) and PHP's string functions like substr() or preg_match() also operate on byte offsets, so
// this is fine.
$offset = $matchedOffset + strlen($matchedStr) + intval($binaryLength);
$offset = $matchedOffset + strlen($matchedStr) + (int) $binaryLength;
if ($offset > strlen($str)) {
throw new \InvalidArgumentException(
"Incomplete binary block at offset $matchedOffset, declared length $binaryLength, but "
Expand Down Expand Up @@ -124,13 +124,13 @@ public static function parseDataElement(string $rawValue, string $type)
if (!is_numeric($rawValue)) {
throw new \InvalidArgumentException("Invalid int: $rawValue");
}
return intval($rawValue);
return (int) $rawValue;
} elseif ($type === 'float') {
$rawValue = str_replace(',', '.', $rawValue, $numCommas);
if (!is_numeric($rawValue) || $numCommas !== 1) {
throw new \InvalidArgumentException("Invalid float: $rawValue");
}
return floatval($rawValue);
return (float) $rawValue;
} elseif ($type === 'bool' || $type === 'boolean') {
if ($rawValue === 'J') {
return true;
Expand Down Expand Up @@ -170,7 +170,7 @@ public static function parseBinaryBlock(string $rawValue): ?Bin
throw new \InvalidArgumentException("Invalid binary block length: $lengthStr");
}

$length = intval($lengthStr);
$length = (int) $lengthStr;
$result = new Bin(substr($rawValue, $delimiterPos + 1));

$actualLength = strlen($result->getData());
Expand Down
2 changes: 1 addition & 1 deletion src/Syntax/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function serializeDataElement($value, string $type): string

if ($type === 'int' || $type === 'integer' || $type === 'string') {
// Convert UTF-8 (PHP's encoding) to ISO-8859-1 (FinTS wire format encoding)
return static::escape(mb_convert_encoding(strval($value), 'ISO-8859-1', 'UTF-8'));
return static::escape(mb_convert_encoding((string) $value, 'ISO-8859-1', 'UTF-8'));
}

if ($type === 'float') {
Expand Down
Loading