Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #25

Merged
merged 36 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8fd6aa8
add phpstan, update phpunit, workflow
grummbeer Dec 7, 2023
4f2d4ee
cleanup Account.php
grummbeer Dec 6, 2023
e517c96
cleanup ExistingAccount
grummbeer Dec 7, 2023
3d87a6f
cleanup Balance.php
grummbeer Dec 6, 2023
55cf478
cleanup Bank.php
grummbeer Dec 6, 2023
7c7110d
cleanup BankCode.php
grummbeer Dec 6, 2023
205c2d5
cleanup ContextFile.php
grummbeer Dec 6, 2023
72a3d08
cleanup ContextXmlRenderer.php
grummbeer Dec 6, 2023
a9f44a2
cleanup User.php
grummbeer Dec 6, 2023
e6a8d6d
cleanup ExistingUser.php
grummbeer Dec 6, 2023
bb8cb76
cleanup Arrayable.php
grummbeer Dec 5, 2023
70e742d
cleanup HbciVersion.php
grummbeer Dec 6, 2023
e5688f3
cleanup Transaction.php
grummbeer Dec 6, 2023
598f8c2
cleanup MoneyElementRender.php
grummbeer Dec 6, 2023
24820e9
cleanup PinFile
grummbeer Dec 6, 2023
4c92e36
cleanup AddUserCommand
grummbeer Dec 6, 2023
7d6aeb2
cleanup AbstractCommand
grummbeer Dec 6, 2023
7809cd8
cleanup Result
grummbeer Dec 6, 2023
b601971
cleanup ShellCommandExecuter
grummbeer Dec 6, 2023
a03f78b
cleanup CheckAqBankingCommand
grummbeer Dec 6, 2023
98be58d
cleanup AddUserFlagsCommand
grummbeer Dec 6, 2023
fd9c6a8
cleanup AddAccountFlagsCommandTest
grummbeer Dec 7, 2023
f9fe1c0
cleanup ListAccountsCommand
grummbeer Dec 7, 2023
5abe703
cleanup, fix Test RenderContextFileToXMLCommand
grummbeer Dec 7, 2023
429ce1b
cleanup GetAccountsCommand
grummbeer Dec 7, 2023
7a3e0db
cleanup GetAccSepaCommand
grummbeer Dec 7, 2023
8a44306
cleanup GetSysIDCommand
grummbeer Dec 7, 2023
0537c23
cleanup ListUsersCommand
grummbeer Dec 7, 2023
a9cc6e4
cleanup RequestCommand
grummbeer Dec 7, 2023
ff32b4f
cleanup SepaTransferCommand
grummbeer Dec 7, 2023
e7a5d7f
cleanup SetAppropriateITanModeCommand
grummbeer Dec 7, 2023
dded38a
cleanup SetITanModeCommand
grummbeer Dec 7, 2023
dc5abf3
phpstan generate baseline
grummbeer Dec 7, 2023
5bfcade
cleanup UserMatcher
grummbeer Dec 9, 2023
9805bed
cleanup AccountMatcher
grummbeer Dec 9, 2023
4e7cf77
add parameter types ContextXMLRenderer
grummbeer Dec 9, 2023
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
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [ push ]
on: [ push, pull_request ]

jobs:
check:
Expand All @@ -19,8 +19,15 @@ jobs:
- name: Check formatting
run: ./vendor/bin/ecs check

- name: Analyse code
run: ./vendor/bin/phpstan

- name: Run tests
uses: php-actions/phpunit@v3
env:
XDEBUG_MODE: coverage
with:
version: 8.5
version: 10.5
php_version: 8.1
php_extensions: "xdebug"
coverage_text: true
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ Run the fixer before push.
```shell
./vendor/bin/ecs --fix
```

Run phpstan before push

```shell
./vendor/bin/phpstan analyse
```
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
"require": {
"php": "^8.1",
"ext-dom": "*",
"ext-simplexml": "*",
"moneyphp/money": "^4.3"
},
"require-dev": {
"phpunit/phpunit": "^8.5",
"phpunit/phpunit": "^10.5",
"mockery/mockery": "*",
"mikey179/vfsstream": "^1.6",
"symplify/easy-coding-standard": "^12.0"
"symplify/easy-coding-standard": "^12.0",
"phpstan/phpstan": "^1.10"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 4 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer;
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocOrderFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesOrderFixer;
use PhpCsFixer\Fixer\Strict\StrictComparisonFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
Expand All @@ -23,6 +25,8 @@
YodaStyleFixer::class,
OrderedClassElementsFixer::class,
NativeFunctionInvocationFixer::class,
PhpdocTypesOrderFixer::class,
PhpdocOrderFixer::class,
]);

$ecsConfig->sets([
Expand Down
46 changes: 46 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
parameters:
grummbeer marked this conversation as resolved.
Show resolved Hide resolved
ignoreErrors:
-
message: "#^Argument of an invalid type DOMDocument supplied for foreach, only iterables are supported\\.$#"
count: 1
path: src/AccountMatcher.php

-
message: "#^Method AqBanking\\\\AccountMatcher\\:\\:__construct\\(\\) has parameter \\$array with no type specified\\.$#"
count: 1
path: src/AccountMatcher.php

-
message: "#^Method AqBanking\\\\AccountMatcher\\:\\:getExistingAccount\\(\\) has no return type specified\\.$#"
count: 1
path: src/AccountMatcher.php

-
message: "#^Method AqBanking\\\\Arrayable\\:\\:toArray\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Arrayable.php

-
message: "#^Method AqBanking\\\\Command\\\\ListAccountsCommand\\:\\:execute\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Command/ListAccountsCommand.php

-
message: "#^Method AqBanking\\\\ContextXmlRenderer\\:\\:renderMultiLineElement\\(\\) has parameter \\$nodes with generic class DOMNodeList but does not specify its types\\: TNode$#"
count: 1
path: src/ContextXmlRenderer.php

-
message: "#^Method AqBanking\\\\ContextXmlRenderer\\:\\:renderSimpleTextElement\\(\\) has parameter \\$valueNodes with generic class DOMNodeList but does not specify its types\\: TNode$#"
count: 1
path: src/ContextXmlRenderer.php

-
message: "#^Access to an undefined property AqBanking\\\\UserMatcher\\:\\:\\$xPath\\.$#"
count: 2
path: src/UserMatcher.php

-
message: "#^Method AqBanking\\\\UserMatcher\\:\\:getExistingUser\\(\\) has no return type specified\\.$#"
count: 1
path: src/UserMatcher.php
6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
includes:
- phpstan-baseline.neon
parameters:
level: 6
paths:
- src
33 changes: 12 additions & 21 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
executionOrder="depends,defects"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
convertDeprecationsToExceptions="true"
verbose="true">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="vendor/autoload.php" executionOrder="depends,defects" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" requireCoverageMetadata="true" beStrictAboutCoverageMetadata="true">
<coverage/>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
54 changes: 15 additions & 39 deletions src/Account.php
Original file line number Diff line number Diff line change
@@ -1,66 +1,42 @@
<?php

declare(strict_types=1);

namespace AqBanking;

class Account implements AccountInterface, Arrayable
{
/**
* @var BankCode
*/
private $bankCode;

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

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

/**
* @param string $accountNumber
* @param string $accountHolderName
* @return \AqBanking\Account
*/
public function __construct(BankCode $bankCode, $accountNumber, $accountHolderName = '')
{
$this->bankCode = $bankCode;
$this->accountNumber = $accountNumber;
$this->accountHolderName = $accountHolderName;
public function __construct(
private readonly BankCode $bankCode,
private readonly string $accountNumber,
private readonly string $accountHolderName = '',
) {
}

/**
* @return BankCode
*/
public function getBankCode()
public function getBankCode(): BankCode
{
return $this->bankCode;
}

/**
* @return string
*/
public function getAccountNumber()
public function getAccountNumber(): string
{
return $this->accountNumber;
}

/**
* @return string
*/
public function getAccountHolderName()
public function getAccountHolderName(): string
{
return $this->accountHolderName;
}

public function toArray()
/**
* @return array<string, string>
*/
public function toArray(): array
{
return [
'bankCode' => $this->getBankCode()->getString(),
'accountHolderName' => $this->getAccountHolderName(),
'accountNumber' => $this->getAccountNumber(),
'accountHolderName' => $this->getAccountHolderName(),
];
}
}
17 changes: 5 additions & 12 deletions src/AccountInterface.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
<?php

declare(strict_types=1);

namespace AqBanking;

interface AccountInterface
{
/**
* @return BankCode
*/
public function getBankCode();
public function getBankCode(): BankCode;

/**
* @return string
*/
public function getAccountHolderName();
public function getAccountHolderName(): string;

/**
* @return string
*/
public function getAccountNumber();
public function getAccountNumber(): string;
}
2 changes: 1 addition & 1 deletion src/Arrayable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

interface Arrayable
{
public function toArray();
public function toArray(): array;
}
45 changes: 11 additions & 34 deletions src/Balance.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,37 @@

namespace AqBanking;

use DateTime;
use Money\Money;

class Balance implements Arrayable
{
/**
* @var string
*/
private $type;

/**
* @var \DateTime
*/
private $date;

/**
* @var Money
*/
private $value;

public function __construct(
\DateTime $date,
Money $value,
string $type
private readonly DateTime $date,
private readonly Money $value,
private readonly string $type
) {
$this->date = $date;
$this->value = $value;
$this->type = $type;
}

/**
* @return \DateTime
*/
public function getDate()
public function getDate(): DateTime
{
return $this->date;
}

/**
* @return string
*/
public function getType()
public function getType(): string
{
return $this->type;
}

/**
* @return \Money\Money
*/
public function getValue()
public function getValue(): Money
{
return $this->value;
}

public function toArray()
/**
* @return array<string, array<int|string>|string>
*/
public function toArray(): array
{
return [
'type' => $this->getType(),
Expand Down
Loading