Skip to content

Commit d388681

Browse files
committed
Updated for php 8.1 support
1 parent bcdf66a commit d388681

11 files changed

+273
-287
lines changed

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "paylike/php-api",
33
"description": "PHP SDK to communicate with the Paylike HTTP API",
4-
"version": "1.0.8",
4+
"version": "2.0.0",
55
"license": "MIT",
66
"authors": [
77
{
@@ -21,10 +21,10 @@
2121
}
2222
},
2323
"require": {
24-
"php": ">=5.3.3",
24+
"php": ">=5.6.0",
2525
"ext-curl": "*"
2626
},
2727
"require-dev": {
28-
"phpunit/phpunit": "^4.8"
28+
"phpunit/phpunit": "^9.6.3"
2929
}
3030
}

src/Endpoint/Merchants.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function update($merchant_id, $args)
5555
{
5656
$url = 'merchants/' . $merchant_id;
5757

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

6161
/**

src/Utils/Cursor.php

+16
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function __construct($endpoint, array $params, array $data, Paylike $payl
5555
* @link http://php.net/manual/en/iterator.rewind.php
5656
* @return void Any returned value is ignored.
5757
*/
58+
#[\ReturnTypeWillChange]
5859
public function rewind()
5960
{
6061
$this->current_index = 0;
@@ -65,6 +66,7 @@ public function rewind()
6566
* @link http://php.net/manual/en/iterator.current.php
6667
* @return mixed Can return any type.
6768
*/
69+
#[\ReturnTypeWillChange]
6870
public function current()
6971
{
7072
return $this->collection[$this->current_index];
@@ -75,6 +77,7 @@ public function current()
7577
* @link http://php.net/manual/en/iterator.key.php
7678
* @return mixed scalar on success, or null on failure.
7779
*/
80+
#[\ReturnTypeWillChange]
7881
public function key()
7982
{
8083
return $this->current_index;
@@ -85,6 +88,7 @@ public function key()
8588
* @link http://php.net/manual/en/iterator.next.php
8689
* @return null any returned value is ignored.
8790
*/
91+
#[\ReturnTypeWillChange]
8892
public function next()
8993
{
9094
++$this->current_index;
@@ -99,6 +103,7 @@ public function next()
99103
* @return boolean The return value will be casted to boolean and then evaluated.
100104
* Returns true on success or false on failure.
101105
*/
106+
#[\ReturnTypeWillChange]
102107
public function valid()
103108
{
104109
return isset($this->collection[$this->current_index]);
@@ -107,6 +112,7 @@ public function valid()
107112
/**
108113
* @return integer
109114
*/
115+
#[\ReturnTypeWillChange]
110116
public function count()
111117
{
112118
return max($this->total_count, count($this->collection));
@@ -123,6 +129,7 @@ public function count()
123129
* <p>
124130
* The return value will be casted to boolean if non-boolean was returned.
125131
*/
132+
#[\ReturnTypeWillChange]
126133
public function offsetExists($offset)
127134
{
128135
$exists = isset($this->collection[$offset]);
@@ -145,6 +152,7 @@ public function offsetExists($offset)
145152
* </p>
146153
* @return mixed Can return all value types.
147154
*/
155+
#[\ReturnTypeWillChange]
148156
public function offsetGet($offset)
149157
{
150158
$value = isset($this->collection[$offset]) ? $this->collection[$offset] : null;
@@ -170,6 +178,7 @@ public function offsetGet($offset)
170178
* </p>
171179
* @return void
172180
*/
181+
#[\ReturnTypeWillChange]
173182
public function offsetSet($offset, $value)
174183
{
175184
if ($offset === null) {
@@ -187,6 +196,7 @@ public function offsetSet($offset, $value)
187196
* </p>
188197
* @return void
189198
*/
199+
#[\ReturnTypeWillChange]
190200
public function offsetUnset($offset)
191201
{
192202
unset($this->collection[$offset]);
@@ -195,6 +205,7 @@ public function offsetUnset($offset)
195205
/**
196206
* @return $this
197207
*/
208+
#[\ReturnTypeWillChange]
198209
private function fetchNext()
199210
{
200211
$this->updateOffset()->fetch();
@@ -205,6 +216,7 @@ private function fetchNext()
205216
/**
206217
* @return $this
207218
*/
219+
#[\ReturnTypeWillChange]
208220
private function fetch()
209221
{
210222
$api_response = $this->paylike->client->request('GET', $this->endpoint, $this->params);
@@ -219,6 +231,7 @@ private function fetch()
219231
/**
220232
* If after is set, then we increment it, otherwise we increment before
221233
*/
234+
#[\ReturnTypeWillChange]
222235
private function updateOffset()
223236
{
224237
if ($this->after()) {
@@ -232,6 +245,7 @@ private function updateOffset()
232245
/**
233246
* @return mixed
234247
*/
248+
#[\ReturnTypeWillChange]
235249
private function after()
236250
{
237251
return $this->params['after'];
@@ -240,6 +254,7 @@ private function after()
240254
/**
241255
* @return mixed
242256
*/
257+
#[\ReturnTypeWillChange]
243258
private function before()
244259
{
245260
return $this->params['before'];
@@ -248,6 +263,7 @@ private function before()
248263
/**
249264
* @return mixed
250265
*/
266+
#[\ReturnTypeWillChange]
251267
private function limit()
252268
{
253269
return $this->params['limit'];

tests/AppsTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class AppsTest extends BaseTest
1111
*/
1212
protected $apps;
1313

14-
public function setUp()
14+
public function setUp():void
1515
{
1616
parent::setUp();
1717
$this->apps = $this->paylike->apps();
@@ -31,6 +31,6 @@ public function testFetch()
3131
{
3232
$app = $this->apps->fetch();
3333

34-
$this->assertEquals($app['id'], $this->app_id, 'app id');
34+
$this->assertEquals($this->app_id, $app['id'], 'app id');
3535
}
3636
}

tests/BaseTest.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
namespace Paylike\Tests;
44

55
use Paylike\Paylike;
6+
use PHPUnit\Framework\TestCase;
67

7-
abstract class BaseTest extends \PHPUnit_Framework_TestCase
8+
abstract class BaseTest extends TestCase
89
{
910
/**
1011
* @var Paylike
@@ -15,12 +16,12 @@ abstract class BaseTest extends \PHPUnit_Framework_TestCase
1516
protected $transaction_id;
1617
protected $merchant_id;
1718

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

2627
}

tests/CardsTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class CardsTest extends BaseTest
1212
*/
1313
protected $cards;
1414

15-
public function setUp()
15+
public function setUp():void
1616
{
1717
parent::setUp();
1818
$this->cards = $this->paylike->cards();
@@ -29,7 +29,7 @@ public function testCreate()
2929
));
3030

3131
$this->assertNotEmpty($card_id, 'primary key');
32-
$this->assertInternalType('string', $card_id, 'primary key type');
32+
$this->assertIsString($card_id, 'primary key type');
3333
}
3434

3535
public function testFetch()
@@ -48,7 +48,7 @@ public function testFetch()
4848

4949
public function testFailFetch()
5050
{
51-
$this->setExpectedException(NotFound::class);
52-
$this->cards->fetch('wrong id');
51+
$this->expectException(NotFound::class);
52+
$this->cards->fetch('wrong_id');
5353
}
5454
}

tests/CurrenciesTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CurrenciesTest extends BaseTest {
1414
/**
1515
*
1616
*/
17-
public function setUp() {
17+
public function setUp():void {
1818
parent::setUp();
1919
$this->currency = new Currencies();
2020
}

tests/MerchantsAppsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MerchantsAppsTest extends BaseTest
1515
/**
1616
*
1717
*/
18-
public function setUp()
18+
public function setUp():void
1919
{
2020
parent::setUp();
2121
$this->apps = $this->paylike->merchants()->apps();

tests/MerchantsLinesTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MerchantsLinesTest extends BaseTest
1515
/**
1616
*
1717
*/
18-
public function setUp()
18+
public function setUp():void
1919
{
2020
parent::setUp();
2121
$this->lines = $this->paylike->merchants()->lines();
@@ -44,7 +44,7 @@ public function testGetAllLinesCursor()
4444
public function testGetAllLinesCursorBefore()
4545
{
4646
$merchant_id = $this->merchant_id;
47-
$before = '5da8594efd0c53603c7bb3a5';
47+
$before = '63ca90ee5c35c032ce597a3e';
4848
$api_lines = $this->lines->before($merchant_id, $before);
4949
$ids = array();
5050
foreach ($api_lines as $line) {
@@ -71,5 +71,5 @@ public function testGetAllMerchantsCursorAfter()
7171

7272
$this->assertGreaterThan(0, count($api_lines), 'number of lines');
7373
}
74-
74+
7575
}

tests/MerchantsTest.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class MerchantsTest extends BaseTest
1414
/**
1515
*
1616
*/
17-
public function setUp()
17+
public function setUp():void
1818
{
1919
parent::setUp();
2020
$this->merchants = $this->paylike->merchants();
@@ -38,7 +38,7 @@ public function testCreate()
3838
));
3939

4040
$this->assertNotEmpty($merchant_id, 'primary key');
41-
$this->assertInternalType('string', $merchant_id, 'primary key type');
41+
$this->assertIsString( $merchant_id, 'primary key type');
4242
}
4343

4444
/**
@@ -60,9 +60,12 @@ public function testUpdate()
6060
{
6161
$merchant_id = $this->merchant_id;
6262

63-
$this->merchants->update($merchant_id, array(
63+
$response = $this->merchants->update($merchant_id, array(
6464
'name' => 'Updated Merchant Name'
6565
));
66+
67+
$this->assertNotEmpty($response, 'response');
68+
6669
}
6770

6871
/**
@@ -88,8 +91,8 @@ public function testGetAllMerchantsCursor()
8891
public function testGetAllMerchantsCursorOptions()
8992
{
9093
$app_id = $this->app_id;
91-
$after = '5952889e764d2754c974fe94';
92-
$before = '5b8e5b8cd294fa04eb4cfbeb';
94+
$after = '601267ebf700a44f17ee4fbf';
95+
$before = '63ea11e29b99b157051e4455';
9396
$api_merchants = $this->merchants->find($app_id, array(
9497
'after' => $after,
9598
'before' => $before
@@ -109,7 +112,7 @@ public function testGetAllMerchantsCursorOptions()
109112
public function testGetAllMerchantsCursorBefore()
110113
{
111114
$app_id = $this->app_id;
112-
$before = '5b8e5b8cd294fa04eb4cfbeb';
115+
$before = '63ea11e29b99b157051e4455';
113116
$api_merchants = $this->merchants->before($app_id, $before);
114117
$ids = array();
115118
foreach ($api_merchants as $merchant) {

0 commit comments

Comments
 (0)