Skip to content

Commit

Permalink
GitHub actions, PHPStan, dependencies update
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinMystikJonas committed Feb 25, 2022
1 parent 209d8da commit e54b3d1
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 41 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PHPStan

on: [push, pull_request]

jobs:
phpstan:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.1', '7.2', '7.3', '7.4']
fail-fast: false

name: PHP ${{ matrix.php }} PHPStan
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- run: composer install --no-progress --prefer-dist
- run: vendor/bin/phpstan

phpstan-lowest:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.1']
fail-fast: false

name: PHP ${{ matrix.php }} PHPStan - lowest dependencies
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- run: composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable
- run: vendor/bin/phpstan

42 changes: 42 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tests

on: [push, pull_request]

env:
php-options: -C -d opcache.enable=0 -d zend.exception_ignore_args=0

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.1', '7.2', '7.3', '7.4']
fail-fast: false

name: PHP ${{ matrix.php }} tests
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- run: composer install --no-progress --prefer-dist
- run: vendor/bin/tester tests -p php -s ${{ env.php-options }}

tests-lowest:
runs-on: ubuntu-latest
strategy:
matrix:
php: ['7.1']
fail-fast: false

name: PHP ${{ matrix.php }} tests - lowest dependencies
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- run: composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable
- run: vendor/bin/tester tests -p php -s ${{ env.php-options }}

20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@
"issues": "https://github.com/MetisFW/PayPal/issues"
},
"require": {
"php": ">=5.6.0",
"php": ">=7.1",
"ext-curl": "*",
"ext-json": "*",
"nette/di": "^2.4",
"nette/application": "^2.4",
"paypal/rest-api-sdk-php": "^1.5"
"paypal/rest-api-sdk-php": "^1.14"
},
"require-dev": {
"nette/bootstrap": "^2.4",
"nette/robot-loader": "^2.4",
"nette/tester": "^2.4",
"mockery/mockery": "^1.4"
"nette/tester": "^2.0",
"mockery/mockery": "^1.3",
"phpstan/phpstan": "^0.11||1.*",
"phpstan/phpstan-nette": "*"
},
"autoload": {
"psr-0": {
Expand Down
9 changes: 9 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
parameters:
level: 5
paths:
- src
- tests/PayPal

includes:
- vendor/phpstan/phpstan-nette/extension.neon
- vendor/phpstan/phpstan-nette/rules.neon
3 changes: 1 addition & 2 deletions src/MetisFW/PayPal/PayPalContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class PayPalContext {
private $experienceProfileId;

/**
* @param string $clientId
* @param string $secret
* @param ApiContext $apiContext
*/
public function __construct(ApiContext $apiContext) {
$this->apiContext = $apiContext;
Expand Down
3 changes: 2 additions & 1 deletion src/MetisFW/PayPal/Payment/BasePaymentOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ protected function getPayer() {
*/
public function getPayment() {
$payer = $this->getPayer();
/** @phpstan-ignore-next-line */
if(!$payer || !($payer instanceof Payer)) {
throw new InvalidArgumentException("Method getPayer has to return instance of Payer. Instead ".
gettype($payer)." given.");
Expand Down Expand Up @@ -106,7 +107,7 @@ public function createPayment(Payment $payment) {
* @param string $paymentId
* @param string $payerId
*
* @return void
* @return Payment
*/
public function handleReturn($paymentId, $payerId) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/MetisFW/PayPal/Payment/PaymentOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function createPayment(Payment $payment);
* @param string $paymentId
* @param string $payerId
*
* @return void
* @return Payment
*/
public function handleReturn($paymentId, $payerId);

Expand Down
2 changes: 1 addition & 1 deletion src/MetisFW/PayPal/Payment/SimplePaymentOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function getTransactions() {
$payPalItem = new Item();
$payPalItem->setName($this->name);
$payPalItem->setCurrency($currency);
$payPalItem->setQuantity($this->quantity);
$payPalItem->setQuantity((string)$this->quantity);
$payPalItem->setPrice($this->price);

$payPalItems[] = $payPalItem;
Expand Down
4 changes: 2 additions & 2 deletions tests/PayPal/Helper/TransactionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static public function createItemList(array $items) {

/**
* @param string $name
* @param int $currency
* @param string $currency
* @param int $quantity
* @param string $sku
* @param int $price
Expand All @@ -81,7 +81,7 @@ static public function createItem($name, $currency, $quantity, $sku, $price) {
$item = new Item();
$item->setName($name);
$item->setCurrency($currency);
$item->setQuantity($quantity);
$item->setQuantity((string)$quantity);
$item->setSku($sku);
$item->setPrice($price);
return $item;
Expand Down
5 changes: 2 additions & 3 deletions tests/paypal.config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ payPal:
currency: EUR
sdkConfig:
mode: sandbox
log.Enabled: true
log.LogEnabled: true
log.FileName: './tmp/PayPal.log'
log.LogLevel: DEBUG
validation.level: log
log.LogLevel: debug
cache.enabled: true
# 'http.CURLOPT_CONNECTTIMEOUT' => 30
# 'http.headers.PayPal-Partner-Attribution-Id' => '123123123'/
3 changes: 0 additions & 3 deletions tests/php.ini-travis

This file was deleted.

3 changes: 0 additions & 3 deletions tests/php.ini-unix

This file was deleted.

2 changes: 1 addition & 1 deletion tests/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ else
runTests=$dir
fi

$dir/../vendor/bin/tester -p php -c $dir/php.ini-unix $runTests $@
$dir/../vendor/bin/tester -p php -C $runTests $@

0 comments on commit e54b3d1

Please sign in to comment.