6
6
*
7
7
*/
8
8
9
+ use Traversable ;
10
+ use ArrayIterator ;
11
+ use InvalidArgumentException ;
9
12
use Psr \Http \Message \ResponseInterface ;
10
- use Consilience \Starling \Payments \HydratableTrait ;
11
13
use Consilience \Starling \Payments \HasErrorsTrait ;
14
+ use Prophecy \Doubler \ClassPatch \TraversablePatch ;
15
+ use Consilience \Starling \Payments \HydratableTrait ;
12
16
13
17
abstract class AbstractCollection implements
14
18
\JsonSerializable,
@@ -56,7 +60,7 @@ public static function fromArray(array $items)
56
60
/**
57
61
* @return int
58
62
*/
59
- public function count ()
63
+ public function count (): int
60
64
{
61
65
return count ($ this ->items );
62
66
}
@@ -79,7 +83,7 @@ public function push($item)
79
83
$ this ->items [] = $ item ;
80
84
}
81
85
82
- public function jsonSerialize ()
86
+ public function jsonSerialize (): mixed
83
87
{
84
88
$ data = [];
85
89
@@ -101,28 +105,28 @@ abstract protected function createInstance(array $data);
101
105
/**
102
106
* @return bool
103
107
*/
104
- public function isEmpty ()
108
+ public function isEmpty (): bool
105
109
{
106
110
return $ this ->count () == 0 ;
107
111
}
108
112
109
113
/**
110
- * @return \ArrayIterator
114
+ * @return Traversable
111
115
*/
112
- public function getIterator ()
116
+ public function getIterator (): Traversable
113
117
{
114
- return new \ ArrayIterator ($ this ->items );
118
+ return new ArrayIterator ($ this ->items );
115
119
}
116
120
117
121
/**
118
122
* @param mixed $item
119
- * @throws \ InvalidArgumentException
123
+ * @throws InvalidArgumentException
120
124
* @return void
121
125
*/
122
126
protected function assertStrictType ($ item )
123
127
{
124
128
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. ' );
126
130
}
127
131
}
128
132
@@ -135,7 +139,7 @@ public function first()
135
139
// ArrayAccess methods
136
140
//
137
141
138
- public function offsetSet ($ offset , $ value )
142
+ public function offsetSet (mixed $ offset , mixed $ value ): void
139
143
{
140
144
if (is_null ($ offset )) {
141
145
$ this ->items [] = $ value ;
@@ -144,17 +148,17 @@ public function offsetSet($offset, $value)
144
148
}
145
149
}
146
150
147
- public function offsetExists ($ offset )
151
+ public function offsetExists (mixed $ offset ): bool
148
152
{
149
153
return isset ($ this ->items [$ offset ]);
150
154
}
151
155
152
- public function offsetUnset ($ offset )
156
+ public function offsetUnset (mixed $ offset ): void
153
157
{
154
158
unset($ this ->items [$ offset ]);
155
159
}
156
160
157
- public function offsetGet ($ offset )
161
+ public function offsetGet (mixed $ offset ): mixed
158
162
{
159
163
return isset ($ this ->items [$ offset ]) ? $ this ->items [$ offset ] : null ;
160
164
}
0 commit comments