Skip to content

Commit 68568b7

Browse files
committed
PHP 8.1 fix deprecation notices
See #24 Also php-money to version 4 (from version 3) and guzzlepphp/psr-7 from 1.x to 2.x Dependency is now with PHP 8.1+ only
1 parent 6a55f06 commit 68568b7

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"nesbot/carbon": "~1.18|^2.0",
2222
"psr/http-message": "^1.0",
2323
"moneyphp/money": "^4.0.4",
24-
"guzzlehttp/psr7": "^1.4"
24+
"guzzlehttp/psr7": "^1.5|^2.2"
2525
},
2626
"require-dev": {
2727
"phpunit/phpunit": "~9.0",

src/AbstractCollection.php

+16-12
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
}
@@ -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
}

0 commit comments

Comments
 (0)