Skip to content

Commit

Permalink
Add PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed Jul 8, 2024
1 parent 66898c5 commit deb6713
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ jobs:
name: Run CS
run: vendor/bin/phpcs --standard=PSR2 src/

-
name: Run PHPStan
run: vendor/bin/phpstan analyse

-
name: Run PHPSpec
run: vendor/bin/phpspec run
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.7",
"phpspec/phpspec": "^7.3"
"phpspec/phpspec": "^7.3",
"phpstan/phpstan": "^1.11"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 6
paths:
- src
2 changes: 1 addition & 1 deletion src/Api/EcRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private function calculateMac(): string

private function convertAmountToString(float $amount): string
{
return str_pad((string)round($amount, 2)*100, 9, '0', STR_PAD_LEFT);
return str_pad((string) (round($amount, 2)*100), 9, '0', STR_PAD_LEFT);
}

private function validate(): void
Expand Down
10 changes: 8 additions & 2 deletions src/Notification/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class Request implements Signed

private ?string $scadenza_pan;

/**
* @param array<string, string|int> $rawParams
*/
private function __construct(array $rawParams)
{
$this->checkForMissingParameters($rawParams);
Expand Down Expand Up @@ -68,15 +71,15 @@ private function __construct(array $rawParams)
$this->session_id = $rawParams['session_id'] ?? null;
}

public static function buildFromHttpRequest(ServerRequestInterface $request): static
public static function buildFromHttpRequest(ServerRequestInterface $request): self
{
if (strtoupper($request->getMethod()) === 'POST') {
$rawParams = $request->getParsedBody();
} else {
$rawParams = $request->getQueryParams();
}

return new static($rawParams);
return new self($rawParams);
}

public function getAlias(): string
Expand Down Expand Up @@ -215,6 +218,9 @@ private function checkForMissingParameters(array $rawParams): void
}
}

/**
* @param array<string, string|int> $rawParams
*/
private function validateParameters(array $rawParams): void
{
$rawAmount = $rawParams['importo'];
Expand Down
2 changes: 1 addition & 1 deletion src/Signature/DefaultSignatureHashingManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function hashSignatureString(string $string, string $method): string
return $encodedString;
}

private function mustEncodeHashResultAsUrlencodedBase64($method): bool
private function mustEncodeHashResultAsUrlencodedBase64(string $method): bool
{
return $method === SignatureMethod::MD5_METHOD;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Signature/Signable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

interface Signable
{
/**
* @return array<string, string|int>
*/
public function getSignatureData(): array;

public function setSignature(string $signature): static;
Expand Down

0 comments on commit deb6713

Please sign in to comment.