Skip to content

Commit 399aa03

Browse files
authored
Merge pull request #84 from simPod/methods
State methods visibility explicitly in interfaces
2 parents 0ae4db4 + a9333f9 commit 399aa03

File tree

3 files changed

+35
-35
lines changed

3 files changed

+35
-35
lines changed

src/Collection.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ interface Collection extends \IteratorAggregate, \Countable, \JsonSerializable
1717
/**
1818
* Removes all values from the collection.
1919
*/
20-
function clear();
20+
public function clear();
2121

2222
/**
2323
* Returns the size of the collection.
2424
*
2525
* @return int
2626
*/
27-
function count(): int;
27+
public function count(): int;
2828

2929
/**
3030
* Returns a shallow copy of the collection.
@@ -33,15 +33,15 @@ function count(): int;
3333
*
3434
* @psalm-return static<TKey, TValue>
3535
*/
36-
function copy();
36+
public function copy();
3737

3838
/**
3939
* Returns whether the collection is empty.
4040
*
4141
* This should be equivalent to a count of zero, but is not required.
4242
* Implementations should define what empty means in their own context.
4343
*/
44-
function isEmpty(): bool;
44+
public function isEmpty(): bool;
4545

4646
/**
4747
* Returns an array representation of the collection.
@@ -52,5 +52,5 @@ function isEmpty(): bool;
5252
*
5353
* @return array<TKey, TValue>
5454
*/
55-
function toArray(): array;
55+
public function toArray(): array;
5656
}

src/Hashable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ interface Hashable
2020
*
2121
* @return mixed
2222
*/
23-
function hash();
23+
public function hash();
2424

2525
/**
2626
* Determines if two objects should be considered equal. Both objects will
2727
* be instances of the same class but may not be the same instance.
2828
*
2929
* @param mixed $obj An instance of the same class to compare to.
3030
*/
31-
function equals($obj): bool;
31+
public function equals($obj): bool;
3232
}

src/Sequence.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @template TValue
1515
* @extends Collection<int, TValue>
1616
*/
17-
interface Sequence extends Collection, \ArrayAccess
17+
interface Sequence extends Collection, \ArrayAccess
1818
{
1919
/**
2020
* Ensures that enough memory is allocated for a required capacity.
@@ -23,7 +23,7 @@ interface Sequence extends Collection, \ArrayAccess
2323
* allocated. Capacity will stay the same if this value
2424
* is less than or equal to the current capacity.
2525
*/
26-
function allocate(int $capacity);
26+
public function allocate(int $capacity);
2727

2828
/**
2929
* Updates every value in the sequence by applying a callback, using the
@@ -33,14 +33,14 @@ function allocate(int $capacity);
3333
*
3434
* @psalm-param callable(TValue): TValue $callback
3535
*/
36-
function apply(callable $callback);
36+
public function apply(callable $callback);
3737

3838
/**
3939
* Returns the current capacity of the sequence.
4040
*
4141
* @return int
4242
*/
43-
function capacity(): int;
43+
public function capacity(): int;
4444

4545
/**
4646
* Determines whether the sequence contains all of zero or more values.
@@ -52,7 +52,7 @@ function capacity(): int;
5252
*
5353
* @psalm-param TValue ...$values
5454
*/
55-
function contains(...$values): bool;
55+
public function contains(...$values): bool;
5656

5757
/**
5858
* Returns a new sequence containing only the values for which a callback
@@ -67,7 +67,7 @@ function contains(...$values): bool;
6767
* @psalm-param (callable(TValue): bool)|null $callback
6868
* @psalm-return Sequence<TValue>
6969
*/
70-
function filter(callable $callback = null): Sequence;
70+
public function filter(callable $callback = null): Sequence;
7171

7272
/**
7373
* Returns the index of a given value, or null if it could not be found.
@@ -78,7 +78,7 @@ function filter(callable $callback = null): Sequence;
7878
*
7979
* @psalm-param TValue $value
8080
*/
81-
function find($value);
81+
public function find($value);
8282

8383
/**
8484
* Returns the first value in the sequence.
@@ -89,7 +89,7 @@ function find($value);
8989
*
9090
* @psalm-return TValue
9191
*/
92-
function first();
92+
public function first();
9393

9494
/**
9595
* Returns the value at a given index (position) in the sequence.
@@ -100,7 +100,7 @@ function first();
100100
*
101101
* @psalm-return TValue
102102
*/
103-
function get(int $index);
103+
public function get(int $index);
104104

105105
/**
106106
* Inserts zero or more values at a given index.
@@ -114,13 +114,13 @@ function get(int $index);
114114
*
115115
* @psalm-param TValue ...$values
116116
*/
117-
function insert(int $index, ...$values);
117+
public function insert(int $index, ...$values);
118118

119119
/**
120120
* Joins all values of the sequence into a string, adding an optional 'glue'
121121
* between them. Returns an empty string if the sequence is empty.
122122
*/
123-
function join(string $glue = null): string;
123+
public function join(string $glue = null): string;
124124

125125
/**
126126
* Returns the last value in the sequence.
@@ -131,7 +131,7 @@ function join(string $glue = null): string;
131131
*
132132
* @psalm-return TValue
133133
*/
134-
function last();
134+
public function last();
135135

136136
/**
137137
* Returns a new sequence using the results of applying a callback to each
@@ -145,7 +145,7 @@ function last();
145145
* @psalm-param callable(TValue): TNewValue $callback
146146
* @psalm-return Sequence<TNewValue>
147147
*/
148-
function map(callable $callback): Sequence;
148+
public function map(callable $callback): Sequence;
149149

150150
/**
151151
* Returns the result of adding all given values to the sequence.
@@ -158,7 +158,7 @@ function map(callable $callback): Sequence;
158158
* @psalm-param iterable<TValue2> $values
159159
* @psalm-return Sequence<TValue|TValue2>
160160
*/
161-
function merge($values): Sequence;
161+
public function merge($values): Sequence;
162162

163163
/**
164164
* Removes the last value in the sequence, and returns it.
@@ -169,7 +169,7 @@ function merge($values): Sequence;
169169
*
170170
* @psalm-return TValue
171171
*/
172-
function pop();
172+
public function pop();
173173

174174
/**
175175
* Adds zero or more values to the end of the sequence.
@@ -178,7 +178,7 @@ function pop();
178178
*
179179
* @psalm-param TValue ...$values
180180
*/
181-
function push(...$values);
181+
public function push(...$values);
182182

183183
/**
184184
* Iteratively reduces the sequence to a single value using a callback.
@@ -196,7 +196,7 @@ function push(...$values);
196196
* @psalm-param TCarry $initial
197197
* @psalm-return TCarry
198198
*/
199-
function reduce(callable $callback, $initial = null);
199+
public function reduce(callable $callback, $initial = null);
200200

201201
/**
202202
* Removes and returns the value at a given index in the sequence.
@@ -209,12 +209,12 @@ function reduce(callable $callback, $initial = null);
209209
*
210210
* @psalm-return TValue
211211
*/
212-
function remove(int $index);
212+
public function remove(int $index);
213213

214214
/**
215215
* Reverses the sequence in-place.
216216
*/
217-
function reverse();
217+
public function reverse();
218218

219219
/**
220220
* Returns a reversed copy of the sequence.
@@ -223,7 +223,7 @@ function reverse();
223223
*
224224
* @psalm-return Sequence<TValue>
225225
*/
226-
function reversed();
226+
public function reversed();
227227

228228
/**
229229
* Rotates the sequence by a given number of rotations, which is equivalent
@@ -232,7 +232,7 @@ function reversed();
232232
*
233233
* @param int $rotations The number of rotations (can be negative).
234234
*/
235-
function rotate(int $rotations);
235+
public function rotate(int $rotations);
236236

237237
/**
238238
* Replaces the value at a given index in the sequence with a new value.
@@ -243,7 +243,7 @@ function rotate(int $rotations);
243243
*
244244
* @psalm-param TValue $value
245245
*/
246-
function set(int $index, $value);
246+
public function set(int $index, $value);
247247

248248
/**
249249
* Removes and returns the first value in the sequence.
@@ -254,7 +254,7 @@ function set(int $index, $value);
254254
*
255255
* @psalm-return TValue
256256
*/
257-
function shift();
257+
public function shift();
258258

259259
/**
260260
* Returns a sub-sequence of a given length starting at a specified index.
@@ -279,7 +279,7 @@ function shift();
279279
*
280280
* @psalm-return Sequence<TValue>
281281
*/
282-
function slice(int $index, int $length = null): Sequence;
282+
public function slice(int $index, int $length = null): Sequence;
283283

284284
/**
285285
* Sorts the sequence in-place, based on an optional callable comparator.
@@ -289,7 +289,7 @@ function slice(int $index, int $length = null): Sequence;
289289
*
290290
* @psalm-param (callable(TValue, TValue): int)|null $comparator
291291
*/
292-
function sort(callable $comparator = null);
292+
public function sort(callable $comparator = null);
293293

294294
/**
295295
* Returns a sorted copy of the sequence, based on an optional callable
@@ -303,14 +303,14 @@ function sort(callable $comparator = null);
303303
* @psalm-param (callable(TValue, TValue): int)|null $comparator
304304
* @psalm-return Sequence<TValue>
305305
*/
306-
function sorted(callable $comparator = null): Sequence;
306+
public function sorted(callable $comparator = null): Sequence;
307307

308308
/**
309309
* Returns the sum of all values in the sequence.
310310
*
311311
* @return int|float The sum of all the values in the sequence.
312312
*/
313-
function sum();
313+
public function sum();
314314

315315
/**
316316
* @inheritDoc
@@ -326,5 +326,5 @@ function toArray(): array;
326326
*
327327
* @psalm-param TValue ...$values
328328
*/
329-
function unshift(...$values);
329+
public function unshift(...$values);
330330
}

0 commit comments

Comments
 (0)