Skip to content

Commit e654701

Browse files
authored
Merge pull request #25 from consilience/php81
PHP 8.1 changes
2 parents 34f7fe2 + 68568b7 commit e654701

20 files changed

+76
-85
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
coverage
44
phpunit.xml
55
composer.lock
6-
vendor/
6+
/vendor
7+
/.phpunit.result.cache

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
## Starling Bank Payments API Objects
99

10-
This is a package for PHP 5.6 to stuff the response body messages
10+
This is a package for PHP 8.1 to stuff the response body messages
1111
from requests to the
1212
[Starling Payments API](https://developer.starlingbank.com/payments/docs#operations-tag-Web_Hook)
1313

14-
This package is in development, and has intially covered just
14+
This package is in development, and has initially covered just
1515
the response messages I am particularly interested in.
1616
Objects to generate the request message bodies are being added now.
1717
The intention is to extend that to include the full PSR-7 message (body,
@@ -22,7 +22,7 @@ added, so the constructors will change.
2222
Additional objects can be submitted by Pull Request if they are something you
2323
would like to see.
2424

25-
The request messags are not included in this package for the moment,
25+
The request messages are not included in this package for the moment,
2626
but they may be in due course. Again, I am happy to accept PRs to hurry
2727
this along.
2828

@@ -34,7 +34,7 @@ The JSON responses will decode to nested arrays of scalar values.
3434
This package provides classes that instantiate objects from that data.
3535

3636
To start with, the classes are just dumb value objects that take the data in properties.
37-
Over time, more logic will be added to the classes to intepret the property values
37+
Over time, more logic will be added to the classes to interpret the property values
3838
in a higher business sense.
3939
In addition, the values will be parsed into more common objects such as
4040
[Money](http://moneyphp.org) and [Carbon](http://carbon.nesbot.com/docs/)

composer.json

+4-9
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,17 @@
1717
}
1818
],
1919
"require": {
20-
"php": ">=7.1.0",
20+
"php": ">=8.1",
2121
"nesbot/carbon": "~1.18|^2.0",
2222
"psr/http-message": "^1.0",
23-
"moneyphp/money": "^3.0",
24-
"guzzlehttp/psr7": "^1.4"
23+
"moneyphp/money": "^4.0.4",
24+
"guzzlehttp/psr7": "^1.5|^2.2"
2525
},
2626
"require-dev": {
27-
"phpunit/phpunit": "~4.0",
27+
"phpunit/phpunit": "~9.0",
2828
"squizlabs/php_codesniffer": "^3.2"
2929
},
3030
"autoload": {
3131
"psr-4": { "Consilience\\Starling\\Payments\\": "src" }
32-
},
33-
"extra": {
34-
"branch-alias": {
35-
"dev-master": "0.3-dev"
36-
}
3732
}
3833
}

src/AbstractCollection.php

+17-13
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
*
77
*/
88

9+
use Traversable;
10+
use ArrayIterator;
11+
use InvalidArgumentException;
912
use Psr\Http\Message\ResponseInterface;
10-
use Consilience\Starling\Payments\HydratableTrait;
1113
use Consilience\Starling\Payments\HasErrorsTrait;
14+
use Prophecy\Doubler\ClassPatch\TraversablePatch;
15+
use Consilience\Starling\Payments\HydratableTrait;
1216

1317
abstract class AbstractCollection implements
1418
\JsonSerializable,
@@ -56,7 +60,7 @@ public static function fromArray(array $items)
5660
/**
5761
* @return int
5862
*/
59-
public function count()
63+
public function count(): int
6064
{
6165
return count($this->items);
6266
}
@@ -79,7 +83,7 @@ public function push($item)
7983
$this->items[] = $item;
8084
}
8185

82-
public function jsonSerialize()
86+
public function jsonSerialize(): mixed
8387
{
8488
$data = [];
8589

@@ -101,28 +105,28 @@ abstract protected function createInstance(array $data);
101105
/**
102106
* @return bool
103107
*/
104-
public function isEmpty()
108+
public function isEmpty(): bool
105109
{
106110
return $this->count() == 0;
107111
}
108112

109113
/**
110-
* @return \ArrayIterator
114+
* @return Traversable
111115
*/
112-
public function getIterator()
116+
public function getIterator(): Traversable
113117
{
114-
return new \ArrayIterator($this->items);
118+
return new ArrayIterator($this->items);
115119
}
116120

117121
/**
118122
* @param mixed $item
119-
* @throws \InvalidArgumentException
123+
* @throws InvalidArgumentException
120124
* @return void
121125
*/
122126
protected function assertStrictType($item)
123127
{
124128
if (! $this->hasExpectedStrictType($item)) {
125-
throw new \InvalidArgumentException('Item is not currect type or is empty.');
129+
throw new InvalidArgumentException('Item is not currect type or is empty.');
126130
}
127131
}
128132

@@ -135,7 +139,7 @@ public function first()
135139
// ArrayAccess methods
136140
//
137141

138-
public function offsetSet($offset, $value)
142+
public function offsetSet(mixed $offset, mixed $value): void
139143
{
140144
if (is_null($offset)) {
141145
$this->items[] = $value;
@@ -144,17 +148,17 @@ public function offsetSet($offset, $value)
144148
}
145149
}
146150

147-
public function offsetExists($offset)
151+
public function offsetExists(mixed $offset): bool
148152
{
149153
return isset($this->items[$offset]);
150154
}
151155

152-
public function offsetUnset($offset)
156+
public function offsetUnset(mixed $offset): void
153157
{
154158
unset($this->items[$offset]);
155159
}
156160

157-
public function offsetGet($offset)
161+
public function offsetGet(mixed $offset): mixed
158162
{
159163
return isset($this->items[$offset]) ? $this->items[$offset] : null;
160164
}

src/AbstractRequest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Consilience\Starling\Payments\HydratableTrait;
1010
use Consilience\Starling\Payments\ValidationTrait;
1111
use Consilience\Starling\Payments\ModelInterface;
12-
1312
use Consilience\Starling\Payments\Request\Models\Endpoint;
1413

1514
abstract class AbstractRequest implements ModelInterface
@@ -172,8 +171,8 @@ public function withProperty($name, $value)
172171
/**
173172
* @return null an empty body by default
174173
*/
175-
public function jsonSerialize()
174+
public function jsonSerialize(): mixed
176175
{
177-
return;
176+
return null;
178177
}
179178
}

src/HydratableTrait.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*
77
*/
88

9-
use UnexpectedValueException;
109
use Exception;
1110
use InvalidArgumentException;
1211
use Psr\Http\Message\ResponseInterface;
@@ -217,7 +216,7 @@ public function hasProperty($name)
217216
*
218217
* @return mixed
219218
*/
220-
public function jsonSerialize()
219+
public function jsonSerialize(): mixed
221220
{
222221
// Start with all properties.
223222

src/Request/CancelMandateRequest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
use Consilience\Starling\Payments\Request\Models\Endpoint;
10-
use UnexpectedValueException;
1110

1211
class CancelMandateRequest extends ActivateMandateRequest
1312
{
@@ -55,7 +54,7 @@ protected function setMandateStatusCancellationReason($value)
5554
/**
5655
* @return CreatePaymentAccountAddressRequest for serializing
5756
*/
58-
public function jsonSerialize()
57+
public function jsonSerialize(): mixed
5958
{
6059
$reason = $this->getProperty('mandateStatusCancellationReason');
6160

src/Request/CreatePaymentAccount.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
*/
88

99
use Consilience\Starling\Payments\Request\Models\Endpoint;
10-
use Consilience\Starling\Payments\AbstractRequest;
11-
use UnexpectedValueException;
1210
use Consilience\Starling\Payments\Request\Models\CreatePaymentAccountRequest;
1311

1412
class CreatePaymentAccount extends GetPaymentAccount
@@ -42,7 +40,7 @@ protected function setCreatePaymentAccountRequest(CreatePaymentAccountRequest $v
4240
/**
4341
* @return CreatePaymentAccountRequest object for serializing
4442
*/
45-
public function jsonSerialize()
43+
public function jsonSerialize(): mixed
4644
{
4745
return $this->getProperty('createPaymentAccountRequest');
4846
}

src/Request/CreatePaymentAccountAddress.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
use Consilience\Starling\Payments\Request\Models\Endpoint;
1010
use Consilience\Starling\Payments\AbstractRequest;
11-
use UnexpectedValueException;
12-
1311
use Consilience\Starling\Payments\Request\Models\CreatePaymentAccountAddressRequest;
1412

1513
class CreatePaymentAccountAddress extends AbstractRequest
@@ -73,7 +71,7 @@ protected function setCreatePaymentAccountAddressRequest(CreatePaymentAccountAdd
7371
/**
7472
* @return CreatePaymentAccountAddressRequest for serializing
7573
*/
76-
public function jsonSerialize()
74+
public function jsonSerialize(): mixed
7775
{
7876
return $this->getProperty('createPaymentAccountAddressRequest');
7977
}

src/Request/CreatePaymentDomestic.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
use Consilience\Starling\Payments\Request\Models\Endpoint;
1111
use Consilience\Starling\Payments\AbstractRequest;
12-
use UnexpectedValueException;
13-
1412
use Consilience\Starling\Payments\Request\Models\DomesticPaymentInstructionRequest;
1513

1614
class CreatePaymentDomestic extends AbstractRequest
@@ -89,7 +87,7 @@ protected function setDomesticPaymentInstructionRequest(DomesticPaymentInstructi
8987
/**
9088
* @return DomesticPaymentInstructionRequest for serializing
9189
*/
92-
public function jsonSerialize()
90+
public function jsonSerialize(): mixed
9391
{
9492
return $this->getProperty('domesticPaymentInstructionRequest');
9593
}

src/Request/CreatePaymentReturn.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
use Consilience\Starling\Payments\Request\Models\Endpoint;
1212
use Consilience\Starling\Payments\AbstractRequest;
13-
use UnexpectedValueException;
14-
1513
use Consilience\Starling\Payments\Request\Models\PaymentReturnRequest;
1614

1715
class CreatePaymentReturn extends AbstractRequest
@@ -88,7 +86,7 @@ protected function setPaymentReturnRequest(PaymentReturnRequest $value)
8886
/**
8987
* @return PaymentReturnRequest for serializing
9088
*/
91-
public function jsonSerialize()
89+
public function jsonSerialize(): mixed
9290
{
9391
return $this->getProperty('paymentReturnRequest');
9492
}

src/Request/GetPaymentAccount.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class GetPaymentAccount extends AbstractRequest
2323

2424
/**
2525
* @param string $paymentBusinessUid
26-
* @param string $accountUid the accound to retrieve
26+
* @param string $accountUid the account to retrieve
2727
*/
2828
public function __construct(Endpoint $endpoint, $accountUid)
2929
{

src/Request/Models/CreatePaymentAccountAddressRequest.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
use Consilience\Starling\Payments\HydratableTrait;
1313
use Consilience\Starling\Payments\ValidationTrait;
1414
use Consilience\Starling\Payments\ModelInterface;
15-
use UnexpectedValueException;
16-
17-
use Consilience\Starling\Payments\Response\Models\CurrencyAndAmount;
1815

1916
class CreatePaymentAccountAddressRequest implements ModelInterface
2017
{
@@ -114,7 +111,7 @@ protected function setAccountNumber($value)
114111
/**
115112
* @return array
116113
*/
117-
public function jsonSerialize()
114+
public function jsonSerialize(): mixed
118115
{
119116
$data = [
120117
'accountName' => $this->accountName,

src/Request/UpdatePaymentAccountAddressFasterPaymentsStatus.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
use Consilience\Starling\Payments\Request\Models\Endpoint;
1414
use Consilience\Starling\Payments\AbstractRequest;
15-
use UnexpectedValueException;
1615
use Consilience\Starling\Payments\Request\Models\ChangeFasterPaymentsStatusPaymentAccountAddressRequest;
1716

1817
class UpdatePaymentAccountAddressFasterPaymentsStatus extends AbstractRequest
@@ -78,7 +77,7 @@ protected function setChangeFasterPaymentsStatusPaymentAccountAddressRequest(
7877
/**
7978
* @return array for serializing
8079
*/
81-
public function jsonSerialize()
80+
public function jsonSerialize(): mixed
8281
{
8382
return $this->getProperty(
8483
'changeFasterPaymentsStatusPaymentAccountAddressRequest'

src/Request/UpdatePaymentAccountAddressStatus.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
use Consilience\Starling\Payments\Request\Models\Endpoint;
1010
use Consilience\Starling\Payments\AbstractRequest;
11-
use UnexpectedValueException;
1211

1312
class UpdatePaymentAccountAddressStatus extends AbstractRequest
1413
{
@@ -75,7 +74,7 @@ protected function setStatus($value)
7574
/**
7675
* @return array for serializing
7776
*/
78-
public function jsonSerialize()
77+
public function jsonSerialize(): mixed
7978
{
8079
return [
8180
'status' => $this->getProperty('status')

0 commit comments

Comments
 (0)