Skip to content

Commit 45b8c29

Browse files
authored
Merge pull request #8 from kinimodmeyer/php8
add php8 support
2 parents 8adfef5 + 6728489 commit 45b8c29

10 files changed

Lines changed: 27 additions & 20 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
php-versions: ['7.3', '7.4']
9+
php-versions: ['7.4.*', '8.0.*', '8.1.*']
1010
steps:
1111
- uses: actions/checkout@v2
1212
- name: Setup PHP

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SDK to handle all different ways to interact with Tradebyte API. more informatio
1212

1313
* credentials (username,password,account-number)
1414
* see https://tb-io.tradebyte.org/how-to/generate-rest-api-credentials-in-tb-one/
15-
* PHP >= 7.3
15+
* PHP >= 7.4
1616
* Composer
1717
* cURL
1818

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"squizlabs/php_codesniffer": "3.*"
2020
},
2121
"require": {
22-
"php": "^7.3",
22+
"php": "7.4.* || 8.0.* || 8.1.*",
2323
"ext-xmlreader": "*",
2424
"ext-simplexml": "*",
2525
"ext-xmlwriter": "*",

src/Base/Iterator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,23 @@ public function setOpenLocalFilepath(bool $openLocalFilepath)
7474
/**
7575
* @return boolean
7676
*/
77-
public function valid()
77+
public function valid(): bool
7878
{
7979
return !empty($this->current);
8080
}
8181

8282
/**
8383
* @return integer
8484
*/
85-
public function key()
85+
public function key(): int
8686
{
8787
return $this->i;
8888
}
8989

9090
/**
9191
* @return void
9292
*/
93-
public function rewind()
93+
public function rewind(): void
9494
{
9595
$this->i = 0;
9696
$this->isOpen = false;

src/Client/Rest.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,27 @@ class Rest
1212
/**
1313
* @var integer
1414
*/
15-
private $accountNumber;
15+
private int $accountNumber;
1616

1717
/**
1818
* @var string
1919
*/
20-
private $accountUser;
20+
private string $accountUser;
2121

2222
/**
2323
* @var string
2424
*/
25-
private $accountPassword;
25+
private string $accountPassword;
2626

2727
/**
2828
* @var string
2929
*/
30-
private $baseURL = 'https://rest.trade-server.net';
30+
private string $baseURL = 'https://rest.trade-server.net';
31+
32+
/**
33+
* @var string
34+
*/
35+
private string $userAgent = 'Tradebyte-SDK-PHP';
3136

3237
/**
3338
* @param integer $number
@@ -155,7 +160,7 @@ public function downloadFile(string $localFilePath, string $url, array $filter =
155160
$context = [
156161
'http' => [
157162
'header' => $this->getAuthHeader()
158-
. "\r\n" . 'User-Agent: Tradebyte-SDK',
163+
. "\r\n" . 'User-Agent: ' . $this->userAgent,
159164
'ignore_errors' => true,
160165
'time_out' => 3600,
161166
]
@@ -212,7 +217,7 @@ public function postXML(string $url, string $postData = ''): string
212217
'header' => $this->getAuthHeader()
213218
. "\r\n" . 'Content-Type: application/xml'
214219
. "\r\n" . 'Accept: application/xml'
215-
. "\r\n" . 'User-Agent: Tradebyte-SDK',
220+
. "\r\n" . 'User-Agent: ' . $this->userAgent,
216221
'content' => $postData,
217222
'ignore_errors' => true,
218223
'time_out' => 3600,
@@ -241,7 +246,7 @@ public function getXML(string $url, array $filter = []): XMLReader
241246
'http' => [
242247
'header' => $this->getAuthHeader()
243248
. "\r\n" . 'Accept: application/xml'
244-
. "\r\n" . 'User-Agent: Tradebyte-SDK',
249+
. "\r\n" . 'User-Agent: ' . $this->userAgent,
245250
'ignore_errors' => true,
246251
'time_out' => 3600,
247252
]

src/Message/Tbmessage/Iterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function current(): Message
2323
/**
2424
* @return void
2525
*/
26-
public function next()
26+
public function next(): void
2727
{
2828
while ($this->xmlReader->read()) {
2929
if (

src/Order/Tborder/Iterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function current(): Order
2323
/**
2424
* @return void
2525
*/
26-
public function next()
26+
public function next(): void
2727
{
2828
while ($this->xmlReader->read()) {
2929
if (

src/Product/Tbcat/Iterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function current(): Product
4141
/**
4242
* @return void
4343
*/
44-
public function next()
44+
public function next(): void
4545
{
4646
while ($this->xmlReader->read()) {
4747
if (

src/Stock/Tbstock/Iterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function current(): Stock
4040
/**
4141
* @return void
4242
*/
43-
public function next()
43+
public function next(): void
4444
{
4545
while ($this->xmlReader->read()) {
4646
if (

tests/Message/MessageTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,11 @@ public function testUpdateMessageProcessed(): void
7474
{
7575
$mock = $this->getMockBuilder(Client\Rest::class)
7676
->disableOriginalConstructor()
77-
->setMethodsExcept(['postXML', 'setAccountNumber', 'setBaseURL'])
77+
->setMethodsExcept(['postXML', 'setAccountNumber', 'setAccountUser', 'setAccountPassword', 'setBaseURL'])
7878
->getMock();
7979
$mock->setAccountNumber(1234);
80+
$mock->setAccountUser('test');
81+
$mock->setAccountPassword('test');
8082
$mock->setBaseURL('localhost');
8183
$mock->expects($this->once())
8284
->method('fileGetContents')
@@ -86,10 +88,10 @@ public function testUpdateMessageProcessed(): void
8688
$this->equalTo([
8789
'http' => [
8890
'method' => 'POST',
89-
'header' => 'Authorization: Basic Og==' . "\r\n" .
91+
'header' => 'Authorization: Basic dGVzdDp0ZXN0' . "\r\n" .
9092
'Content-Type: application/xml' . "\r\n" .
9193
'Accept: application/xml' . "\r\n" .
92-
'User-Agent: Tradebyte-SDK',
94+
'User-Agent: Tradebyte-SDK-PHP',
9395
'content' => '',
9496
'ignore_errors' => true,
9597
'time_out' => 3600

0 commit comments

Comments
 (0)