Skip to content

Commit

Permalink
Updated for php 8.1 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ionutcalara committed Feb 15, 2023
1 parent bcdf66a commit d388681
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 287 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "paylike/php-api",
"description": "PHP SDK to communicate with the Paylike HTTP API",
"version": "1.0.8",
"version": "2.0.0",
"license": "MIT",
"authors": [
{
Expand All @@ -21,10 +21,10 @@
}
},
"require": {
"php": ">=5.3.3",
"php": ">=5.6.0",
"ext-curl": "*"
},
"require-dev": {
"phpunit/phpunit": "^4.8"
"phpunit/phpunit": "^9.6.3"
}
}
2 changes: 1 addition & 1 deletion src/Endpoint/Merchants.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function update($merchant_id, $args)
{
$url = 'merchants/' . $merchant_id;

$this->paylike->client->request('PUT', $url, $args);
return $this->paylike->client->request('PUT', $url, $args);
}

/**
Expand Down
16 changes: 16 additions & 0 deletions src/Utils/Cursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public function __construct($endpoint, array $params, array $data, Paylike $payl
* @link http://php.net/manual/en/iterator.rewind.php
* @return void Any returned value is ignored.
*/
#[\ReturnTypeWillChange]
public function rewind()
{
$this->current_index = 0;
Expand All @@ -65,6 +66,7 @@ public function rewind()
* @link http://php.net/manual/en/iterator.current.php
* @return mixed Can return any type.
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->collection[$this->current_index];
Expand All @@ -75,6 +77,7 @@ public function current()
* @link http://php.net/manual/en/iterator.key.php
* @return mixed scalar on success, or null on failure.
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->current_index;
Expand All @@ -85,6 +88,7 @@ public function key()
* @link http://php.net/manual/en/iterator.next.php
* @return null any returned value is ignored.
*/
#[\ReturnTypeWillChange]
public function next()
{
++$this->current_index;
Expand All @@ -99,6 +103,7 @@ public function next()
* @return boolean The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure.
*/
#[\ReturnTypeWillChange]
public function valid()
{
return isset($this->collection[$this->current_index]);
Expand All @@ -107,6 +112,7 @@ public function valid()
/**
* @return integer
*/
#[\ReturnTypeWillChange]
public function count()
{
return max($this->total_count, count($this->collection));
Expand All @@ -123,6 +129,7 @@ public function count()
* <p>
* The return value will be casted to boolean if non-boolean was returned.
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
$exists = isset($this->collection[$offset]);
Expand All @@ -145,6 +152,7 @@ public function offsetExists($offset)
* </p>
* @return mixed Can return all value types.
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
$value = isset($this->collection[$offset]) ? $this->collection[$offset] : null;
Expand All @@ -170,6 +178,7 @@ public function offsetGet($offset)
* </p>
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
if ($offset === null) {
Expand All @@ -187,6 +196,7 @@ public function offsetSet($offset, $value)
* </p>
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->collection[$offset]);
Expand All @@ -195,6 +205,7 @@ public function offsetUnset($offset)
/**
* @return $this
*/
#[\ReturnTypeWillChange]
private function fetchNext()
{
$this->updateOffset()->fetch();
Expand All @@ -205,6 +216,7 @@ private function fetchNext()
/**
* @return $this
*/
#[\ReturnTypeWillChange]
private function fetch()
{
$api_response = $this->paylike->client->request('GET', $this->endpoint, $this->params);
Expand All @@ -219,6 +231,7 @@ private function fetch()
/**
* If after is set, then we increment it, otherwise we increment before
*/
#[\ReturnTypeWillChange]
private function updateOffset()
{
if ($this->after()) {
Expand All @@ -232,6 +245,7 @@ private function updateOffset()
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
private function after()
{
return $this->params['after'];
Expand All @@ -240,6 +254,7 @@ private function after()
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
private function before()
{
return $this->params['before'];
Expand All @@ -248,6 +263,7 @@ private function before()
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
private function limit()
{
return $this->params['limit'];
Expand Down
4 changes: 2 additions & 2 deletions tests/AppsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AppsTest extends BaseTest
*/
protected $apps;

public function setUp()
public function setUp():void
{
parent::setUp();
$this->apps = $this->paylike->apps();
Expand All @@ -31,6 +31,6 @@ public function testFetch()
{
$app = $this->apps->fetch();

$this->assertEquals($app['id'], $this->app_id, 'app id');
$this->assertEquals($this->app_id, $app['id'], 'app id');
}
}
13 changes: 7 additions & 6 deletions tests/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace Paylike\Tests;

use Paylike\Paylike;
use PHPUnit\Framework\TestCase;

abstract class BaseTest extends \PHPUnit_Framework_TestCase
abstract class BaseTest extends TestCase
{
/**
* @var Paylike
Expand All @@ -15,12 +16,12 @@ abstract class BaseTest extends \PHPUnit_Framework_TestCase
protected $transaction_id;
protected $merchant_id;

public function setUp()
public function setUp(): void
{
$this->paylike = new Paylike("dbcf01af-8667-4967-9791-56101ca87ac8");
$this->app_id = "594d3cde5be12d547cbe2ec2";
$this->transaction_id = "5da8272132aad22568a511b7";
$this->merchant_id = "594d3c455be12d547cbe2ebe";
$this->paylike = new Paylike("a61437c5-1043-443b-ac3a-fe49c2b58481");
$this->app_id = "601268435b1f7e3d1ebf8271";
$this->transaction_id = "63ca94a11ec6fb693b1da497";
$this->merchant_id = "601267ebf700a44f17ee4fbf";
}

}
8 changes: 4 additions & 4 deletions tests/CardsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CardsTest extends BaseTest
*/
protected $cards;

public function setUp()
public function setUp():void
{
parent::setUp();
$this->cards = $this->paylike->cards();
Expand All @@ -29,7 +29,7 @@ public function testCreate()
));

$this->assertNotEmpty($card_id, 'primary key');
$this->assertInternalType('string', $card_id, 'primary key type');
$this->assertIsString($card_id, 'primary key type');
}

public function testFetch()
Expand All @@ -48,7 +48,7 @@ public function testFetch()

public function testFailFetch()
{
$this->setExpectedException(NotFound::class);
$this->cards->fetch('wrong id');
$this->expectException(NotFound::class);
$this->cards->fetch('wrong_id');
}
}
2 changes: 1 addition & 1 deletion tests/CurrenciesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CurrenciesTest extends BaseTest {
/**
*
*/
public function setUp() {
public function setUp():void {
parent::setUp();
$this->currency = new Currencies();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/MerchantsAppsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MerchantsAppsTest extends BaseTest
/**
*
*/
public function setUp()
public function setUp():void
{
parent::setUp();
$this->apps = $this->paylike->merchants()->apps();
Expand Down
6 changes: 3 additions & 3 deletions tests/MerchantsLinesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MerchantsLinesTest extends BaseTest
/**
*
*/
public function setUp()
public function setUp():void
{
parent::setUp();
$this->lines = $this->paylike->merchants()->lines();
Expand Down Expand Up @@ -44,7 +44,7 @@ public function testGetAllLinesCursor()
public function testGetAllLinesCursorBefore()
{
$merchant_id = $this->merchant_id;
$before = '5da8594efd0c53603c7bb3a5';
$before = '63ca90ee5c35c032ce597a3e';
$api_lines = $this->lines->before($merchant_id, $before);
$ids = array();
foreach ($api_lines as $line) {
Expand All @@ -71,5 +71,5 @@ public function testGetAllMerchantsCursorAfter()

$this->assertGreaterThan(0, count($api_lines), 'number of lines');
}

}
15 changes: 9 additions & 6 deletions tests/MerchantsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MerchantsTest extends BaseTest
/**
*
*/
public function setUp()
public function setUp():void
{
parent::setUp();
$this->merchants = $this->paylike->merchants();
Expand All @@ -38,7 +38,7 @@ public function testCreate()
));

$this->assertNotEmpty($merchant_id, 'primary key');
$this->assertInternalType('string', $merchant_id, 'primary key type');
$this->assertIsString( $merchant_id, 'primary key type');
}

/**
Expand All @@ -60,9 +60,12 @@ public function testUpdate()
{
$merchant_id = $this->merchant_id;

$this->merchants->update($merchant_id, array(
$response = $this->merchants->update($merchant_id, array(
'name' => 'Updated Merchant Name'
));

$this->assertNotEmpty($response, 'response');

}

/**
Expand All @@ -88,8 +91,8 @@ public function testGetAllMerchantsCursor()
public function testGetAllMerchantsCursorOptions()
{
$app_id = $this->app_id;
$after = '5952889e764d2754c974fe94';
$before = '5b8e5b8cd294fa04eb4cfbeb';
$after = '601267ebf700a44f17ee4fbf';
$before = '63ea11e29b99b157051e4455';
$api_merchants = $this->merchants->find($app_id, array(
'after' => $after,
'before' => $before
Expand All @@ -109,7 +112,7 @@ public function testGetAllMerchantsCursorOptions()
public function testGetAllMerchantsCursorBefore()
{
$app_id = $this->app_id;
$before = '5b8e5b8cd294fa04eb4cfbeb';
$before = '63ea11e29b99b157051e4455';
$api_merchants = $this->merchants->before($app_id, $before);
$ids = array();
foreach ($api_merchants as $merchant) {
Expand Down
Loading

0 comments on commit d388681

Please sign in to comment.