Skip to content

Commit

Permalink
[Investigation] [WIP] [Part-2] feature/DTSERWONE-1083 - PHP 8.1 - Add…
Browse files Browse the repository at this point in the history
…ress Documentation issue (#120)

* DTSERWONE-1083 - Add PHPStan to perform static analysis and prevent PHP version issues

* DTSERWONE-1083 - Address PHP-8.1 issues

* DTSERWONE-1083 - Fix documentation errors and Access to an undefined property for businessName

* DTSERWONE-1083 - Remove 7.0 from static analyses due dev tool dependencies

* DTSERWONE-1083 - Chain CI steps

* DTSERWONE-1083 - Address documentation issue and missing references pointed by PHPStan level 2

* DTSERWONE-1083 - Bump up PHPStan level 1
  • Loading branch information
grmeyer-hw-dev committed Nov 10, 2022
1 parent fc7d86d commit d4b08bd
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 54 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,46 @@ on:
- bugfix/**

jobs:
static-analysis:
name: Static-analysis
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ 'ubuntu-latest' ]
php-versions: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ]

steps:
- uses: actions/checkout@master

#sets up the PHP version
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: xdebug

#validate composer files
- name: Validate composer.json and composer.lock
run: composer validate

#get dependencies
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest

#get static analysis tool
- name: Install static analysis tool
run: |
composer require --dev phpstan/phpstan
#evaluate the code
- name: Run static analysis tool
run: |
vendor/bin/phpstan analyse -l 1 src/Hyperwallet tests
tests:
name: Tests
needs: [static-analysis]
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
Expand All @@ -28,6 +66,7 @@ jobs:
steps:
- uses: actions/checkout@master

#sets up the PHP version
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -47,6 +86,7 @@ jobs:
code-coverage:
name: Report code coverage
needs: [tests]
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
Expand Down
7 changes: 4 additions & 3 deletions src/Hyperwallet/Exception/HyperwalletApiException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace Hyperwallet\Exception;
use Exception;
use Hyperwallet\Response\ErrorResponse;

/**
Expand All @@ -24,12 +25,12 @@ class HyperwalletApiException extends HyperwalletException {
private $relatedResources;

/**
* Creates a instance of the HyperwalletArgumentException
* Creates an instance of the HyperwalletArgumentException
*
* @param ErrorResponse $errorResponse The error response
* @param \Exception|null $previous The original exception
* @param Exception $previous The original exception
*/
public function __construct(ErrorResponse $errorResponse, \Exception $previous) {
public function __construct(ErrorResponse $errorResponse, Exception $previous) {
$message = $errorResponse[0] == null ? "Error message is not defined" : $errorResponse[0]->getMessage();
parent::__construct($message, 0, $previous);

Expand Down
42 changes: 26 additions & 16 deletions src/Hyperwallet/Hyperwallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Hyperwallet {
* @param string $password The API password
* @param string|null $programToken The program token that is used for some API calls
* @param string $server The API server to connect to
* @param string $encryptionData Encryption data to initialize ApiClient with encryption enabled
* @param array $encryptionData Encryption data to initialize ApiClient with encryption enabled
* @param array $clientOptions Guzzle Client Options
*
* @throws HyperwalletArgumentException
Expand Down Expand Up @@ -1467,9 +1467,9 @@ public function createBankCardStatusTransition($userToken, $bankCardToken, BankC
/**
* Get a bank card status transition
*
* @param $userToken The user token
* @param $bankCardToken The bank card token
* @param $statusTransitionToken The status transition token
* @param string $userToken The user token
* @param string $bankCardToken The bank card token
* @param string $statusTransitionToken The status transition token
* @return BankCardStatusTransition
*
* @throws HyperwalletApiException
Expand Down Expand Up @@ -2150,7 +2150,9 @@ public function createUserStatusTransition($userToken, UserStatusTransition $tra
* Activate a User
*
* @param string $userToken The user token
* @return UserStatusTransition
* @return UserStatusTransition the status transition
* @throws HyperwalletArgumentException
* @throws HyperwalletApiException
*/
public function activateUser($userToken) {
$transition = new UserStatusTransition();
Expand All @@ -2162,7 +2164,9 @@ public function activateUser($userToken) {
* De-activate a User
*
* @param string $userToken The user token
* @return UserStatusTransition
* @return UserStatusTransition the status transition
* @throws HyperwalletArgumentException
* @throws HyperwalletApiException
*/
public function deactivateUser($userToken) {
$transition = new UserStatusTransition();
Expand All @@ -2173,8 +2177,10 @@ public function deactivateUser($userToken) {
/**
* Lock a User account
*
* @param userToken User token
* @return The status transition
* @param string $userToken User token
* @return UserStatusTransition the status transition
* @throws HyperwalletArgumentException
* @throws HyperwalletApiException
*/
public function lockUser($userToken) {
$transition = new UserStatusTransition();
Expand All @@ -2185,8 +2191,10 @@ public function lockUser($userToken) {
/**
* Freeze a User account
*
* @param userToken User token
* @return The status transition
* @param string $userToken User token
* @return UserStatusTransition the status transition
* @throws HyperwalletArgumentException
* @throws HyperwalletApiException
*/
public function freezeUser($userToken) {
$transition = new UserStatusTransition();
Expand All @@ -2197,8 +2205,10 @@ public function freezeUser($userToken) {
/**
* Pre-activate a User account
*
* @param userToken User token
* @return The status transition
* @param string $userToken User token
* @return UserStatusTransition the status transition
* @throws HyperwalletArgumentException
* @throws HyperwalletApiException
*/
public function preactivateUser($userToken) {
$transition = new UserStatusTransition();
Expand Down Expand Up @@ -2489,12 +2499,14 @@ public function uploadDocumentsForBusinessStakeholder($userToken, $businessToken
/**
* Create a Business Stakeholder
*
* @param Business Stakeholder $BusinessStakeholder The Business Stakeholder data
* @param string $userToken The user token
* @param BusinessStakeholder $businessStakeholder The business stakeholder
* @return BusinessStakeholder
*
* @throws HyperwalletArgumentException
* @throws HyperwalletApiException
*/
public function createBusinessStakeholder($userToken,$businessStakeholder) {
public function createBusinessStakeholder($userToken, $businessStakeholder) {
if (empty($userToken)) {
throw new HyperwalletArgumentException('userToken is required!');
}
Expand All @@ -2505,9 +2517,7 @@ public function createBusinessStakeholder($userToken,$businessStakeholder) {
/**
* Update a Business Stakeholder
*
* @param Business Stakeholder $BusinessStakeholder The Business Stakeholder
* @return BusinessStakeholder
*
* @throws HyperwalletArgumentException
* @throws HyperwalletApiException
Expand Down
10 changes: 5 additions & 5 deletions src/Hyperwallet/Model/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct(array $readOnlyProperties = array(), array $properti
*
* Magic get method
*
* @param $key
* @param string $key
* @return mixed
*/
public function __get($key) {
Expand All @@ -68,8 +68,8 @@ public function __get($key) {
*
* Magic set method
*
* @param $key
* @param $value
* @param string $key
* @param mixed $value
*/
public function __set($key, $value) {
if (!in_array($key, $this->updatedProperties)) {
Expand All @@ -84,7 +84,7 @@ public function __set($key, $value) {
*
* Magic isset method
*
* @param $key
* @param string $key
* @return bool
*
* @access private
Expand All @@ -98,7 +98,7 @@ public function __isset($key) {
*
* Magic unset method
*
* @param $key
* @param string $key
*/
public function __unset($key) {
unset($this->updatedProperties[array_search($key, $this->updatedProperties)]);
Expand Down
30 changes: 17 additions & 13 deletions src/Hyperwallet/Model/BusinessStakeholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* Represents a V4 BusinessStakeholder
*
* @property string $token The BusinessStakeholder token
* @property boolen $isBusinessContact The business contact
* @property boolen $isDirector The Director
* @property boolen $isUltimateBeneficialOwner The UltimateBeneficial Owner
* @property boolen $isSeniorManagingOfficial The Senior Managing Official
* @property bool $isBusinessContact The business contact
* @property bool $isDirector The Director
* @property bool $isUltimateBeneficialOwner The UltimateBeneficial Owner
* @property bool $isSeniorManagingOfficial The Senior Managing Official
* @property string $verificationStatus The status of Business user verification
* @property string $status The Business user status
* @property \DateTime $createdOn The Business user creation date
Expand Down Expand Up @@ -65,6 +65,10 @@ class BusinessStakeholder extends BaseModel {

const GOVERNMENT_ID_TYPE_PASSPORT = 'PASSPORT';
const GOVERNMENT_ID_TYPE_NATIONAL_ID_CARD = 'NATIONAL_ID_CARD';
/**
* @var mixed|null
*/
private $businessName;

public static function FILTERS_ARRAY() {
return array('status', 'createdBefore', 'createdAfter', 'sortBy', 'limit');
Expand Down Expand Up @@ -102,15 +106,15 @@ public function setToken($token) {
/**
* Get the BusinessStakeholder Contact
*
* @return Boolean
* @return bool
*/
public function getIsBusinessContact() {
return $this->isBusinessContact;
}
/**
* Set the BusinessStakeholder Contact
*
* @param Boolean $isBusinessContact
* @param bool $isBusinessContact
* @return BusinessStakeholder
*/
Expand All @@ -122,7 +126,7 @@ public function setIsBusinessContact($isBusinessContact) {
/**
* Get the BusinessStakeholder Director
*
* @return Boolean
* @return bool
*/
public function getIsDirector() {
return $this->isDirector;
Expand All @@ -131,7 +135,7 @@ public function getIsDirector() {
/**
* Set the BusinessStakeholder Director
*
* @param Boolean $isDirector
* @param bool $isDirector
* @return BusinessStakeholder
*/
Expand All @@ -143,7 +147,7 @@ public function setIsDirector($isDirector) {
/**
* Get the BusinessStakeholder Ultimate Beneficial Owner
*
* @return Boolean
* @return bool
*/
public function getIsUltimateBeneficialOwner() {
return $this->isUltimateBeneficialOwner;
Expand All @@ -152,7 +156,7 @@ public function getIsUltimateBeneficialOwner() {
/**
* Set the BusinessStakeholder Ultimate Beneficial Owner
*
* @param Boolean $isUltimateBeneficialOwner
* @param bool $isUltimateBeneficialOwner
* @return BusinessStakeholder
*/
Expand All @@ -164,7 +168,7 @@ public function setIsUltimateBeneficialOwner($isUltimateBeneficialOwner) {
/**
* Get the BusinessStakeholder Senior Managing Official
*
* @return Boolean
* @return bool
*/
public function getIsSeniorManagingOfficial() {
return $this->isSeniorManagingOfficial;
Expand All @@ -173,7 +177,7 @@ public function getIsSeniorManagingOfficial() {
/**
* Set the BusinessStakeholder Senior Managing Official
*
* @param Boolean $isSeniorManagingOfficial
* @param bool $isSeniorManagingOfficial
* @return BusinessStakeholder
*/
Expand Down Expand Up @@ -482,7 +486,7 @@ public function getGovernmentIdType() {
/**
* Set the business governmentIdType
*
* @param string $businessType
* @param string $governmentIdType
* @return BusinessStakeholder
*/
public function setGovernmentIdType($governmentIdType) {
Expand Down
4 changes: 2 additions & 2 deletions src/Hyperwallet/Model/PrepaidCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function getReplacementOf() {
/**
* Set the prepaid card token to be replaced
*
* @param string $token
* @param string $replacementOf
* @return PrepaidCard
*/
public function setReplacementOf($replacementOf) {
Expand All @@ -237,7 +237,7 @@ public function getReplacementReason() {
/**
* set the prepaid card's replacement reason
*
* @param string $token
* @param string $replacementReason
* @return PrepaidCard
*/
public function setReplacementReason($replacementReason) {
Expand Down
8 changes: 4 additions & 4 deletions src/Hyperwallet/Model/TransferRefund.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getClientRefundId() {
/**
* Set the transfer token
*
* @param string $token
* @param string $clientRefundId
* @return TransferRefund
*/
public function setClientRefundId($clientRefundId) {
Expand Down Expand Up @@ -298,7 +298,7 @@ public function setMemo($memo) {
}

/**
* Get transfer memo
* Get the Foreign Exchanges
*
* @return string
*/
Expand All @@ -307,9 +307,9 @@ public function getForeignExchanges() {
}

/**
* Set transfer memo
* Set the Foreign Exchanges
*
* @param string $memo
* @param string $foreignExchanges
* @return TransferRefund
*/
public function setForeignExchanges($foreignExchanges) {
Expand Down
Loading

0 comments on commit d4b08bd

Please sign in to comment.