Skip to content

Commit

Permalink
Add phpstan
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Aug 1, 2021
1 parent 84e1ed3 commit 183b123
Show file tree
Hide file tree
Showing 25 changed files with 93 additions and 92 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/.gitignore export-ignore
/.php_cs export-ignore
/.travis.yml export-ignore
/phpstan-baseline.neon export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml export-ignore
/CHANGELOG-*.md export-ignore
/CODE_OF_CONDUCT.md export-ignore
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
/vendor/*
/composer.lock

# PHPStan
/phpstan.neon

# PHPUnit
/coverage/*
/.phpunit.result.cache
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
"require": {
"php": "^7.2 || ^8.0",
"jomweb/ringgit": "^2.3.1",
"laravie/codex": "^5.3.1",
"laravie/codex-filter": "^1.2",
"laravie/codex": "^5.3.2",
"laravie/codex-filter": "^1.2.1",
"php-http/multipart-stream-builder": "^1.0"
},
"require-dev": {
"mockery/mockery": "~1.3.1 || ^1.4.2",
"php-http/guzzle7-adapter": "^0.1",
"phpstan/phpstan": "^0.12.90",
"phpunit/phpunit": "^8.4 || ^9.3.3 || ^10.0"
},
"extra": {
Expand Down
52 changes: 52 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
parameters:
ignoreErrors:
-
message: "#^Method Billplz\\\\Client\\:\\:bank\\(\\) should return Billplz\\\\Contracts\\\\BankAccount but returns Laravie\\\\Codex\\\\Contracts\\\\Request\\.$#"
count: 1
path: src/Client.php

-
message: "#^Method Billplz\\\\Client\\:\\:bill\\(\\) should return Billplz\\\\Contracts\\\\Bill but returns Laravie\\\\Codex\\\\Contracts\\\\Request\\.$#"
count: 1
path: src/Client.php

-
message: "#^Method Billplz\\\\Client\\:\\:card\\(\\) should return Billplz\\\\Contracts\\\\Card but returns Laravie\\\\Codex\\\\Contracts\\\\Request\\.$#"
count: 1
path: src/Client.php

-
message: "#^Method Billplz\\\\Client\\:\\:collection\\(\\) should return Billplz\\\\Contracts\\\\Collection but returns Laravie\\\\Codex\\\\Contracts\\\\Request\\.$#"
count: 1
path: src/Client.php

-
message: "#^Method Billplz\\\\Client\\:\\:openCollection\\(\\) should return Billplz\\\\Contracts\\\\OpenCollection but returns Laravie\\\\Codex\\\\Contracts\\\\Request\\.$#"
count: 1
path: src/Client.php

-
message: "#^Method Billplz\\\\Client\\:\\:payout\\(\\) should return Billplz\\\\Contracts\\\\Payout but returns Laravie\\\\Codex\\\\Contracts\\\\Request\\.$#"
count: 1
path: src/Client.php

-
message: "#^Method Billplz\\\\Client\\:\\:payoutCollection\\(\\) should return Billplz\\\\Contracts\\\\Collection\\\\Payout but returns Laravie\\\\Codex\\\\Contracts\\\\Request\\.$#"
count: 1
path: src/Client.php

-
message: "#^Method Billplz\\\\Client\\:\\:transaction\\(\\) should return Billplz\\\\Contracts\\\\Bill\\\\Transaction but returns Laravie\\\\Codex\\\\Contracts\\\\Request\\.$#"
count: 1
path: src/Client.php

-
message: "#^Method Billplz\\\\Four\\\\Collection\\:\\:payout\\(\\) should return Billplz\\\\Four\\\\Collection\\\\Payout but returns Laravie\\\\Codex\\\\Contracts\\\\Request\\.$#"
count: 1
path: src/Four/Collection.php

-
message: "#^Call to an undefined method Laravie\\\\Codex\\\\Contracts\\\\Endpoint\\:\\:withUserInfo\\(\\)\\.$#"
count: 1
path: src/Request.php

16 changes: 16 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
includes:
- ./phpstan-baseline.neon

parameters:

paths:
- src

# The level 8 is the highest level
level: 8

ignoreErrors:
- '#Unsafe usage of new static#'

treatPhpDocTypesAsCertain: false
checkMissingIterableValueType: false
8 changes: 0 additions & 8 deletions src/Base/BankAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ abstract class BankAccount extends Request implements Contract
{
/**
* Get A Bank Account.
*
* @return \Billplz\Response
*/
public function get(string $accountNumber): Response
{
Expand All @@ -20,8 +18,6 @@ public function get(string $accountNumber): Response

/**
* Create A Bank Account.
*
* @return \Billplz\Response
*/
public function create(
string $name,
Expand All @@ -39,8 +35,6 @@ public function create(

/**
* Check Bank Account Number.
*
* @return \Billplz\Response
*/
public function checkAccount(string $accountNumber): Response
{
Expand All @@ -49,8 +43,6 @@ public function checkAccount(string $accountNumber): Response

/**
* Get list of bank for Bank Direct Feature.
*
* @return \Billplz\Response
*/
public function supportedForFpx(): Response
{
Expand Down
15 changes: 5 additions & 10 deletions src/Base/Bill.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ abstract class Bill extends Request implements Contract
* @param \Billplz\Contracts\PaymentCompletion|string $paymentCompletion
*
* @throws \InvalidArgumentException
*
* @return \Billplz\Response
*/
public function create(
string $collectionId,
Expand Down Expand Up @@ -56,8 +54,6 @@ public function create(

/**
* Show an existing bill.
*
* @return \Billplz\Response
*/
public function get(string $id): Response
{
Expand All @@ -66,20 +62,19 @@ public function get(string $id): Response

/**
* Show an existing bill transactions.
*
* @return \Billplz\Response
*/
public function transaction(string $id, array $optional = []): Response
{
return $this->client->uses(
/** @var \Billplz\Contracts\Bill\Transaction $transaction */
$transaction = $this->client->uses(
'Bill.Transaction', $this->getVersion()
)->get($id, $optional);
);

return $transaction->get($id, $optional);
}

/**
* Destroy an existing bill.
*
* @return \Billplz\Response
*/
public function destroy(string $id): Response
{
Expand Down
2 changes: 0 additions & 2 deletions src/Base/Bill/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ abstract class Transaction extends Request
{
/**
* Show an existing bill transactions.
*
* @return \Billplz\Response
*/
public function get(string $id, array $optional = []): Response
{
Expand Down
10 changes: 0 additions & 10 deletions src/Base/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ abstract class Collection extends Request implements Contract

/**
* Create a new collection.
*
* @return \Billplz\Response
*/
public function create(string $title, array $optional = []): Response
{
Expand All @@ -25,8 +23,6 @@ public function create(string $title, array $optional = []): Response

/**
* Get collection.
*
* @return \Billplz\Response
*/
public function get(string $id): Response
{
Expand All @@ -35,8 +31,6 @@ public function get(string $id): Response

/**
* Get collection index.
*
* @return \Billplz\Response
*/
public function all(array $optional = []): Response
{
Expand All @@ -45,8 +39,6 @@ public function all(array $optional = []): Response

/**
* Activate a collection.
*
* @return \Billplz\Response
*/
public function activate(string $id): Response
{
Expand All @@ -55,8 +47,6 @@ public function activate(string $id): Response

/**
* Deactivate a collection.
*
* @return \Billplz\Response
*/
public function deactivate(string $id): Response
{
Expand Down
6 changes: 0 additions & 6 deletions src/Base/Collection/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class PaymentMethod extends Request implements Contract
{
/**
* Get payment method index.
*
* @return \Billplz\Response
*/
public function get(string $collectionId): Response
{
Expand All @@ -20,10 +18,6 @@ public function get(string $collectionId): Response

/**
* Update payment methods.
*
* @param string $id
*
* @return \Billplz\Response
*/
public function update(string $collectionId, array $codes = []): Response
{
Expand Down
6 changes: 0 additions & 6 deletions src/Base/OpenCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class OpenCollection extends Request implements Contract
* Create a new open collection.
*
* @param \Money\Money|\Duit\MYR|int $amount
*
* @return \Billplz\Response
*/
public function create(
string $title,
Expand All @@ -31,8 +29,6 @@ public function create(

/**
* Get open collection.
*
* @return \Billplz\Response
*/
public function get(string $collectionId): Response
{
Expand All @@ -41,8 +37,6 @@ public function get(string $collectionId): Response

/**
* Get open collection index.
*
* @return \Billplz\Response
*/
public function all(array $optional = []): Response
{
Expand Down
3 changes: 3 additions & 0 deletions src/Base/PaymentCompletion.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use InvalidArgumentException;
use Billplz\Exceptions\FailedSignatureVerification;

/**
* @property \Billplz\Client $client
*/
trait PaymentCompletion
{
/**
Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(HttpClient $http, string $apiKey, ?string $signature
/**
* Make a client.
*
* @return $this
* @return static
*/
public static function make(string $apiKey, ?string $signatureKey = null)
{
Expand Down
4 changes: 0 additions & 4 deletions src/Contracts/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ public function create(

/**
* Activate the card.
*
* @return \Billplz\Response
*/
public function activate(string $cardId, string $cardToken): Response;

/**
* Deactivate the card.
*
* @return \Billplz\Response
*/
public function deactivate(string $cardId, string $cardToken): Response;
}
2 changes: 0 additions & 2 deletions src/Contracts/Collection/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ public function get(string $collectionId): Response;

/**
* Update payment methods.
*
* @param string $id
*/
public function update(string $collectionId, array $codes = []): Response;
}
8 changes: 5 additions & 3 deletions src/Exceptions/ExceedRequestLimits.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

namespace Billplz\Exceptions;

use Exception;
use Laravie\Codex\Exceptions\HttpException;

/**
* @property \Billplz\Response $response
*/
class ExceedRequestLimits extends HttpException
{
/**
* Construct a new HTTP exception.
*
* @param \Billplz\Response $response
* @param string $message
* @param \Exception|null $previous
*/
public function __construct(
$response,
Expand All @@ -20,7 +22,7 @@ public function __construct(
int $code = 0
) {
parent::__construct(
$response, $message ?: 'Too many requests', $previous, 419
$response, $message ?: 'Too many requests', $previous, $code = 419
);

$this->setResponse($response);
Expand Down
Loading

0 comments on commit 183b123

Please sign in to comment.