Skip to content

Commit 0efaad9

Browse files
committed
Add rector
1 parent ad7ae7c commit 0efaad9

File tree

4 files changed

+44
-9
lines changed

4 files changed

+44
-9
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44

55
# ecs
66
/.ecs-cache
7+
8+
# rector
9+
/.rector-cache

composer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "m_arcus/php-fints-wrapper",
33
"description": "A simple wrapper for nemiah/php-fints",
44
"type": "library",
5-
"version": "1.0.0",
5+
"version": "1.0.1",
66
"require": {
77
"nemiah/php-fints": "^3.4"
88
},
@@ -19,6 +19,7 @@
1919
}
2020
],
2121
"require-dev": {
22-
"symplify/easy-coding-standard": "^12.1"
22+
"symplify/easy-coding-standard": "^12.1",
23+
"rector/rector": "^1.0"
2324
}
2425
}

rector.php

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PHPStan\Cache\FileCacheStorage;
6+
use Rector\Config\RectorConfig;
7+
use Rector\Set\ValueObject\SetList;
8+
9+
return RectorConfig::configure()
10+
->withPaths([
11+
__DIR__ . '/ecs.php',
12+
__DIR__ . '/rector.php',
13+
__DIR__ . '/src',
14+
])
15+
->withCache(__DIR__ . '/.rector-cache')
16+
->withSets([
17+
SetList::CODE_QUALITY,
18+
SetList::CODING_STYLE,
19+
SetList::DEAD_CODE,
20+
SetList::STRICT_BOOLEANS,
21+
SetList::PRIVATIZATION,
22+
SetList::TYPE_DECLARATION,
23+
SetList::EARLY_RETURN,
24+
SetList::INSTANCEOF,
25+
]);

src/ActionService.php

+13-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static function login(FinTs $finTs): void
2424
}
2525
}
2626

27-
public static function action(FinTs $finTs, BaseAction $action)
27+
public static function action(FinTs $finTs, BaseAction $action): void
2828
{
2929
$finTs->execute($action);
3030

@@ -59,7 +59,7 @@ public static function action(FinTs $finTs, BaseAction $action)
5959
*/
6060
public static function handleStrongAuthentication(FinTs $finTs, BaseAction $action): void
6161
{
62-
if ($finTs->getSelectedTanMode()?->isDecoupled()) {
62+
if ($finTs->getSelectedTanMode()?->isDecoupled() === true) {
6363
self::handleDecoupled($finTs, $action);
6464
} else {
6565
self::handleTan($finTs, $action);
@@ -79,13 +79,14 @@ protected static function handleTan(FinTs $finTs, BaseAction $action): void
7979
if ($tanRequest?->getChallenge() !== null) {
8080
echo ' Instructions: ' . $tanRequest?->getChallenge();
8181
}
82+
8283
echo "\n";
8384
if ($tanRequest?->getTanMediumName() !== null) {
8485
echo 'Please use this device: ' . $tanRequest?->getTanMediumName() . "\n";
8586
}
8687

8788
// Challenge Image for PhotoTan/ChipTan
88-
if ($tanRequest?->getChallengeHhdUc()) {
89+
if ($tanRequest?->getChallengeHhdUc() instanceof \Fhp\Syntax\Bin) {
8990
try {
9091
$flicker = new TanRequestChallengeFlicker($tanRequest?->getChallengeHhdUc());
9192
echo 'There is a challenge flicker.' . PHP_EOL;
@@ -117,7 +118,7 @@ protected static function handleTan(FinTs $finTs, BaseAction $action): void
117118
echo "Please enter the TAN:\n";
118119
$tan = trim(fgets(STDIN));
119120

120-
echo "Submitting TAN: $tan\n";
121+
echo sprintf('Submitting TAN: %s%s', $tan, PHP_EOL);
121122
$finTs->submitTan($action, $tan);
122123
}
123124

@@ -135,6 +136,7 @@ protected static function handleDecoupled(FinTs $finTs, BaseAction $action): voi
135136
if ($tanRequest?->getChallenge() !== null) {
136137
echo ' Instructions: ' . $tanRequest?->getChallenge();
137138
}
139+
138140
echo "\n";
139141
if ($tanRequest?->getTanMediumName() !== null) {
140142
echo 'Please check this device: ' . $tanRequest?->getTanMediumName() . "\n";
@@ -145,7 +147,7 @@ protected static function handleDecoupled(FinTs $finTs, BaseAction $action): voi
145147
// browser). This PHP sample code just serves to show the *logic* of the polling. Alternatively, you can even do
146148
// without polling entirely and just let the user confirm manually in all cases (i.e. only implement the `else`
147149
// branch below).
148-
if ($tanMode?->allowsAutomatedPolling()) {
150+
if ($tanMode?->allowsAutomatedPolling() === true) {
149151
echo "Polling server to detect when the decoupled authentication is complete.\n";
150152
sleep($tanMode?->getFirstDecoupledCheckDelaySeconds());
151153
for ($attempt = 0;
@@ -156,20 +158,24 @@ protected static function handleDecoupled(FinTs $finTs, BaseAction $action): voi
156158
echo "Confirmed.\n";
157159
return;
158160
}
161+
159162
echo "Still waiting...\n";
160163
sleep($tanMode?->getPeriodicDecoupledCheckDelaySeconds());
161164
}
162-
throw new RuntimeException("Not confirmed after $attempt attempts, which is the limit.");
165+
166+
throw new RuntimeException(sprintf('Not confirmed after %d attempts, which is the limit.', $attempt));
163167
}
164168

165-
if ($tanMode?->allowsManualConfirmation()) {
169+
if ($tanMode?->allowsManualConfirmation() === true) {
166170
do {
167171
echo "Please type 'done' and hit Return when you've completed the authentication on the other device.\n";
168172
while (trim(fgets(STDIN)) !== 'done') {
169173
echo "Try again.\n";
170174
}
175+
171176
echo "Confirming that the action is done.\n";
172177
} while (! $finTs->checkDecoupledSubmission($action));
178+
173179
echo "Confirmed\n";
174180
} else {
175181
throw new AssertionError('Server allows neither automated polling nor manual confirmation');

0 commit comments

Comments
 (0)